diff --git a/Sam.pl b/Sam.pl index f609ebd832be921dd376a7e497c85567c1d2d5af..c2aceeb8ac50efd21c2b40ab5889fd80749337d6 100755 --- a/Sam.pl +++ b/Sam.pl @@ -9,12 +9,11 @@ use JSON; use Module::Reload; use FindBin; -use lib "$FindBin::Bin/lib/"; -use Logging; -use commands::parser; -use sites::parser; +use Sam::Logging; +use Sam::commands::parser; +use Sam::sites::parser; -my $log = Logging->new('STDOUT', 1); +my $log = Sam::Logging->new('STDOUT', 1); # config my $serveur = 'IRC.iiens.net'; @@ -78,8 +77,8 @@ sub cycle sub setConf { - commands::parser::setConf($nick, $irc, $dbh, $log, \%lastID); - sites::parser::setConf($nick, $irc, $dbh, $log, \%lastID); + Sam::commands::parser::setConf($nick, $irc, $dbh, $log, \%lastID); + Sam::sites::parser::setConf($nick, $irc, $dbh, $log, \%lastID); } @@ -125,7 +124,7 @@ sub on_query my @args = ($kernel, $user, \@fake_chan, $msg); my $fake_chan = \@fake_chan; - return if (commands::parser::exec(@args)); + return if (Sam::commands::parser::exec(@args)); if ($msg =~ m/^!/ && $nick eq $admin) { my $commande = ( $msg =~ m/^!([^ ]*)/ )[0]; @@ -162,8 +161,8 @@ sub on_speak my ($nick,$mask) = split(/!/,$user); - commands::parser::exec(@args); - sites::parser::exec(@args); + Sam::commands::parser::exec(@args); + Sam::sites::parser::exec(@args); } # Boucle des events diff --git a/lib/Logging.pm b/Sam/Logging.pm similarity index 99% rename from lib/Logging.pm rename to Sam/Logging.pm index 6b7085bbfda620b556316df2384c1a529e868b98..e3d7cf174ba1db743ee72b608c4e46eaae7017c2 100644 --- a/lib/Logging.pm +++ b/Sam/Logging.pm @@ -1,4 +1,4 @@ -package Logging; +package Sam::Logging; # ==============[ Classe pour gérer les logs correctement ]============== # # Date : 29/10/2010 # diff --git a/lib/commands/add.pm b/Sam/commands/add.pm similarity index 95% rename from lib/commands/add.pm rename to Sam/commands/add.pm index 964dffc6fdc453c4ff8837959d0f20d7682c684e..922c1acfe1d4bab61a94942694481b6ff3e629ab 100644 --- a/lib/commands/add.pm +++ b/Sam/commands/add.pm @@ -1,4 +1,4 @@ -package commands::add; +package Sam::commands::add; require Exporter; our @ISA = qw(Exporter); diff --git a/lib/commands/addUser.pm b/Sam/commands/addUser.pm similarity index 97% rename from lib/commands/addUser.pm rename to Sam/commands/addUser.pm index 77a5eed9580bf5dcf00466d65a9770d1379d3757..acfa6e12f2313f8844c2c86eb236794e96965f0d 100644 --- a/lib/commands/addUser.pm +++ b/Sam/commands/addUser.pm @@ -1,4 +1,4 @@ -package commands::addUser; +package Sam::commands::addUser; require Exporter; our @ISA = qw(Exporter); diff --git a/lib/commands/edit.pm b/Sam/commands/edit.pm similarity index 97% rename from lib/commands/edit.pm rename to Sam/commands/edit.pm index 22e8729d1fba26ebdfac50a4447dee933ff8211c..97819404077d5b5824c326121b6de043e9847547 100644 --- a/lib/commands/edit.pm +++ b/Sam/commands/edit.pm @@ -1,4 +1,4 @@ -package commands::edit; +package Sam::Sam::commands::edit; require Exporter; our @ISA = qw(Exporter); diff --git a/lib/commands/getUsers.pm b/Sam/commands/getUsers.pm similarity index 97% rename from lib/commands/getUsers.pm rename to Sam/commands/getUsers.pm index 9d537cd0dc5831d6ff262f0518056216a4191a30..ac80daa27daf2af3a428d672a707c21e16d7a648 100644 --- a/lib/commands/getUsers.pm +++ b/Sam/commands/getUsers.pm @@ -1,4 +1,4 @@ -package commands::getUsers; +package Sam::commands::getUsers; our $dbh; our $log; diff --git a/lib/commands/list.pm b/Sam/commands/list.pm similarity index 98% rename from lib/commands/list.pm rename to Sam/commands/list.pm index 9d6a62db83b01e9da0db07172c58f012bcafe74c..a01826d889f5380a7d11b1f3d39821a50659e389 100644 --- a/lib/commands/list.pm +++ b/Sam/commands/list.pm @@ -1,4 +1,4 @@ -package commands::list; +package Sam::commands::list; require Exporter; our @ISA = qw(Exporter); diff --git a/lib/commands/parser.pm b/Sam/commands/parser.pm similarity index 79% rename from lib/commands/parser.pm rename to Sam/commands/parser.pm index 64dabdacd3d5a18e4531f8becd7454496ae7a1c5..a35257a7a7ca72a50a840930bc2ab2298e35ea5d 100644 --- a/lib/commands/parser.pm +++ b/Sam/commands/parser.pm @@ -1,4 +1,4 @@ -package commands::parser; +package Sam::commands::parser; require Exporter; our @ISA = qw(Exporter); @@ -6,12 +6,11 @@ our @EXPORT_OK = qw(exec); use strict; -use lib "$FindBin::Bin/lib/"; -use commands::add; -use commands::list; -use commands::addUser; -use commands::edit; -use commands::getUsers; +use Sam::commands::add; +use Sam::commands::list; +use Sam::commands::addUser; +use Sam::commands::edit; +use Sam::commands::getUsers; my $nick; my $irc; @@ -20,22 +19,22 @@ my $lastID; sub setConf { my ($nickNew, $ircNew, $dbh, $log, $lastIDnew) = @_; - $commands::add::dbh = $dbh; - $commands::list::dbh = $dbh; - $commands::addUser::dbh = $dbh; - $commands::edit::dbh = $dbh; - $commands::getUsers::dbh = $dbh; + $Sam::commands::add::dbh = $dbh; + $Sam::commands::list::dbh = $dbh; + $Sam::commands::addUser::dbh = $dbh; + $Sam::commands::edit::dbh = $dbh; + $Sam::commands::getUsers::dbh = $dbh; - $commands::add::log = $log; - $commands::list::log = $log; - $commands::addUser::log = $log; - $commands::edit::log = $log; - $commands::getUsers::log = $log; + $Sam::commands::add::log = $log; + $Sam::commands::list::log = $log; + $Sam::commands::addUser::log = $log; + $Sam::commands::edit::log = $log; + $Sam::commands::getUsers::log = $log; - $commands::list::irc = $ircNew; - $commands::addUser::irc = $ircNew; - $commands::edit::irc = $ircNew; - $commands::getUsers::irc = $ircNew; + $Sam::commands::list::irc = $ircNew; + $Sam::commands::addUser::irc = $ircNew; + $Sam::commands::edit::irc = $ircNew; + $Sam::commands::getUsers::irc = $ircNew; $nick = $nickNew; $irc = $ircNew; @@ -67,7 +66,7 @@ sub exec { $place =~ s/ $//; - my $id = commands::add::exec($title, $day, $month, $year, $place, $desc); + my $id = Sam::commands::add::exec($title, $day, $month, $year, $place, $desc); if ($id) { $lastID->{$chan->[0]} = $id; @@ -79,23 +78,23 @@ sub exec { my $command = $2; my $arg = $3; - commands::edit::exec($id, $command, $arg, $chan); + Sam::commands::edit::exec($id, $command, $arg, $chan); } elsif ($msg =~ /^Sam(?:,|:) +j'y +vais/) { - commands::addUser::exec($nick, $lastID->{$chan->[0]}, $chan); + Sam::commands::addUser::exec($nick, $lastID->{$chan->[0]}, $chan); } elsif ($msg =~ /^Sam(?:,|:) +je +vais +à +la +(\d+)/) { - commands::addUser::exec($nick, $1, $chan); + Sam::commands::addUser::exec($nick, $1, $chan); } elsif ($msg =~ /^Sam(?:,|:) +qui +va +à +la +(\d+) +?/) { - my $id = commands::getUsers::exec($chan->[0], $1); + my $id = Sam::commands::getUsers::exec($chan->[0], $1); if ($id) { $lastID->{$chan->[0]} = $id; } } elsif ($msg =~ /^Sam(?:,|:) +liste/) { - commands::list::exec($chan); + Sam::commands::list::exec($chan); } elsif ($msg =~ /^Sam(?:,|:) +(help|aide)/) { $irc->yield(privmsg => $nick => 'Sam: <titre de la soirée> le jj/mm/aa @ <salle/lieu> : <description>'); diff --git a/lib/sites/parser.pm b/Sam/sites/parser.pm similarity index 77% rename from lib/sites/parser.pm rename to Sam/sites/parser.pm index 442ed295b3e51f29b092edd66d4904b9c0437eba..579c7d78528a7683520aad1a77026a73ff9df129 100644 --- a/lib/sites/parser.pm +++ b/Sam/sites/parser.pm @@ -1,4 +1,4 @@ -package sites::parser; +package Sam::sites::parser; require Exporter; our @ISA = qw(Exporter); @@ -6,12 +6,10 @@ our @EXPORT_OK = qw(exec); use strict; -use lib "$FindBin::Bin/lib/"; -use commands::add; -use commands::edit; +use Sam::commands::add; +use Sam::commands::edit; -use lib "$FindBin::Bin/lib/sites"; -use residentadvisor; +use Sam::sites::residentadvisor; my $nick; my $irc; @@ -33,13 +31,13 @@ sub exec { my $id; if ($msg =~ /^Sam(?:,|:) +https?:\/\/(?:www.residentadvisor.net\/event.aspx\?)([0-9]+)/) { - eval { %content = residentadvisor::get($1) }; + eval { %content = Sam::sites::residentadvisor::get($1) }; } else { return 0; } - $id = commands::add::exec( + $id = Sam::commands::add::exec( $content{'title'}, $content{'day'}, $content{'month'}, @@ -57,7 +55,7 @@ sub exec { ); } - commands::edit::exec($id, 'url', $content{'url'}, $chan); + Sam::commands::edit::exec($id, 'url', $content{'url'}, $chan); return 1; } diff --git a/lib/sites/residentadvisor.pm b/Sam/sites/residentadvisor.pm similarity index 94% rename from lib/sites/residentadvisor.pm rename to Sam/sites/residentadvisor.pm index be868b78699ca49b7cdfda4b4f1df27856ce8d0a..0284d5a6815a2e4bac9cfa38fd21773e838fd34f 100644 --- a/lib/sites/residentadvisor.pm +++ b/Sam/sites/residentadvisor.pm @@ -1,4 +1,4 @@ -package residentadvisor; +package Sam::sites::residentadvisor; use Inline Python => 'DATA';