Added core commands MODUNLOAD and MODRELOAD. And fixed some typos.
This commit is contained in:
1 parent
f50df43fbe
commit
3b95067bf6
3 files changed
+104
-4
No files matched your search
@@ -292,6 +292,8 @@ undef $it;
|
|||||||
API::Std::hook_add("on_uprivmsg", "ctcp_version_reply", \&Core::IRC::version_reply);
|
API::Std::hook_add("on_uprivmsg", "ctcp_version_reply", \&Core::IRC::version_reply);
|
||||||
# Create core commands.
|
# Create core commands.
|
||||||
API::Std::cmd_add("MODLOAD", 1, \%Core::IRC::SHELP_MODLOAD, \%Core::IRC::FHELP_MODLOAD, \&Core::IRC::cmd_modload);
|
API::Std::cmd_add("MODLOAD", 1, \%Core::IRC::SHELP_MODLOAD, \%Core::IRC::FHELP_MODLOAD, \&Core::IRC::cmd_modload);
|
||||||
|
API::Std::cmd_add("MODUNLOAD", 1, \%Core::IRC::SHELP_MODUNLOAD, \%Core::IRC::FHELP_MODUNLOAD, \&Core::IRC::cmd_modunload);
|
||||||
|
API::Std::cmd_add("MODRELOAD", 1, \%Core::IRC::SHELP_MODRELOAD, \%Core::IRC::FHELP_MODRELOAD, \&Core::IRC::cmd_modreload);
|
||||||
|
|
||||||
# Infinite while loop.
|
# Infinite while loop.
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ Auto IRC Bot 3.0: Change Log
|
|||||||
|
|
||||||
3.0 Indev
|
3.0 Indev
|
||||||
==================================================================
|
==================================================================
|
||||||
|
* Added core command MODRELOAD.
|
||||||
|
* Added core command MODUNLOAD.
|
||||||
* Added core command MODLOAD.
|
* Added core command MODLOAD.
|
||||||
* Added Weather module.
|
* Added Weather module.
|
||||||
* Added Calc module.
|
* Added Calc module.
|
||||||
|
|||||||
+100
-4
@@ -23,14 +23,14 @@ sub version_reply
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Help hashes for CMDLOAD. Spanish, French and German needed.
|
# Help hashes for MODLOAD. Spanish, French and German needed.
|
||||||
our %SHELP_CMDLOAD = (
|
our %SHELP_MODLOAD = (
|
||||||
'en' => 'Load a module.',
|
'en' => 'Load a module.',
|
||||||
);
|
);
|
||||||
our %FHELP_CMDLOAD = (
|
our %FHELP_MODLOAD = (
|
||||||
'en' => 'Loads a module into the running Auto live.',
|
'en' => 'Loads a module into the running Auto live.',
|
||||||
);
|
);
|
||||||
# CMDLOAD callback.
|
# MODLOAD callback.
|
||||||
sub cmd_modload
|
sub cmd_modload
|
||||||
{
|
{
|
||||||
my (%data) = @_;
|
my (%data) = @_;
|
||||||
@@ -70,5 +70,101 @@ sub cmd_modload
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Help hashes for MODUNLOAD. Spanish, French and German needed.
|
||||||
|
our %SHELP_MODUNLOAD = (
|
||||||
|
'en' => 'Unload a module.',
|
||||||
|
);
|
||||||
|
our %FHELP_MODUNLOAD = (
|
||||||
|
'en' => 'Unloads a module from the running Auto live.',
|
||||||
|
);
|
||||||
|
# MODUNLOAD callback.
|
||||||
|
sub cmd_modunload
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the module exists.
|
||||||
|
if (!API::Std::mod_exists($argv[0])) {
|
||||||
|
notice($data{svr}, $data{nick}, "Module \002".$argv[0]."\002 is not loaded.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Go for it!
|
||||||
|
my $tn = API::Std::mod_void($argv[0]);
|
||||||
|
|
||||||
|
# Check if we were successful or not.
|
||||||
|
if ($tn) {
|
||||||
|
# We were!
|
||||||
|
notice($data{svr}, $data{nick}, "Module \002".$argv[0]."\002 successfully unloaded.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# We weren't.
|
||||||
|
notice($data{svr}, $data{nick}, "Module \002".$argv[0]."\002 failed to unload.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Help hashes for MODRELOAD. Spanish, French and German needed.
|
||||||
|
our %SHELP_MODRELOAD = (
|
||||||
|
'en' => 'Reload a module.',
|
||||||
|
);
|
||||||
|
our %FHELP_MODRELOAD = (
|
||||||
|
'en' => 'Unloads then loads a module into the running Auto live.',
|
||||||
|
);
|
||||||
|
# MODRELOAD callback.
|
||||||
|
sub cmd_modreload
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the module exists.
|
||||||
|
if (!API::Std::mod_exists($argv[0])) {
|
||||||
|
notice($data{svr}, $data{nick}, "Module \002".$argv[0]."\002 is not loaded.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Go for it!
|
||||||
|
my ($tvn, $tln) = (0, 0);
|
||||||
|
$tvn = API::Std::mod_void($argv[0]);
|
||||||
|
$tln = Auto::mod_load($argv[0]) if $tvn;
|
||||||
|
|
||||||
|
# Check if we were successful or not.
|
||||||
|
if ($tvn and $tln) {
|
||||||
|
# We were!
|
||||||
|
notice($data{svr}, $data{nick}, "Module \002".$argv[0]."\002 successfully reloaded.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# We weren't.
|
||||||
|
notice($data{svr}, $data{nick}, "Module \002".$argv[0]."\002 failed to reload.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
Reference in new issue
Block a user