Created
October 12, 2016 19:04
-
-
Save zoffixznet/2f028fa4e1fa45e90c535c4ff34beab8 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'; | |
my @channels = <##sqt-test>; | |
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/^\%//; | |
} | |
await .start; | |
$!proc = $_; | |
} | |
} | |
method irc-privmsg-channel ($e) { | |
$!proc.write: "$e.channel() >$bot_username\< \<$e.nick()> $e.text()\n"; | |
Nil; | |
} | |
} | |
.run with IRC::Client.new: | |
:nick<sqttestbot> | |
:host<irc.freenode.net> | |
:@channels | |
:debug | |
:plugins(said2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment