Implement indexing into Apache Druid #1
25
core/bot.py
25
core/bot.py
|
@ -156,6 +156,7 @@ class IRCBot(IRCClient):
|
||||||
# syntax from now on
|
# syntax from now on
|
||||||
self.wantList = False # we want to send a LIST, but not all relays are active yet
|
self.wantList = False # we want to send a LIST, but not all relays are active yet
|
||||||
self.chanlimit = 0
|
self.chanlimit = 0
|
||||||
|
self.prefix = {}
|
||||||
self.servername = None
|
self.servername = None
|
||||||
|
|
||||||
self._regAttempt = None
|
self._regAttempt = None
|
||||||
|
@ -376,12 +377,11 @@ class IRCBot(IRCClient):
|
||||||
|
|
||||||
def sanit(self, data):
|
def sanit(self, data):
|
||||||
if len(data) >= 1:
|
if len(data) >= 1:
|
||||||
if data[0] in ["!", "~", "&", "@", "%", "+"]:
|
if data[0] in self.prefix.keys():
|
||||||
data = data[1:]
|
return (self.prefix[data[0]], data[1:]) # would use a set but it's possible these are the same
|
||||||
return data
|
return (None, data)
|
||||||
return data
|
|
||||||
else:
|
else:
|
||||||
return False
|
return (None, False)
|
||||||
|
|
||||||
def names(self, channel):
|
def names(self, channel):
|
||||||
d = Deferred()
|
d = Deferred()
|
||||||
|
@ -412,9 +412,9 @@ class IRCBot(IRCClient):
|
||||||
newNicklist = []
|
newNicklist = []
|
||||||
for i in nicklist[1]:
|
for i in nicklist[1]:
|
||||||
for x in i:
|
for x in i:
|
||||||
f = self.sanit(x)
|
mode, nick = self.sanit(x)
|
||||||
if f:
|
if nick:
|
||||||
newNicklist.append(f)
|
newNicklist.append((mode, nick))
|
||||||
userinfo.initialNames(self.net, nicklist[0], newNicklist)
|
userinfo.initialNames(self.net, nicklist[0], newNicklist)
|
||||||
|
|
||||||
def myInfo(self, servername, version, umodes, cmodes):
|
def myInfo(self, servername, version, umodes, cmodes):
|
||||||
|
@ -503,10 +503,8 @@ class IRCBot(IRCClient):
|
||||||
chankeep.initialList(self.net, self.num, listinfo, self.chanlimit)
|
chankeep.initialList(self.net, self.num, listinfo, self.chanlimit)
|
||||||
|
|
||||||
def recheckList(self):
|
def recheckList(self):
|
||||||
print("list being rechecked")
|
|
||||||
allRelays = chankeep.allRelaysActive(self.net)
|
allRelays = chankeep.allRelaysActive(self.net)
|
||||||
if allRelays:
|
if allRelays:
|
||||||
print("allrelays now passed")
|
|
||||||
name = self.net+"1"
|
name = self.net+"1"
|
||||||
if main.IRCPool[name].wantList == True:
|
if main.IRCPool[name].wantList == True:
|
||||||
main.IRCPool[name].list(nocheck=True)
|
main.IRCPool[name].list(nocheck=True)
|
||||||
|
@ -536,7 +534,12 @@ class IRCBot(IRCClient):
|
||||||
self.recheckList()
|
self.recheckList()
|
||||||
|
|
||||||
def seed_prefix(self, prefix):
|
def seed_prefix(self, prefix):
|
||||||
print("PREFIX", prefix)
|
prefix = prefix.replace(")", "")
|
||||||
|
prefix = prefix.replace("(", "")
|
||||||
|
length = len(prefix)
|
||||||
|
half = int(length/2)
|
||||||
|
prefixToMode = dict(zip(prefix[half:], prefix[:half]))
|
||||||
|
self.prefix = prefixToMode
|
||||||
|
|
||||||
def isupport(self, options):
|
def isupport(self, options):
|
||||||
interested = {"CHANLIMIT", "MAXCHANNELS", "PREFIX"}
|
interested = {"CHANLIMIT", "MAXCHANNELS", "PREFIX"}
|
||||||
|
|
|
@ -19,6 +19,8 @@ def parsemeta(numName, c):
|
||||||
# in which case, do not do this
|
# in which case, do not do this
|
||||||
if c["type"] in ["msg", "notice", "action", "topic", "mode"]:
|
if c["type"] in ["msg", "notice", "action", "topic", "mode"]:
|
||||||
userinfo.editUser(c["net"], c["muser"])
|
userinfo.editUser(c["net"], c["muser"])
|
||||||
|
if c["type"] == "mode":
|
||||||
|
userinfo.updateMode(c)
|
||||||
elif c["type"] == "nick":
|
elif c["type"] == "nick":
|
||||||
userinfo.renameUser(c["net"], c["nick"], c["muser"], c["user"], c["user"]+"!"+c["ident"]+"@"+c["host"])
|
userinfo.renameUser(c["net"], c["nick"], c["muser"], c["user"], c["user"]+"!"+c["ident"]+"@"+c["host"])
|
||||||
elif c["type"] == "kick":
|
elif c["type"] == "kick":
|
||||||
|
|
|
@ -91,9 +91,11 @@ def initialUsers(name, channel, users):
|
||||||
def _initialNames(name, channel, names):
|
def _initialNames(name, channel, names):
|
||||||
namespace = "live.who.%s.%s" % (name, channel)
|
namespace = "live.who.%s.%s" % (name, channel)
|
||||||
p = main.r.pipeline()
|
p = main.r.pipeline()
|
||||||
for i in names:
|
for mode, nick in names:
|
||||||
p.sadd(namespace, i)
|
p.sadd(namespace, nick)
|
||||||
p.sadd("live.chan."+name+"."+i, channel)
|
p.sadd("live.chan."+name+"."+nick, channel)
|
||||||
|
if mode:
|
||||||
|
p.hset("live.prefix."+name+"."+channel, nick, mode)
|
||||||
p.execute()
|
p.execute()
|
||||||
|
|
||||||
def initialNames(name, channel, names):
|
def initialNames(name, channel, names):
|
||||||
|
@ -126,6 +128,7 @@ def delUser(name, channel, nick, user):
|
||||||
p.srem(namespace, nick)
|
p.srem(namespace, nick)
|
||||||
if channels == {channel.encode()}: # can we only see them on this channel?
|
if channels == {channel.encode()}: # can we only see them on this channel?
|
||||||
p.delete(chanspace) # remove channel tracking entry
|
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
|
p.hdel(mapspace, nick) # remove nick mapping entry
|
||||||
if user:
|
if user:
|
||||||
p.srem(gnamespace, user) # remove global userinfo entry
|
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.sadd("live.who."+name+"."+i, newnick)
|
||||||
p.hdel(mapspace, oldnick)
|
p.hdel(mapspace, oldnick)
|
||||||
p.hset(mapspace, newnick, newuser)
|
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):
|
if main.r.exists(chanspace):
|
||||||
p.rename(chanspace, newchanspace)
|
p.rename(chanspace, newchanspace)
|
||||||
else:
|
else:
|
||||||
|
@ -197,6 +204,8 @@ def delUserByNetwork(name, nick, user): # quit
|
||||||
p.srem(gnamespace, user)
|
p.srem(gnamespace, user)
|
||||||
for i in main.r.smembers(chanspace):
|
for i in main.r.smembers(chanspace):
|
||||||
p.srem("live.who."+name+"."+i.decode(), nick)
|
p.srem("live.who."+name+"."+i.decode(), nick)
|
||||||
|
p.hdel("live.prefix."+name+"."+i, nick)
|
||||||
|
|
||||||
p.delete(chanspace)
|
p.delete(chanspace)
|
||||||
p.hdel(mapspace, nick)
|
p.hdel(mapspace, nick)
|
||||||
p.execute()
|
p.execute()
|
||||||
|
@ -216,14 +225,16 @@ def _delChannels(net, channels):
|
||||||
if main.r.smembers("live.chan."+net+"."+nick) == {channel.encode()}:
|
if main.r.smembers("live.chan."+net+"."+nick) == {channel.encode()}:
|
||||||
if user:
|
if user:
|
||||||
p.srem(gnamespace, user)
|
p.srem(gnamespace, user)
|
||||||
|
|
||||||
p.delete("live.chan."+net+"."+nick)
|
p.delete("live.chan."+net+"."+nick)
|
||||||
p.hdel(mapspace, nick) # remove map entry
|
p.hdel(mapspace, nick) # remove map entry
|
||||||
else:
|
else:
|
||||||
p.srem("live.chan."+net+"."+nick, channel)
|
p.srem("live.chan."+net+"."+nick, channel)
|
||||||
p.delete(namespace)
|
p.delete(namespace)
|
||||||
|
p.delete("live.prefix."+net+"."+channel)
|
||||||
p.execute()
|
p.execute()
|
||||||
|
|
||||||
def delChannels(net, channels):
|
def delChannels(net, channels): # we have left a channel
|
||||||
debug("Purging channel %s for %s" % (", ".join(channels), net))
|
debug("Purging channel %s for %s" % (", ".join(channels), net))
|
||||||
d = deferToThread(_delChannels, net, channels)
|
d = deferToThread(_delChannels, net, channels)
|
||||||
#d.addCallback(testCallback)
|
#d.addCallback(testCallback)
|
||||||
|
|
Loading…
Reference in New Issue