From 3c3eca5b42ff624a5f2bc59b182dbd669a86a012 Mon Sep 17 00:00:00 2001 From: "J.P. Neverwas" Date: Sun, 27 Sep 2020 04:31:43 -0700 Subject: [PATCH] Allow comma-separated chans in server userlist join --- irc3d/plugins/userlist.py | 21 ++++++++++++--------- tests/test_irc3d_userlist.py | 3 ++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/irc3d/plugins/userlist.py b/irc3d/plugins/userlist.py index bbeb94d..4ba7284 100644 --- a/irc3d/plugins/userlist.py +++ b/irc3d/plugins/userlist.py @@ -71,15 +71,18 @@ def JOIN(self, client, args=None, **kwargs): %%JOIN """ - if args[''] in client.channels: - return - message = ':{mask} JOIN {}' - kwargs.update( - broadcast=message.format(mask=client.mask, **args), - channel=args['']) - self.join(client.nick, client.mask, client=client, **kwargs) - client.channels.add(args['']) - self.NAMES(client=client, **kwargs) + for channel in args[''].split(','): + if channel in client.channels: + continue + message = ':{mask} JOIN {}' + kwargs.update( + broadcast=message.format( + mask=client.mask, **dict(args, **{'': channel}) + ), + channel=channel) + self.join(client.nick, client.mask, client=client, **kwargs) + client.channels.add(channel) + self.NAMES(client=client, **kwargs) @irc3d.command def PART(self, client, args=None, **kwargs): diff --git a/tests/test_irc3d_userlist.py b/tests/test_irc3d_userlist.py index 7009c47..7d5502f 100644 --- a/tests/test_irc3d_userlist.py +++ b/tests/test_irc3d_userlist.py @@ -87,7 +87,7 @@ def test_userlist(self): self.assertSent(s.client2, ':client1!uclient1@127.0.0.1 NICK irc3') self.assertNotSent(s.client3, ':client1!uclient1@127.0.0.1 NICK irc3') - s.client3.dispatch('JOIN #irc') + s.client3.dispatch('JOIN #irc,#irc3') s.client1.dispatch('NICK client1') self.assertSent(s.client1, ':irc3!uclient1@127.0.0.1 NICK client1') self.assertSent(s.client2, ':irc3!uclient1@127.0.0.1 NICK client1') @@ -116,6 +116,7 @@ def test_userlist(self): self.assertSent(s.client1, ':irc.com 319 client1 :#irc3') s.client3.dispatch('PART #irc :Bye') + s.client3.dispatch('PART #irc3 :Bye') self.assertSent(s.client3, ':{mask} PART #irc :Bye', s.client3) self.assertSent(s.client1, ':{mask} PART #irc :Bye', s.client3) self.assertNotSent(s.client2, ':{mask} PART #irc :Bye', s.client3)