Exemplo n.º 1
0
def get_bans(bot, channel):
    # :ironforge.sorcery.net 367 basla #eth0 *!*@71174af5.e1d1a3cf.net.hmsk [email protected] 1200657224
    # :ironforge.sorcery.net 367 basla #eth0 *!*@6ca5f0a3.14055a38.89.123.imsk [email protected] 1200238584
    # :ironforge.sorcery.net 368 basla #eth0 :End of Channel Ban List
    if bot.type != "irc": return []
    global bans
    channel = channel.lower()
    if not bot.cfg.name in bans:
        bans[bot.cfg.name] = {}
    bans[bot.cfg.name][channel] = []
    queue368 = queue.Queue()
    waiter.register('368', channel, queue368)
    bot._raw('MODE %s +b' % (channel, ))
    # wait for End of Channel Ban List
    try: res = queue368.get(1, 2)
    except queue.Empty: pass
    try: return bans[bot.cfg.name][channel]
    except KeyError: return []
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
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)