|
1 year ago | |
---|---|---|
README.md | 1 year ago | |
config.example.py | 1 year ago | |
convert.txt | 1 year ago | |
motivationbot.py | 1 year ago | |
motivationbot.service | 1 year ago | |
motivationbot.timer | 1 year ago | |
requirements.txt | 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.