do_task sends str of text before being done, other minor changes
This commit is contained in:
parent
f8f8c53ce0
commit
97a6261b53
18
bot.py
18
bot.py
@ -12,8 +12,10 @@ from Task import Task
|
|||||||
PROPERTY_LAST_COMMAND = "last_command"
|
PROPERTY_LAST_COMMAND = "last_command"
|
||||||
PROPERTY_LAST_ARGUMENTS = "last_arguments"
|
PROPERTY_LAST_ARGUMENTS = "last_arguments"
|
||||||
|
|
||||||
|
CONFIG_FILE='config.json'
|
||||||
|
|
||||||
with open('config.json') as file:
|
|
||||||
|
with open(CONFIG_FILE) as file:
|
||||||
CONFIG = json.loads(file.read())
|
CONFIG = json.loads(file.read())
|
||||||
|
|
||||||
BOT = telepot.Bot(CONFIG['token'])
|
BOT = telepot.Bot(CONFIG['token'])
|
||||||
@ -269,15 +271,15 @@ def ls_tasks(arguments, chat_id):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# filter checking
|
# filter checking
|
||||||
for ii in filters:
|
for j in filters:
|
||||||
filter_pass = ii in str(task)
|
filter_pass = j in str(task)
|
||||||
|
|
||||||
# needs continue statement after each filter list
|
# needs continue statement after each filter list
|
||||||
if not filter_pass:
|
if not filter_pass:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for ii in nfilters:
|
for j in nfilters:
|
||||||
filter_pass = ii not in str(task)
|
filter_pass = j not in str(task)
|
||||||
|
|
||||||
if not filter_pass:
|
if not filter_pass:
|
||||||
continue
|
continue
|
||||||
@ -286,7 +288,6 @@ def ls_tasks(arguments, chat_id):
|
|||||||
|
|
||||||
BOT.sendMessage(chat_id, text)
|
BOT.sendMessage(chat_id, text)
|
||||||
|
|
||||||
|
|
||||||
def do_tasks(task_ids, chat_id):
|
def do_tasks(task_ids, chat_id):
|
||||||
"""
|
"""
|
||||||
Mark tasks by ID as done
|
Mark tasks by ID as done
|
||||||
@ -295,9 +296,10 @@ def do_tasks(task_ids, chat_id):
|
|||||||
"""
|
"""
|
||||||
for i in task_ids:
|
for i in task_ids:
|
||||||
task = get_task(int(i), chat_id)
|
task = get_task(int(i), chat_id)
|
||||||
|
task_text = str(task)
|
||||||
task.do()
|
task.do()
|
||||||
set_task(int(i), task, chat_id)
|
set_task(int(i), task, chat_id)
|
||||||
BOT.sendMessage(chat_id, "Did task: {0}".format(task))
|
BOT.sendMessage(chat_id, "Did task: {0}".format(task_text))
|
||||||
|
|
||||||
|
|
||||||
def undo_tasks(task_ids, chat_id):
|
def undo_tasks(task_ids, chat_id):
|
||||||
@ -371,6 +373,8 @@ def delete_all_tasks(chat_id):
|
|||||||
BOT.sendMessage(chat_id, "Deleted all tasks.")
|
BOT.sendMessage(chat_id, "Deleted all tasks.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
MessageLoop(BOT, on_message).run_as_thread()
|
MessageLoop(BOT, on_message).run_as_thread()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
Reference in New Issue
Block a user