Skip to content

Commit 35ed840

Browse files
committed
Handle mroe cases where the channel is provided in a message
1 parent e6edae3 commit 35ed840

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

cloudbot/clients/irc.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,16 +382,19 @@ def data_received(self, data):
382382
ctcp_text = None
383383

384384
# Channel
385-
# TODO: Migrate plugins using chan for storage to use chan.lower() instead so we can pass the original case
386-
if command_params and (len(command_params) > 2 or not command_params[0].startswith(":")):
387-
388-
if command_params[0].lower() == self.conn.nick.lower():
389-
# this is a private message - set the channel to the sender's nick
385+
channel = None
386+
if command_params:
387+
if command in ["NOTICE", "PRIVMSG", "KICK", "JOIN", "PART", "MODE"]:
388+
channel = command_params[0]
389+
elif command == "INVITE":
390+
channel = command_params[1]
391+
elif len(command_params) > 2 or command_params[0][0] != ':':
392+
channel = command_params[0]
393+
394+
if channel:
395+
channel = channel.lower()
396+
if channel == self.conn.nick.lower():
390397
channel = nick.lower()
391-
else:
392-
channel = command_params[0].lower()
393-
else:
394-
channel = None
395398

396399
# Set up parsed message
397400
# TODO: Do we really want to send the raw `prefix` and `command_params` here?
@@ -401,3 +404,12 @@ def data_received(self, data):
401404

402405
# handle the message, async
403406
asyncio.async(self.bot.process(event), loop=self.loop)
407+
408+
# Channel Commands
409+
# NOTICE #chan :Text
410+
# PRIVMSG #chan :Text
411+
# KICK #chan nick :reason
412+
# JOIN #chan
413+
# PART #chan :reason
414+
# MODE #chan +<modes>
415+
# INVITE nick :#chan

0 commit comments

Comments
 (0)