Added core command MODLOAD.
This commit is contained in:
1 parent
ff06548d72
commit
76571af1d3
3 files changed
+46
-1
No files matched your search
@@ -28,7 +28,7 @@ BEGIN {
|
||||
RSTAGE => 'd'
|
||||
};
|
||||
}
|
||||
use API::Std qw(conf_get err cmd_add cmd_del);
|
||||
use API::Std qw(conf_get err);
|
||||
use API::Log qw(println alog dbug);
|
||||
use DB::Flatfile;
|
||||
use Parser::Config;
|
||||
@@ -290,6 +290,8 @@ undef $it;
|
||||
|
||||
# Create core hooks.
|
||||
API::Std::hook_add("on_uprivmsg", "ctcp_version_reply", \&Core::IRC::version_reply);
|
||||
# Create core commands.
|
||||
API::Std::cmd_add("MODLOAD", 1, \%Core::IRC::SHELP_MODLOAD, \%Core::IRC::FHELP_MODLOAD, \&Core::IRC::cmd_modload);
|
||||
|
||||
# Infinite while loop.
|
||||
while (1) {
|
||||
|
||||
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
|
||||
|
||||
3.0 Indev
|
||||
==================================================================
|
||||
* Added core command MODLOAD.
|
||||
* Added Weather module.
|
||||
* Added Calc module.
|
||||
* Fixed the NAME,VER,SVER,REV,RSTAGE constants.
|
||||
|
||||
@@ -7,6 +7,7 @@ package Core::IRC;
|
||||
use strict;
|
||||
use warnings;
|
||||
use English;
|
||||
use API::Std qw(trans has_priv match_user);
|
||||
use API::IRC qw(notice usrc);
|
||||
|
||||
sub version_reply
|
||||
@@ -22,4 +23,45 @@ sub version_reply
|
||||
}
|
||||
|
||||
|
||||
# Help hashes for CMDLOAD. Spanish, French and German needed.
|
||||
our %SHELP_CMDLOAD = (
|
||||
'en' => 'Load a module.',
|
||||
);
|
||||
our %FHELP_CMDLOAD = (
|
||||
'en' => 'Loads a module into the running Auto live.',
|
||||
);
|
||||
# CMDLOAD callback.
|
||||
sub cmd_modload
|
||||
{
|
||||
my (%data) = @_;
|
||||
my @argv = @{ $data{args} };
|
||||
|
||||
# Check for the appropriate privilege.
|
||||
if (!has_priv(match_user(%data), "cfunc.modules")) {
|
||||
notice($data{svr}, $data{nick}, trans("Permission denied").".");
|
||||
return 0;
|
||||
}
|
||||
# Check for the needed parameters.
|
||||
if (!defined $argv[0]) {
|
||||
notice($data{svr}, $data{nick}, trans("Not enough parameters").".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
my $tn = Auto::mod_load($argv[0]);
|
||||
|
||||
# Check if we were successful or not.
|
||||
if ($tn) {
|
||||
# We were!
|
||||
notice($data{svr}, $data{nick}, "Module \002".$argv[0]."\002 successfully loaded.");
|
||||
}
|
||||
else {
|
||||
# We weren't.
|
||||
notice($data{svr}, $data{nick}, "Module \002".$argv[0]."\002 failed to load.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
Reference in new issue
Block a user