コード例 #1
0
ファイル: 000_core.py プロジェクト: richo/pyBawt
 def handle(self, msg):
     # We contruct this list at runtime, which makes the objects mutable,
     # whereas if it were constructed and stored, we would not be able to
     # alter them on the fly
     try:
         self.handlers[msg.event](msg)
     except KeyError:
         logging.fixme("Module %s attached a handler to an event it couldn't handle" % (self._name))
コード例 #2
0
ファイル: core_modules.py プロジェクト: psych0tik/pyBawt
 def handle_part(self, msg):
     logging.info("Losing sight of %s" % msg.nick)
     try:
         self.visible[msg.address_segment].remove(msg.nick)
     except ValueError:
         logging.fixme("%s left %s without having been seen, testing auth anyway" % (msg.nick, msg.address_segment))
     if self.visible.refcount(msg.nick) == 0:
         logging.info("Can't see %s; deauthing" % msg.nick)
         self.parent.authenticator.revoke_auth(msg.nick)
コード例 #3
0
ファイル: ircSocket.py プロジェクト: psych0tik/pyBawt
 def add_module(self, module):
     # Really haxy test for modules already loaded
     try:
         mod = getattr(bModules, module)
         for i in self.modules:
             logging.fixme("Scanning %s against %s" % (i, mod))
             if isinstance(i, mod):
                 raise bModules.ModuleAlreadyLoaded
         self.modules.append(mod(self.parent, self))
         return True
     except AttributeError:
         return False
コード例 #4
0
ファイル: ircSocket.py プロジェクト: richo/pyBawt
 def __init__(self, msg):
     self.msg = msg
     self.data_segment = None
     self.address_segment = None
     self.nick = None
     self.name = None
     self.host = None
     self.numeric = False
     self._debug = False
     self.source, self.event, self.data = msg.split(" ", 2)
     self.event = self.event.upper()
     self.replyto = None
     self.origin = None
     try:
         int(self.event)
         self.numeric = True
         if ":" in self.data:
             self.address_segment, self.data_segment = [i.strip() for i in self.data.split(":", 1)]
     except ValueError:
         # For the most part, we can safely only look at stuff that's non-numeric
         # Implies that self.event wasn't a number
         if ":" in self.data:
             self.address_segment, self.data_segment = [i.strip() for i in self.data.split(":", 1)]
         else:
             logging.fixme("No address segment: %s" % self.data)
             self.data_segment = self.data
             self.address_segment = "<NoAddress>"
         # We go a bit further in attempting to gather info...
         #:[email protected]
         m = RE_NICK_MATCH.search(self.source)
         if m:
             self.nick = m.group(1)
             self.name = m.group(2)
             self.host = m.group(3)
     # Hax to make this slightly more logical
     if self.event == "JOIN":
         self.address_segment = self.data_segment
     # Hanlder hax
     if self.event == "MODE":
         self.address_segment = self.data_segment.split(" ", 1)[0]
     if self.is_private():
         self.replyto = self.nick
         self.origin = 'privmsg'
     else:
         self.replyto = self.address_segment
         self.origin = self.address_segment