Example #1
0
 async def updateZoom(self, ctx, *, s):
     info = s.split()
     num = None
     link = None
     schedules = self.unserialize(Schedule.readSchedule())
     for i in range(0, len(schedules)):
         if schedules[i].periods[0].userid == str(ctx.message.author.id):
             try:
                 num = int(info[0])
                 link = info[1]
             except:
                 await ctx.channel.send('Please separate them by space!')
                 return
             for j in range(0, len(schedules[i].periods)):
                 if schedules[i].periods[j].period == num:
                     schedules[i].periods[j].zoomlink = link
                     Schedule.writeSchedule(self.serialize(schedules))
                     await ctx.message.delete()
                     await ctx.channel.send(
                         'Your zoom link has been updated!')
                     return
     await ctx.channel.send(
         'Oops, something went wrong, make sure your period number is correct and try again!'
     )
     return
Example #2
0
 def unserialize(self, d):
     #takes a serialized json dictionary, unserialize it to a list of schedules
     result = []
     for dct in d['schedule']:
         name = dct['name']
         lectures = []
         for period in dct['periods']:
             lectures.append(
                 Lecture(period[0], period[1], period[2], period[3]))
         schedule = Schedule(name, [], False, period[3])
         schedule.periods = lectures
         result.append(schedule)
     return result
Example #3
0
 async def deleteSchedule(self, ctx):
     found = False
     schedules = self.unserialize(Schedule.readSchedule())
     for i in range(0, len(schedules)):
         if not found:
             if schedules[i].periods[0].userid == str(
                     ctx.message.author.id):
                 schedules.pop(i)
                 found = True
     Schedule.writeSchedule(self.serialize(schedules))
     if found:
         await ctx.send('Schedule found and deleted')
     else:
         await ctx.send('Schedule not found, try again')
Example #4
0
 async def findSchedule(self, ctx):
     found = False
     schedules = self.unserialize(Schedule.readSchedule())
     for schedule in schedules:
         if schedule.periods[0].userid == str(ctx.message.author.id):
             display = discord.Embed(title=f'Schedule of {schedule.name}',
                                     author='Emu Bot',
                                     colour=discord.Colour.green(),
                                     description='This is your schedule')
             for period in schedule.periods:
                 display.add_field(
                     name=f'Period {period.period}',
                     value=f'{period.name} \n Zoom Link: {period.zoomlink}')
             await ctx.send(embed=display)
Example #5
0
 async def showAllSchedule(self, ctx):
     if ctx.message.author.id != 479427064336875530:
         await ctx.send('Sorry, you are not authorized to use this command')
         return
     schedules = self.unserialize(Schedule.readSchedule())
     display = discord.Embed(title='All Schedules Entry in the Data Base',
                             colour=discord.Colour.green(),
                             description='Available Methods: none',
                             author='Emu Bot')
     for schedule in schedules:
         periodnames = []
         for period in schedule.periods:
             periodnames.append(period.name)
         display.add_field(name=f'The schedule of {schedule.name}',
                           value=str(periodnames))
     await ctx.send(embed=display)
Example #6
0
 def storeSchedule(self, name, periods, ifAM, userID):
     sched = Schedule(name, periods, ifAM, userID)
     sched.appendSchedule()
Example #7
0
 async def remindOn(self, ctx):
     schedules = self.unserialize(Schedule.readSchedule())
     self.appendSignups(ctx.message.author.id)
     await ctx.send(
         'OK, you have signed up for the schedule remind function!')
Example #8
0
 def findScheduleInstance(self, userid):
     schedules = self.unserialize(Schedule.readSchedule())
     for schedule in schedules:
         if schedule.periods[0].userid == str(userid):
             return schedule