Added core command SHUTDOWN.

This commit is contained in:
Elijah Perrault committed 2011-02-01 23:48:14 -07:00
1 parent 99b75be85b
commit 4cb122df85
3 files changed
+37 -2

No files matched your search

+2 -1
View File
@@ -246,7 +246,7 @@ dbug "* Connecting to servers...";
# Get servers from config.
my %cservers = conf_get("server");
# Set the hashes and processes hashes.
my (%SOCKET, %SOCKETH, $SELECT);
our (%SOCKET, $SELECT);
$SELECT = IO::Select->new();
my $it = 0;
# Iterate through each configured server.
@@ -294,6 +294,7 @@ API::Std::hook_add("on_uprivmsg", "ctcp_version_reply", \&Core::IRC::version_rep
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);
API::Std::cmd_add("SHUTDOWN", 2, \%Core::IRC::SHELP_SHUTDOWN, \%Core::IRC::FHELP_SHUTDOWN, \&Core::IRC::cmd_shutdown);
# Infinite while loop.
while (1) {
+1
View File
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
3.0 Indev
==================================================================
* Added core command SHUTDOWN.
* Added core command MODRELOAD.
* Added core command MODUNLOAD.
* Added core command MODLOAD.
+34 -1
View File
@@ -8,7 +8,8 @@ use strict;
use warnings;
use English;
use API::Std qw(trans has_priv match_user);
use API::IRC qw(notice usrc);
use API::Log qw(dbug alog);
use API::IRC qw(notice quit usrc);
sub version_reply
{
@@ -166,5 +167,37 @@ sub cmd_modreload
return 1;
}
# Help hashes for SHUTDOWN. Spanish, French and German needed.
our %SHELP_SHUTDOWN = (
'en' => 'Shutdown Auto.',
);
our %FHELP_SHUTDOWN = (
'en' => 'This will send out shutdown notifications, quit all networks, flush the database then exit the program.',
);
# SHUTDOWN callback.
sub cmd_shutdown
{
my (%data) = @_;
# Check for the appropriate privilege.
if (!has_priv(match_user(%data), "cmd.shutdown")) {
notice($data{svr}, $data{nick}, trans("Permission denied").".");
return 0;
}
# Goodbye world!
notice($data{svr}, $data{nick}, "Shutting down.");
dbug "Got SHUTDOWN from ".$data{nick}."!".$data{user}."@".$data{host}."! Shutting down. . .";
alog "Got SHUTDOWN from ".$data{nick}."!".$data{user}."@".$data{host}."! Shutting down. . .";
quit($_, "SHUTDOWN from ".$data{nick}) foreach (keys %Auto::SOCKET);
sleep 1;
DB::flush();
sleep 1;
exit;
# To appease PerlCritic.
return 1;
}
1;