Implement fair channel allocation in ChanKeep

* Allocate channels to relays only if they have free space based on
their chanlimit value
* Minify channels by removing ones that are already covered before
passing them off to be joined
This commit is contained in:
2019-10-12 21:05:55 +01:00
parent 7a6e3338c0
commit 0321651c20
4 changed files with 103 additions and 31 deletions

View File

@@ -164,12 +164,15 @@ class IRCBot(IRCClient):
increment = 0.7
increment += 0.1
else:
print("Already on %s, skipping." % i)
error("%s - %i - Cannot join channel we are already on - %s" % (self.net, self.num, i))
def checkChannels(self):
if self.net in main.TempChan.keys():
if self.num in main.TempChan[self.net].keys():
self.joinChannels(main.TempChan[self.net][self.num])
del main.TempChan[self.net][self.num]
if not main.TempChan[self.net]:
del main.TempChan[self.net]
def event(self, **cast):
for i in list(cast.keys()): # Make a copy of the .keys() as Python 3 cannot handle iterating over
@@ -392,7 +395,6 @@ class IRCBot(IRCClient):
def got_list(self, listinfo):
if len(listinfo) == 0: # probably ngircd not supporting LIST >0
return
chankeep.initialList(self.net, self.num, listinfo, self.chanlimit)
def isupport(self, options):