Skip to content

Commit 4fb17d4

Browse files
committed
Backport pull request #2215
coretasks: alert owner if nick in `RPL_WELCOME` does not match config
1 parent 8a610d1 commit 4fb17d4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

sopel/coretasks.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,29 @@ def startup(bot, trigger):
245245
if bot.connection_registered:
246246
return
247247

248+
# nick shenanigans are serious business, but fortunately RPL_WELCOME
249+
# includes the actual nick used by the server after truncation, removal
250+
# of invalid characters, etc. so we can check for such shenanigans
251+
if trigger.event == events.RPL_WELCOME:
252+
if bot.nick != trigger.args[0]:
253+
# setting modes below is just one of the things that won't work
254+
# as expected if the conditions for running this block are met
255+
privmsg = (
256+
"Hi, I'm your bot, %s. The IRC server didn't assign me the "
257+
"nick you configured. This can cause problems for me, and "
258+
"make me do weird things. You'll probably want to stop me, "
259+
"figure out why my nick isn't acceptable, and fix that before "
260+
"starting me again." % bot.nick
261+
)
262+
debug_msg = (
263+
"RPL_WELCOME indicated the server did not accept the bot's "
264+
"configured nickname. Requested '%s'; got '%s'. This can "
265+
"cause unexpected behavior. Please modify the configuration "
266+
"and restart the bot." % (bot.nick, trigger.args[0])
267+
)
268+
LOGGER.critical(debug_msg)
269+
bot.say(privmsg, bot.config.core.owner)
270+
248271
# set flag
249272
bot.connection_registered = True
250273

0 commit comments

Comments
 (0)