Cache registered user status

Speeds up acting on a user's command when we previously determined
they were registered. Also should be nicer to NickServ.
This commit is contained in:
moneromooo 2014-12-25 20:43:45 +00:00
parent d3e4b99f99
commit 159528d7f7

View file

@ -53,6 +53,7 @@ admins = ["moneromooo", "moneromoo"]
no_rain_to_nicks = [] no_rain_to_nicks = []
userstable=dict() userstable=dict()
registered_users=set()
calltable=dict() calltable=dict()
last_wallet_update_time = None last_wallet_update_time = None
last_ping_time = time.time() last_ping_time = time.time()
@ -148,7 +149,10 @@ def CheckRegistered(nick,ifyes,yesdata,ifno,nodata):
if nick not in calltable: if nick not in calltable:
calltable[nick] = [] calltable[nick] = []
calltable[nick].append([ifyes,yesdata,ifno,nodata]) calltable[nick].append([ifyes,yesdata,ifno,nodata])
SendTo('nickserv', "ACC " + nick) if nick in registered_users:
PerformNextAction(nick,True)
else:
SendTo('nickserv', "ACC " + nick)
def IsAdmin(nick): def IsAdmin(nick):
return nick in admins return nick in admins
@ -161,6 +165,10 @@ def CheckAdmin(nick,ifyes,yesdata,ifno,nodata):
CheckRegistered(nick,ifyes,yesdata,ifno,nodata) CheckRegistered(nick,ifyes,yesdata,ifno,nodata)
def PerformNextAction(nick,registered): def PerformNextAction(nick,registered):
if registered:
registered_users.add(nick)
else:
registered_users.discard(nick)
if nick not in calltable: if nick not in calltable:
log_error( 'Nothing in queue for %s' % nick) log_error( 'Nothing in queue for %s' % nick)
return return
@ -775,6 +783,7 @@ while True:
if data.find ( 'Welcome to the freenode Internet Relay Chat Network' ) != -1: if data.find ( 'Welcome to the freenode Internet Relay Chat Network' ) != -1:
userstable = dict() userstable = dict()
registered_users.clear()
SendTo("nickserv", "IDENTIFY %s" % GetPassword()) SendTo("nickserv", "IDENTIFY %s" % GetPassword())
Join(irc_homechan) Join(irc_homechan)
#ScanWho(None,[irc_homechan]) #ScanWho(None,[irc_homechan])