Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created October 13, 2016 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/818582205af68dea8900ce0209633d65 to your computer and use it in GitHub Desktop.
Save zoffixznet/818582205af68dea8900ce0209633d65 to your computer and use it in GitHub Desktop.
#!/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