def executeInternal(self, args): if args.order == "asc": manager.m_config.m_isAscendingSort = True else: manager.m_config.m_isAscendingSort = False manager.publish() resultStr = "Ascending" if manager.m_config.m_isAscendingSort == True else "Descending" return [["Sorting", resultStr]]
def executeInternal(self, args): print("Edit Command - Execute Internal") foundEvent = manager.find_event_by_id(args.UID) if foundEvent == None: raise Exception(f"No event found with ID {args.UID}") foundEvent.isDirty = True # String Updates if args.name != None: foundEvent.name = args.title if args.description != None: foundEvent.description = args.description if args.image != None: foundEvent.image = args.image if args.thumbnail != None: foundEvent.thumbnail = args.thumbnail # Time Updates now = helpers.get_now_offset() # Start start = helpers.merge_time_with_date_base(foundEvent.start, args.start, args.start_date) if start != foundEvent.start: if start < now: raise Exception(f"Start time is in the past!") # End end = foundEvent.end if args.end != None or args.end_date != None: baseEnd = end if end == None: baseEnd = start end = helpers.merge_time_with_date_base(baseEnd, args.end, args.end_date) if end != None: if end < start: raise Exception(f"End is before start") foundEvent.start = start foundEvent.end = end manager.publish() results = [f"Updated event :id: {foundEvent.id}"] results.append( f'Title: "{foundEvent.name}"\nStart: {foundEvent.start}\nEnd: {foundEvent.end}\nDescription: "{foundEvent.description}"' ) if foundEvent.thumbnail != None: results[1] = f"{results[1]}\nThumbnail: '{foundEvent.thumbnail}'" if foundEvent.image != None: results[1] = f'{results[1]}\nImage: "{foundEvent.image}"' return results
def executeInternal(self, args): if args.addremove == "add": manager.m_config.m_reminders.append( Reminder(abs(args.hours), args.message)) manager.publish() return [[ "Reminders", f"Reminder Added {args.hours} hours before events begin." ]] else: for reminder in manager.m_config.m_reminders: if reminder.hours == args.hours: manager.m_config.m_reminders.remove(reminder) manager.publish() return [[ "Reminders", f"Reminder {args.hours} has been removed." ]] raise Exception(f"Reminder {args.hours} could not be found.")
def executeInternal(self, args): manager.m_config.m_welcomeMessage = args.message manager.publish() return [["Welcome Message", args.message]]
def executeInternal(self, args): # Validate Channel? Maybe do that at a higher level? manager.m_config.m_debugChannel = args.channel manager.publish() return [["Debug", f"Debug channel set to <#{args.channel}>"]]
def executeInternal(self, args): manager.m_config.m_signupLimit = args.limit manager.publish() return [["Signup Limit", f"Signup limit set to {args.limit}"]]
def executeInternal(self, args): # Validate this? Maybe keep less than +-12 # In the future could add names of timezones or countries but not required manager.m_config.m_utcOffset = args.offset manager.publish() return [["Timezone", f"Timezone set to {args.offset}"]]
def executeInternal(self, args): # Validate Channel? Maybe do that at a higher level? manager.m_config.m_heartbeatChannel = args.channel manager.publish() return [["Heartbeat", f"Heartbeat channel set to <#{args.channel}>"]]
def executeInternal(self, args): manager.m_config.m_announcementChannel = args.channel manager.publish() return [[ "Announcements", f"Announcements channel set to <#{args.channel}>" ]]
def executeInternal(self, args): now = helpers.get_now_offset() # Validate Start start = args.start start_date = args.start_date if start_date != None: gmStartDate = time.gmtime(start_date.timestamp()) start = start.replace(year=gmStartDate.tm_year, month=gmStartDate.tm_mon, day=gmStartDate.tm_mday) if start < now: raise Exception("Start time is in the past!") # Validate End end = args.end end_date = args.end_date if end != None and end_date == None: gmStart = time.gmtime(start.timestamp()) end = end.replace(year=gmStart.tm_year, month=gmStart.tm_mon, day=gmStart.tm_mday) elif end == None and end_date != None: gmStart = time.gmtime(start.timestamp()) end = end.replace(hour=gmStart.tm_hour, minute=gmStart.tm_min) elif end != None and end_date != None: gmEnd = time.gmtime(end.timestamp()) end = end_date.replace(hour=gmEnd.tm_hour, minute=gmEnd.tm_min) if end != None and end < start: raise Exception("End time is before start!") thumbnail = args.thumbnail if thumbnail == None: thumbnail = manager.m_config.m_thumbnails[start.weekday()] image = args.image newEvent = Event(args.title, start, end=end, description=args.description, image=image, thumbnail=thumbnail) # If event is started past a reminder time, set as reminded for reminder in manager.m_config.m_reminders: reminderDelta = timedelta(hours=reminder.hours) reminderTime = newEvent.start - reminderDelta if reminderTime < now: newEvent.reminded.append(reminder.hours) signups = {} for emoji in manager.m_config.m_reactions.keys(): signups[emoji] = [] manager.add_event(newEvent) manager.publish() results = [f"New event created :id: {newEvent.id}"] results.append( f'Title: "{newEvent.name}"\nStart: {newEvent.start}\nEnd: {newEvent.end}\nDescription: "{newEvent.description}"' ) if newEvent.thumbnail != None: results[1] = f"{results[1]}\nThumbnail: '{newEvent.thumbnail}'" if newEvent.image != None: results[1] = f'{results[1]}\nImage: "{newEvent.image}"' return results