diff --git a/core/bot.py b/core/bot.py index 8c33855..7ac0820 100644 --- a/core/bot.py +++ b/core/bot.py @@ -112,10 +112,12 @@ class IRCBot(IRCClient): self.versionEnv = None self.sourceURL = None - self._tempWho = {} - self._getWho = {} + self._getWho = {} # LoopingCall objects -- needed to be able to stop them - self._names = {} + self._tempWho = {} # Temporary storage for gathering WHO info + self._tempNames = {} # Temporary storage for gathering NAMES info + self._tempList = ([], []) # Temporary storage for gathering LIST info + self.listOngoing = False def parsen(self, user): step = user.split("!") @@ -276,28 +278,28 @@ class IRCBot(IRCClient): def names(self, channel): d = Deferred() - if channel not in self._names: - self._names[channel] = ([], []) - self._names[channel][0].append(d) + if channel not in self._tempNames: + self._tempNames[channel] = ([], []) + self._tempNames[channel][0].append(d) self.sendLine("NAMES %s" % channel) return d def irc_RPL_NAMREPLY(self, prefix, params): channel = params[2] nicklist = params[3].split(' ') - if channel not in self._names: + if channel not in self._tempNames: return - n = self._names[channel][1] + n = self._tempNames[channel][1] n.append(nicklist) def irc_RPL_ENDOFNAMES(self, prefix, params): channel = params[1] - if channel not in self._names: + if channel not in self._tempNames: return - callbacks, namelist = self._names[channel] + callbacks, namelist = self._tempNames[channel] for cb in callbacks: cb.callback((channel, namelist)) - del self._names[channel] + del self._tempNames[channel] def got_names(self, nicklist): newNicklist = [] @@ -308,6 +310,35 @@ class IRCBot(IRCClient): newNicklist.append(f) userinfo.initialNames(self.net, nicklist[0], newNicklist) + def _list(self): + d = Deferred() + self._tempList = ([], []) + self._tempList[0].append(d) + self.sendLine("LIST") + return d + + def list(self): + if not self.listOngoing: + self._list().addCallback(self.got_list) + self.listOngoing = True + + def irc_RPL_LIST(self, prefix, params): + channel = params[1] + users = params[2] + topic = params[3] + self._tempList[1].append([channel, users, topic]) + + def irc_RPL_LISTEND(self, prefix, params): + callbacks, info = self._tempList + for cb in callbacks: + cb.callback((info)) + self.listOngoing = False + self._tempList[0].clear() + self._tempList[1].clear() + + def got_list(self, listinfo): + print("have list", listinfo) + #twisted sucks so i have to do this to actually get the user info def irc_JOIN(self, prefix, params): """ diff --git a/modules/chankeep.py b/modules/chankeep.py new file mode 100644 index 0000000..8ee9bae --- /dev/null +++ b/modules/chankeep.py @@ -0,0 +1 @@ +import main