[1146] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r1092 - in trunk/owl/perl/modules/IRC/lib/BarnOwl/Module: . IRC

daemon@ATHENA.MIT.EDU (geofft@MIT.EDU)
Thu Oct 29 18:13:28 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
X-Original-To: nelhage@nelhage.com
Date: Thu, 24 Jul 2008 01:55:36 -0400 (EDT)
To: dirty-owl-hackers@mit.edu
From: geofft@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU

Author: geofft
Date: 2008-07-24 01:55:35 -0400 (Thu, 24 Jul 2008)
New Revision: 1092

Modified:
   trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
   trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
Log:
IRC: Support for displaying :irc-whois replies, and various bugfixes.

Modified: trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
===================================================================
--- trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm	2008-07-24 01:05:18 UTC (rev 1091)
+++ trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm	2008-07-24 05:55:35 UTC (rev 1092)
@@ -44,7 +44,7 @@
     $self->channels([]);
     $self->motd("");
     $self->connected(0);
-    $self->names_tmp([]);
+    $self->names_tmp(0);
     $self->whois_tmp("");
 
     $self->conn->add_handler(376 => sub { shift; $self->on_connect(@_) });
@@ -70,6 +70,7 @@
     $self->conn->add_handler(topicinfo => sub { shift; $self->on_topicinfo(@_) });
     $self->conn->add_handler(namreply  => sub { shift; $self->on_namreply(@_) });
     $self->conn->add_handler(endofnames=> sub { shift; $self->on_endofnames(@_) });
+    $self->conn->add_handler(endofwhois=> sub { shift; $self->on_endofwhois(@_) });
 
     return $self;
 }
@@ -131,7 +132,7 @@
     BarnOwl::admin_message("IRC",
             BarnOwl::Style::boldify('IRC ' . $evt->type . ' message from '
                 . $self->alias) . "\n"
-            . strip_irc_formatting(join '\n', $evt->args));
+            . strip_irc_formatting(join ' ', cdr($evt->args)));
 }
 
 sub on_motdstart {
@@ -163,7 +164,7 @@
     my $msg = $self->new_message($evt,
         loginout   => 'login',
         channel    => $evt->to,
-        replycmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick,
+        replycmd => 'irc-msg -a ' . $self->alias . ' ' . join(' ', $evt->to),
         replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick
         );
     BarnOwl::queue_message($msg);
@@ -174,7 +175,7 @@
     my $msg = $self->new_message($evt,
         loginout   => 'logout',
         channel    => $evt->to,
-        replycmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick,
+        replycmd => 'irc-msg -a ' . $self->alias . ' ' . join(' ', $evt->to),
         replysendercmd => 'irc-msg -a ' . $self->alias . ' ' . $evt->nick
         );
     BarnOwl::queue_message($msg);
@@ -217,33 +218,53 @@
         "Topic for $args[1] set by $args[2] at " . localtime($args[3]));
 }
 
-sub on_event {
-    my ($self, $evt) = @_;
-    BarnOwl::admin_message("IRC",
-            "[" . $self->alias . "] Unhandled IRC event of type " . $evt->type . ":\n"
-            . strip_irc_formatting(join("\n", $evt->args)))
-        if BarnOwl::getvar('irc:spew') eq 'on';
-}
-
 # IRC gives us a bunch of namreply messages, followed by an endofnames.
 # We need to collect them from the namreply and wait for the endofnames message.
 # After this happens, the names_tmp variable is cleared.
 
 sub on_namreply {
     my ($self, $evt) = @_;
+    return unless $self->names_tmp;
     $self->names_tmp([@{$self->names_tmp}, split(' ', [$evt->args]->[3])]);
 }
 
 sub on_endofnames {
     my ($self, $evt) = @_;
+    return unless $self->names_tmp;
     my $names = BarnOwl::Style::boldify("Members of " . [$evt->args]->[1] . ":\n");
     for my $name (@{$self->names_tmp}) {
         $names .= "  $name\n";
     }
     BarnOwl::popless_ztext($names);
-    $self->names_tmp([]);
+    $self->names_tmp(0);
 }
 
+sub on_whois {
+    my ($self, $evt) = @_;
+    $self->whois_tmp(
+      $self->whois_tmp . "\n" . $evt->type . ":\n  " .
+      join("\n  ", cdr(cdr($evt->args))) . "\n"
+    );
+}
+
+sub on_endofwhois {
+    my ($self, $evt) = @_;
+    BarnOwl::popless_ztext(
+        BarnOwl::Style::boldify("/whois for " . [$evt->args]->[1] . ":\n") .
+        $self->whois_tmp
+    );
+    $self->whois_tmp([]);
+}
+
+sub on_event {
+    my ($self, $evt) = @_;
+    return on_whois(@_) if ($evt->type =~ /^whois/);
+    BarnOwl::admin_message("IRC",
+            "[" . $self->alias . "] Unhandled IRC event of type " . $evt->type . ":\n"
+            . strip_irc_formatting(join("\n", $evt->args)))
+        if BarnOwl::getvar('irc:spew') eq 'on';
+}
+
 ################################################################################
 ########################### Utilities/Helpers ##################################
 ################################################################################

Modified: trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
===================================================================
--- trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm	2008-07-24 01:05:18 UTC (rev 1091)
+++ trunk/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm	2008-07-24 05:55:35 UTC (rev 1092)
@@ -262,6 +262,7 @@
     my $cmd = shift;
     my $conn = get_connection(\@_);
     my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n");
+    $conn->names_tmp([]);
     $conn->conn->names($chan);
 }
 


home help back first fref pref prev next nref lref last post