martynsmith / node-irc

NodeJS IRC client library
GNU General Public License v3.0
1.32k stars 425 forks source link

Self messages listen #471

Open gamelaster opened 8 years ago

gamelaster commented 8 years ago

Hello, is possible to emit message, action etc. when I send message, action etc, best when the message is sent? Thanks

moshmage commented 8 years ago

Could you.. rewrite your question? We got lost in translation :)

gamelaster commented 8 years ago

Sorry for bad explain. For sample: I (the logged user) send the message (or action). When is the message sent and delivered, the "message" event will be emitted.

moshmage commented 8 years ago

Sorry. Some pseudo-code of what you're trying to accomplish would make it easier for me to understand.

gamelaster commented 8 years ago
client.say("#neko", "Hello all!");
//after send, the this event will be emitted
client.addListener('message', function (nick, to, text, message) {
  /*
  nick = gamelaster
  to = #neko
  text = Hello all!
  message = Message object
   */
});
moshmage commented 8 years ago

Ok. i get what you're trying to do now;

You want to listen to a message only after another one has been sent, correct? If yes, then you have to:

1) create a listener on #neko for all messages; 2) send message to #neko sayin "hello, all" 2.1) set a flag to "listen for any messages after hello" (pex: sentHello = true) 3) on the listener we created on the first bullet, create a condition "if (sentHello === true) 3.1) if the above condition is true, check if message === "hello neko" 3.2) if true do what you gotta do :)

is that it ?