src/irclib.py: set caps in Irc.__init__

This allows other plugins to request capabilities in a straightforward
way.
This commit is contained in:
nyuszika7h 2014-08-04 21:32:49 +02:00
parent 8efcc4a009
commit 581d167e5e

View File

@ -654,6 +654,7 @@ class Irc(IrcCommandDispatcher):
self._setNonResettingVariables() self._setNonResettingVariables()
self._queueConnectMessages() self._queueConnectMessages()
self.startedSync = ircutils.IrcDict() self.startedSync = ircutils.IrcDict()
self.caps = ['account-notify', 'extended-join']
def isChannel(self, s): def isChannel(self, s):
"""Helper function to check whether a given string is a channel on """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,))) self.queueMsg(ircmsgs.IrcMsg(command='AUTHENTICATE', args=(authstring,)))
def doCap(self, msg): def doCap(self, msg):
caps = ['account-notify', 'extended-join']
if self.sasl_password: if self.sasl_password:
if self.sasl_username: if self.sasl_username:
caps.append('sasl') self.caps.append('sasl')
else: else:
log.warning('%s: SASL username is not set, unable to ' log.warning('%s: SASL username is not set, unable to '
'identify.', self.network) 'identify.', self.network)
for cap in msg.args[2].split(' '): 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) log.debug('%s: Requesting capability %r', self.network, cap)
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', cap))) self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', cap)))
elif msg.args[1] == 'ACK': elif msg.args[1] == 'ACK':