aatxe / irc

the irc crate – usable, async IRC for Rust
Mozilla Public License 2.0
528 stars 97 forks source link

Answer to private messages #144

Closed msehnout closed 6 years ago

msehnout commented 6 years ago

Hi,

first of all, thank you for the library, I really like it!

I have a bot, which works fine when I talk to it in a specific channel such as #test, but I'd also like to talk to it in a private conversation (/QUERY bot ...) so that I don't spam the channel too much. My code looks a lot like in the available examples: https://github.com/msehnout/lunch-bot/blob/master/src/main.rs#L125 but it does not respond and I cannot figure out how to make it work from the documentation. Can you help me with this? Is it possible?

msehnout commented 6 years ago

I was able to figure it out, but it took a bit longer. Maybe it would be worth mentioning in some example, that you should respond to message.prefix in case the target from Command::PRIVMSG(target, _) is the same as the current nickname. What to you think?

aatxe commented 6 years ago

This question came up a few years ago (#20), and I think is definitely a confusing thing about the IRC protocol (PRIVMSG really doesn't sound like the name for sending a message to everything...). There's a useful utility function Message::response_target(...) that will yield either the channel being messaged in a PRIVMSG or NOTICE or the nickname of the sender. I've pushed an update to develop that adds this information directly to the docs for PRIVMSG and NOTICE.

Thanks for the report though, and let me know if you think there's more that can be done to clear things up! 🍻