This is my first telegram bot written in Python
/bug - Link to create issue on github
/cat <Number> - Random cat photo from Tumbler
/hat - Sorting hat from Harry Potter
/db <SQL query> - Manage your database (Only for admins)
/dog <Number> - Random dog photo from dog.ceo
/ibash <Number> - Random quote from ibash.org.ru
/info - Information about this bot
/loglist <Number> - Random quote from loglist.net
/ping - Show usage of pinger command wich allow to
+ add ping phrases for user who call this command
/w <City> - Short form of /w
/weather <City> - Weather in a city for now, today and tommorow
/wset <City> - Set default city for /weather
git clone https://github.com/Cuttlerat/pybot.git
cd pybot
Add your telegram username, tokens, and database path into ./tokens/tokens.py
file
BOT_TOKEN = '<YOUR TOKEN>'
WEATHER_TOKEN = '<YOUR TOKEN>'
DATABASE_HOST = 'data/pybot.db'
ADMINS = [ 'YOUR TELEGRAM USERNAME WITHOUT @' ]
MODE = 'Webhook' # Or Polling
WEBHOOK_PORT = 30222
WEBHOOK_URL = "https://example.com/{}".format(BOT_TOKEN)
# Uncomment this if you want to run with webhook not in docker
# LISTEN_IP = "<your ip>"
Then just launch the bot
./pybot.py
In order to build and create a docker container, docker-compose
must be installed in your system
docker-compose up --build pybot
You can get a weather token here: http://openweathermap.org/
Register your bot here: https://t.me/BotFather
If you want that your bot triggers on a some type of messages, there some options here.
If you want a simple trigger on a message responding with your specified string
/db INSERT INTO answers(match,string) VALUES("hello!", "Hi!")
Cuttlerat: Hello!
Cutltebot: Hi!
You also can use the /ping
command for this, and so all the others (besides the administrator) can use this to add trigers but not more than 10
If you want to summon someone with just mentioning of his name or nickname
/db INSERT INTO pingers(username,match) VALUES("Cuttlerat", "rat")
Cuttlerat: rat!
*nothing*
Why? Because we didn't set a ping phrase yet
/db INSERT INTO ping_phrases(phrase) VALUES("ping")
Cuttlerat: ping rat
Cuttlebot: @Cuttlerat
There is a little trick to summon all persons from the pingers table
/db INSERT INTO pingers(username,match) VALUES("hotkosc", "kosc")
/db INSERT INTO pingers(username,match) VALUES("EVERYONE GET IN HERE", "all")
Cuttlerat: ping all
Cuttlebot: @Cuttlerat @hotkosc
But what if you want to call everyone except one guy?
You will need to add a ping exclude phrase
/db INSERT INTO ping_exclude(match) VALUES("except")
Cuttlerat: ping all except kosc
Cuttlebot: @Cuttlerat
And is it! Enjoy your bot!