Created
September 24, 2016 20:48
-
-
Save zoffixznet/c47f02fc7772147eafdb72e0be1f6dcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use IRC::Client; | |
.run with IRC::Client.new: | |
:host<localhost>, | |
:channels<#zofbot>, | |
:debug, | |
plugins => | |
class :: does IRC::Client::Plugin { | |
method irc-addressed ($e) { | |
$e does role { method is-addressed { True } } | |
$.NEXT; | |
} | |
subset BotCommand of IRC::Client::Message::Privmsg where { | |
$^e.?is-addressed | |
?? $e.text ~~ /^ $<command>=\S+ \s+ $<command-args>=.+/ | |
!! $^e.args[1] ~~ /^ '.' $<command>=\S+ \s+ $<command-args>=.+/; | |
my $m = $/; | |
$e does role { | |
method com { ~($m<command>//'') } | |
method com-args { ~($m<command-args>//'') } | |
} | |
True; | |
} | |
multi method irc-privmsg-channel (BotCommand $e where .com eq 'google' ) { | |
"Googling: $e.com-args()"; | |
} | |
multi method irc-privmsg-channel (BotCommand $e where .com eq 'run' ) { | |
"Running: $e.com-args()"; | |
} | |
multi method irc-privmsg ($e where .?is-addressed) { | |
"Don't know how to do `$e.text()`"; | |
} | |
} |
Author
zoffixznet
commented
Sep 24, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment