Purge metadata entries on quit and escape glob characters
This commit is contained in:
parent
3b42f19291
commit
7cd6bc3616
|
@ -383,6 +383,7 @@ class IRCBotFactory(ReconnectingClientFactory):
|
|||
def __init__(self, name):
|
||||
self.instance = main.pool[name]
|
||||
self.name = name
|
||||
self.net = "".join([x for x in self.name if not x in digits])
|
||||
self.client = None
|
||||
self.maxDelay = self.instance["maxdelay"]
|
||||
self.initialDelay = self.instance["initialdelay"]
|
||||
|
@ -396,6 +397,7 @@ class IRCBotFactory(ReconnectingClientFactory):
|
|||
return entry
|
||||
|
||||
def clientConnectionLost(self, connector, reason):
|
||||
userinfo.delNetwork(self.net, self.client.channels)
|
||||
if not self.client == None:
|
||||
self.client.connected = False
|
||||
self.client.channels = []
|
||||
|
|
|
@ -100,9 +100,16 @@ def delUser(name, channel, nick, user):
|
|||
p.srem(chanspace, channel)
|
||||
p.execute()
|
||||
|
||||
def escape(text):
|
||||
chars = ["[", "]", "^", "-", "*", "?"]
|
||||
text = text.replace("\\", "\\\\")
|
||||
for i in chars:
|
||||
text = text.replace(i, "\\"+i)
|
||||
return text
|
||||
|
||||
def getUserByNick(name, nick):
|
||||
gnamespace = "live.who.%s" % name
|
||||
usermatch = main.r.sscan(gnamespace, match=nick+"!*")
|
||||
usermatch = main.r.sscan(gnamespace, match=escape(nick)+"!*", count=9999999)
|
||||
if usermatch[1] == []:
|
||||
return False
|
||||
else:
|
||||
|
@ -110,6 +117,7 @@ def getUserByNick(name, nick):
|
|||
user = usermatch[1][0]
|
||||
return user
|
||||
else:
|
||||
warn("Entry doesn't exist: %s on %s" % (nick, gnamespace))
|
||||
return False
|
||||
|
||||
def renameUser(name, oldnick, olduser, newnick, newuser):
|
||||
|
@ -130,7 +138,6 @@ def renameUser(name, oldnick, olduser, newnick, newuser):
|
|||
p.execute()
|
||||
|
||||
def delUserByNick(name, channel, nick):
|
||||
gnamespace = "live.who.%s" % name
|
||||
user = getUserByNick(name, nick)
|
||||
delUser(name, channel, nick, user)
|
||||
|
||||
|
@ -153,8 +160,15 @@ def delChannel(name, channel):
|
|||
if main.r.smembers("live.chan."+name+"."+i.decode()) == {channel.encode()}:
|
||||
if user:
|
||||
p.srem(gnamespace, user)
|
||||
|
||||
p.delete("live.chan."+name+"."+i.decode())
|
||||
else:
|
||||
p.srem("live.chan."+name+"."+i.decode(), channel)
|
||||
p.delete(namespace)
|
||||
p.execute()
|
||||
|
||||
def delNetwork(name, channels):
|
||||
log("Purging channels for %s" % name)
|
||||
for i in channels:
|
||||
delChannel(name, i)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue