Search code examples
pythonpython-3.xcountdown

Creating a program that will keep track of my schedule


I'm currently working on a project to make a chat bot that would make my life a little bit easier. One of the features that i'm working on is to make it help me with my schedule, and I would write "!cal" (! is my prefix).

And it would return something like, "You have a meeting coming up in 45 minutes". I know how to make a countdown to a said date or time, but not how to make it 'remember' my whole schedule. How would I do this?


Solution

  • You could use a data structure such as a dictionary for this chatbot.

    cal = {}
    
    def addEvent(event, time, length): #time is a datetime
        cal[time] = [event, length]
    

    The dictionary will store your events with the times as indices. You can access the events at a specific time, sort the calendar and query for the closest upcoming event, automatically delete events that have already passed, query for a time and see if there are any conflicts, or honestly do just about anything you would need.