aboutsummaryrefslogtreecommitdiff
path: root/examples/02-trickster-bot.p6
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2016-07-29 19:21:20 -0400
committerZoffix Znet <cpan@zoffix.com>2016-07-29 19:21:20 -0400
commite3c619494601a8628b8a27bd855fa9b1506c0728 (patch)
tree5bce316ec49ba996b69e2d150cf075fc3ec5bd65 /examples/02-trickster-bot.p6
parentdb4b16e06ee14205a988263942524e1d754f8f64 (diff)
Add examples; fix up docs
Diffstat (limited to 'examples/02-trickster-bot.p6')
-rw-r--r--examples/02-trickster-bot.p619
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/02-trickster-bot.p6 b/examples/02-trickster-bot.p6
new file mode 100644
index 0000000..178fcdd
--- /dev/null
+++ b/examples/02-trickster-bot.p6
@@ -0,0 +1,19 @@
+use lib <lib>;
+
+use IRC::Client;
+class Trickster {
+ multi method irc-to-me ($ where /time/) { DateTime.now }
+ multi method irc-to-me ($ where /temp \s+ $<temp>=\d+ $<unit>=[F|C]/) {
+ $<unit> eq 'F' ?? "That's {($<temp> - 32) × .5556}°C"
+ !! "That's { $<temp> × 1.8 + 32 }°F"
+ }
+}
+
+class BFF { method irc-to-me ($ where /'♥'/) { 'I ♥ YOU!' } }
+
+.run with IRC::Client.new:
+ :nick<MahBot>
+ :host<irc.freenode.net>
+ :channels<#zofbot>
+ :debug
+ :plugins(Trickster, BFF)