Пример #1
0
    def getRoster(self):
        t = time.time()
        
        if self.last_roster is not None and self.last_roster_check_time is not None:
            if self.last_roster_check_time + self.MIN_DELAY_BETWEEN_ROSTER_CHECKS > t:
                return self.last_roster
        
        Logger.debug(self, "Checking Steam Roster")
        roster = {}
        
        try:
            for friend in self.user.friends:

                if friend.state == 0:
                    continue
                
                roster[friend.steamid] = {
                        'name': str(friend),
                        'special': friend.currently_playing is not None,
                        'currently_playing': friend.currently_playing
                    }
        except:
            Logger.debug(self, "Exception while trying to load Steam user friends/state!")
            return self.last_roster
        
        
        self.last_roster = roster
        self.last_roster_check_time = t
        
        return roster
Пример #2
0
 def start(self):
     super(SteamChatMedium, self).start()
     
     Logger.debug(self, "Starting SteamChat for '%s'" % self._alias)
     steamapi.core.APIConnection(api_key=self._config['api_key'])
     self.user = steamapi.user.SteamUser(self._config['SteamUser'])
     while True:
         time.sleep(10)
Пример #3
0
 def start(self):
     super(IrcChatMedium, self).start()
     
     while True:
         Logger.debug(self, "Starting IrcChat for '%s'" % self._alias)
         self._irc = IRCBot(self)
         self._irc.start()
         Logger.warning(self, "IrcChat loop for '%s' ended" % self._alias)
         time.sleep(10)
Пример #4
0
 def processMessageQueue(self):
     while True:
         message = self._message_queue.get(True)
         
         if message is None:
             Logger.debug(self, "No message found in processMessageQueue, skipping...")
             continue
         
         #Logger.debug(self, "Message queue found message to send.")
         
         if time.time() - self._last_message_sent < self.MIN_DELAY_BETWEEN_MESSAGES:
             sleep_time = self.MIN_DELAY_BETWEEN_MESSAGES - (time.time() - self._last_message_sent)
             Logger.debug(self, "Recently sent a message. Sleeping for %f seconds..." % sleep_time)
             time.sleep(sleep_time)
         
         #Logger.debug(self, "Message queue sending message.")     
         self.sendMessage(message)
Пример #5
0
 def start(self):
     super(JabberChatMedium, self).start()
     
     while True:
         Logger.debug(self, "Starting JabberChat for '%s'" % self._alias)
         self._xmpp = JabberBot(self._config['username'], self._config['password'], self)
         self._xmpp.register_plugin('xep_0030') # Service Discovery
         self._xmpp.register_plugin('xep_0045') # Multi-User Chat
         #self._xmpp.register_plugin('xep_0249') # Direct MUC Invitations
         self._xmpp.register_plugin('xep_0199') # XMPP Ping                     
         
         self._xmpp.add_event_handler("message", self.onJabberMessage)
         self._xmpp.add_event_handler("groupchat_message", self.onJabberGroupMessage)
         
         use_ssl = self._config.has_key('use_ssl') and self._config['use_ssl']
         self._xmpp.connect((self._config['server'], self._config['port']), use_ssl=use_ssl)
         self._xmpp.process(threaded=False)
         
         self._xmpp = None
     
         Logger.warning(self, "JabberChat loop for '%s' ended" % self._alias)
         time.sleep(10)