}
-# reread_config()
-#
-# reread configuration & execute changes
-#
-# parameter:
-# none
-# return:
-# none
-sub reread_config {
-die("FIXME: implement me! reread_config()\n");
- print_msg('Rereading config');
- if (length(config_get_key('IRCBotCommandChannel')) > 0) {
- write_to_channel(config_get_key('IRCBotCommandChannel'), "reread config");
- }
-
- # remember old channel list
- my $irc_channels = config_get_key('IRCChannels');
- print_msg("Old channel list: $irc_channels", DEBUG);
- my @old_irc_channels = split(/,[\s\t]*/, $irc_channels);
-
- # remember old nickname list
- my $nick_names = config_get_key('IRCNick');
- print_msg("Old nickname list: $nick_names", DEBUG);
- my @old_nicknames = split(/,[\s\t]*/, $nick_names);
-
-
- my $old_max_channels = config_get_key('IRCMaxChannels');
- my $old_max_sessions = config_get_key('IRCMaxSessions');
- my $old_bot_command_channel = config_get_key('IRCBotCommandChannel');
- my $old_irc_server = config_get_key('IRCServer');
- my $old_irc_name = config_get_key('IRCName');
- my $old_irc_pass = config_get_key('IRCPass');
-
-
-
- # drop old configuration and reread config
- $main::config->empty_config();
- read_config($main::config->config_file());
-
-
- # read new channel list
- $irc_channels = config_get_key('IRCChannels');
- print_msg("New channel list: $irc_channels", DEBUG);
- my @new_irc_channels = split(/,[\s\t]*/, $irc_channels);
-
- # read new nickname list
- $nick_names = config_get_key('IRCNick');
- print_msg("New nickname list: $nick_names", DEBUG);
- my @new_nicknames = split(/,[\s\t]*/, $nick_names);
-
-
- # pre-checks
- my $new_max_channels = config_get_key('IRCMaxChannels');
- my $new_max_sessions = config_get_key('IRCMaxSessions');
- my $new_bot_command_channel = config_get_key('IRCBotCommandChannel');
- my $new_irc_server = config_get_key('IRCServer');
- my $new_irc_name = config_get_key('IRCName');
- my $new_irc_pass = config_get_key('IRCPass');
-
- if ($old_max_channels != $new_max_channels) {
- print_msg("'IRCMaxChannels' can't be changed during reload, restart is required", ERROR);
- if ($old_max_channels > $new_max_channels) {
- death();
- }
- }
- if ($old_max_sessions != $new_max_sessions) {
- print_msg("'IRCMaxSessions' can't be changed during reload, restart is required", ERROR);
- if ($old_max_sessions > $new_max_sessions) {
- death();
- }
- }
- if ($old_bot_command_channel ne $new_bot_command_channel) {
- print_msg("'IRCBotCommandChannel' can't be changed during reload, restart is required", ERROR);
- death();
- }
- if ($old_irc_server ne $new_irc_server) {
- print_msg("'IRCServer' can't be changed during reload, restart is required", ERROR);
- }
- if ($old_irc_name ne $new_irc_name) {
- print_msg("'IRCName' can't be changed during reload, restart is required", ERROR);
- }
- if ($old_irc_pass ne $new_irc_pass) {
- print_msg("'IRCPass' can't be changed during reload, restart is required", ERROR);
- }
-
- if (($#new_irc_channels + 1) > (config_get_key('IRCMaxSessions') * config_get_key('IRCMaxChannels'))) {
- print_msg("Too many configured channels (channels > sessions * number channels per session)", ERROR);
- death();
- }
- if (($#new_nicknames + 1) != config_get_key('IRCMaxSessions')) {
- print_msg("You must provide a nick name for each possible session!", ERROR);
- death();
- }
-
-
- # find new channels
- foreach my $channel (@new_irc_channels) {
- if (!grep {lc($_) eq lc($channel)} @old_irc_channels) {
- print_msg("join new channel: $channel", INFO);
- channel_join($channel);
- }
- }
-
- # part old channels
- foreach my $channel (@old_irc_channels) {
- if (!grep {lc($_) eq lc($channel)} @new_irc_channels) {
- print_msg("part old channel: $channel", INFO);
- channel_part($channel);
- }
- }
-
-
- # verify nicknames per session
- for (my $i = 1; $i <= config_get_key('IRCMaxSessions'); $i++) {
- if ($new_nicknames[$i - 1] ne $main::sessions{$i}{'nick_name'}) {
- print_msg("session $i changes nick from '" . $main::sessions{$i}{'nick_name'} . "' to '" . $new_nicknames[$i - 1] . "'", INFO);
- nick_change($i, $new_nicknames[$i - 1]);
- }
- }
-
-
-
- # FIXME: reopen database connection?
-
-}
-
-
# print_msg()
#
# print out a message on stderr
}
-sub channel_join {
- my $channel = shift;
-
- print_msg("join channel: $channel", DEBUG);
-}
-
-
-sub channel_part {
- my $channel = shift;
-
- print_msg("part channel: $channel", DEBUG);
-}
-
-
-sub nick_change {
-
-}
-
-
# find_irc_session()
#
# find an IRC session in the internal state
push(@commands, 'lost: ' . $main::statistics{'command_counter_lost'});
push(@commands, 'url: ' . $main::statistics{'command_counter_url'});
push(@commands, 'key: ' . $main::statistics{'command_counter_key'});
+ # don't bother to add 'quit' statistic here
$irc->yield( privmsg => $channel, 'Number of executed IRC commands: ' . join(", ", @commands) );
$irc->yield( privmsg => $channel, 'Number of denied IRC requests: ' . $main::statistics{'command_access_denied'} );
}
-
-
-
# on_whois_identified()
#
# parse whois lines