def unquiet(bot, trigger): """ This gives admins the ability to unquiet a user. The bot must be a Channel Operator for this command to work. """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < OP: return bot.reply("Non sono OP :(") text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) quietmask = opt channel = trigger.sender if not opt.is_nick(): if argc < 3: return quietmask = text[2] channel = opt quietmask = configureHostMask(quietmask) if quietmask == '': return bot.write(['MODE', opt, '-q', quietmask])
def kickban(bot, trigger): """ This gives admins the ability to kickban a user. The bot must be a Channel Operator for this command to work .kickban [#chan] user1 user!*@* get out of here """ if (not trigger.owner) and (not trigger.admin) and (bot.privileges[trigger.sender][trigger.nick] < OP): return text = trigger.group().split() argc = len(text) if argc < 4: return opt = Nick(text[1]) nick = opt mask = text[2] reasonidx = 3 if not opt.is_nick(): if argc < 5: return channel = opt nick = text[2] mask = text[3] reasonidx = 4 reason = ' '.join(text[reasonidx:]) mask = configureHostMask(mask) if mask == '': return bot.write(['MODE', channel, '+b', mask]) bot.write(['KICK', channel, nick, ' :', reason])
def kick(bot, trigger): """ Kick a user from the channel. """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < HALFOP: return bot.reply("Non sono OP :(") text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) nick = opt channel = trigger.sender reasonidx = 2 if not opt.is_nick(): if argc < 3: return nick = text[2] channel = opt reasonidx = 3 reason = '_'.join(text[reasonidx:]) if nick != bot.config.nick: bot.write(['KICK', channel, nick, reason])
def ban(bot, trigger): """ This give admins the ability to ban a user. The bot must be a Channel Operator for this command to work. """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < HALFOP: return bot.reply("Non sono OP :(") text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) banmask = opt channel = trigger.sender if not opt.is_nick(): if argc < 3: return channel = opt banmask = text[2] banmask = configureHostMask(banmask) if banmask == '': return bot.write(['MODE', channel, '+b', banmask])
def kick(bot, trigger): """ Kick a user from the channel. """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < HALFOP: return bot.reply("I'm not a channel operator!") text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) nick = opt channel = trigger.sender reasonidx = 2 if not opt.is_nick(): if argc < 3: return nick = text[2] channel = opt reasonidx = 3 reason = ' '.join(text[reasonidx:]) if nick != bot.config.nick: bot.write(['KICK', channel, nick, reason])
def unquiet(bot, trigger): """ This gives admins the ability to unquiet a user. The bot must be a Channel Operator for this command to work. """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < OP: return bot.reply("I'm not a channel operator!") text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) quietmask = opt channel = trigger.sender if not opt.is_nick(): if argc < 3: return quietmask = text[2] channel = opt quietmask = configureHostMask(quietmask) if quietmask == '': return bot.write(['MODE', opt, '-q', quietmask])
def kickban(bot, trigger): """ This gives admins the ability to kickban a user. The bot must be a Channel Operator for this command to work. .kickban [#chan] user1 user!*@* get out of here """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < HALFOP: return bot.reply("I'm not a channel operator!") text = trigger.group().split() argc = len(text) if argc < 4: return opt = Nick(text[1]) nick = opt mask = text[2] reasonidx = 3 if not opt.is_nick(): if argc < 5: return channel = opt nick = text[2] mask = text[3] reasonidx = 4 reason = ' '.join(text[reasonidx:]) mask = configureHostMask(mask) if mask == '': return bot.write(['MODE', channel, '+b', mask]) bot.write(['KICK', channel, nick, ' :', reason])
def ban(bot, trigger): """ This give admins the ability to ban a user. The bot must be a Channel Operator for this command to work. """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < HALFOP: return bot.reply("I'm not a channel operator!") text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) banmask = opt channel = trigger.sender if not opt.is_nick(): if argc < 3: return channel = opt banmask = text[2] banmask = configureHostMask(banmask) if banmask == '': return bot.write(['MODE', channel, '+b', banmask])
def kick(bot, trigger): """ Echa a un usuario del canal actual """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < HALFOP: return bot.reply("No soy un operador del canal!") text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) nick = opt channel = trigger.sender reasonidx = 2 if not opt.is_nick(): if argc < 3: return nick = text[2] channel = opt reasonidx = 3 reason = ' '.join(text[reasonidx:]) if nick != bot.config.nick: bot.write(['KICK', channel, nick, reason])
def kickban(bot, trigger): """ Echa y veta a un usuario o máscara %kickban [#chan] user1 user!*@* fuera de aquí """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < HALFOP: return bot.reply("No soy operador de este canal!!") text = trigger.group().split() argc = len(text) if argc < 4: return opt = Nick(text[1]) nick = opt mask = text[2] reasonidx = 3 if not opt.is_nick(): if argc < 5: return channel = opt nick = text[2] mask = text[3] reasonidx = 4 reason = ' '.join(text[reasonidx:]) mask = configureHostMask(mask) if mask == '': return bot.write(['MODE', channel, '+b', mask]) bot.write(['KICK', channel, nick, ' :', reason])
def track_modes(bot, trigger): """Track usermode changes and keep our lists of ops up to date.""" # Mode message format: <channel> *( ( "-" / "+" ) *<modes> *<modeparams> ) channel = Nick(trigger.args[0]) line = trigger.args[1:] # If the first character of where the mode is being set isn't a # # then it's a user mode, not a channel mode, so we'll ignore it. if channel.is_nick(): return def handle_old_modes(nick, mode): #Old mode maintenance. Drop this crap in 5.0. if mode[1] == 'o' or mode[1] == 'q' or mode[1] == 'a': if mode[0] == '+': bot.add_op(channel, nick) else: bot.del_op(channel, nick) elif mode[1] == 'h': # Halfop if mode[0] == '+': bot.add_halfop(channel, nick) else: bot.del_halfop(channel, nick) elif mode[1] == 'v': if mode[0] == '+': bot.add_voice(channel, nick) else: bot.del_voice(channel, nick) mapping = {'v': willie.module.VOICE, 'h': willie.module.HALFOP, 'o': willie.module.OP, 'a': willie.module.ADMIN, 'q': willie.module.OWNER} modes = [] for arg in line: if arg[0] in '+-': # There was a comment claiming IRC allows e.g. MODE +aB-c foo, but # I don't see it in any RFCs. Leaving in the extra parsing for now. sign = '' modes = [] for char in arg: if char == '+' or char == '-': sign = char else: modes.append(sign + char) else: arg = Nick(arg) for mode in modes: priv = bot.privileges[channel].get(arg, 0) value = mapping.get(mode[1]) if value is not None: if mode[0] == '+': priv = priv | value else: priv = priv & ~value bot.privileges[channel][arg] = priv handle_old_modes(arg, mode)
def kick(bot, trigger): """ Kick a user from the channel. """ if (not trigger.owner) and (not trigger.admin) and (bot.privileges[trigger.sender][trigger.nick] < OP): return text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) nick = opt channel = trigger.sender reasonidx = 2 if not opt.is_nick(): if argc < 3: return nick = text[2] channel = opt reasonidx = 3 reason = ' '.join(text[reasonidx:]) if nick != bot.config.nick: bot.write(['KICK', channel, nick, reason])
def quiet(bot, trigger): """ This gives admins the ability to quiet a user. The bot must be a Channel Operator for this command to work """ if (not trigger.owner) and (not trigger.admin) and (bot.privileges[trigger.sender][trigger.nick] < OP): return text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) quietmask = opt channel = trigger.sender if not opt.is_nick(): if argc < 3: return quietmask = text[2] channel = opt quietmask = configureHostMask(quietmask) if quietmask == '': return bot.write(['MODE', channel, '+q', quietmask])
def unquiet(bot, trigger): """ Quita el silencio de un usuario o máscara """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < OP: return bot.reply("No soy operador de este canal!!") text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) quietmask = opt channel = trigger.sender if not opt.is_nick(): if argc < 3: return quietmask = text[2] channel = opt quietmask = configureHostMask(quietmask) if quietmask == '': return bot.write(['MODE', opt, '-q', quietmask])
def unban(bot, trigger): """ Remueve un veto en el canal """ if bot.privileges[trigger.sender][trigger.nick] < OP: return if bot.privileges[trigger.sender][bot.nick] < HALFOP: return bot.reply("No soy un operador de este canal!") text = trigger.group().split() argc = len(text) if argc < 2: return opt = Nick(text[1]) banmask = opt channel = trigger.sender if not opt.is_nick(): if argc < 3: return channel = opt banmask = text[2] banmask = configureHostMask(banmask) if banmask == '': return bot.write(['MODE', channel, '-b', banmask])