def run(self) -> None: discord_client = discord.Client() weather_service = WeatherService( self._settings.integration_settings.open_weather_map_api_key, self._settings.integration_settings.weather_underground_api_key) message_factory = MessageFactory(self._settings) command_handler = CommandHandler(self._settings, weather_service, discord_client, message_factory) weather_discord_service = WeatherDiscordService( self._settings.measurement_system, self._settings.home_settings, weather_service, discord_client) @discord_client.event async def on_message(message) -> None: await command_handler.handle(message) discord_client.loop.create_task( weather_discord_service.send_home_forecast()) discord_client.loop.create_task( weather_discord_service.update_profile()) discord_client.loop.create_task( weather_discord_service.update_presence()) discord_client.run( self._settings.integration_settings.discord_bot_token)
def run_loop(stdscreen): command_handler = CommandHandler(stdscreen) search_key = 115 select_key = ord('\n') spotify_client_key = 102 quit_key = 113 goto_index_key = 105 artist_tracks_key = 116 album_tracks_key = 97 move_up_key = curses.KEY_UP move_up_key_2 = 107 move_down_key = curses.KEY_DOWN move_down_key_2 = 106 next_song_key = curses.KEY_RIGHT next_song_key_2 = 108 prev_song_key = curses.KEY_LEFT prev_song_key_2 = 104 play_pause_key = 32 back_key = 98 forward_key = 110 command_list_key = 99 country_change_key = 121 command_dict = { move_up_key: command_handler.move_up, move_down_key: command_handler.move_down, next_song_key: command_handler.next_song, prev_song_key: command_handler.prev_song, move_up_key_2: command_handler.move_up, move_down_key_2: command_handler.move_down, next_song_key_2: command_handler.next_song, prev_song_key_2: command_handler.prev_song, search_key: command_handler.search_content, select_key: command_handler.current_song, spotify_client_key: command_handler.show_client, goto_index_key: command_handler.play_at_index, artist_tracks_key: command_handler.get_artist_top, album_tracks_key: command_handler.get_album_tracks, play_pause_key: command_handler.toggle_play_pause, back_key: command_handler.prev_track_list, forward_key: command_handler.next_track_list, command_list_key: command_handler.print_command_list, country_change_key: command_handler.country_check, } curses.curs_set(0) intro(stdscreen) command_handler.country_check() command_handler.prompt_area.addstr(0, 0, "Good To Go! Start a search with [S]") command_handler.prompt_area.refresh() while True: char_input = stdscreen.getch() if char_input == quit_key: sys.exit() elif char_input in command_dict: command_dict.get(char_input)()
def access(bot, event): """Report user's access levels.""" target = event.target if event.type == 'pubmsg' else event.source.nick sender = event.source.nick dummy = CommandHandler(event, bot) access_level = dummy.perm_level() bot.connection.privmsg(target, f'{sender} has level {access_level} clearance.')
def __init__(self, bot_jid, stream): self.bot_jid = bot_jid self._stream = stream self.cmd_handler = CommandHandler(message_bus=self) self.admin_cmd_handler = AdminCMDHandler(message_bus=self) self.logger = get_logger() self.offline_split_symbol = "$_$_$_$" return