Created
October 13, 2016 14:27
-
-
Save zoffixznet/213f910e23e8f6a3bacbf066398f4d20 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 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