Skip to content

Instantly share code, notes, and snippets.

@amiryousefi
Created January 31, 2020 18:33
Show Gist options
  • Save amiryousefi/2c83874c188e1cf3a68c3acb7f94bcc3 to your computer and use it in GitHub Desktop.
Save amiryousefi/2c83874c188e1cf3a68c3acb7f94bcc3 to your computer and use it in GitHub Desktop.
class TodoistBot:
# all other functions
# .
# .
# .
# handler for buttons
def button(self, bot, update):
query = update.callback_query
# general handler for messages
def general_handler(self, bot, update):
chat_id = update.message.chat_id
text = update.message.text
def main(self):
updater = self.updater
dp = updater.dispatcher
# Add command handlers
dp.add_handler(CommandHandler('projects', self.projects))
# other commands will goes here
# Add callback handlers for buttons
updater.dispatcher.add_handler(CallbackQueryHandler(self.button))
# general message handler
updater.dispatcher.add_handler(MessageHandler(Filters.all, self.general_handler))
updater.start_polling()
updater.idle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment