Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created October 12, 2016 19:03
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/97e56682494761d923eb756a64f322cc to your computer and use it in GitHub Desktop.
Save zoffixznet/97e56682494761d923eb756a64f322cc to your computer and use it in GitHub Desktop.
#!/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-started {
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