From 581d167e5e0e6a48626caf9d44aa8c5ea4041954 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Mon, 4 Aug 2014 21:32:49 +0200 Subject: [PATCH 1/2] src/irclib.py: set caps in Irc.__init__ This allows other plugins to request capabilities in a straightforward way. --- src/irclib.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/irclib.py b/src/irclib.py index 91e5b0b1b..834c37d18 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -654,6 +654,7 @@ class Irc(IrcCommandDispatcher): self._setNonResettingVariables() self._queueConnectMessages() self.startedSync = ircutils.IrcDict() + self.caps = ['account-notify', 'extended-join'] def isChannel(self, s): """Helper function to check whether a given string is a channel on @@ -969,17 +970,15 @@ class Irc(IrcCommandDispatcher): self.queueMsg(ircmsgs.IrcMsg(command='AUTHENTICATE', args=(authstring,))) def doCap(self, msg): - caps = ['account-notify', 'extended-join'] - if self.sasl_password: if self.sasl_username: - caps.append('sasl') + self.caps.append('sasl') else: log.warning('%s: SASL username is not set, unable to ' 'identify.', self.network) for cap in msg.args[2].split(' '): - if msg.args[1] == 'LS' and cap in caps: + if msg.args[1] == 'LS' and cap in self.caps: log.debug('%s: Requesting capability %r', self.network, cap) self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', cap))) elif msg.args[1] == 'ACK': From da817603ddb75008dd55c0bb09f510768b81c2a9 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Mon, 4 Aug 2014 21:54:44 +0200 Subject: [PATCH 2/2] src/irclib.py: use a set instead of a list for Irc.caps --- src/irclib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/irclib.py b/src/irclib.py index 834c37d18..bae4d5186 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -654,7 +654,7 @@ class Irc(IrcCommandDispatcher): self._setNonResettingVariables() self._queueConnectMessages() self.startedSync = ircutils.IrcDict() - self.caps = ['account-notify', 'extended-join'] + self.caps = set(['account-notify', 'extended-join']) def isChannel(self, s): """Helper function to check whether a given string is a channel on