#!/usr/bin/perl
# keitairc
-# $Id: keitairc,v 1.16 2004-03-23 16:12:56 ishikawa Exp $
+# $Id: keitairc,v 1.20 2004-06-07 01: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.16 2004-03-23 16:12:56 ishikawa Exp $;
+my $rcsid = q$Id: keitairc,v 1.20 2004-06-07 01:27:57 morimoto Exp $;
my ($version) = $rcsid =~ m#,v ([0-9.]+)#;
use strict;
qw(irc_nick irc_username irc_desc
irc_server irc_port irc_password
web_port web_title web_lines web_root
- web_username web_password)
+ web_username web_password show_newmsgonly)
);
$config->file('/etc/keitairc');
################################################################
sub on_irc_join{
my ($kernel, $who, $channel) = @_[KERNEL, ARG0, ARG1];
+ $who =~ s/!.*//;
+
+ # chop off after the gap (bug workaround of madoka)
+ $channel =~ 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;
}
}
}
$content .= '<a accesskey="7" href="#1"></a>';
$content .= sprintf('<form action="%s%s" method="post">',
- $docroot, $uri);
+ $docroot, uri_escape($channel));
$content .= '<input type="text" name="m" size="10">';
$content .= '<input type="submit" accesskey="1" value="OK[1]">';
$content .= qq(<a accesskey="8" href="$docroot">back[8]</a><br>);
if(defined($channel_buffer{$channel}) &&
length($channel_buffer{$channel})){
$content .= '<a accesskey="9" href="#2"></a>';
- if (($update_chk eq 1)||($send_chk eq 1)) {
+ if ((($update_chk eq 1)||((defined $config->show_newmsgonly) && ($send_chk eq 1)))) {
$content .= &render($channel_recent{$channel});
$content .= sprintf('<a accesskey="5" href="%s%s">
..more[5]</a>', $docroot, uri_escape($channel));