diff --git a/PlayBot.pl b/PlayBot.pl index d37ec2ba2b7806efc4ff68903d7ecd988195eb5d..74339346b694bd84f7862663ae6e1184719eb6cd 100755 --- a/PlayBot.pl +++ b/PlayBot.pl @@ -59,8 +59,7 @@ my $dbh = DBI->connect('DBI:mysql:'.$conf->{'bdd'}.';host='.$conf->{'host'}, $co }) or die("Couldn't connect to database: ".DBI->errstr); -$commands::parser::irc = $irc; -$commands::parser::dbh = $dbh; +$commands::parser::setConf($irc, $dbh); # Evenements que le bot va gérer POE::Session->create( @@ -141,8 +140,7 @@ sub cycle Module::Refresh->refresh; - $commands::parser::irc = $irc; - $commands::parser::dbh = $dbh; + $commands::parser::setConf($irc, $dbh); $commands::parser::lastID = $lastID; } diff --git a/lib/commands/parser.pm b/lib/commands/parser.pm index 73d285b2884d813d1ed69a50c83a435f52041697..f1709761c25905d0969ecd4e2bba35b5653f8c2c 100644 --- a/lib/commands/parser.pm +++ b/lib/commands/parser.pm @@ -7,14 +7,21 @@ our @EXPORT_OK = qw(exec); use lib "$FindBin::Bin/lib/"; use commands::fav; use commands::later; -#use later; -#use tag; -#use help; +use commands::tag; -our $irc; -our $dbh; our $lastID; +my $irc; + +sub setConf { + my ($ircNew, $dbh) = @_; + + $commands::fav::dbh = $dbh; + $commands::tag::dbh = $dbh; + + $irc = $ircNew; +} + sub exec { my ($kernel, $user, $chan, $msg) = @_; my ($nick,$mask) = split(/!/,$user); @@ -29,7 +36,7 @@ sub exec { my $id = ($1) ? $1 : $lastID; my ($time, $unit) = ($2, $3); - commands::later::exec ($id, $time, $unit); + commands::later::exec($id, $time, $unit); } elsif ($msg =~ /^!tag( +([0-9]+))?/) { my $id = ($2) ? $2 : $lastID;