Start implementing prefixes
This commit is contained in:
@@ -91,9 +91,11 @@ def initialUsers(name, channel, users):
|
||||
def _initialNames(name, channel, names):
|
||||
namespace = "live.who.%s.%s" % (name, channel)
|
||||
p = main.r.pipeline()
|
||||
for i in names:
|
||||
p.sadd(namespace, i)
|
||||
p.sadd("live.chan."+name+"."+i, channel)
|
||||
for mode, nick in names:
|
||||
p.sadd(namespace, nick)
|
||||
p.sadd("live.chan."+name+"."+nick, channel)
|
||||
if mode:
|
||||
p.hset("live.prefix."+name+"."+channel, nick, mode)
|
||||
p.execute()
|
||||
|
||||
def initialNames(name, channel, names):
|
||||
@@ -126,6 +128,7 @@ def delUser(name, channel, nick, user):
|
||||
p.srem(namespace, nick)
|
||||
if channels == {channel.encode()}: # can we only see them on this channel?
|
||||
p.delete(chanspace) # remove channel tracking entry
|
||||
p.hdel("live.prefix."+name+"."+channel, nick) # remove prefix tracking entry
|
||||
p.hdel(mapspace, nick) # remove nick mapping entry
|
||||
if user:
|
||||
p.srem(gnamespace, user) # remove global userinfo entry
|
||||
@@ -177,6 +180,10 @@ def renameUser(name, oldnick, olduser, newnick, newuser):
|
||||
p.sadd("live.who."+name+"."+i, newnick)
|
||||
p.hdel(mapspace, oldnick)
|
||||
p.hset(mapspace, newnick, newuser)
|
||||
if main.r.exists("live.prefix."+name+"."+i): # if there's a prefix entry for the channel
|
||||
if main.r.hexists("live.prefix."+name+"."+i, oldnick): # if the old nick is in it
|
||||
mode = main.r.hget("live.prefix."+name+"."+i, oldnick) # retrieve old modes
|
||||
p.hset("live.prefix."+name+"."+i, newnick, mode) # set old modes to new nickname
|
||||
if main.r.exists(chanspace):
|
||||
p.rename(chanspace, newchanspace)
|
||||
else:
|
||||
@@ -197,6 +204,8 @@ def delUserByNetwork(name, nick, user): # quit
|
||||
p.srem(gnamespace, user)
|
||||
for i in main.r.smembers(chanspace):
|
||||
p.srem("live.who."+name+"."+i.decode(), nick)
|
||||
p.hdel("live.prefix."+name+"."+i, nick)
|
||||
|
||||
p.delete(chanspace)
|
||||
p.hdel(mapspace, nick)
|
||||
p.execute()
|
||||
@@ -216,14 +225,16 @@ def _delChannels(net, channels):
|
||||
if main.r.smembers("live.chan."+net+"."+nick) == {channel.encode()}:
|
||||
if user:
|
||||
p.srem(gnamespace, user)
|
||||
|
||||
p.delete("live.chan."+net+"."+nick)
|
||||
p.hdel(mapspace, nick) # remove map entry
|
||||
else:
|
||||
p.srem("live.chan."+net+"."+nick, channel)
|
||||
p.delete(namespace)
|
||||
p.delete("live.prefix."+net+"."+channel)
|
||||
p.execute()
|
||||
|
||||
def delChannels(net, channels):
|
||||
def delChannels(net, channels): # we have left a channel
|
||||
debug("Purging channel %s for %s" % (", ".join(channels), net))
|
||||
d = deferToThread(_delChannels, net, channels)
|
||||
#d.addCallback(testCallback)
|
||||
|
||||
Reference in New Issue
Block a user