def quit(instance, source, _): curtime = time.time() nick = Irc.get_nickname(source, "") account = None with Global.account_lock: if nick == instance: chans = [] for channel in Global.account_cache: if nick in Global.account_cache[channel]: chans.append(channel) for channel in chans: del Global.account_cache[channel] Logger.log("w", "Removing cache for " + channel) return for channel in Global.account_cache: if nick in Global.account_cache[channel] and channel[0] != "@": account = Global.account_cache[channel][nick] if account != None: break for channel in Global.account_cache: if nick in Global.account_cache[channel] and channel[0] != "@": del Global.account_cache[channel][nick] Logger.log("w", "Removing %s from %s" % (nick, channel)) if account != None and account != False: Expire.bump_last(account)
def join(instance, source, channel, account, _): curtime = time.time() if account == "*": account = False nick = Irc.get_nickname(source, "") with Global.account_lock: if nick == instance: Global.account_cache[channel] = {} Global.account_cache[channel][nick] = account Global.nick_source_cache[nick] = source if account != False and account != None: Global.acctnick_list[account] = nick for channel in Global.account_cache: if nick in Global.account_cache[channel] and channel[0] != "@": if channel in Config.config["welcome_channels"] and (not account or not Transactions.check_exists(account)) and not Transactions.check_exists(nick) and (nick not in Global.welcome_list or Global.welcome_list[nick] + (60*10) < curtime): Global.welcome_list[nick] = curtime # Irc.instance_send(instance, ("PRIVMSG", channel, "Welcome our newest Rogeteer - %s! Try &help, &rogerme and &faucet to get started!" % (nick)), priority = 20, lock = False) Irc.instance_send(instance, ("PRIVMSG", channel, "Welcome our newest Rogeteer - %s! Try &help, &rogerme and &faucet to get started!" % (nick)), priority = 20, lock = False) elif channel in Config.config["welcome_channels"] and account and (Transactions.check_exists(nick) or Transactions.check_exists(account)) and (nick not in Global.welcome_list or Global.welcome_list[nick] + (60*10) < curtime): Global.welcome_list[nick] = curtime welcome_str = str(Commands.random_line('quotes_welcome')) Irc.instance_send(instance, ("NOTICE", nick, "Welcome back %s! %s" % (nick, welcome_str)), priority = 20, lock = False) Global.account_cache[channel][nick] = account Logger.log("w", "Propagating %s=%s into %s" % (nick, account, channel)) if account != False: Expire.bump_last(account)
def kick(instance, _, channel, nick, *__): account = None with Global.account_lock: if nick == instance: del Global.account_cache[channel] Logger.log("w", "Removing cache for " + channel) return if nick in Global.account_cache[channel]: account = Global.account_cache[channel][nick] if nick in Global.account_cache[channel]: del Global.account_cache[channel][nick] Logger.log("w", "Removing %s from %s" % (nick, channel)) if account != None and account != False: Expire.bump_last(account)
def notice(instance, source, target, text): if "@" in source and Irc.get_host(source) == "services." and Irc.get_nickname(source, "") == "NickServ": m = re.match("Information on (\\S*) \\(account (\\S*)\\):", text) if m: Global.svsdata = {"nick": m.group(1), "account": m.group(2)} return m = re.match("(\\S*) is not registered\\.", text) if m: Global.svsdata = None Expire.svsdata({"nick": m.group(1)}) return if Global.svsdata != None: m = re.match("Registered : ([^(]*) \\([^)]* ago\\)", text) if m: Global.svsdata["reg"] = int(date_timestamp(m.group(1))) return m = re.match("User Reg\\. : ([^(]*) \\([^)]* ago\\)", text) if m: Global.svsdata["userreg"] = int(date_timestamp(m.group(1))) return m = re.match("Last seen : ([^(]*) \\([^)]* ago\\)", text) if m: Global.svsdata["last"] = int(date_timestamp(m.group(1))) return m = re.match("Last seen : now", text) if m: Global.svsdata["last"] = int(time.time()) return m = re.match("Last seen : \\(about (\\d*) weeks ago\\)", text) if m: Global.svsdata["lastweeks"] = int(m.group(1)) return m = re.match("User seen : ([^(]*) \\([^)]* ago\\)", text) if m: Global.svsdata["userlast"] = int(date_timestamp(m.group(1))) return m = re.match("User seen : now", text) if m: Global.svsdata["userlast"] = int(time.time()) return m = re.match("User seen : \\(about (\\d*) weeks ago\\)", text) if m: Global.svsdata["userlastweeks"] = int(m.group(1)) return m = re.match("\\*\\*\\* End of Info \\*\\*\\*", text) if m: Expire.svsdata(Global.svsdata) Global.svsdata = None return
def part(instance, source, channel, *_): nick = Irc.get_nickname(source, "") account = None with Global.account_lock: if nick == instance: del Global.account_cache[channel] Logger.log("w", "Removing cache for " + channel) return if nick in Global.account_cache[channel]: account = Global.account_cache[channel][nick] if nick in Global.account_cache[channel]: del Global.account_cache[channel][nick] Logger.log("w", "Removing %s from %s" % (nick, channel)) if account != None and account != False: Expire.bump_last(account)
def _nick(instance, source, newnick): nick = Irc.get_nickname(source, "") account = None with Global.account_lock: for channel in Global.account_cache: if nick in Global.account_cache[channel]: account = Global.account_cache[channel][nick] if account != None: break for channel in Global.account_cache: if nick in Global.account_cache[channel]: Global.account_cache[channel][newnick] = Global.account_cache[channel][nick] Logger.log("w", "%s -> %s in %s" % (nick, newnick, channel)) del Global.account_cache[channel][nick] if account != None and account != False: Expire.bump_last(account)