Closed jaraco closed 8 years ago
irccat (and other scripts in the examples directories) aren't designed to be production-class scripts. Instead, they're designed to help the developer gain a familiarity with the system.
As a result, the example is very simple and doesn't account for higher-level behaviors (like ping timeouts, or processing incoming messages at all for that matter).
The way the irc library handles asynchronous I/O is through callbacks, so it's important that the process_once
be called periodically to handle incoming messages (pings) and respond accordingly.
You might try calling process_once
in the loop, which may cause the "ping-ponger" to respond to pings:
C:\Users\jaraco\projects\irc [default ~1 master tip]> hg diff
diff -r af0a10dde638 scripts/irccat.py
--- a/scripts/irccat.py Sun Sep 22 18:09:50 2013 -0400
+++ b/scripts/irccat.py Sun Oct 20 15:52:03 2013 -0400
@@ -34,6 +34,7 @@
for line in itertools.takewhile(bool, get_lines()):
print(line)
connection.privmsg(target, line)
+ connection.irclibobj.process_once()
connection.quit("Using irc.client.py")
def on_disconnect(connection, event):
However, even that isn't necessarily going to work if input from stdin isn't received frequently enough to trigger the ping responses.
Your other option would be to create a separate thread or other asynchronous technique to ensure that 'process_once' is called periodically even when input isn't received on stdin.
Original comment by: Jason R. Coombs
If you play around with irccat long enough, it will eventually ping timeout.