예제 #1
0
파일: bot.py 프로젝트: buzzworkers/tl
 def gettopic(self, channel, event=None):
     """ get topic data. """
     q = queue.Queue()
     i332 = waiter.register("332", queue=q)
     i333 = waiter.register("333", queue=q)
     self.putonqueue(7, None, 'TOPIC %s' % channel)
     res = waitforqueue(q, 5000)
     who = what = when = None
     for r in res:
         if not r.postfix: continue
         try:
             if r.cmnd == "332": what = r.txt ; waiter.ready(i332) ; continue
             waiter.ready(i333)
             splitted = r.postfix.split()
             who = splitted[2]
             when = float(splitted[3])
         except (IndexError, ValueError): continue
         return (what, who, when)
예제 #2
0
파일: irc.py 프로젝트: buzzworkers/tl
def handle_nicks(bot, event):
    """ no arguments - return nicks on channel. """
    if bot.type != 'irc': event.reply('nicks only works on irc bots') ; return
    event.ctl = 2
    def aggregate(bot, e):
        global nickresult
        nickresult.extend(e.txt.split())

    def nickscb(bot, e):
        global nickresult
        event.reply("nicks on %s (%s): " % (event.channel, bot.cfg.server), nickresult)
        nickresult = []
        waiter.remove("tl.plugs.core.irc")

    w353 = waiter.register('353', aggregate)
    w366 = waiter.register('366', nickscb)
    event.reply('searching for nicks')
    bot.names(event.channel)
    time.sleep(5)
    waiter.ready(w353)
    waiter.ready(w366)