Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created October 13, 2016 14:27
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/213f910e23e8f6a3bacbf066398f4d20 to your computer and use it in GitHub Desktop.
Save zoffixznet/213f910e23e8f6a3bacbf066398f4d20 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
use lib </home/zoffix/services/lib/IRC-Client/lib/>;
use IRC::Client;
my $bot_username = 'sqttestbot2';
my $username = 'sqttestbot2';
my @channels = <#zofbot>;
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
:debug
:plugins(said2.new);
$irc.run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment