aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2016-05-21 18:44:25 -0400
committerZoffix Znet <cpan@zoffix.com>2016-05-21 18:44:25 -0400
commit40fad4debbb4e9f3100421a1687e9b0f1ec7f7ca (patch)
tree99c9540df95274171b1fb37f7491b395cf6c61b8
parent3f65d48264430428a2165f6a9f5a4e16f823f6b8 (diff)
Write some more
-rw-r--r--DESIGN/01-main.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/DESIGN/01-main.md b/DESIGN/01-main.md
index 16ecf24..2b4d419 100644
--- a/DESIGN/01-main.md
+++ b/DESIGN/01-main.md
@@ -68,3 +68,37 @@ implementation. This includes user's plugins responsible for handling
events.
###
+
+## Message Delivery
+
+An event listener receives the event message in the form of an object.
+The object must provide all the relevant information about the source
+and content of the message.
+
+The message object's attributes must be mutable, and where appropriate,
+it must provide the means to send the message back to the originator
+of the message. For example, here's a potential implementation of
+`PRIVMSG` handler that receives the message object:
+
+ use IRC::Client::Plugin;
+ unit Plugin::Foo is IRC::Client::Plugin;
+
+ method irc-privmsg ($msg) {
+ return IRC_NOT_HANDLED unless $msg.channel eq '#perl6';
+ $msg.what = "Nice to meet you, $msg.who()";
+ $msg.send;
+ }
+
+The message object should include a means to access the Client Object to
+perform operations best suited for it and not the message object. Here is
+a possible implementation to re-emit a `NOTICE` message sent to channel
+`#perl6` as a `PRIVMSG` message.
+
+ method irc-notice ($msg) {
+ if $msg.channel eq '#perl6' {
+ $msg.how = 'PRIVMSG';
+ $msg.irc.emit: 'PRIVMSG', $msg;
+ }
+
+ return IRC_NOT_HANDLED;
+ }