1
0
Fork 0
Motivation Telegram bot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Felix 4fb460138f
Update README, add example config.py
1 year ago
README.md Update README, add example config.py 1 year ago
config.example.py Update README, add example config.py 1 year ago
convert.txt Initial commit 1 year ago
motivationbot.py Initial commit 1 year ago
motivationbot.service Initial commit 1 year ago
motivationbot.timer Initial commit 1 year ago
requirements.txt Initial commit 1 year ago

README.md

Motivation Telegram bot

Bot that sends a daily motivational message with an image via Telegram private conversation.

Register bot

Create a new bot from @botfather:

/newbot
<Bot Name>
<Bot Handle> (for t.me/bot_handle)

Start conversation with bot at t.me/<bot_handle>

Forward piece of convo to @getidsbot, copy channel id

Note: This is not a bot that will post in a channel, but rather send messages directly to the user

Install packages

The motivation bot requires the python-telegram-bot package.

Either install it in a virtual environment:

virtualenv .venv-bot
.venv-bot/bin/pip install python-telegram-bot
.venv-bot/bin/activate

Or, for distributions with native packages, install it:

Arch Linux

pacman -S python-telegram-bot

Ubuntu

apt install python3-python-telegram-bot

Adjust images and captions

Put images into images/ directory. They should be pre-formatted and not too large, as the bot has no way of compressing them before uploading.

An example config is provided as config.example.py. Rename it to config.py and fill in your captions:

CAPTIONS = [
    "My motivational message",
    "My even more motivational message",
]

Run bot

Set the following environment variables with bot token and chat id:

export MOTIVATION_BOT_TOKEN='<bot-token>'
export MOTIVATION_BOT_CHAT_ID='<my-chat-id>'

Run the bot on a timer, either via systemd timers or cronjobs. Alternatively, use the primitive python sleep()-based timer in the __main__ function.