Start implementing prefixes
This commit is contained in:
25
core/bot.py
25
core/bot.py
@@ -156,6 +156,7 @@ class IRCBot(IRCClient):
|
||||
# syntax from now on
|
||||
self.wantList = False # we want to send a LIST, but not all relays are active yet
|
||||
self.chanlimit = 0
|
||||
self.prefix = {}
|
||||
self.servername = None
|
||||
|
||||
self._regAttempt = None
|
||||
@@ -376,12 +377,11 @@ class IRCBot(IRCClient):
|
||||
|
||||
def sanit(self, data):
|
||||
if len(data) >= 1:
|
||||
if data[0] in ["!", "~", "&", "@", "%", "+"]:
|
||||
data = data[1:]
|
||||
return data
|
||||
return data
|
||||
if data[0] in self.prefix.keys():
|
||||
return (self.prefix[data[0]], data[1:]) # would use a set but it's possible these are the same
|
||||
return (None, data)
|
||||
else:
|
||||
return False
|
||||
return (None, False)
|
||||
|
||||
def names(self, channel):
|
||||
d = Deferred()
|
||||
@@ -412,9 +412,9 @@ class IRCBot(IRCClient):
|
||||
newNicklist = []
|
||||
for i in nicklist[1]:
|
||||
for x in i:
|
||||
f = self.sanit(x)
|
||||
if f:
|
||||
newNicklist.append(f)
|
||||
mode, nick = self.sanit(x)
|
||||
if nick:
|
||||
newNicklist.append((mode, nick))
|
||||
userinfo.initialNames(self.net, nicklist[0], newNicklist)
|
||||
|
||||
def myInfo(self, servername, version, umodes, cmodes):
|
||||
@@ -503,10 +503,8 @@ class IRCBot(IRCClient):
|
||||
chankeep.initialList(self.net, self.num, listinfo, self.chanlimit)
|
||||
|
||||
def recheckList(self):
|
||||
print("list being rechecked")
|
||||
allRelays = chankeep.allRelaysActive(self.net)
|
||||
if allRelays:
|
||||
print("allrelays now passed")
|
||||
name = self.net+"1"
|
||||
if main.IRCPool[name].wantList == True:
|
||||
main.IRCPool[name].list(nocheck=True)
|
||||
@@ -536,7 +534,12 @@ class IRCBot(IRCClient):
|
||||
self.recheckList()
|
||||
|
||||
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):
|
||||
interested = {"CHANLIMIT", "MAXCHANNELS", "PREFIX"}
|
||||
|
||||
Reference in New Issue
Block a user