From b232bb5a3520c656ac825a33328ecca76f1dd0f6 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Tue, 4 Sep 2007 21:11:11 +0200 Subject: [PATCH] Add command name as argument and modify quote commands --- Misc.pm | 2 +- Quotes.pm | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Misc.pm b/Misc.pm index 926ad0a..37501f2 100644 --- 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; } } diff --git a/Quotes.pm b/Quotes.pm index 8451480..bebc9bb 100644 --- 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 ?} -- 2.39.2