Created
October 13, 2016 14:23
-
-
Save zoffixznet/818582205af68dea8900ce0209633d65 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
#!/usr/bin/env perl6 | |
use IRC::Client; | |
my $bot_username = 'sqttestbot'; | |
my $username = 'sqttestbot'; | |
class said2 does IRC::Client::Plugin { | |
has Proc::Async $!proc; | |
method irc-connected ($) { | |
return if $!proc; | |
given Proc::Async.new: 'perl', 'said.in.pl' { | |
.stdout.tap: -> $line { | |
$.irc.send: :where($_) :text($line) for .channels; | |
if ( $line ~~ s/^\%// ) { | |
say 'Match'; | |
} | |
} | |
await .start; | |
$!proc = $_; | |
} | |
} | |
method irc-privmsg-channel ($e) { | |
my $body = $e.text; | |
my $who_said = $e.nick; | |
my $channel = $e.channel; | |
#$!proc.write: "$e.channel() >$bot_username\< \<$e.nick()> $e.text()\n"; | |
$!proc.write: "$channel >$bot_username\< \<$who_said> $body\n"; | |
Nil; | |
} | |
} | |
my $irc = IRC::Client.new: | |
:nick<sqttestbot> | |
:host<irc.freenode.net> | |
:channels<##sqt-test> | |
:debug | |
:plugins(said2); | |
$irc.run; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment