Exemplo n.º 1
0
 def on_disconnect(self, connection, event):
     if 'CLOSE_OK' in event.arguments:
         log.info("Connection closed")
         self.system_message(translate_key(
             MODULE_KEY.join(['twitch',
                              'connection_closed'])).format(self.nick),
                             category='connection')
         raise TwitchNormalDisconnect()
     else:
         log.info("Connection lost")
         log.debug("connection: {}".format(connection))
         log.debug("event: {}".format(event))
         self.chat_module.set_offline(self.nick)
         self.system_message(translate_key(
             MODULE_KEY.join(['twitch',
                              'connection_died'])).format(self.nick),
                             category='connection')
         timer = threading.Timer(5.0,
                                 self.reconnect,
                                 args=[
                                     self.main_class.host,
                                     self.main_class.port,
                                     self.main_class.nickname
                                 ])
         timer.start()
Exemplo n.º 2
0
 def on_join(self, connection, event):
     log.debug("connection: {}".format(connection))
     log.debug("event: {}".format(event))
     msg = translate_key(MODULE_KEY.join(['twitch', 'join_success'
                                          ])).format(self.channel)
     log.info(msg)
     self.system_message(msg, category='connection')
Exemplo n.º 3
0
 def opened(self):
     success_msg = "Connection Successful"
     log.info(success_msg)
     self.chat_module.set_online(self.main_thread.nick)
     try:
         self.chat_module.set_viewers(
             self.main_thread.nick,
             self.chat_module.get_viewers(self.main_thread.nick))
     except Exception as exc:
         log.exception(exc)
     self.system_message(translate_key(
         MODULE_KEY.join(['goodgame', 'connection_success'
                          ])).format(self.main_thread.nick),
                         category='connection')
     # Sending join channel command to goodgame websocket
     join = json.dumps(
         {
             'type': "join",
             'data': {
                 'channel_id': self.ch_id,
                 'hidden': "true"
             }
         },
         sort_keys=False)
     self.send(join)
     # self.ggPing()
     log.info("Sent join message")
Exemplo n.º 4
0
    def closed(self, code, reason=None):
        """
        Codes used by LC
        4000 - Normal disconnect by LC
        4001 - Invalid Channel ID

        :param code: 
        :param reason: 
        """
        self.chat_module.set_offline(self.channel_name)
        if code in [4000, 4001]:
            self.crit_error = True
            self.fs_system_message(translate_key(
                MODULE_KEY.join(['sc2tv', 'connection_closed'])).format(self.channel_name),
                                category='connection')
        else:
            log.info("Websocket Connection Closed Down")
            self.fs_system_message(
                translate_key(MODULE_KEY.join(['sc2tv', 'connection_died'])).format(self.channel_name),
                category='connection')
            timer = threading.Timer(5.0, self.main_thread.connect)
            timer.start()
Exemplo n.º 5
0
 def _process_user_ban(self, msg):
     if msg['data']['duration']:
         self.ws_class.system_message(translate_key(
             MODULE_KEY.join(['goodgame',
                              'ban'])).format(msg['data']['moder_name'],
                                              msg['data']['user_name'],
                                              msg['data']['duration'] / 60,
                                              msg['data']['reason']),
                                      category='chat')
     else:
         if msg['data']['permanent']:
             self.ws_class.system_message(translate_key(
                 MODULE_KEY.join(['goodgame', 'ban_permanent'
                                  ])).format(msg['data']['moder_name'],
                                             msg['data']['user_name']),
                                          category='chat')
         else:
             self.ws_class.system_message(translate_key(
                 MODULE_KEY.join(['goodgame', 'unban'
                                  ])).format(msg['data']['moder_name'],
                                             msg['data']['user_name']),
                                          category='chat')
Exemplo n.º 6
0
    def fs_join(self):
        # Then we send the message acording to needed format and
        #  hope it joins us
        if self.channel_id:
            payload = [
                '/chat/join',
                {
                    'channel': 'stream/{0}'.format(str(self.channel_id))
                }
            ]
            self.fs_send(payload)

            msg_joining = translate_key(MODULE_KEY.join(['sc2tv', 'joining']))
            self.fs_system_message(msg_joining.format(self.channel_name), category='connection')
            log.info(msg_joining.format(self.channel_id))
Exemplo n.º 7
0
 def on_welcome(self, connection, event):
     log.info("Welcome Received, joining {0} channel".format(self.channel))
     log.debug("event: {}".format(event))
     self.tw_connection = connection
     self.system_message(translate_key(
         MODULE_KEY.join(['twitch', 'joining'])).format(self.channel),
                         category='connection')
     self.chat_module.set_online(self.nick)
     # After we receive IRC Welcome we send request for join and
     #  request for Capabilities (Twitch color, Display Name,
     #  Subscriber, etc)
     connection.join(self.channel)
     connection.cap('REQ', ':twitch.tv/tags')
     connection.cap('REQ', ':twitch.tv/commands')
     ping_handler = TwitchPingHandler(connection, self.chat_module, self)
     ping_handler.start()
Exemplo n.º 8
0
 def _process_user_warn(self, msg):
     self.ws_class.system_message(translate_key(
         MODULE_KEY.join(['goodgame',
                          'warning'])).format(msg['data']['moder_name'],
                                              msg['data']['user_name']),
                                  category='chat')
Exemplo n.º 9
0
 def _process_join(self):
     self.ws_class.system_message(translate_key(
         MODULE_KEY.join(['goodgame', 'join_success'])).format(self.nick),
                                  category='connection')
Exemplo n.º 10
0
 def opened(self):
     log.info("Websocket Connection Succesfull")
     self.fs_system_message(translate_key(MODULE_KEY.join(['sc2tv', 'connection_success'])), category='connection')
Exemplo n.º 11
0
 def _process_joined(self):
     self.chat_module.set_online(self.channel_name)
     self.fs_system_message(
         translate_key(MODULE_KEY.join(['sc2tv', 'join_success'])).format(self.channel_name), category='connection')
Exemplo n.º 12
0
 def gui_button_press(self, gui_module, event, list_keys):
     log.debug("Received button press for id {0}".format(event.GetId()))
     keys = MODULE_KEY.join(list_keys)
     if keys == 'menu.reload':
         self.reload_chat()
     event.Skip()
Exemplo n.º 13
0
 def gui_button_press(self, gui_module, event, list_keys):
     log.debug("Received button press for id {0}".format(event.GetId()))
     keys = MODULE_KEY.join(list_keys)
     if keys == 'menu.reload':
         self.reload_chat()
     event.Skip()