Python Telegram BOT main features:
- Store and retrive data from a database: you can save what you want and read it when you want.
- Set an alarm: when time is up the BOT will remind you what you asked for.
- Exchange messages between strangers: store a message in unknown way. You can also send it for a certain person. In this way he/she will be able to read it but he/she will never know the writer of the message.
The BOT is hosted on Heroku.
For its development I used python-telegram-bot API and sqlite3.
Check it out on telegram: @J4NN0_Bot
You need to
import sqlite3
and I also suggest you to download DB Browser for SQLite to easly manage (create, read, delete, modifiy, etc.) the databases.
-
⭕ Developer
- /about: to see info about developer
-
📝 List
- /addtolist <items>: to add one or several items to your personal list (to do list, reminders or what you want)
- /rmfromlist <items>: to remove one or several itmes from your personal list
- /show_list: it shows items that you added to your personal list
- /clear_list: to delete all items from your pesonal list
-
❓ Message from strangers
- /topic: to see topic that contains at least one message from a stranger
- /msg [-user] <topic> <text>: to sent a message that everyone can read; -user is optional, if inserted your username will be showed with the message you sent
- /showmsg <topic>: to see message about a specific topic
- /delmsg <topic>: to delete a your message that you posted in that topic
- /tagmsg: to check if someone tag you in a topic or message (tag in telegram: @username)
- /personalmsg: to see all messages you sent
-
🔀 Random value
- /random <number>: it will return a random number between 0 and
-
⏰ Alarm
- /timer <seconds>: to set a timer and wait for your message
-
Info about bot
- /help: to have info about all commands
There are also a lot of easter eggs (you can't find it in this code) that i wrote to have fun with my friends. Try to find them and enjoy!
-
Register on Heroku
-
Download and install Heroku CLI and git
-
Create a folder and put inside it
bot.py Procfile runtime.txt requirements.txt
You can also have a "app.json" schema useful to declare environment variables, add-ons, and other information required to run an app on Heroku. More info here
-
Put inside "Procfile"
worker: python script.py
-
Check your python version with
python --version
And put it in "runtime.txt". For example, if the Python version is 3.6.6 just put inside the file:
python-3.6.6
-
Specify explicit dependency versions inside "requirements.txt"
For example i'm using python-telegram-bot API. So my file "requirements.txt" will contain
python-telegram-bot==8.1.1
To update this file, you can use the pip freeze command in your active virtual environment:
pip freeze > requirements.txt
More info here
-
Now in terminal If you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key
heroku login
Create git repository
git init
Or clone this repo
git clone https://github.com/J4NN0/j4nn0-b0t.git
Create heroku app
heroku create
Push your code (or deploy changes) into heroku app
git add . git commit -m 'message' git push heroku master
-
Run your worker
heroku ps:scale worker=1
-
Check logs with
heroku logs --tail
-
Enjoy your bot
Checkout also the offical heroku guide: Getting Started on Heroku with Python