Fix getting LIST output to work with more networks
* Parse ISUPPORT properly if more than one channel prefix is supported * Retry getting LIST another way is the response is empty
This commit is contained in:
parent
a027a0b4f6
commit
da14a86e70
45
core/bot.py
45
core/bot.py
|
@ -19,6 +19,7 @@ from utils.get import getRelay
|
|||
|
||||
import main
|
||||
from utils.logging.log import *
|
||||
from utils.logging.debug import *
|
||||
from utils.logging.send import *
|
||||
|
||||
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
||||
|
@ -119,8 +120,9 @@ class IRCBot(IRCClient):
|
|||
self._tempNames = {} # Temporary storage for gathering NAMES info
|
||||
self._tempList = ([], []) # Temporary storage for gathering LIST info
|
||||
self.listOngoing = False
|
||||
self.listRetried = False
|
||||
|
||||
self.chanLimit = 0
|
||||
self.chanlimit = 0
|
||||
|
||||
def parsen(self, user):
|
||||
step = user.split("!")
|
||||
|
@ -313,16 +315,19 @@ class IRCBot(IRCClient):
|
|||
newNicklist.append(f)
|
||||
userinfo.initialNames(self.net, nicklist[0], newNicklist)
|
||||
|
||||
def _list(self):
|
||||
def _list(self, noargs):
|
||||
d = Deferred()
|
||||
self._tempList = ([], [])
|
||||
self._tempList[0].append(d)
|
||||
if noargs:
|
||||
self.sendLine("LIST")
|
||||
else:
|
||||
self.sendLine("LIST >0")
|
||||
return d
|
||||
|
||||
def list(self):
|
||||
def list(self, noargs=False):
|
||||
if not self.listOngoing:
|
||||
self._list().addCallback(self.got_list)
|
||||
self._list(noargs).addCallback(self.got_list)
|
||||
|
||||
def irc_RPL_LISTSTART(self, prefix, params):
|
||||
self.listOngoing = True
|
||||
|
@ -335,27 +340,45 @@ class IRCBot(IRCClient):
|
|||
|
||||
def irc_RPL_LISTEND(self, prefix, params):
|
||||
callbacks, info = self._tempList
|
||||
self.listOngoing = False
|
||||
for cb in callbacks:
|
||||
cb.callback((info))
|
||||
self.listOngoing = False
|
||||
noResults = False
|
||||
if len(self._tempList[1]) == 0:
|
||||
noResults = True
|
||||
self._tempList[0].clear()
|
||||
self._tempList[1].clear()
|
||||
if noResults:
|
||||
if not self.listRetried:
|
||||
self.list(True)
|
||||
else:
|
||||
warn("List still empty after retry: %s - %i" % (net, num))
|
||||
self.listRetried = False
|
||||
return
|
||||
else:
|
||||
self.listRetried = False
|
||||
|
||||
def got_list(self, listinfo):
|
||||
chankeep.initialList(self.net, self.num, listinfo, self.chanLimit)
|
||||
if len(listinfo) == 0: # probably ngircd not supporting LIST >0
|
||||
return
|
||||
|
||||
chankeep.initialList(self.net, self.num, listinfo, self.chanlimit)
|
||||
|
||||
def irc_unknown(self, prefix, command, params):
|
||||
debug("Unknown message: %s - %s - %s" % (prefix, command, params))
|
||||
|
||||
def isupport(self, options):
|
||||
for i in options:
|
||||
if i.startswith("CHANLIMIT"):
|
||||
if "#" in i:
|
||||
split = i.split("#")
|
||||
if ":" in i:
|
||||
split = i.split(":")
|
||||
if len(split) >= 2:
|
||||
chanLimit = split[-1].replace(":", "")
|
||||
chanlimit = split[1]
|
||||
try:
|
||||
self.chanLimit = int(chanLimit)
|
||||
self.chanlimit = int(chanlimit)
|
||||
return
|
||||
except TypeError:
|
||||
error("Invalid CHANLIMIT: %s" % i)
|
||||
warn("Invalid CHANLIMIT: %s" % i)
|
||||
|
||||
#twisted sucks so i have to do this to actually get the user info
|
||||
def irc_JOIN(self, prefix, params):
|
||||
|
|
Loading…
Reference in New Issue