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

irccat and irccat2 fail pong #171

Open
AiyionPrime opened this issue May 25, 2020 · 2 comments
Open

irccat and irccat2 fail pong #171

AiyionPrime opened this issue May 25, 2020 · 2 comments

Comments

@AiyionPrime
Copy link

Hey there,
I really like the framework, and especially the numerous examples which give a good understanding of what the limits of it are.

I just stumbled upon the frameworks quality:

Handles server PONGing transparently.

I haven't checked all four, but at least the examples irccat and irccat2 are written in a way, that apparently blocks this feature.

I tested this on freenode:
env/bin/python irccat2.py irc.freenode.net beloved_test "#irccattest"

write something, make sure it works and then don't do anything for about four minutes and eight seconds (maybe a few more). Freenode will kick you for not having responded in quite a while.

Maybe it would be possible to rewrite the examples, that they don't get kicked while their external input function (bash input) stays silent for a while?

Thanks for the read, aiyion.

@AiyionPrime
Copy link
Author

If I understand it correctly, this could be done by registering an event to call a 'read-all-available-from-stdin' function on a time basis (e.g. every few seconds).
This could then also resolve #167 ?

@jaraco
Copy link
Owner

jaraco commented Jul 18, 2020

The problem with both irccat scripts is they're not written for asynchronous programming. They either bypass the event loop (in the case of irccat2) or hijack it (in the case of irccat).

If I understand it correctly, [handling blocking input] could be done by registering an event to call.

Yes, that sounds suitable, and may be the best approach.

For another example, in the pmxbot.webhooks project, an HTTP server runs in a separate thread and when it receives new messages over the HTTP API, it adds those messages to a queue and then in the IRC bot, relays messages from the queue every .3 seconds. Something similar could be written for to address this need.

Alternatively, one could write a custom event loop that's aware of stdin as one of the file descriptors to monitor and handles that directly.

I welcome investigations and contributions on the matter.

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

No branches or pull requests

2 participants