Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IRC Bot reconn strategy question #222

Open
accedic opened this issue Feb 1, 2024 · 2 comments
Open

IRC Bot reconn strategy question #222

accedic opened this issue Feb 1, 2024 · 2 comments
Labels

Comments

@accedic
Copy link

accedic commented Feb 1, 2024

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
Copy link
Author

accedic commented Feb 1, 2024

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.

@jaraco
Copy link
Owner

jaraco commented Mar 28, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants