diff options
Diffstat (limited to 'lib/IRC/Client.pm6')
-rw-r--r-- | lib/IRC/Client.pm6 | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6 index 7c30c4a..7d8369a 100644 --- a/lib/IRC/Client.pm6 +++ b/lib/IRC/Client.pm6 @@ -13,6 +13,7 @@ has Str:D $.userhost = 'localhost'; has Str:D $.userreal = 'Perl6 IRC Client'; has Str:D @.channels = ['#perl6']; has @.plugins; +has @.servers; has IO::Socket::Async $!sock; method run { @@ -28,24 +29,17 @@ method run { my $str = try $buf.decode: 'utf8'; $str or $str = $buf.decode: 'latin-1'; $str ~= $left-overs; - $!debug and "[server {DateTime.now}] {$str}".put; - (my $events, $left-overs) = IRC::Client::Grammar.parse( - $str, actions => IRC::Client::Grammar::Actions - ).made; - - for @$events -> $e { - say "[event] $e"; - CATCH { warn .backtrace } - } + + (my $events, $left-overs) = self!parse: $str; + # for @$events -> $e { + # say "[event] $e"; + # CATCH { warn .backtrace } + # } } CATCH { warn .backtrace } } - - say "Closing connection"; $!sock.close; - - # CATCH { warn .backtrace } }); } @@ -54,3 +48,13 @@ method !ssay (Str:D $msg) { $!sock.print("$msg\n"); self; } + +method !parse (Str:D $str) { + return IRC::Client::Grammar.parse( + $str, + actions => IRC::Client::Grammar::Actions.new( + irc => self, + server => 'dummy', + ), + ).made; +} |