Skip to content

Instantly share code, notes, and snippets.

@dkhd
Created August 25, 2017 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkhd/8a18c68ea2a26183a462769860fc6f64 to your computer and use it in GitHub Desktop.
Save dkhd/8a18c68ea2a26183a462769860fc6f64 to your computer and use it in GitHub Desktop.
A Python script that will make our Telegram bot alive!
from telegram.ext import Updater, CommandHandler
from engine import get_random_quote
# Your bot token (from BotFather)
token = "YOUR TOKEN HERE"
def start(bot, update):
bot.sendMessage(chat_id=update.message.chat_id, text=("Hi %s. Send me /quote command to get a random quote from "
"me!" %
update.message.from_user.name))
def quote(bot, update):
bot.sendMessage(chat_id=update.message.chat_id,
text=get_random_quote())
def main():
updater = Updater(token);
dp = updater.dispatcher
# Define all the commands that the bot will receive
dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("quote", quote))
# Start the bot
updater.start_polling()
print("================================")
print("========= Bot Running ==========")
print("================================")
updater.idle()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment