示例#1
0
 def pipelined(self, bot, event, wait=0, *args, **kwargs):
     """ split cmnds, create events for them, chain the queues and dispatch.  """
     origqueues = event.queues
     event.queues = []
     event.allowqueue = True
     event.closequeue = True
     event.pipelined = True 
     events = []
     splitted = event.txt.split(" ! ")
     for item in splitted:
         e = cpy(event)
         e.queues = []
         e.onlyqueues = True
         e.dontclose = True
         e.txt = item.strip()
         e.usercmnd = e.txt.split()[0].lower()
         if not cmnds.woulddispatch(bot, e): events.append(event) ; break
         logging.debug('creating event for %s' % e.txt)
         e.bot = bot
         e.makeargs()
         events.append(e)
     prevq = None
     for e in events[:-1]:
         q = Queue.Queue()
         e.queues.append(q)
         if prevq:
             e.inqueue = prevq
         prevq = q
     lq = events[-1]
     lq.inqueue = prevq
     lq.closequeue = True
     lq.dontclose = False
     if origqueues: lq.queues = origqueues
     for e in events: self.dispatch(bot, e, wait=wait)
     return lq
示例#2
0
 def docmnd(self,
            origin,
            channel,
            txt,
            event=None,
            wait=0,
            showall=False,
            nooutput=False):
     """ do a command. """
     if event: e = cpy(event)
     else: e = EventBase()
     e.cbtype = "CMND"
     e.bot = self
     e.origin = origin
     e.auth = origin
     e.userhost = origin
     e.channel = channel
     e.txt = unicode(txt)
     e.nick = e.userhost.split('@')[0]
     e.usercmnd = e.txt.split()[0]
     e.allowqueues = True
     e.closequeue = True
     e.showall = showall
     e.nooutput = nooutput
     e.bind(self)
     if cmnds.woulddispatch(self, e) or e.txt[0] == "?":
         return self.doevent(e)
示例#3
0
 def docmnd(self, origin, channel, txt, event=None, wait=0, showall=False, nooutput=False):
     """ do a command. """
     if event: e = cpy(event)
     else: e = EventBase()   
     e.cbtype = "CMND"
     e.bot = self
     e.origin = origin
     e.auth = origin
     e.userhost = origin
     e.channel = channel
     e.txt = unicode(txt)
     e.nick = e.userhost.split('@')[0]
     e.usercmnd = e.txt.split()[0]
     e.allowqueues = True
     e.closequeue = True 
     e.showall = showall 
     e.nooutput = nooutput
     e.bind(self)
     if cmnds.woulddispatch(self, e) or e.txt[0] == "?": return self.doevent(e)
示例#4
0
 def pipelined(self, bot, event, wait=0, *args, **kwargs):
     """ split cmnds, create events for them, chain the queues and dispatch.  """
     origqueues = event.queues
     event.queues = []
     event.allowqueue = True
     event.closequeue = True
     event.pipelined = True
     events = []
     splitted = event.txt.split(" ! ")
     for item in splitted:
         e = cpy(event)
         e.queues = []
         e.onlyqueues = True
         e.dontclose = True
         e.txt = item.strip()
         e.usercmnd = e.txt.split()[0].lower()
         if not cmnds.woulddispatch(bot, e):
             events.append(event)
             break
         logging.debug('creating event for %s' % e.txt)
         e.bot = bot
         e.makeargs()
         events.append(e)
     prevq = None
     for e in events[:-1]:
         q = Queue.Queue()
         e.queues.append(q)
         if prevq:
             e.inqueue = prevq
         prevq = q
     lq = events[-1]
     lq.inqueue = prevq
     lq.closequeue = True
     lq.dontclose = False
     if origqueues: lq.queues = origqueues
     for e in events:
         self.dispatch(bot, e, wait=wait)
     return lq