def prof_response(self, arg_list): prof_name = " ".join(arg_list) prof_list = [ prof for prof in self.stevens.professor_list if prof_name in prof.name.lower() ] professor = None for prof in prof_list: if prof.name.lower() == prof_name: professor = prof if not prof_list: return "No professors with name {}".format(prof_name) elif len(prof_list) > 1 and professor is None: return "Multiple professors found: " + ", ".join( [prof.name.title() for prof in prof_list]) ret_str = "Professor {}:".format(professor.name) ret_str += "\n-------------" for day_code, section_list in professor.day_section_list_dict.items(): ret_str += "\n" + self.day_code_bict.find(day_code).title() for section in section_list: ret_str += "\n\t" + "{} - {}: Room {} - {}".format( Functions.get_pretty_time(section.start_time), Functions.get_pretty_time(section.end_time), section.room_name, section.name) return ret_str
def room_response(self, arg_list): """ This function will always run with at least one arg because the of the command class's required_args. """ room_name, *day_code_list = arg_list room_list = [ room for room in self.stevens.room_list if room_name in room.name.lower() ] if not room_list: return "No rooms found with {} prefix".format(room_name) elif len(room_list) > 1: return "Multiple rooms found: " + ", ".join( [room.name.upper() for room in room_list]) if not day_code_list: day_code_list.append( self.day_code_bict.find( datetime.datetime.now().strftime("%A").lower())) day_code_list = [ dc.lower() for dc in day_code_list if self.day_code_bict.exists(dc) ] day_code_list = [ dc if len(dc) < 2 else self.day_code_bict.find(dc) for dc in day_code_list ] room = room_list[0] ret_str = "Room {}: searching for {}".format( room.name.upper(), ", ".join([ self.day_code_bict.find(dc) for dc in day_code_list if self.day_code_bict.exists(dc) ])) for day_code in day_code_list: ret_str += "\n{}".format(self.day_code_bict.find(day_code).title()) if section_list := room.day_section_list_dict.get(day_code): for section in section_list: ret_str += "\n\t{} - {}: {} ({})".format( Functions.get_pretty_time(section.start_time), Functions.get_pretty_time(section.end_time), section.name, section.professor_name) else: ret_str += "\n\tNo sections on this day"
def main(): twitch_credentials_dict = Functions.parse_json(Constants.twitch_credentials_file_path) twitch_oauth_dict = TwitchLib.get_oauth_dict(twitch_credentials_dict["client_id"], twitch_credentials_dict["secret"]) streamer = Streamer.Streamer( credentials_dict=twitch_credentials_dict, oauth_dict=twitch_oauth_dict, **TwitchLib.get_streamer_dict(twitch_credentials_dict["client_id"], twitch_oauth_dict["access_token"])["data"][0] ) print("Current followers as of {}:".format(Functions.get_pretty_time(datetime.datetime.now()))) print(Functions.tab_str("\n".join([str(x) for x in streamer.get_follower_list()]), 1)) print("-------------\n") streamer.listen_for_followers()
def __str__(self): return "{} | name: {} id: {}".format( Functions.get_pretty_time(self.followed_at), Functions.str_to_length(self.from_name, 18), self.from_id )