OSDN Git Service

2004-04-08 Jun Morimoto <morimoto@xantia.citroen.org>
authormorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Thu, 8 Apr 2004 15:27:57 +0000 (15:27 +0000)
committermorimoto <morimoto@180c8125-5b33-4295-ad04-72a68a15b4cc>
Thu, 8 Apr 2004 15:27:57 +0000 (15:27 +0000)
\e$B%A%c%M%k%j%9%H$NH/8@?tI=<($,$*$+$7$$$3$H$,$"$C$?\e(B
* foo@bar \e$B7A<0$r\e(B mailto \e$B%j%s%/$K$7$J$$$h$&$K$7$?\e(B
* https:// \e$B7A<0$b%j%s%/$K$9$k\e(B
\e$BC/$+$,\e(B channel \e$B$+$iH4$1$?$H$-$N%a%C%;!<%8$r=q<0JQ99\e(B
\e$BC/$+$,\e(B channel \e$B$K\e(B join \e$B$7$F$-$?$H$-$K%a%C%;!<%8$rDI2C\e(B

keitairc

index a47508e..4d755ea 100755 (executable)
--- a/keitairc
+++ b/keitairc
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 # keitairc
-# $Id: keitairc,v 1.18 2004-03-24 17:34:43 ishikawa Exp $
+# $Id: keitairc,v 1.19 2004-04-08 15:27:57 morimoto Exp $
 #
 # Copyright (c) 2003 Jun Morimoto <morimoto@xantia.citroen.org>
 # This program is covered by the GNU General Public License 2
@@ -8,7 +8,7 @@
 # Depends: libjcode-pm-perl, libpoe-component-irc-perl,
 #   liburi-perl, libwww-perl, libappconfig-perl
 
-my $rcsid = q$Id: keitairc,v 1.18 2004-03-24 17:34:43 ishikawa Exp $;
+my $rcsid = q$Id: keitairc,v 1.19 2004-04-08 15:27:57 morimoto Exp $;
 my ($version) = $rcsid =~ m#,v ([0-9.]+)#;
 
 use strict;
@@ -96,7 +96,11 @@ sub on_irc_start{
 ################################################################
 sub on_irc_join{
     my ($kernel, $who, $channel) = @_[KERNEL, ARG0, ARG1];
+    $who =~ s/!.*//;
     $channel_name{$channel}++;
+    unless ($who eq $config->irc_nick) {
+      &add_message($channel, undef, "$who joined");
+    }
 }
 
 ################################################################
@@ -110,7 +114,7 @@ sub on_irc_part{
     if ($who eq $config->irc_nick) {
        delete $channel_name{$channel};
     } else {
-       &add_message($channel, 'SYSOP', $who . ' leaves');
+       &add_message($channel, undef, "$who leaves");
     }
 }
 
@@ -138,7 +142,12 @@ sub on_irc_notice{
 sub add_message{
     my($channel, $who, $msg) = @_;
 
-    my $message = sprintf('%s %s> %s', &now, $who, $msg);
+    my $message;
+    if(length $who){
+      $message = sprintf('%s %s> %s', &now, $who, $msg);
+    }else{
+      $message = sprintf('%s %s', &now, $msg);
+    }
 
     my @tmp = split("\n", $channel_buffer{$channel});
     push @tmp, $message;
@@ -163,7 +172,7 @@ sub add_message{
     $mtime{$channel} = time;
 
     # unread lines
-    $unread{$channel} = @tmp2;
+    $unread{$channel} = scalar(@tmp2);
 
     if ($unread{$channel} > $config->web_lines) {
        $unread{$channel} = $config->web_lines;
@@ -266,11 +275,11 @@ sub render{
 
        $_ = &escape($_);
 
-       unless(s,(http://[!-;=-\177]+),<a href="$1">$1</a>,g){
-           unless(s|(www\.[!-\177]+)|<A HREF="http://$1">$1</A>|g){
+       unless(s,\b(https?://[!-;=-\177]+)\b,<a href="$1">$1</a>,g){
+           unless(s|\b(www\.[!-\177]+)\b|<a href="http://$1">$1</a>|g){
                # phone to
-               unless(s|(0\d{1,3}[-(]?\d{2,4}[-)]?\d{4})|<a href="tel:$1">$1</a>|g){
-                   s|(\w[\w.+=-]+\@[\w.-]+[\w])|<a href="mailto:$1">$1</a>|g;
+               unless(s|\b(0\d{1,3})([-(]?)(\d{2,4})([-)]?)(\d{4})\b|<a href="tel:$1$3$5">$1$2$3$4$5</a>|g){
+                   s|\b(\w[\w.+=-]+\@[\w.-]+[\w]\.[\w]{2,4})\b|<a href="mailto:$1">$1</a>|g;
                }
            }
        }