mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-21 08:01:00 +01:00
Include start and end messages in a batch.
They may have useful server tags (especially when we start supporting labeled-response).
This commit is contained in:
parent
d627ba7683
commit
cc0af4e790
@ -845,9 +845,10 @@ class IrcState(IrcCommandDispatcher, log.Firewalled):
|
|||||||
batch_type = msg.args[1]
|
batch_type = msg.args[1]
|
||||||
batch_arguments = tuple(msg.args[2:])
|
batch_arguments = tuple(msg.args[2:])
|
||||||
self.batches[batch_name] = Batch(type=batch_type,
|
self.batches[batch_name] = Batch(type=batch_type,
|
||||||
arguments=batch_arguments, messages=[])
|
arguments=batch_arguments, messages=[msg])
|
||||||
elif msg.args[0].startswith('-'):
|
elif msg.args[0].startswith('-'):
|
||||||
batch = self.batches.pop(batch_name)
|
batch = self.batches.pop(batch_name)
|
||||||
|
batch.messages.append(msg)
|
||||||
msg.tag('batch', batch)
|
msg.tag('batch', batch)
|
||||||
else:
|
else:
|
||||||
assert False, msg.args[0]
|
assert False, msg.args[0]
|
||||||
|
@ -748,12 +748,13 @@ class IrcTestCase(SupyTestCase):
|
|||||||
def testBatch(self):
|
def testBatch(self):
|
||||||
self.irc.reset()
|
self.irc.reset()
|
||||||
self.irc.feedMsg(ircmsgs.IrcMsg(':someuser1 JOIN #foo'))
|
self.irc.feedMsg(ircmsgs.IrcMsg(':someuser1 JOIN #foo'))
|
||||||
self.irc.feedMsg(ircmsgs.IrcMsg(':host BATCH +name netjoin'))
|
m1 = ircmsgs.IrcMsg(':host BATCH +name netjoin')
|
||||||
m1 = ircmsgs.IrcMsg('@batch=name :someuser2 JOIN #foo')
|
|
||||||
self.irc.feedMsg(m1)
|
self.irc.feedMsg(m1)
|
||||||
self.irc.feedMsg(ircmsgs.IrcMsg(':someuser3 JOIN #foo'))
|
m2 = ircmsgs.IrcMsg('@batch=name :someuser2 JOIN #foo')
|
||||||
m2 = ircmsgs.IrcMsg('@batch=name :someuser4 JOIN #foo')
|
|
||||||
self.irc.feedMsg(m2)
|
self.irc.feedMsg(m2)
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(':someuser3 JOIN #foo'))
|
||||||
|
m3 = ircmsgs.IrcMsg('@batch=name :someuser4 JOIN #foo')
|
||||||
|
self.irc.feedMsg(m3)
|
||||||
class Callback(irclib.IrcCallback):
|
class Callback(irclib.IrcCallback):
|
||||||
batch = None
|
batch = None
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -763,10 +764,11 @@ class IrcTestCase(SupyTestCase):
|
|||||||
c = Callback()
|
c = Callback()
|
||||||
self.irc.addCallback(c)
|
self.irc.addCallback(c)
|
||||||
try:
|
try:
|
||||||
self.irc.feedMsg(ircmsgs.IrcMsg(':host BATCH -name'))
|
m4 = ircmsgs.IrcMsg(':host BATCH -name')
|
||||||
|
self.irc.feedMsg(m4)
|
||||||
finally:
|
finally:
|
||||||
self.irc.removeCallback(c.name())
|
self.irc.removeCallback(c.name())
|
||||||
self.assertEqual(c.batch, irclib.Batch('netjoin', (), [m1, m2]))
|
self.assertEqual(c.batch, irclib.Batch('netjoin', (), [m1, m2, m3, m4]))
|
||||||
|
|
||||||
class SaslTestCase(SupyTestCase):
|
class SaslTestCase(SupyTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user