From d2da9fcd250533bee5df17bd182648a8cea0d7b0 Mon Sep 17 00:00:00 2001 From: Zoffix Znet Date: Sun, 6 Dec 2015 18:07:19 -0500 Subject: Prerelease --- lib/IRC/Client.pm6 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/IRC/Client.pm6') diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6 index dcf0fcb..a27c18d 100644 --- a/lib/IRC/Client.pm6 +++ b/lib/IRC/Client.pm6 @@ -1,5 +1,6 @@ use v6; use IRC::Parser; # parse-irc +use IRC::Client::Plugin::PingPong; role IRC::Client::Plugin { ... } class IRC::Client:ver<1.001001> { has Bool:D $.debug = False; @@ -11,8 +12,10 @@ class IRC::Client:ver<1.001001> { has Str:D $.userreal = 'Perl6 IRC Client'; has Str:D @.channels = ['#perl6bot']; has IO::Socket::Async $.sock; - has IRC::Client::Plugin @.plugins = []; - has IRC::Client::Plugin @.plugins-essential = []; + has @.plugins = []; + has @.plugins-essential = [ + IRC::Client::Plugin::PingPong.new + ]; method run { await IO::Socket::Async.connect( $!host, $!port ).then({ @@ -27,10 +30,11 @@ class IRC::Client:ver<1.001001> { react { whenever $!sock.Supply -> $str is copy { $!debug and $str.say; - # say parse-irc($str).WHAT; - my $x = parse-irc $str; - @!plugins[0].msg(self, $x); - .msg(self, $x) for @!plugins.grep(*.msg); + my $messages = parse-irc $str; + for @$messages -> $message { + .msg(self, $message) + for (@!plugins-essential, @!plugins).flat.grep(*.msg); + } } } -- cgit v1.1