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):
|
def __init__(self, name):
|
||||||
self.instance = main.pool[name]
|
self.instance = main.pool[name]
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.net = "".join([x for x in self.name if not x in digits])
|
||||||
self.client = None
|
self.client = None
|
||||||
self.maxDelay = self.instance["maxdelay"]
|
self.maxDelay = self.instance["maxdelay"]
|
||||||
self.initialDelay = self.instance["initialdelay"]
|
self.initialDelay = self.instance["initialdelay"]
|
||||||
|
@ -396,6 +397,7 @@ class IRCBotFactory(ReconnectingClientFactory):
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
def clientConnectionLost(self, connector, reason):
|
def clientConnectionLost(self, connector, reason):
|
||||||
|
userinfo.delNetwork(self.net, self.client.channels)
|
||||||
if not self.client == None:
|
if not self.client == None:
|
||||||
self.client.connected = False
|
self.client.connected = False
|
||||||
self.client.channels = []
|
self.client.channels = []
|
||||||
|
|
|
@ -100,9 +100,16 @@ def delUser(name, channel, nick, user):
|
||||||
p.srem(chanspace, channel)
|
p.srem(chanspace, channel)
|
||||||
p.execute()
|
p.execute()
|
||||||
|
|
||||||
|
def escape(text):
|
||||||
|
chars = ["[", "]", "^", "-", "*", "?"]
|
||||||
|
text = text.replace("\\", "\\\\")
|
||||||
|
for i in chars:
|
||||||
|
text = text.replace(i, "\\"+i)
|
||||||
|
return text
|
||||||
|
|
||||||
def getUserByNick(name, nick):
|
def getUserByNick(name, nick):
|
||||||
gnamespace = "live.who.%s" % name
|
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] == []:
|
if usermatch[1] == []:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
@ -110,6 +117,7 @@ def getUserByNick(name, nick):
|
||||||
user = usermatch[1][0]
|
user = usermatch[1][0]
|
||||||
return user
|
return user
|
||||||
else:
|
else:
|
||||||
|
warn("Entry doesn't exist: %s on %s" % (nick, gnamespace))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def renameUser(name, oldnick, olduser, newnick, newuser):
|
def renameUser(name, oldnick, olduser, newnick, newuser):
|
||||||
|
@ -130,7 +138,6 @@ def renameUser(name, oldnick, olduser, newnick, newuser):
|
||||||
p.execute()
|
p.execute()
|
||||||
|
|
||||||
def delUserByNick(name, channel, nick):
|
def delUserByNick(name, channel, nick):
|
||||||
gnamespace = "live.who.%s" % name
|
|
||||||
user = getUserByNick(name, nick)
|
user = getUserByNick(name, nick)
|
||||||
delUser(name, channel, nick, user)
|
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 main.r.smembers("live.chan."+name+"."+i.decode()) == {channel.encode()}:
|
||||||
if user:
|
if user:
|
||||||
p.srem(gnamespace, user)
|
p.srem(gnamespace, user)
|
||||||
|
|
||||||
p.delete("live.chan."+name+"."+i.decode())
|
p.delete("live.chan."+name+"."+i.decode())
|
||||||
else:
|
else:
|
||||||
p.srem("live.chan."+name+"."+i.decode(), channel)
|
p.srem("live.chan."+name+"."+i.decode(), channel)
|
||||||
p.delete(namespace)
|
p.delete(namespace)
|
||||||
p.execute()
|
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