irc icon indicating copy to clipboard operation
irc copied to clipboard

IRC Bot reconn strategy question

Open accedic opened this issue 2 years ago • 2 comments

HI, I see theres a startegy based on disconnect. If it disconnect the bot try's to reconnect. However, in my case i'm using this i want the bot to stop reconnecting if i send it a specific command. How would i go about this? I want it to reconnect when something fails, but not when i want it to stop, as i am starting it in a seperate thread.

Thanks

accedic avatar Feb 01 '24 01:02 accedic

I found a work around to do it, but i would like to no have to modify the code for ExponentialBackoff if possible. If theres already a way somewhere in the code which i missed. I would like the module to stay as stock as possible so i deploy this easy without modifying or forking it. Thanks in advance.

accedic avatar Feb 01 '24 03:02 accedic

Agreed, you shouldn't have to modify ExponentialBackoff in order to disconnect.

I presume you're using the irc.bot.SingleServerIRCBot. Why not override _on_disconnect in a subclass? Or you could set your bot's .recon to a strategy that does nothing:

class DoNotReconnect(ReconnectStrategy):
    def run(self, but):
        pass

Then when you've decided not to reconnect, set bot.recon = DoNotReconnect().

Let me know how that goes.

jaraco avatar Mar 28 '24 13:03 jaraco

I'm closing this issue, but I'd love to hear if the recommendation works for you or if there's more you think the library could do to help here.

jaraco avatar Jul 12 '24 16:07 jaraco