From 09a6b129a08d5dd23a4f1e1b5b167bd982774804 Mon Sep 17 00:00:00 2001 From: vylion Date: Sun, 15 Oct 2017 11:36:07 +0200 Subject: [PATCH] uncommented some code that was not intended to keep commented --- main.py | 43 ++++++++++++++++++++----------------------- task.py | 2 +- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/main.py b/main.py index 9e100a2..0f58baa 100644 --- a/main.py +++ b/main.py @@ -47,30 +47,27 @@ def addTask(bot, update, args): chat = Chat(tchat.id, title) else: chat = chats[ident] - # Args: name repeat hour day/month/year - if len(args) > 2: - args[2] = args[2].strip('h') - if len(args) > 3: - date = args[3].split('/') - for i in range(len(date)): - if date[i] == '': - date[i] = '0' - t = chat.addTask(args[0],int(args[1]),int(args[2]),int(date[0]),int(date[1]),int(date[2])) + try: + # Args: name repeat hour day/month/year + if len(args) > 2: + args[2] = args[2].strip('h') + if len(args) > 3: + date = args[3].split('/') + for i in range(len(date)): + if date[i] == '': + date[i] = '0' + t = chat.addTask(args[0],int(args[1]),int(args[2]),int(date[0]),int(date[1]),int(date[2])) + else: + t = chat.addTask(args[0],int(args[1]),int(args[2])) + elif len(args) > 1: + t = chat.addTask(args[0],int(args[1])) else: - t = chat.addTask(args[0],int(args[1]),int(args[2])) - elif len(args) > 1: - t = chat.addTask(args[0],int(args[1])) - else: - t = chat.addTask(args[0]) - update.message.reply_text('Task ' + t.name + ' added') - chats[ident] = chat - -""" -except ValueError as ve: - update.message.reply_text('A task already exists under this name') -except Exception as e: - update.message.reply_text('Wrong format. Send /help for more details') -""" + t = chat.addTask(args[0]) + update.message.reply_text('Task ' + t.name + ' added') + except ValueError as ve: + update.message.reply_text('A task already exists under this name') + except Exception as e: + update.message.reply_text('Wrong format. Send /help for more details') # except: # update.message.reply_text('Wrong format') diff --git a/task.py b/task.py index 6259d98..85a9cd7 100644 --- a/task.py +++ b/task.py @@ -45,7 +45,7 @@ class Task(object): def __str__(self): s = "Task " + self.name + ":\n" s += "Date: " + " " + str(self.date.day) + "/" + str(self.date.month) + "/" + str(self.date.year) - s += " at " + str(self.date.hour) + ":00\n" + s += " at " + str(self.date.hour) + "h\n" if self.repeat > 0: s += "Repeats every " + str(self.repeat) + " days." return s