Skip to content

Commit 4e63489

Browse files
authored
Merge pull request CloudBotIRC#118 from linuxdaemon/tracker-fix
Fix core_tracker.py tracking of bot joins/parts
2 parents ca65237 + 3daae24 commit 4e63489

2 files changed

Lines changed: 28 additions & 14 deletions

File tree

cloudbot/clients/irc.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,16 +382,21 @@ 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[0] == ':':
397+
channel = channel[1:].split()[0] # Just in case there is more data
398+
if channel == self.conn.nick.lower():
390399
channel = nick.lower()
391-
else:
392-
channel = command_params[0].lower()
393-
else:
394-
channel = None
395400

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

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

plugins/core_tracker.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,23 @@ def on_nick(irc_paramlist, conn, irc_raw):
6969
# mostly when using a BNC which saves channels
7070
@asyncio.coroutine
7171
@hook.irc_raw("JOIN")
72-
def on_join(conn, chan, target):
72+
def on_join(conn, chan, nick):
7373
"""
7474
:type conn: cloudbot.client.Client
7575
:type chan: str
7676
:type nick: str
7777
"""
78-
if target == conn.nick:
78+
if nick == conn.nick:
7979
bot_joined_channel(conn, chan)
8080

8181

8282
@asyncio.coroutine
8383
@hook.irc_raw("PART")
84-
def on_join(conn, chan, target):
84+
def on_part(conn, chan, nick):
8585
"""
8686
:type conn: cloudbot.client.Client
8787
:type chan: str
8888
:type nick: str
8989
"""
90-
if target == conn.nick:
91-
bot_joined_channel(conn, chan)
90+
if nick == conn.nick:
91+
bot_left_channel(conn, chan)

0 commit comments

Comments
 (0)