Ejemplo n.º 1
0
    def parse_message(self, msg):
        # Extract details from message
        sender_id = msg['sender_id']['chat_id']
        msg_type = msg['event_type']
        timestamp = int(msg['timestamp']) / 1000000

        # Check if conversation participant is known
        participant = self.get_participant(sender_id)
        if participant is None:
            LOG_DEBUG('Parsing message for unkown participant')
            self.message_data.append([timestamp, msg_type, sender_id])
            return

        # Add message to database
        self.message_data.append(
            [timestamp, msg_type,
             participant.get_name_or_id()])
        participant.add_message(msg_type)

        # Perform message-type-based actions
        if msg_type == 'RENAME_CONVERSATION':
            self.conversation_names.append(
                msg['conversation_rename']['new_name'])
        elif msg_type == 'ADD_USER':
            for id in msg['membership_change']['participant_id']:
                if not self.is_participant(id['chat_id']):
                    self.add_participant(id['chat_id'])
        elif msg_type == 'HANGOUT_EVENT':
            event = msg['hangout_event']
            event_type = event['event_type']

            if event_type == 'END_HANGOUT':
                self.hangouts_duration_s += int(event['hangout_duration_secs'])
Ejemplo n.º 2
0
 def add_message(self, msg_type):
     if msg_type not in self.num_messages.keys():
         LOG_DEBUG(
             'Trying to parse unknown message type: {}'.format(msg_type))
         return
     else:
         self.num_messages[msg_type] += 1
Ejemplo n.º 3
0
 def saveConfig(self, file, data):
     LOG_DEBUG('GUIFlash :', 'Save config in file "%s".' % file)
     with open(file, 'wb') as file:
         json.dump(data,
                   codecs.getwriter('utf-8')(file),
                   indent=4,
                   sort_keys=True,
                   ensure_ascii=False)
Ejemplo n.º 4
0
def newBattleRoyalePageCloseSpawnPoints(self):
    try:
        LOG_DEBUG('newBattleRoyalePageCloseSpawnPoints called!')
        g_guiHooks.onBattleRoyaleSpawnVisibilityChanged(False)
    except StandardError:
        pass
    finally:
        hooked_closeSpawnPoints(self)
Ejemplo n.º 5
0
 def saveConfig(self, path, data):
     LOG_DEBUG("Save config in file '%s'." % path)
     with open(path, 'wb') as f:
         json.dump(data,
                   codecs.getwriter('utf-8')(f),
                   indent=4,
                   sort_keys=True,
                   ensure_ascii=False)
Ejemplo n.º 6
0
    def _populate(self):
        g_eventBus.addListener(events.GameEvent.SHOW_CURSOR,
                               self.__handleShowCursor, EVENT_BUS_SCOPE.GLOBAL)
        g_eventBus.addListener(events.GameEvent.HIDE_CURSOR,
                               self.__handleHideCursor, EVENT_BUS_SCOPE.GLOBAL)
        g_eventBus.addListener(events.GameEvent.RADIAL_MENU_CMD,
                               self.__toggleRadialMenu,
                               scope=EVENT_BUS_SCOPE.BATTLE)
        g_eventBus.addListener(events.GameEvent.FULL_STATS,
                               self.__toggleFullStats,
                               scope=EVENT_BUS_SCOPE.BATTLE)
        g_eventBus.addListener(events.GameEvent.FULL_STATS_QUEST_PROGRESS,
                               self.__toggleFullStatsQuestProgress,
                               scope=EVENT_BUS_SCOPE.BATTLE)
        g_guiResetters.add(self.__onResizeStage)

        ctrl = self.sessionProvider.dynamic.maps
        if ctrl is not None and hasattr(ctrl, 'onVisibilityChanged'):
            ctrl.onVisibilityChanged += self.__onMapVisibilityChanged

        # NOTE: frontline respawn screen
        ctrl = self.sessionProvider.dynamic.respawn
        if ctrl is not None and hasattr(ctrl, 'onRespawnVisibilityChanged'):
            ctrl.onRespawnVisibilityChanged += self.__onRespawnVisibilityChanged

        # NOTE: steel hunter select spawn screen
        spawnCtrl = self.sessionProvider.dynamic.spawn
        if spawnCtrl is not None:
            if hasattr(BattleRoyalePage, 'showSpawnPoints'):
                global hooked_showSpawnPoints
                if hooked_showSpawnPoints is None:
                    hooked_showSpawnPoints = BattleRoyalePage.showSpawnPoints
                    BattleRoyalePage.showSpawnPoints = newBattleRoyalePageShowSpawnPoints
                    LOG_DEBUG('BattleRoyalePage:showSpawnPoints hooked!')

            if hasattr(BattleRoyalePage, 'closeSpawnPoints'):
                global hooked_closeSpawnPoints
                if hooked_closeSpawnPoints is None:
                    hooked_closeSpawnPoints = BattleRoyalePage.closeSpawnPoints
                    BattleRoyalePage.closeSpawnPoints = newBattleRoyalePageCloseSpawnPoints
                    LOG_DEBUG('BattleRoyalePage:closeSpawnPoints hooked!')
Ejemplo n.º 7
0
 def readConfig(self, file):
     LOG_DEBUG("Read config from file '%s'." % file)
     with open(file, "r") as file:
         data = json.load(file)
     return data
Ejemplo n.º 8
0
 def delete(self, alias):
     LOG_DEBUG("Destroy cache: '%s'" % alias)
     del self.components[alias]
Ejemplo n.º 9
0
 def update(self, alias, props):
     LOG_DEBUG("Change cache: '%s' -> Properties: %s" % (alias, props))
     self.components[alias].get('props').update(props)
Ejemplo n.º 10
0
 def create(self, alias, type, props):
     LOG_DEBUG("Create cache: '%s' [%s] -> Properties: %s" %
               (alias, type, props))
     self.components[alias] = {'type': type, 'props': props}
Ejemplo n.º 11
0
 def delete(self, alias):
     if self.ui is not None:
         LOG_DEBUG("Destroy component: '%s'" % alias)
         self.ui.as_deleteS(alias)
Ejemplo n.º 12
0
 def update(self, alias, props, params):
     if self.ui is not None:
         LOG_DEBUG(
             "Change component: '%s' -> Properties: %s | Parameters: %s" %
             (alias, props, params))
         self.ui.as_updateS(alias, props, params)
Ejemplo n.º 13
0
 def create(self, alias, type, props):
     if self.ui is not None:
         self.ui.as_createS(alias, type, props)
         LOG_DEBUG(
             'GUIFlash :', 'Component "%s" [%s] created. Parameters: %s' %
             (alias, type, props))
Ejemplo n.º 14
0
 def readConfig(self, file):
     LOG_DEBUG('GUIFlash :', 'Read config from file "%s".' % file)
     with open(file, "r") as file:
         data = json.load(file)
     return data
Ejemplo n.º 15
0
 def delete(self, alias):
     del self.components[alias]
     LOG_DEBUG('GUIFlash :', 'Cache "%s" deleted.' % alias)
Ejemplo n.º 16
0
 def update(self, alias, props):
     self.components[alias].get('props').update(props)
     LOG_DEBUG('GUIFlash :',
               'Cache "%s" updated. Parameters: %s' % (alias, props))
Ejemplo n.º 17
0
 def create(self, alias, type, props):
     self.components[alias] = {'type': type, 'props': props}
     LOG_DEBUG(
         'GUIFlash :',
         'Cache "%s" [%s] created. Parameters: %s' % (alias, type, props))
Ejemplo n.º 18
0
 def delete(self, alias):
     if self.ui is not None:
         self.ui.as_deleteS(alias)
         LOG_DEBUG('GUIFlash :', 'Component "%s" deleted.' % alias)
Ejemplo n.º 19
0
 def update(self, alias, props):
     if self.ui is not None:
         self.ui.as_updateS(alias, props)
         LOG_DEBUG(
             'GUIFlash :',
             'Component "%s" updated. Parameters: %s' % (alias, props))
Ejemplo n.º 20
0
 def create(self, alias, type, props):
     if self.ui is not None:
         LOG_DEBUG("Create component: '%s' [%s] -> Properties: %s" %
                   (alias, type, props))
         self.ui.as_createS(alias, type, props)
Ejemplo n.º 21
0
 def readConfig(self, path):
     LOG_DEBUG("Read config from file '%s'." % path)
     with open(path, "r") as f:
         data = json.load(f)
     return data