From 90b0541926acb6ef39cb0ad5c854687662f32d0a Mon Sep 17 00:00:00 2001 From: Zoffix Znet Date: Mon, 21 Dec 2015 09:28:29 -0500 Subject: Fix synopsis --- README.md | 86 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index a61c5c9..e32dec8 100644 --- a/README.md +++ b/README.md @@ -19,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[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 eq 'PRIVMSG' and $e[0] eq $irc.nick; + + # Store arbitrary data in the `pipe` for other plugins to use + $e = True + if $e eq 'PRIVMSG'; + + say $e, :indent(4); + return IRC_NOT_HANDLED; +} + +``` + # TABLE OF CONTENTS - [NAME](#name) - [SYNOPSIS](#synopsis) @@ -69,49 +112,6 @@ IRC::Client - Extendable Internet Relay Chat client - [AUTHOR](#author) - [LICENSE](#license) -## 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[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 eq 'PRIVMSG' and $e[0] eq $irc.nick; - - # Store arbitrary data in the `pipe` for other plugins to use - $e = True - if $e eq 'PRIVMSG'; - - say $e, :indent(4); - return IRC_NOT_HANDLED; -} - -``` - # DESCRIPTION ***Note: this is a preview dev release. Things might change and new things -- cgit v1.1