Created
January 31, 2020 18:54
-
-
Save amiryousefi/352292a4ac12a18e5096ce5b97a8f6e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TodoistBot: | |
class Flags: | |
new_task = False | |
def __init__(self, flag=False): | |
self.new_task = flag | |
flags = Flags() | |
def __init__(self): | |
... | |
def new_task(self, bot, update): | |
chat_id = update.message.chat_id | |
self.flags.new_task = True | |
bot.send_message(chat_id=chat_id, text="enter name for new task") | |
def general_handler(self, bot, update): | |
chat_id = update.message.chat_id | |
text = update.message.text | |
if self.flags.new_task: | |
if self.api.create_task(text): | |
bot.send_message(chat_id=chat_id, text="task created: " + text) | |
def main(self): | |
updater = self.updater | |
dp = updater.dispatcher | |
# Add command handlers | |
# . | |
# . | |
# . | |
dp.add_handler(CommandHandler('newtask', self.new_task)) | |
# ... | |
# 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