]> git.donarmstrong.com Git - infobot.git/blobdiff - blootbot/src/Modules/OnJoin.pl
* Moved old /trunk/www out of trunk
[infobot.git] / blootbot / src / Modules / OnJoin.pl
index 60ca2d0a1f2a3b37f0451f48c7366cff7257402e..74ca9d8de9c2b9ee719a1e15549623ac1aa1c189 100644 (file)
@@ -1,9 +1,10 @@
+#!/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;
 
@@ -24,7 +25,7 @@ sub onjoin {
 
        # 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);
@@ -47,7 +48,7 @@ sub Cmdonjoin {
        my $nick = $3;
        my $msg = $5;
 
-       # get options 
+       # get options
        my $strict = &getChanConf('onjoinStrict');
        my $ops = &getChanConf('onjoinOpsOnly');
 
@@ -83,9 +84,9 @@ sub Cmdonjoin {
        # 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;
        }
@@ -108,8 +109,13 @@ sub Cmdonjoin {
 
        # 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;
 }