]> ruin.nu Git - NDIRC.git/commitdiff
Add command name as argument and modify quote commands
authorMichael Andreen <harv@ruin.nu>
Tue, 4 Sep 2007 19:11:11 +0000 (21:11 +0200)
committerMichael Andreen <harv@ruin.nu>
Tue, 4 Sep 2007 19:11:11 +0000 (21:11 +0200)
Misc.pm
Quotes.pm

diff --git a/Misc.pm b/Misc.pm
index 926ad0adaa83a71b7b39ea7039e1b56465ae6cb3..37501f20d3944b5ef244e66ff24c1a0ca25dae15 100644 (file)
--- a/Misc.pm
+++ b/Misc.pm
@@ -72,7 +72,7 @@ sub parseCommand {
                        my $a = $commands{$c}->{acc};
                        my $b = (exists $channels{lc $channel} ? $channels{lc $channel} : ['all']);
                        if (intersect($a,$b) > 0){
-                               $commands{$c}->{fun}->($args);
+                               $commands{$c}->{fun}->($args,$c);
                                return 1;
                        }
                }
index 84514801af0a2667571765e7d19233be5a3b1157..bebc9bbcb0f3509bb765e6c7b51eb34a10454e0b 100644 (file)
--- a/Quotes.pm
+++ b/Quotes.pm
@@ -33,6 +33,12 @@ tie our @OLDFILE, 'Tie::File',"/home/ndawn/.eos/scripts/oldquotes.txt" or die "t
 
 sub quote {
        my ($n) = @_;
+       if (defined $n && $n =~ /(\d+)/){
+               $n = $1;
+       }else{
+               $n = undef;
+       }
+               
        $n = $n-1 if defined $n;
        $n = int(rand($#FILE)) unless defined $n;
        my $text = $FILE[$n];
@@ -44,6 +50,10 @@ sub quote {
 
 sub addQuote {
        my ($quote) = @_;
+       unless (defined $quote){
+               $ND::server->command("notice $ND::nick Usage: .addquote quote");
+               return;
+       }
        push @FILE, $quote;
        my $num = $#FILE+1;
        $ND::server->command("msg $ND::target Quote $ND::B$num$ND::B added");
@@ -56,9 +66,9 @@ sub lastQuote {
        $ND::server->command("msg $ND::target Quote $ND::B$n$ND::B of $ND::B$n:$ND::B $text");
 }
 sub findQuote {
-       my ($type,$pattern) = @_;
+       my ($pattern,$type) = @_;
        my $matcher;
-       if ($type eq 'qre'){
+       if ($type eq 'findqre'){
                if (defined (eval 'm/$pattern/ix')){
                        $matcher = 'm/$pattern/ix';
                }else {
@@ -92,6 +102,11 @@ sub findQuote {
 sub delQuote {
        my ($n) = @_;
        if (hc){
+               if ($n =~ /^(\d+)$/){
+               $n = $1;
+               }else{
+                       return
+               }
                $n = $n-1;
                if (exists $FILE[$n]){
                        my ($uid,$username) = $ND::DBH->selectrow_array(q{SELECT uid,username FROM users where hostmask ILIKE ?}