UNICT-DMI / Telegram-DMI-Bot

A telegram bot for the DMI students 🎓 (@DMI_Bot)
https://t.me/DMI_Bot
GNU General Public License v3.0
41 stars 30 forks source link
bot dmi dmibot telegram telegram-bot

Telegram-DMI-Bot

Telegram-DMI-Bot is the platform that powers @DMI_bot, a Telegram bot aided at helping students find informations about professors, classes' schedules, administration's office hours and more.

Using the live version

The bot is live on Telegram with the username @DMI_Bot. Send /start to start it, /help to see a list of commands.

Please note that the commands and their answers are in Italian.


Setting up a local instance

Automatically

Manually

If you want to test the bot by creating your personal instance, follow this steps:

(If you don't have a token, message Telegram's @BotFather to create a bot and get a token for it)

System requirements

To install all the requirements you can run:

pip3 install -r requirements.txt

Docker

docker-compose(recommended)

version: "2"
services:
  dmibot:
    image: ghcr.io/unict-dmi/telegram-dmi-bot:master
    container_name: dmibot
    volumes:
      - </path/to/settings.yaml>:/dmibot/config/settings.yaml
      - </path/to/DMI_DB.db>:/dmibot/data/DMI_DB.db
      - </path/to/drive_credentials.json>:/dmibot/config/drive_credentials.json

docker cli

docker run -v </path/to/settings.yaml>:/dmibot/config/settings.yaml -v </path/to/DMI_DB.db>:/dmibot/data/DMI_DB.db -v </path/to/drive_credentials.json>:/dmibot/config/drive_credentials.json -t ghcr.io/unict-dmi/telegram-dmi-bot:master

Parameter

Container images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate \:\ respectively.

Parameter Function
-v /dmibot/config/settings.yaml configurations file
-v /dmibot/data/DMI_DB.db database
-v /dmibot/config/drive_credentials.json drive credentials

Building locally

git clone https://github.com/UNICT-DMI/Telegram-DMI-Bot.git
cd Telegram-DMI-Bot
docker build --no-cache -t dmibot .

Special functions

Notes: only some users are allowed to use these commands indeed there is an if condition that check the chatid of the user that can use them

- /stats

You can enable these commands setting disable_db = 0 and copy data/DMI_DB.db.dist into data/DMI_DB.db

This command shows the statistics of the times where the commands are used in the last 30 days.

- /drive

You can enable these commands setting disable_drive = 0 and configuring the GoogleDrive credentials.

/drive: command to get the GoogleDrive files

Configure Drive

Testing

To install all the test requirements you can run:

pip3 install -r requirements_dev.txt

Start unit tests:

pytest tests/unit/

If you want to check also the code coverage report through an HTML format use:

pytest --cov . tests/unit/ --cov-report=html

To run the end-to-end tests read the following steps below.

Steps:

test:
  api_hash: hash of the telegram app used for testing
  api_id: id of the telegram app used for testing
  session: session of the telegram app used for testing (see steps below)
  tag: tag of the bot used for testing
  token: token for the bot used for testing
  representatives_group: representatives' group id used for testing
  dev_group_chatid: dev's group id used for testing
python3 conftest.py .

Check here if you want to have more information on the steps above

Start end-to-end tests:

pytest tests/e2e/

:books: Documentation

Check the gh-pages branch

Link to the documentation

License

This open-source software is published under the GNU General Public License (GNU GPL) version 3. Please refer to the "LICENSE" file of this project for the full text.

Contributors

You can find the list of contributors here If you want to contribute, make sure to read the guidelines