3

I'm currently developing a bot with POE::Component::IRC whose job, amongst other things, is to post a notice to a list of channels on a schedule, for one week.

I can't seem to find a way to check that the message has been successfully sent to a channel though. The old Net::IRC package would fire a message received event for every message sent to a channel, including ones it itself had sent. POE seems not to do this - at least, the irc_public event is not firing when the bot's own message is published on the channel.

Is there a flag I can pass to the event handler to say "I'd really like to receive all messages please, even my own"? Or is there a way to do this with some sort of RAW event handler?

Miller
  • 34,962
  • 4
  • 39
  • 60
GodEater
  • 3,445
  • 2
  • 27
  • 30

1 Answers1

1

The IRC protocol does not echo your PRIVMSGs back to you, so you just have to trust that the server received your message and handled it the way it should.

If you just want to receive POE events for messages you send, there's a plug-in for that: POE::Component::IRC::Plugin::BotTraffic. It doesn't actually do anything to verify that the messages ever reach the server, though.

Fortunately, IRC runs on top of TCP, which provides guaranteed in-order delivery. Thus, as long as the connection doesn't drop or hang indefinitely, you can pretty safely assume that your commands will reach the server.

If you wanted to be absolutely sure, you could always follow your PRIVMSG with some command, such as TIME or PING, that you know the server will reply to; if it does, you'll know that it received your PRIVMSG too. Of course, even then there's still no guarantee that the server actually passed the message on to the intended recipient(s); things like netsplits do occur from time to time, and can cause messages to be dropped.

Ilmari Karonen
  • 49,047
  • 9
  • 93
  • 153
  • Interesting - I guess I should actually read the IRC RFC at some point - I should have realised that already. I was basing my assumption that Net::IRC did this on some code I inherited from a colleague, and his perl checked to see if messages he received were ones he himself had sent. Ho hum. Guess I'll have to do as you say, and trust TCP :) – GodEater Sep 18 '14 at 08:16
  • The RFCs don't actually spell this out clearly -- in fact, they don't seem to *forbid* servers from echoing PRIVMSGs back, they just don't require it, either. The closest I can find is Example 4 in [RFC 2810, section 5.2.1](http://tools.ietf.org/html/rfc2810#section-5.2.1), which says that messages sent to a channel with no other users "go to the server and then nowhere else." What you can do, however, is telnet / netcat to a real IRC server, type in your own IRC commands and see what happens. (In fact, as a corner case, if you directly PRIVMSG your own nick, you *do* seem to get an echo.) – Ilmari Karonen Sep 18 '14 at 11:07