Пример #1
0
    def on_kick(self, c, e):
        """Handle kicks.

        | If somebody else was kicked, just log it.
        | Record who kicked us and what for to use in :func:`on_join`.
        | Wait 5 seconds and then rejoin.
        """
        self.handler.do_log(e.target, e.source.nick, ','.join(e.arguments), 'kick')
        # we don't care about other people.
        if e.arguments[0] != c.real_nickname:
            return
        logging.info("Kicked from channel %s" % e.target)
        defer.defer(5, c.join, e.target)
Пример #2
0
    def do_welcome(self, c):
        """Do setup when connected to server.

        | Pass the connection to handler.
        | Join the primary channel.
        | Join the control channel.
        """
        logging.info("Connected to server %s" % self.config['core']['host'])
        self.handler.connection = c
        self.handler.channels = self.channels
        self.handler.get_admins(c)
        c.join(self.config['core']['channel'])
        c.join(self.config['core']['ctrlchan'], self.config['auth']['ctrlkey'])
        workers.start_workers(self.handler)
        extrachans = self.config['core']['extrachans']
        if extrachans:
            extrachans = [x.strip() for x in extrachans.split(',')]
            for i in range(len(extrachans)):
                defer.defer(i, c.join, extrachans[i])
Пример #3
0
def cmd(send, msg, args):
    """Says something at a later time.
    Syntax: !defersay <delay> <msg>
    """
    if not args['is_admin'](args['nick']):
        send("Admins only")
        return
    msg = msg.split(maxsplit=1)
    if len(msg) != 2:
        send("Not enough arguments")
        return
    t = parse_time(msg[0])
    if t is None:
        send("Invalid unit.")
    elif t < 0:
        send("Time travel not yet implemented, sorry.")
    else:
        ident = defer(t, send, msg[1])
        send("Message deferred, ident: %s" % ident)
Пример #4
0
def cmd(send, msg, args):
    """Quiets a user, then unquiets them after the specified period of time.
    Syntax: !timeout timespec nickname
    timespec is in the format: {number}{unit}, where unit is m, h, or d.
    """
    setmode = args['handler'].connection.mode
    channel = args['target']
    ops = list(args['handler'].channels[channel].opers())
    if not args['is_admin'](args['nick']):
        send("Ops only")
        return
    if args['botnick'] not in ops:
        send("Bot must be an op.")
        return
    time, user = msg.split(maxsplit=1)
    defer_args = [channel, " -q %s!*@*" % user]

    time = parse_time(time)
    if time is None:
        send("Invalid unit.")
    else:
        setmode(channel, " +q %s!*@*" % user)
        ident = defer(time, setmode, *defer_args)
        send("%s has been put in timeout, ident: %d" % (user, ident))
Пример #5
0
 def on_nicknameinuse(self, c, e):
     self.connection.nick('Guest%d' % getrandbits(20))
     self.connection.privmsg('NickServ', 'REGAIN %s %s' % (self.config['core']['nick'], self.config['auth']['nickpass']))
     defer.defer(5, self.do_welcome, c)
Пример #6
0
 def on_bannedfromchan(self, c, e):
     # FIXME: Implement auto-rejoin on ban.
     defer.defer(5, c.join, e.arguments[0])