Coder Social home page Coder Social logo

scambifestival / resina Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 84 KB

A Telegram bot to automate and ease Scambi Festival’s staff workload

License: GNU Affero General Public License v3.0

Python 100.00%
association baserow bot database scambifestival telegram telegram-bot

resina's Introduction

Resina Bot - Introduzione

Questa repository contiene il codice sorgente di r3sinabot.

Per sapere ciò su cui stiamo lavorando, vedi Scambi Telegram Bot project.

Nota: Resina Bot è ancora in fase di sviluppo.

Cos'è Resina

Resina è un bot pensato per ausiliare lo staff di Scambi nell'organizzazione interna nonché favorirne la comunicazione e facilitarne l'uso di alcuni strumenti istitutivi attraverso alcune funzionalità, tra le quali:

  1. l'automatizzazione dell'iscrizione dei nuovi membri alla nostra associazione, tramite:
  • la creazione degli account sulle nostre piattaforme;
  • la giunta dell'utente al nostro libro soci;
  1. la facilitazione dell'uso di Pino, il nostro database, da dispositivi mobili;
  2. la collezione delle idee proposte, catalogate tramite appositi hashtag;

ed altre funzioni ancora in fase di progettazione.

Struttura dello script

Lo script del bot, interamente programmato in Pyhton attraverso la libreria Python Telegram Bot, è articolato in diversi moduli:

  • main.py costituisce il core dello script. Al suo interno è definito lo scheletro del bot e descritto il suo comportamento generale;
  • dispatcher.py costituisce l'espressione pratica del comportamento di Resina; in base al valore di ritorno, passato tramite il main, lancia la funzione adibita allo scopo;
  • db_functions.py contiene tutte le funzioni utili all'interazione col database interno, tra cui la connessione e la formulazione di queries;
  • utils.py è una sorta di coltellino svizzero che offre funzioni che possono risultare utili agli altri moduli, come la formulazione della risposta testuale del bot o il salvataggio delle informazioni relative ad un utente;
  • variables.py include tutte quelle variabili che sono necessarie agli altri moduli al fine di garantire il corretto funzionamento dell'intero script.

Il database

Resina interagisce con un database interno basato su SQLite attraverso la libreria sqlite3.

Esso consente di fornire protezione dallo spam e di facilitare l'uso del bot da parte di utenti che ne hanno già fatto uso.

Nota: non si esclude che possa avere altri scopi in futuro.

resina's People

Contributors

2ale2 avatar xplosionmind avatar

Stargazers

 avatar

Watchers

 avatar  avatar

resina's Issues

Manipulate Baserow data

The bot should be capable of making anyone in the Scambi Festival staff manipulate Pino data by chatting with it

🤖 Bot Feature: Automate the #registration of #newmembers.

Briefly

Our bot will be able to complete the iscription process all by itself. This should reduce the workload for Tortoises.

In progress

Implemented the sending message to the executive group. Now all the people in the group along with Resina can interact with it. Currently.

Note: I'm thinking about implementing the possibility to cancel the confirmation request from the requesting user-side. That can take a while to be developed.

For instance

The bot should be able to:

  • Ask for user details that are needed to create the accounts (name, surname, email address, working group, ...);
  • Create an account with those details on Pino and on Nuvola;
  • Add the user to our shareholders' register on Pino.

Possible issues

  • 1. Some problems may arise during account creation due to required authentication and permissions.

Creating accounts (expecially on Nuvola) is not a feasible operation by every kind of user.

Possible issues solutions

  1. Some problems may arise during account creation due to required authentication and permissions.
  • It's possible to access with an admin account obtaining a token useble to create new user through the admin panel.

Implementing of simultaneous management of multiple subscription requests by multiple users

Using database and ConversationHandlers

Fixing idea

Of each user who requests to be signed up his username and the status associated with his application are added to a table in the database.

Please note: the database is persistent, therefore it is not removed after a script interruption.

Whenever the user has decided to subscribe, the check must be asked before the process begins, in fact a first database query about the user's username needs to be made within the main in the function wrapper.

Database checking

If the username of the user isn't in the database:

  • the script adds an entry to the DB (username and status) and the signin up process is started (launching dispatcher.py).

If the username is in the DB:

  • If he already asked Resina to be signed up ...
  • ... but the executive request has not been sent:
  • query.data = str(ISCRIZIONE),
  • the signing up process is started.
  • ... but the executive request has not been accepted from the executive group:
  • signing up process is not started,
  • user is notified.
  • If the request as been accepted from the executive group ...
  • ... but the subscription process has not been completed:
  • signing up process it resumed from the last point.

After each step the process status needs to be updated in the database.

Note: If it is not possible to create an account (Nuvola or Baserow) or insert the entry in the membership book, we have two choises:

  1. undo previous actions and mark the user as unsubscribed;
  2. terminate all the operations whatever are the outcomes and notify the new member about not completed ones.

Handlers structure

In the article describing the default behavior of an handler it is said that two users are handled separately in chronological order of request. Therefore, if a user A requests to be signed up, when a user B is already performing one of the subscription steps, it is necessary that the current function for user B is completed before the user A request is handled.
As the handlers have been structured, the termination of the function invoked by the handler via user B may cause changes on the pending request of user A, since currently handlers are added independently.

⬆️ Needs to be verified

The management method described above should permit simultaneous registration of multiple users.

Telegram does not require a username, with which Resina can work

Currently

Resina is currently working with usernames:

  1. User data are collected through his username;
  2. Users are menaged through his username;
  3. The bot offers the possibility to contact a user for communications through his username.

But

However, Telegram does not require a username to create an account: the only required field is a phone number, which can even be private so Resina cannot detect it.

So

Resina needs something strictly related to each user that uses the bot, so he can differntiate a user from another.

Solutions

  • Ask the user who has not set a username, to set one in Telegram settings.
  • Work with user ID, which is a unique identification number (users cannot contact other users through their ID)

Gathering user's full name method

The Issue

Resina rises an exeption if the user has not set his last name. Furthermore, it's not said that the user gave his actual name details.

Why this issue

In order to perform the executive group payment confirmation request and then add the user to the staff, Resina has to know his correct first name and last name, otherwise the group members could not recognize him while checking for payment proof.

Scambidee integration

The bot should be added to the Telegram group “Scambidee” and automatically log ideas that are written there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.