Skip to content

Commit 165724c

Browse files
authored
Merge pull request CloudBotIRC#180 from linuxdaemon/gonzobot+chans-fix
Fix multiple joins being attempted to the same channel
2 parents 4ea66d8 + da570b6 commit 165724c

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

plugins/core_misc.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import socket
3+
from copy import copy
34

45
from cloudbot import hook
56

@@ -15,8 +16,12 @@ def invite(irc_paramlist, conn):
1516
:type conn: cloudbot.client.Client
1617
"""
1718
invite_join = conn.config.get('invite_join', True)
19+
chan = irc_paramlist[-1]
20+
if chan.startswith(':'):
21+
chan = chan[1:]
22+
1823
if invite_join:
19-
conn.join(irc_paramlist[-1])
24+
conn.join(chan)
2025

2126

2227
@hook.irc_raw('JOIN')
@@ -64,6 +69,7 @@ def onjoin(conn, bot):
6469
:type conn: cloudbot.clients.clients.IrcClient
6570
:type bot: cloudbot.bot.CloudBot
6671
"""
72+
chans = copy(conn.channels)
6773
bot.logger.info("[{}|misc] Bot is sending join commands for network.".format(conn.name))
6874
nickserv = conn.config.get('nickserv')
6975
if nickserv and nickserv.get("enabled", True):
@@ -100,7 +106,7 @@ def onjoin(conn, bot):
100106
# Join config-defined channels
101107
join_throttle = conn.config.get('join_throttle', 0.4)
102108
bot.logger.info("[{}|misc] Bot is joining channels for network.".format(conn.name))
103-
for channel in conn.channels:
109+
for channel in chans:
104110
conn.join(channel)
105111
yield from asyncio.sleep(join_throttle)
106112

plugins/core_tracker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def bot_left_channel(conn, chan):
2424

2525
def bot_joined_channel(conn, chan):
2626
logger.info("[{}|tracker] Bot joined channel '{}'".format(conn.name, chan))
27-
conn.channels.append(chan)
27+
if chan not in conn.channels:
28+
conn.channels.append(chan)
29+
2830
conn.history[chan] = deque(maxlen=100)
2931

3032

0 commit comments

Comments
 (0)