use v6-alpha; use Net::IRC; # Parse @*ARGS my $nick = @*ARGS[0] // "blechbot"; my $server = @*ARGS[1] // "localhost"; my ($host, $port) = split ":", $server; $port //= 6667; # Create new bot "object" my $bot = new_bot(nick => $nick, host => $host, port => $port, debug_raw => 0); $bot("INVITE", &on_invite); $bot("PRIVMSG", &on_privmsg); $bot("JOIN", &on_join); $bot("PART", &on_part); $bot("QUIT", &on_quit); $bot(); $bot(); $bot(); # Later, some kind of timestamp will need to be added, but there isn't yet a # strftime(). sub log(Str $msg) { print "$msg\n" } sub on_invite($event) { my ($from, $chan) = $event; debug "Got an invitation from \"$from\" to join channel \"$chan\"."; $bot($chan); } sub on_privmsg($event) { if $event ~~ rx:P5/^\x01(?:ACTION )(.*)\x01?$/ { log "* $event $0"; } else { log "<$event> $event"; } } sub on_join($event) { log "*** $event has joined $event" } sub on_part($event) { log "*** $event has left $event ($event)" } sub on_quit($event) { log "*** $event has quit IRC ($event)" }