diff --git a/README.md b/README.md index 06f9b4e..29a89a9 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,35 @@ # Finder-UniCT Bot -A Telegram bot for UNICT students that allows students to get to know each other semi-anonymously. +A Telegram bot for [UNICT (University of Catania)](https://www.unict.it/en) students enabling them to connect semi-anonymously. -## Bot's features +## Features +- **Login**: Authenticate with your UniCT email. +- **Random Chat**: Engage in conversations with strangers. +- **Interest Matching**: Specify your interests and connect with students of similar tastes. +- **Global Chat**: Join a community chat with all UniCT students. -- Login system with UniCT email -- Chat with strangers -- Choose your interests and the bot will match you with someone with similar tastes as yours -- Global chat with all UniCT students +> **Note**: The bot commands and their responses are in Italian. Use `/start` to initiate and `/help` for a command list. +## Getting Started -Send **'/start'** to start it, **'/help'** to see a list of commands. -Please note that the commands and their answers are in Italian. +### Obtain a Telegram Bot Token +1. Open Telegram and search for @BotFather. +2. Start a conversation with `/start`. +3. Create a new bot using `/newbot`. +4. Name your bot and assign a tag (it should end with `bot`). +5. Copy the provided token. ---- +# Usage +The bot operates through a set of commands and reacts to specific triggers. Below is an overview of the bot's main commands and their descriptions: -## How to create a Telegram bot and get its token -To start testing this bot you need to get a Telegram Bot's token: -- Go to Telegram and search for @BotFather -- Start it using `/start` -- Create a new bot using the `/newbot`command -- Give it a name and a tag (the tag must end with `bot`) -- Now copy the token it gives you +/start: Sends a welcome message. (Translation: messaggio di benvenuto) +/help: Provides guidance on available commands. (Translation: ricevi aiuto sui comandi) +/report: Allows users to report an issue or problem. (Translation: segnala un problema) +/chatid: Returns the chat ID of the current conversation. This can be useful for debugging and administration purposes. +The bot is also programmed to handle messages and commands in private chats, ensuring the safety and privacy of user interactions. -## Requirements -- Pip3 -- Python3 +### Running with Docker +#### Using Docker Compose -## Docker-compose ```yaml version: '2' services: @@ -34,38 +37,41 @@ services: image: ghcr.io/unict-dmi/finderunictbot container_name: finderunictbot volumes: - - :/app/config/settings.yaml + - :/app/config/settings.yaml restart: unless-stopped -``` -### Building locally +``` +**Local Build**: -```bash +\```bash git clone git@github.com:UNICT-DMI/FinderUniCT-Bot.git cd FinderUniCT-Bot docker build --tag finderunictbot . -``` - ---- - -## Docker CLI -To test the bot with docker compose on Windows follow these steps: -1) Clone the repository -2) Copy the existing `config/settings.yaml.dist` and rename it into `config/settings.yaml` -3) In `token` add your Telegram bot's token -4) Open the terminal on the cloned repository and run ```docker build -t finderunictbot .``` to build the new image -5) Next run ```docker run -v "/c/Users/your/absolute/path/finderunictbot/config/settings.yaml":"/finderunictbot/config/settings.yaml" finderunictbot``` - -To test it with Linux follow the steps above to the point 4) and: - -5) Run ```$ docker run -v "/home/your/absolute/path/finderunictbot/config/settings.yaml":"/finderunictbot/config/settings.yaml" finderunictbot``` - - -## Run live -To test the bot directly on your machine follow these steps: -1) Clone this repository -2) Copy the existing `config/settings.yaml.dist` and rename it into `config/settings.yaml` -3) In `token` add your Telegram bot's token -4) Run `$ python main.py` to start the bot +\``` + +#### Using Docker CLI + +1. Clone the repository. +2. Make a copy of `config/settings.yaml.dist` and rename it to `config/settings.yaml`. +3. Add your Telegram bot's token in the `token` field. +4. Build the image: `docker build -t finderunictbot .` +5. Run: + + - On Windows: + \```bash + docker run -v "C:\path\to\your\settings.yaml:/finderunictbot/config/settings.yaml" finderunictbot + \``` + + - On Linux: + \```bash + docker run -v "/path/to/your/settings.yaml:/finderunictbot/config/settings.yaml" finderunictbot + \``` + +### Running Natively + +1. Clone this repository. +2. Copy `config/settings.yaml.dist` to `config/settings.yaml`. +3. Update the `token` field with your Telegram bot's token. +4. Execute: `python main.py`. ## Credits diff --git a/module/commands/report.py b/module/commands/report.py index 937464d..1f96fdc 100644 --- a/module/commands/report.py +++ b/module/commands/report.py @@ -2,6 +2,7 @@ from telegram import Update from telegram.ext import CallbackContext + def report(update: Update, context: CallbackContext) -> None: """Called by the /report command Sends a report to the admin group @@ -10,3 +11,38 @@ def report(update: Update, context: CallbackContext) -> None: update: update event context: context passed by the handler """ + # post(update, context) + print(update, context) + +# Here is an example on how to log everyone's messages to a central location using MQTT. +# def post(topic: str, payload: str, retain: bool = False, +# _client=establishBroker()): +# """ +# Post msg to MQTT broker +# +# :type _client: object +# :type retain: bool +# :param _client: Logging handler. By default, it is created by this module +# :param retain: Retain topic on broker +# :param topic: Project name +# :param payload: Sensor Data +# """ +# topic = str(f'{project}/{topic}') +# payload = str(payload) +# try: +# _client.publish(topic=topic, payload=payload, qos=0, retain=retain) +# except ValueError: +# logger.warning( +# f"pub Failed because of wildcard: {str(topic)}=:={str(payload)}") +# logger.warning(f"Attempting fix...") +# try: +# tame_t = topic.replace("+", "_") +# tame_topic = tame_t.replace("#", "_") +# tame_p = payload.replace("+", "_") +# tame_payload = tame_p.replace("#", "_") +# _client.publish(topic=str(tame_topic), payload=str(tame_payload), +# qos=1, retain=retain) +# logger.debug("Fix successful, Sending data...") +# except Exception as error: +# logger.warning(f"Fix Failed. Bug report sent.") +# _client.publish(f"{project}/error", str(error), qos=1, retain=True) diff --git a/requirements.txt b/requirements.txt index 8efa51d..9a71bfb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -python-telegram-bot==20.6 +python-telegram-bot==13.5 pyyaml