aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2015-12-13 19:14:23 -0500
committerZoffix Znet <cpan@zoffix.com>2015-12-13 19:14:23 -0500
commit05647bd1f2312cc756f71152252a6349e86f43c5 (patch)
tree68e2238ed3ec868de1316f21ef1df2d1ea367831 /README.md
parent22e34475c8fe5d6957525962adb4f65d910e46d0 (diff)
update docs
Diffstat (limited to 'README.md')
-rw-r--r--README.md45
1 files changed, 45 insertions, 0 deletions
diff --git a/README.md b/README.md
index b2bcad9..0568858 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,8 @@ IRC::Client - Extendable Internet Relay Chat client
# SYNOPSIS
+## Client script
+
```perl6
use IRC::Client;
use IRC::Client::Plugin::Debugger;
@@ -17,6 +19,49 @@ IRC::Client - Extendable Internet Relay Chat client
).run;
```
+## Custom plugins
+
+### Basic response to an IRC command:
+
+The plugin chain handling the message will stop after this plugin.
+
+```
+unit class IRC::Client::Plugin::PingPong is IRC::Client::Plugin;
+method irc-ping ($irc, $msg) { $irc.ssay("PONG {$irc.nick} $msg<params>[0]") }
+```
+
+### More involved handling
+
+On startup, start sending message `I'm an annoying bot` to all channels
+every five seconds. We also subscribe to all events and print some debugging
+info. By returning a special constant, we tell other plugins to continue
+processing the data.
+
+```
+use IRC::Client::Plugin; # import constants
+unit class IRC::Client::Plugin::Debugger is IRC::Client::Plugin;
+
+method register($irc) {
+ Supply.interval( 5, 5 ).tap({
+ $irc.privmsg($_, "I'm an annoying bot!")
+ for $irc.channels;
+ })
+}
+
+method all-events ($irc, $e) {
+ say "We've got a private message"
+ if $e<command> eq 'PRIVMSG' and $e<params>[0] eq $irc.nick;
+
+ # Store arbitrary data in the `pipe` for other plugins to use
+ $e<pipe><respond-to-notice> = True
+ if $e<command> eq 'PRIVMSG';
+
+ say $e, :indent(4);
+ return IRC_NOT_HANDLED;
+}
+
+```
+
# DESCRIPTION
***Note: this is a preview dev release. Things might change and new things