aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2015-12-31 13:23:17 -0500
committerZoffix Znet <cpan@zoffix.com>2015-12-31 13:23:17 -0500
commit938d734988bd99db66968698360a2a1a08f18025 (patch)
tree0f2f84760e8a94fdd7f2f78ac35a30c96437ae10 /lib
parent2163e6413cf38126f4e96e2e9e00632542bea649 (diff)
Fix freeze up on broken messages
Diffstat (limited to 'lib')
-rw-r--r--lib/IRC/Client.pm614
-rw-r--r--lib/IRC/Grammar/Actions.pm63
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6
index e130174..8c0b2c1 100644
--- a/lib/IRC/Client.pm6
+++ b/lib/IRC/Client.pm6
@@ -24,13 +24,17 @@ class IRC::Client:ver<2.001001> {
await IO::Socket::Async.connect( $!host, $!port ).then({
$!sock = .result;
$.ssay("NICK $!nick\n");
- $.ssay("USER $!username $!userhost $!host :$!userreal\n");
- $.ssay("JOIN $_\n") for @!channels;
+ $.ssay("USER $!username $!username $!host :$!userreal\n");
+ $.ssay("JOIN {@!channels[]} x\n");
.irc-connected: self for @!plugs.grep(*.^can: 'irc-connected');
+ # my $left-overs = '';
react {
- whenever $!sock.Supply -> $str is copy {
+ whenever $!sock.Supply :bin -> $buf is copy {
+ 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 = parse-irc $str;
EVENTS: for @$events -> $e {
@@ -80,7 +84,7 @@ class IRC::Client:ver<2.001001> {
say "Closing connection";
$!sock.close;
- CATCH { warn .backtrace }
+ # CATCH { warn .backtrace }
});
}
@@ -91,7 +95,7 @@ class IRC::Client:ver<2.001001> {
}
method privmsg (Str $who, Str $what) {
- my $msg = ":$!nick!$!username\@$!userhost PRIVMSG $who :$what\n";
+ my $msg = "PRIVMSG $who :$what\n";
$!debug and "{plug-name}$msg".put;
$!sock.print("$msg\n");
self;
diff --git a/lib/IRC/Grammar/Actions.pm6 b/lib/IRC/Grammar/Actions.pm6
index 469f8f8..e7f5292 100644
--- a/lib/IRC/Grammar/Actions.pm6
+++ b/lib/IRC/Grammar/Actions.pm6
@@ -10,7 +10,8 @@ method message ($/) {
%args<who><host> = ~$pref<servername> if $pref<servername>.defined;
my $p = $/<params>;
- loop {
+
+ for ^100 { # bail out after 100 iterations; we're stuck
if ( $p<middle>.defined ) {
%args<params>.append: ~$p<middle>;
}