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
import requests | |
api_url = "https://beta.todoist.com/API/v8" | |
api_token = "" | |
requests.post( | |
"%s/tasks" % api_url, | |
data=json.dumps({ | |
"content": task_content, | |
}), | |
headers={ |
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
import requests | |
api_url = "https://beta.todoist.com/API/v8" | |
api_token = "" | |
requests.get( | |
"%s/tasks" % api_url, | |
headers={ | |
"Authorization": "Bearer %s" % api_token | |
}).json() |
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): |
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
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") |
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_project = False | |
new_task = False | |
select_project_for_task = False | |
def __init__(self, flag=False): | |
self.new_project = flag | |
self.new_task = flag | |
self.select_project_for_task = flag |
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: | |
# all other functions | |
# . | |
# . | |
# . | |
# handler for buttons | |
def button(self, bot, update): | |
query = update.callback_query | |
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
@staticmethod | |
def task_button_markup(tasks): | |
keyboard = [] | |
for task in tasks: | |
keyboard.append( | |
[InlineKeyboardButton(task['content'], url=task['url'], callback_data=task['id'])]) | |
markup = InlineKeyboardMarkup(keyboard) | |
return markup |
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
import configparser | |
from telegram import InlineKeyboardButton, InlineKeyboardMarkup | |
from telegram.ext import Updater, MessageHandler, CommandHandler, CallbackQueryHandler, Filters | |
from APIHandler import APIHandler | |
class TodoistBot: | |
def __init__(self): | |
# Read Configs from file | |
config = configparser.ConfigParser() |
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
from telegram.ext import Updater, MessageHandler, CommandHandler, CallbackQueryHandler, Filters | |
bot_token = "YOUR_BOT_TOKEN" | |
updater = Updater(bot_token) | |
dp = updater.dispatcher | |
# Add command handler | |
dp.add_handler(CommandHandler('COMMAND_NAME', COMMAND_HANDLER)) |
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
from todoist.api import TodoistAPI | |
import requests | |
from datetime import datetime | |
import uuid | |
import json | |
class APIHandler: | |
def __init__(self, api_token, api_url): |
NewerOlder