Ejemplo n.º 1
0
 def doevent(self, event):
     """ dispatch an event. """
     time.sleep(0.01)
     if not self.cfg:
         raise Exception(
             "eventbase - cfg is not set .. can't handle event.")
         return
     if not event: raise NoEventProvided()
     self.ecounter += 1
     if event.userhost in self.state['ignore']:
         logging.warn("%s - ignoring %s" % (self.cfg.name, event.userhost))
         return
     try:
         if event.isremote():
             self.doremote(event)
             return
         if event.type == "groupchat" and event.fromm in self.ids:
             logging.debug("%s - receiving groupchat from self (%s)" %
                           (self.cfg.name, event.fromm))
             return
         event.txt = self.inputmorphs.do(fromenc(event.txt, self.encoding),
                                         event)
     except UnicodeDecodeError:
         logging.warn("%s - got decode error in input .. ingoring" %
                      self.cfg.name)
         return
     event.bind(self, noraise=True)
     try:
         logging.debug("%s - event dump: %s" %
                       (self.cfg.name, event.dump()))
     except:
         pass
     self.status = "callback"
     starttime = time.time()
     if self.closed:
         if self.gatekeeper.isblocked(event.origin):
             logging.warn("%s is blocked" % event.origin)
             return
     if event.status == "done":
         logging.warn("%s - event is done .. ignoring" % self.cfg.name)
         return
     if event.msg or event.isdcc: event.speed = 2
     if event.channelchanged:
         cmnds.dispatch(self, event)
         return
     e1 = cpy(event)
     first_callbacks.check(self, e1)
     if not e1.stop:
         callbacks.check(self, e1)
         if not e1.stop: last_callbacks.check(self, e1)
     event.callbackdone = True
     waiter.check(self, event)
     #mainsink.put(5, self, event)
     self.lastiter = time.time()
     self.benice()
     return event
Ejemplo n.º 2
0
 def dispatch(self, bot, event, wait=0, *args, **kwargs):
     """ dispatch event onto the cmnds object. check for pipelines first. """
     result = []
     if not event.pipelined and ' ! ' in event.txt:
         return self.pipelined(bot, event, wait=wait, *args, **kwargs)
     self.reloadcheck(bot, event)
     return cmnds.dispatch(bot, event, wait=wait, *args, **kwargs)
Ejemplo n.º 3
0
 def doevent(self, event):
     """ dispatch an event. """ 
     time.sleep(0.01)
     if not self.cfg: raise Exception("eventbase - cfg is not set .. can't handle event.") ; return
     if not event: raise NoEventProvided()
     self.ecounter += 1
     if event.userhost in self.state['ignore']: logging.warn("%s - ignoring %s" % (self.cfg.name, event.userhost)) ; return
     try:
         if event.isremote(): self.doremote(event) ; return
         if event.type == "groupchat" and event.fromm in self.ids:
             logging.debug("%s - receiving groupchat from self (%s)" % (self.cfg.name, event.fromm))
             return
         event.txt = self.inputmorphs.do(fromenc(event.txt, self.encoding), event)
     except UnicodeDecodeError: logging.warn("%s - got decode error in input .. ingoring" % self.cfg.name) ; return
     event.bind(self, noraise=True)
     try: logging.debug("%s - event dump: %s" % (self.cfg.name, event.dump()))
     except: pass
     self.status = "callback"
     starttime = time.time()
     if self.closed:
         if self.gatekeeper.isblocked(event.origin):
             logging.warn("%s is blocked" % event.origin) ; return
     if event.status == "done":
         logging.warn("%s - event is done .. ignoring" % self.cfg.name)
         return
     if event.msg or event.isdcc: event.speed = 2
     if event.channelchanged: cmnds.dispatch(self, event) ; return
     e1 = cpy(event)
     first_callbacks.check(self, e1)
     if not e1.stop: 
         callbacks.check(self, e1)
         if not e1.stop: last_callbacks.check(self, e1)
     event.callbackdone = True
     waiter.check(self, event)
     #mainsink.put(5, self, event)
     self.lastiter = time.time()
     self.benice()
     return event
Ejemplo n.º 4
0
 def dispatch(self, bot, event, wait=0, *args, **kwargs):
     """ dispatch event onto the cmnds object. check for pipelines first. """
     result = []
     if not event.pipelined and ' ! ' in event.txt: return self.pipelined(bot, event, wait=wait, *args, **kwargs)
     self.reloadcheck(bot, event)
     return cmnds.dispatch(bot, event, wait=wait, *args, **kwargs)