|
|
@ -19,6 +19,7 @@ from utils.get import getRelay
|
|
|
|
|
|
|
|
|
|
|
|
import main
|
|
|
|
import main
|
|
|
|
from utils.logging.log import *
|
|
|
|
from utils.logging.log import *
|
|
|
|
|
|
|
|
from utils.logging.debug import *
|
|
|
|
from utils.logging.send import *
|
|
|
|
from utils.logging.send import *
|
|
|
|
|
|
|
|
|
|
|
|
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
|
|
|
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
|
|
@ -119,8 +120,9 @@ class IRCBot(IRCClient):
|
|
|
|
self._tempNames = {} # Temporary storage for gathering NAMES info
|
|
|
|
self._tempNames = {} # Temporary storage for gathering NAMES info
|
|
|
|
self._tempList = ([], []) # Temporary storage for gathering LIST info
|
|
|
|
self._tempList = ([], []) # Temporary storage for gathering LIST info
|
|
|
|
self.listOngoing = False
|
|
|
|
self.listOngoing = False
|
|
|
|
|
|
|
|
self.listRetried = False
|
|
|
|
|
|
|
|
|
|
|
|
self.chanLimit = 0
|
|
|
|
self.chanlimit = 0
|
|
|
|
|
|
|
|
|
|
|
|
def parsen(self, user):
|
|
|
|
def parsen(self, user):
|
|
|
|
step = user.split("!")
|
|
|
|
step = user.split("!")
|
|
|
@ -313,16 +315,19 @@ class IRCBot(IRCClient):
|
|
|
|
newNicklist.append(f)
|
|
|
|
newNicklist.append(f)
|
|
|
|
userinfo.initialNames(self.net, nicklist[0], newNicklist)
|
|
|
|
userinfo.initialNames(self.net, nicklist[0], newNicklist)
|
|
|
|
|
|
|
|
|
|
|
|
def _list(self):
|
|
|
|
def _list(self, noargs):
|
|
|
|
d = Deferred()
|
|
|
|
d = Deferred()
|
|
|
|
self._tempList = ([], [])
|
|
|
|
self._tempList = ([], [])
|
|
|
|
self._tempList[0].append(d)
|
|
|
|
self._tempList[0].append(d)
|
|
|
|
self.sendLine("LIST >0")
|
|
|
|
if noargs:
|
|
|
|
|
|
|
|
self.sendLine("LIST")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.sendLine("LIST >0")
|
|
|
|
return d
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
|
|
|
def list(self):
|
|
|
|
def list(self, noargs=False):
|
|
|
|
if not self.listOngoing:
|
|
|
|
if not self.listOngoing:
|
|
|
|
self._list().addCallback(self.got_list)
|
|
|
|
self._list(noargs).addCallback(self.got_list)
|
|
|
|
|
|
|
|
|
|
|
|
def irc_RPL_LISTSTART(self, prefix, params):
|
|
|
|
def irc_RPL_LISTSTART(self, prefix, params):
|
|
|
|
self.listOngoing = True
|
|
|
|
self.listOngoing = True
|
|
|
@ -335,27 +340,45 @@ class IRCBot(IRCClient):
|
|
|
|
|
|
|
|
|
|
|
|
def irc_RPL_LISTEND(self, prefix, params):
|
|
|
|
def irc_RPL_LISTEND(self, prefix, params):
|
|
|
|
callbacks, info = self._tempList
|
|
|
|
callbacks, info = self._tempList
|
|
|
|
|
|
|
|
self.listOngoing = False
|
|
|
|
for cb in callbacks:
|
|
|
|
for cb in callbacks:
|
|
|
|
cb.callback((info))
|
|
|
|
cb.callback((info))
|
|
|
|
self.listOngoing = False
|
|
|
|
noResults = False
|
|
|
|
|
|
|
|
if len(self._tempList[1]) == 0:
|
|
|
|
|
|
|
|
noResults = True
|
|
|
|
self._tempList[0].clear()
|
|
|
|
self._tempList[0].clear()
|
|
|
|
self._tempList[1].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):
|
|
|
|
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):
|
|
|
|
def isupport(self, options):
|
|
|
|
for i in options:
|
|
|
|
for i in options:
|
|
|
|
if i.startswith("CHANLIMIT"):
|
|
|
|
if i.startswith("CHANLIMIT"):
|
|
|
|
if "#" in i:
|
|
|
|
if ":" in i:
|
|
|
|
split = i.split("#")
|
|
|
|
split = i.split(":")
|
|
|
|
if len(split) >= 2:
|
|
|
|
if len(split) >= 2:
|
|
|
|
chanLimit = split[-1].replace(":", "")
|
|
|
|
chanlimit = split[1]
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
self.chanLimit = int(chanLimit)
|
|
|
|
self.chanlimit = int(chanlimit)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
except TypeError:
|
|
|
|
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
|
|
|
|
#twisted sucks so i have to do this to actually get the user info
|
|
|
|
def irc_JOIN(self, prefix, params):
|
|
|
|
def irc_JOIN(self, prefix, params):
|
|
|
|