luk3yx / miniirc

A mini IRC framework.
MIT License
11 stars 1 forks source link

Underscore keeps getting appended to nick #26

Closed impredicative closed 1 year ago

impredicative commented 1 year ago

If my bot's nick is say MyBot, then over time, its nick keeps getting changed to MyBot_, then sometimes MyBot__, and rarely even MyBot___, etc. I have tried to remedy this without reliable success. Can miniirc be updated to prevent this or to reliably fix it when it happens? This is with v1.8.4 and Python 3.11. I think that the responsibility of ensuring that the bot always has the correct nick should be that of miniirc.

luk3yx commented 1 year ago

Currently irc.nick is updated whenever the bot changes nickname. If the bot can't get MyBot, it will change to MyBot_, and so on. The new nickname is (unfortunately) used if the bot reconnects to IRC.

I think the best fix would be to add a keepnick argument to miniirc that makes miniirc store the original nickname and try and obtain the original nickname if it can't while connecting. I'll (hopefully) implement this soon.

impredicative commented 1 year ago

miniirc store the original nickname and try and obtain the original nickname if it can't while connecting.

I personally think that this should always be the behavior. I can't think of a case when this wouldn't be wanted. As such, I am personally not in favor of a new keepnick option.

luk3yx commented 1 year ago

I'm just worried about breaking something since I plan on making irc.nick store the original nickname and irc.current_nick store the current one when keepnick is enabled, though irc.current_nick has existed as an alias since 2019 and any potential breakage would likely be minimal.

impredicative commented 1 year ago

Something will break if the bot stays unconnected for a long time if it cannot get the correct nick. Perhaps versions <2.0 can have keepnick, and versions >=2.0 can eliminate the option once it's known to be very stable.

luk3yx commented 1 year ago

Something will break if the bot stays unconnected for a long time if it cannot get the correct nick.

Good point. I've released miniirc v1.9.0 with a "keepnick" feature (without an option to disable it), please let me know if there are any bugs.

I've made irc.nick emulate what it does in earlier versions, hopefully that will prevent anything from breaking.