From 34db4ccc719f18ae605084de8aed1f5bfebe57cd Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@gmail.com> Date: Sun, 11 Aug 2013 13:23:04 +0200 Subject: [PATCH] Command !fav corrections - new arg $nick to exec() - better regex - remove useless $irc --- lib/commands/fav.pm | 5 +++-- lib/commands/parser.pm | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/commands/fav.pm b/lib/commands/fav.pm index c8639f4..278b425 100644 --- a/lib/commands/fav.pm +++ b/lib/commands/fav.pm @@ -4,11 +4,10 @@ require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(exec); -our $irc; our $dbh; sub exec { - my $id = shift; + my ($nick, $id) = @_; my $sth = $dbh->prepare_cached('SELECT user FROM playbot_codes WHERE nick = ?'); $sth->execute($nick) @@ -23,3 +22,5 @@ sub exec { or $log->error("Couldn't finish transaction: " . $dbh->errstr); } } + +1; diff --git a/lib/commands/parser.pm b/lib/commands/parser.pm index 70a2645..73d285b 100644 --- a/lib/commands/parser.pm +++ b/lib/commands/parser.pm @@ -19,10 +19,11 @@ sub exec { my ($kernel, $user, $chan, $msg) = @_; my ($nick,$mask) = split(/!/,$user); - if ($msg =~ /^!fav( ([0-9]+))?/) { - $commands::fav::irc = $irc; + if ($msg =~ /^!fav(?: ([0-9]+))?/) { + $id = ($1) ? $1 : $lastID; + $commands::fav::dbh = $dbh; - commands::fav::exec($2) + commands::fav::exec($nick, $id) } elsif ($msg =~ /^!later(?: ([0-9]+))?(?: in ([0-9]*)?(h|m|s)?)?/) { my $id = ($1) ? $1 : $lastID; -- GitLab