mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-03-29 02:47:23 +01:00
irclib: Fix hang in cap nego when echo-message is available but not labeled-response.
echo-message ended up in self.state.capabilities_req even though it wasn't requested, so the bot was stuck in state: "Waiting for ACK/NAK of capabilities: {'echo-message'}".
This commit is contained in:
parent
c9c05cf8e1
commit
568b84847b
@ -1682,8 +1682,6 @@ class Irc(IrcCommandDispatcher, log.Firewalled):
|
|||||||
self._requestCaps(common_supported_unrequested_capabilities)
|
self._requestCaps(common_supported_unrequested_capabilities)
|
||||||
|
|
||||||
def _requestCaps(self, caps):
|
def _requestCaps(self, caps):
|
||||||
self.state.capabilities_req |= caps
|
|
||||||
|
|
||||||
caps = list(sorted(caps))
|
caps = list(sorted(caps))
|
||||||
cap_lines = []
|
cap_lines = []
|
||||||
if 'echo-message' in caps \
|
if 'echo-message' in caps \
|
||||||
@ -1701,6 +1699,9 @@ class Irc(IrcCommandDispatcher, log.Firewalled):
|
|||||||
# This makes sure they are always on the same line (which
|
# This makes sure they are always on the same line (which
|
||||||
# happens to be the first):
|
# happens to be the first):
|
||||||
caps = ['echo-message', 'labeled-response'] + caps
|
caps = ['echo-message', 'labeled-response'] + caps
|
||||||
|
|
||||||
|
self.state.capabilities_req |= set(caps)
|
||||||
|
|
||||||
caps = ' '.join(caps)
|
caps = ' '.join(caps)
|
||||||
# textwrap works here because in ASCII, all chars are 1 bytes:
|
# textwrap works here because in ASCII, all chars are 1 bytes:
|
||||||
cap_lines = textwrap.wrap(
|
cap_lines = textwrap.wrap(
|
||||||
|
@ -522,6 +522,13 @@ class IrcCapsTestCase(SupyTestCase):
|
|||||||
m = self.irc.takeMsg()
|
m = self.irc.takeMsg()
|
||||||
self.assertIsNone(m)
|
self.assertIsNone(m)
|
||||||
|
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(command='CAP',
|
||||||
|
args=('*', 'ACK', 'account-notify')))
|
||||||
|
|
||||||
|
m = self.irc.takeMsg()
|
||||||
|
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||||
|
self.assertEqual(m.args, ('END',), m)
|
||||||
|
|
||||||
def testEchomessageLabeledresponseGrouped(self):
|
def testEchomessageLabeledresponseGrouped(self):
|
||||||
self.irc = irclib.Irc('test')
|
self.irc = irclib.Irc('test')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user