+#!/usr/bin/perl
#
# OnJoin.pl: emit a message when a user enters the channel
# Author: Corey Edwards <tensai@zmonkey.org>
-# Version: v0.2.2
+# Version: v0.3.1
# Created: 20051222
-# Updated: 20060105
+# Updated: 20060112
use strict;
# print the message, if there was one
if ($message){
- $message = substVars($message);
+ $message = substVars($message, 1);
if ($message =~ m/^<action>\s*(.*)/){
&status("OnJoin: $nick arrived, performing action");
&action($chan, $1);
my $nick = $3;
my $msg = $5;
- # get options
+ # get options
my $strict = &getChanConf('onjoinStrict');
my $ops = &getChanConf('onjoinOpsOnly');
# if msg not set, show what the message would be
if (!$msg){
$nick = $who if (!$nick);
- $msg = &sqlSelect('onjoin', 'message', { nick => $nick, channel => $ch } ) || '';
- if ($msg){
- &performReply($msg);
+ my %row = &sqlSelectRowHash('onjoin', 'message, modified_by, modified_time', { nick => $nick, channel => $ch } );
+ if ($row{'message'}){
+ &performStrictReply("onjoin for $nick set by $row{modified_by} on " . localtime($row{modified_time}) . ": $row{message}");
}
return;
}
# remove old one (if exists) and add new message
&sqlDelete('onjoin', { nick => $nick, channel => $ch });
- &sqlInsert('onjoin', { nick => $nick, channel => $ch, message => $msg });
- &performReply("ok");
+ my $insert = &sqlInsert('onjoin', { nick => $nick, channel => $ch, message => $msg, modified_by => $who, modified_time => time() });
+ if ($insert){
+ &performReply('ok');
+ }
+ else{
+ &performReply('whoops. database error');
+ }
return;
}