Skip to content

Commit

Permalink
Backport pull request #2215
Browse files Browse the repository at this point in the history
coretasks: alert owner if nick in `RPL_WELCOME` does not match config
  • Loading branch information
dgw committed Dec 11, 2021
1 parent 8a610d1 commit 4fb17d4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions sopel/coretasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,29 @@ def startup(bot, trigger):
if bot.connection_registered:
return

# nick shenanigans are serious business, but fortunately RPL_WELCOME
# includes the actual nick used by the server after truncation, removal
# of invalid characters, etc. so we can check for such shenanigans
if trigger.event == events.RPL_WELCOME:
if bot.nick != trigger.args[0]:
# setting modes below is just one of the things that won't work
# as expected if the conditions for running this block are met
privmsg = (
"Hi, I'm your bot, %s. The IRC server didn't assign me the "
"nick you configured. This can cause problems for me, and "
"make me do weird things. You'll probably want to stop me, "
"figure out why my nick isn't acceptable, and fix that before "
"starting me again." % bot.nick
)
debug_msg = (
"RPL_WELCOME indicated the server did not accept the bot's "
"configured nickname. Requested '%s'; got '%s'. This can "
"cause unexpected behavior. Please modify the configuration "
"and restart the bot." % (bot.nick, trigger.args[0])
)
LOGGER.critical(debug_msg)
bot.say(privmsg, bot.config.core.owner)

# set flag
bot.connection_registered = True

Expand Down

0 comments on commit 4fb17d4

Please sign in to comment.