Skip to content

Instantly share code, notes, and snippets.

Created November 23, 2015 21:11
use v6;
my $nick = "jdv_bot_n_1";
my $chan = "#jdv_bot_c_1";
my $conn = await IO::Socket::Async.connect: 'chat.freenode.net', 6667;
sub send { await do { say "SEND:$_"; $conn.print("$_\n") } for @_ }
send("USER $nick - - :$nick", "NICK $nick", "JOIN $chan", "PRIVMSG $chan Hi");
#react whenever $conn.chars-supply.lines {
react whenever $conn.chars-supply.map({say "C GOT:$_";$_}).lines {
say "GOT:$_";
given $_ {
when /^'PING '(.+)$/ { send("PONG $0") }
when /\!time/ { send("PRIVMSG $chan {DateTime.now}") }
when /\!echo/ { send("PRIVMSG $chan $_") }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment