jaraco / irc

Full-featured Python IRC library for Python.
MIT License
390 stars 84 forks source link

Bug: Replying to PING with another PING #150

Closed carter-yagemann closed 5 years ago

carter-yagemann commented 5 years ago

https://github.com/jaraco/irc/blob/e8f6ed2ab1966a7fca0db7b0e6beeb0f8f6cd31a/irc/bot.py#L326-L328

In the class SingleServerIRCBot, on_ctcp appears to reply to ping messages with ping instead of pong. Is this a typo?

jaraco commented 5 years ago

I don't know. Do you have a reference that indicates that it should be otherwise?

carter-yagemann commented 5 years ago

I haven't tested this class directly, but I used it as a reference for my own project and had to patch line 328. I'll connect it to rizon or freenode and see what happens.

carter-yagemann commented 5 years ago

The relevant part of the RFC:

https://github.com/jaraco/irc/blob/7c95b5e49ef19c3515a47d1a10b28790a58393a3/irc/rfc2812.txt#L1986-L1990

When I directly instantiate the class:

bot = SingleServerIRCBot(
          server_list = [('irc.rizon.net', 6667)],
          realname = 'testbot',
          nickname = 'bnXWpKc',
          recon=LogDisconnect()
      )

bot.start()

And ping it myself, I get the following message and response (generated using HexChat raw logger):

<< PRIVMSG bnXWpKc :PING 1532305032381
>> :bnXWpKc!~bnXWpKc@xxx NOTICE aaf39e4ef :PING 1532305032381

This seems like a bug to me, but rizon does not disconnect the bot. There may be a difference between HexChat's /ping command, which sends the request via PRIVMSG, and the server's ping request via CTCP.

I'll close this issue for now. If someone who knows the IRC protocol better wants to weigh in, they can reopen it.

AiyionPrime commented 4 years ago

One's supposed to answer every ping with a pong, but apparently most of the servers I visit are fine, if I answer their ping with another ping, to which they then respond a correct pong.

Furthermore, one can prevent e.g. freenode from ever asking you for a pong, if you keep regularly asking them for one i a shorter interval, the theirs (e.g. one minute).

So, though it appears to be wrong, most servers won't kick you for not responding to ping correctly in time, but for not having had a successful ping-pong in the last x seconds in any direction.