Meme bot @tendTo_bot is a Telegram meme bot
The bot is live on Telegram with the username @tendTo_bot. To see the posts, once published, check Meme channel di meme_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 istance
- 🐳 Setting up a Docker container
- 📊 [Optional] Setting up testing
- 📚 Documentation
- 🔀 About Pull Requests
- Python 3 (3.8.5)
- python-pip3
Listed in requirements.txt
- Clone this repository
- Rename "data/db/sqlite.db.dist" in "data/db/sqlite.db"
- Rename "config/settings.yaml.dist" in "config/settings.yaml" and edit the desired parameters:
data:
db_url: url of your postgres database (false recommended for local)
remote: whether the data will be saved remotely (postgres) or locally (mysql)
debug:
db_log: save each and every message in a log file. Make sure the path "logs/messages.log" is valid before putting it to 1
local_log: /
meme:
channel_group_id: id of the group associated with the channel. Needed if comments are enabled
channel_id: id of the channel to which the bot will send the approved memes
comments: whether or not the channel the bot will send the memes to has comments enabled
group_id: id of the admin group the memebot will use
n_votes: votes needed to approve/reject a pending post
reset_on_load: whether or not the database should reset every time the bot launches. USE CAREFULLY
test:
api_hash: hash of the telegram app used for testing
api_id: id of the telegram app used for testing
remote: whether you want to test the remote database, the local one or both
session: session of the telegram app used for testing
tag: tag of the telegram bot used for testing. Include the '@' character
token: token for the telegram bot used for testing
token: the token for your telegram bot
webhook:
enabled: whether or not the bot should use webhook (false recommended for local)
url: the url used by the webhook
- Run
python3 main.py
- Docker
- Clone this repository
- In "config/settings.yaml.dist", edit the desired values. Be mindful that the one listed below will overwrite the ones in "config/settings.yaml.dist", even if they aren't used in the command line
- Run
docker build --tag botimage --build-arg TOKEN=<token_arg> [...] .
In the command line (after each --build-arg) |
Type | Function | Optional |
---|---|---|---|
TOKEN=<token_args> | string | the token for your telegram bot | REQUIRED |
WEB_URL=<web_url> | string | the url used by the webhook | REQUIRED |
DATABASE_URL=<db_url> | string | url of your postgres database | REQUIRED |
GROUP_ID=<group_id> | int | id of the admin group the memebot will use | REQUIRED |
CHANNEL_ID=<channel_id> | int | id of the channel to which the bot will send the approved memes | REQUIRED |
CHANNEL_GROUP_ID=<channel_id> | int | id of the group associated with the channel | REQUIRED IF comments = true |
- Run
docker run -d --name botcontainer botimage
- Run
docker stop botcontainer
to stop the container - Run
docker rm -f botcontainer
to remove the container
- Sign in your Telegram account with your phone number here. Then choose “API development tools”
- If it is your first time doing so, it will ask you for an app name and a short name, you can change both of them later if you need to. Submit the form when you have completed it
- You will then see the api_id and api_hash for your app. These are unique to your app, and not revocable.
- Put those values in the conf/settings.yaml file for local or in the conf/settings.yaml.dist file if you are setting up a docker container
test:
api_hash: HERE
api_id: HERE
...
- Copy the file tests/conftest.py in the root folder and Run
python3 conftest.py
. Follow the procedure and copy the session string it provides in the settings file:
test:
...
session: HERE
...
- You can then delete the conftest.py file present in the root folder, you won't need it again
- Edit the remaining values in the file as you see fit
Check here you you want to have more information on the steps above
- Run
pytest
- Add telethon, pytest and pytest-asyncio to the requirements.txt file
- Access the container and Run
pytest
or edit the Dockerfile to do so
Check the gh-pages branch
Upon submitting a Pull Request, a github action will be triggered. The workflow will run all the tests to make sure everything still works correctly
The workflow will fail if your repository lacks even one of the following secrets:
SECRET | Type | Function |
---|---|---|
API_ID | int | id of the telegram app used for testing |
API_HASH | string | hash of the telegram app used for testing |
SESSION | string | session of the telegram app used for testing |
TEST_TAG | string | tag of the bot used for testing |
TEST_TOKEN | string | token for the bot used for testing |
To pass the workflow is not mandatory, but is highly suggested