#!/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
# 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;
################################################################
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");
+ }
}
################################################################
if ($who eq $config->irc_nick) {
delete $channel_name{$channel};
} else {
- &add_message($channel, 'SYSOP', $who . ' leaves');
+ &add_message($channel, undef, "$who leaves");
}
}
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;
$mtime{$channel} = time;
# unread lines
- $unread{$channel} = @tmp2;
+ $unread{$channel} = scalar(@tmp2);
if ($unread{$channel} > $config->web_lines) {
$unread{$channel} = $config->web_lines;
$_ = &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;
}
}
}