Skip to content

Commit

Permalink
update reminder date time
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzaizai2k committed Jan 18, 2024
1 parent 305b9ca commit b4d1b8e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
31 changes: 16 additions & 15 deletions src/Microsofttodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,13 @@ def get_task_id_by_name(self, list_name: str, task_name: str):
raise

def create_task(self,
task_name: str,
list_name: str = None,
list_id: str = None,
importance:bool = False,
dueDateTime: datetime = None,
body=None,
task_name: str,
list_name: str = None,
list_id: str = None,
importance:bool = False,
dueDateTime: datetime = None,
body=None,
reminder_datetime: datetime = None,
):
assert (list_name is not None) or (
list_id is not None
Expand All @@ -320,26 +321,26 @@ def create_task(self,
# For compatibility with cli
if list_id is None:
list_id = self.get_list_id_by_name(list_name)

if dueDateTime is not None:
dueDateTime = datetime.strptime(dueDateTime, '%Y-%m-%d:%H:%M:%S')
if reminder_datetime is None:
reminder_datetime = dueDateTime

importance = 'high' if importance else 'normal'

if body is None:
body ={"content": task_name,
"contentType": "text"
}

if dueDateTime is not None:
dueDateTime = datetime.strptime(dueDateTime, '%Y-%m-%d:%H:%M:%S')

if importance == False:
importance = 'normal'
else:
importance = 'high'


endpoint = f"{BASE_URL}/{list_id}/tasks"
request_body = {
"title": task_name,
"body":body,
"importance": importance,
"dueDateTime": datetime_to_api_timestamp(dueDateTime),
"reminderDateTime": datetime_to_api_timestamp(reminder_datetime),
}
session = get_oauth_session()
response = session.post(endpoint, json=request_body)
Expand Down
6 changes: 3 additions & 3 deletions src/Utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def create_env_file():
def sync_task_to_todo(tasks_list:list[dict]):
todo = MicrosoftToDo()
# Split the text by '\n' and create a list
for tmp in tasks_list:
todo.create_task(task_name=tmp["title"], list_name='Tasks',
importance=tmp["important"], dueDateTime=tmp["dueDateTime"])
for task in tasks_list:
todo.create_task(task_name=task["title"], list_name='Tasks',
importance=task["important"], dueDateTime=task["dueDateTime"])
return

def filter_stocks(param):
Expand Down
11 changes: 6 additions & 5 deletions src/stock_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,23 +461,24 @@ def summarize_sound(message):
bot.reply_to(message, f"Here's your note:\n {text}")
except Exception as e:
print('Error', e)
text = None
bot.reply_to(message, f"Sorry, I can't understand your voice. Please try again!")

os.remove(file_path)

if text is None:
return

reply_markup = handle_checklist(text)
bot.send_message(message.chat.id, 'Click to toggle', reply_markup=reply_markup)

tasks_list = speech_to_text.get_task_list()
print('tasks_list', tasks_list)
if validate_mrzaizai2k_user(message.chat.id):

if tasks_list is not None and validate_mrzaizai2k_user(message.chat.id):
sync_task_to_todo(tasks_list)
bot.send_message(message.chat.id, f"The tasks have been integrated to Microsoft To Do!")





# Define the function to handle all other messages
@bot.message_handler(func=lambda message: True)
def echo(message):
Expand Down
4 changes: 4 additions & 0 deletions src/summarize_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ def segment_text(self, result) -> str:
print(f"An error occurred: {str(e)}")
segmented_text = re.sub(r'[\.,\n]', '\n', segmented_text) # Replace dots, commas, and newlines with newlines
segmented_text = segmented_text.replace(' and ', '\n') # Replace 'and' with newlines separate
self.create_response_list()

return segmented_text

def create_response_list(self):
self.response_list = None

def translate_to_english(self, text, to_lang='en'):
# Step 5: Translate the text to English
translated_text = self.translator.translate(text,to_lang=to_lang)
Expand Down

0 comments on commit b4d1b8e

Please sign in to comment.