def unquiet(irc, event, args): """[<channel>] [<nick|hostmask>...] Unquiets <nick> (or yourself if no <nick> is specified) in <channel>. <channel> is only necessary if the command isn't sent in the channel itself. """ setmodes = [] try: if utils.is_private(event): channel = args[0] if len(args) > 1: nicks = args[1:] else: nicks = [event.source.nick] else: if len(args) > 0: if irc.is_channel(args[0]): channel = args[0] if len(args) > 1: nicks = args[1:] else: nicks = [event.source.nick] else: channel = event.target nicks = args else: channel = event.target nicks = [event.source.nick] except IndexError: irc.reply(event, utils.gethelp("unquiet")) else: if utils.is_allowed(irc, event.source, channel): for nick in nicks: if utils.is_hostmask(nick): hmask = nick else: hmask = utils.gethm(irc, nick) if hmask and channel in irc.state["channels"]: for bmask in irc.state["channels"][channel]["quiets"]: if fnmatch(utils.irclower(hmask), utils.irclower(bmask)): setmodes.append("-q {}".format(bmask)) else: return if len(setmodes) == 0: return already_op = irc.is_opped(irc.get_nick(), channel) if not already_op: setmodes.append("-o {}".format(irc.get_nick())) gotop = utils.getop(irc, channel) if gotop: for mode in utils.unsplit_modes(setmodes): irc.mode(channel, mode)
def seen(irc, event, args): """<nick> Returns the last action by <nick> that the bot has seen and how long ago. """ try: nick = args[0] except IndexError: irc.reply(event, utils.gethelp("seen")) else: try: last = irc.state["users"][nick]["lastmsg"] hmask = irclib.NickMask(utils.gethm(irc, nick)) if last["command"] == "pubmsg" or last["command"] == "pubnotice": # \? irc.reply( event, '{} ({}@{}) was last seen {} ago in {} saying "{}"'.format( nick, hmask.user, hmask.host, timesince(last["time"]), last["channel"], last["message"].strip() ), ) elif last["command"] == "join": irc.reply( event, "{} ({}@{}) was last seen {} ago joining {}".format( nick, hmask.user, hmask.host, timesince(last["time"]), last["channel"] ), ) elif last["command"] == "part": irc.reply( event, "{} ({}@{}) was last seen {} ago leaving {} ({})".format( nick, hmask.user, hmask.host, timesince(last["time"]), last["channel"], last["message"] ), ) elif last["command"] == "kick": irc.reply( event, "{} ({}@{}) was last seen {} ago being kicked from {} ({})".format( nick, hmask.user, hmask.host, timesince(last["time"]), last["channel"], last["message"] ), ) elif last["command"] == "quit": irc.reply( event, "{} ({}@{}) was last seen {} ago quitting ({})".format( nick, hmask.user, hmask.host, timesince(last["time"]), last["message"] ), ) except KeyError: irc.reply(event, "I have not seen {}".format(nick))