From 08db17fab80b8a771cb9484f0df2f2a3d4201c34 Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@gmail.com> Date: Mon, 19 Aug 2013 00:06:20 +0200 Subject: [PATCH] $commands::parser::lastID is now a hash ref --- PlayBot.pl | 17 ++++++++--------- lib/commands/parser.pm | 16 ++++++++-------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/PlayBot.pl b/PlayBot.pl index 7f270d8..5396f99 100755 --- a/PlayBot.pl +++ b/PlayBot.pl @@ -116,7 +116,6 @@ sub later $irc->yield(privmsg => $nick => $donnees[0]); $lastID{$nick} = $id; - $commands::parser::lastID{$nick} = $id; } } @@ -129,8 +128,13 @@ sub cycle Module::Reload->check; - commands::parser::setConf($irc, $dbh, $log); - %commands::parser::lastID = %lastID; + setConf(); +} + + +sub setConf +{ + commands::parser::setConf($irc, $dbh, $log, \%lastID); $sites::parser::dbh = $dbh; $sites::parser::irc = $irc; @@ -276,7 +280,6 @@ sub on_speak if ($id) { # if yes, we need to save the new content's id $lastID{$chan->[0]} = $id; - $commands::parser::lastID{$chan->[0]} = $id; # we insert the potiential tags commands::parser::tag($msg, $chan); @@ -285,11 +288,7 @@ sub on_speak } -commands::parser::setConf($irc, $dbh, $log); - -$sites::parser::dbh = $dbh; -$sites::parser::irc = $irc; -$sites::parser::log = $log; +setConf(); # Boucle des events $poe_kernel->run(); diff --git a/lib/commands/parser.pm b/lib/commands/parser.pm index 40c595f..adcbdb6 100644 --- a/lib/commands/parser.pm +++ b/lib/commands/parser.pm @@ -12,12 +12,11 @@ use commands::later; use commands::tag; use commands::get; -our %lastID; - +my $lastID; my $irc; sub setConf { - my ($ircNew, $dbh, $log) = @_; + my ($ircNew, $dbh, $log, $lastIDnew) = @_; $commands::fav::dbh = $dbh; $commands::tag::dbh = $dbh; @@ -32,6 +31,7 @@ sub setConf { $commands::get::irc = $ircNew; $irc = $ircNew; + $lastID = $lastIDnew; } sub exec { @@ -39,12 +39,12 @@ sub exec { my ($nick, $mask) = split(/!/,$user); if ($msg =~ /^ *!fav(?: ([0-9]+))?/) { - my $id = ($1) ? $1 : $lastID{$chan->[0]}; + my $id = ($1) ? $1 : $lastID->{$chan->[0]}; commands::fav::exec($nick, $id) } elsif ($msg =~ /^ *!later(?: ([0-9]+))?(?: in ([0-9]*)?(h|m|s)?)?/) { - my $id = ($1) ? $1 : $lastID{$chan->[0]}; + my $id = ($1) ? $1 : $lastID->{$chan->[0]}; my ($time, $unit) = ($2, $3); commands::later::exec($kernel, $nick, $id, $time, $unit); @@ -56,7 +56,7 @@ sub exec { $msg = substr $msg, (length $1) + (length $2) + (length $id); } else { - $id = $lastID{$chan->[0]}; + $id = $lastID->{$chan->[0]}; $msg = substr $msg, (length $1) + (length $2); } @@ -68,7 +68,7 @@ sub exec { my $id = commands::get::exec(@args); if ($id) { - $lastID{$chan->[0]} = $id; + $lastID->{$chan->[0]} = $id; } } elsif ($msg =~ /^ *!help/) { @@ -90,7 +90,7 @@ sub tag { my ($msg, $chan) = @_; my @tags = ($msg =~ /#([a-zA-Z0-9_-]+)/g); - commands::tag::exec($lastID{$chan->[0]}, "@tags"); + commands::tag::exec($lastID->{$chan->[0]}, "@tags"); } 1; -- GitLab