use POSIX ":sys_wait_h";
use Scalar::Util 'refaddr';
use YAML::XS qw (/./);
-use Switch;
use URI::Escape;
+use feature qw/switch/;
import docbot::config;
import docbot::db;
my $channel = shift;
- switch ($command) {
- case('search') {
+ given ($command) {
+ when('search') {
$main::statistics{'command_counter_search'}++;
return handle_command_search($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('help') {
+ when('help') {
$main::statistics{'command_counter_help'}++;
return handle_command_help($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('info') {
+ when('info') {
$main::statistics{'command_counter_info'}++;
}
- case('learn') {
+ when('learn') {
$main::statistics{'command_counter_learn'}++;
return handle_command_learn($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('forget') {
+ when('forget') {
$main::statistics{'command_counter_forget'}++;
return handle_command_forget($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('config') {
+ when('config') {
$main::statistics{'command_counter_config'}++;
}
- case('status') {
+ when('status') {
$main::statistics{'command_counter_status'}++;
return handle_command_status($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('wallchan') {
+ when('wallchan') {
$main::statistics{'command_counter_wallchan'}++;
return handle_command_wallchan($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('say') {
+ when('say') {
return handle_command_say($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('join') {
+ when('join') {
return handle_command_join($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('leave') {
+ when('leave') {
return handle_command_leave($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('lost') {
+ when('lost') {
$main::statistics{'command_counter_lost'}++;
return handle_command_lost($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('url') {
+ when('url') {
return handle_command_url($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
- case('key') {
+ when('key') {
return handle_command_key($command, $string, $mode, $kernel, $heap, $who, $nick, $where, $msg, $sender, $irc, $channel);
}
}
my $irc = $sender->get_heap();
my $session = find_irc_session($irc);
- switch ($who) {
- case(/^NickServ/) {}
- case(/^ChanServ/) {}
- case(/\.freenode\.net/i) {}
- else {
+ given ($who) {
+ when(/^NickServ/) {}
+ when(/^ChanServ/) {}
+ when(/\.freenode\.net/i) {}
+ default {
# send to commandchannel
my $text = 'irc notice on session ' . $irc->nick_name() . ' from: ' . $nick;
send_to_commandchannel($text);
my $print_it = 1;
- switch ($event) {
- case('autoping') { $print_it = 0; }
- case('irc_ping') { $print_it = 0; }
- case('irc_pong') { $print_it = 0; }
- case('irc_connected') { $print_it = 0; }
- case('irc_snotice') { $print_it = 0; }
- case('irc_whois') { $print_it = 0; }
- case('irc_mode') { $print_it = 0; }
- case('irc_topic') { $print_it = 0; }
- case('irc_ctcp_action') { $print_it = 0; }
- case('irc_ctcp') { $print_it = 0; }
- case('irc_isupport') { $print_it = 0; }
- case('irc_nick') { $print_it = 0; }
- case('autoping') { $print_it = 0; }
- case('irc_disconnected') { $print_it = 0; }
- case('irc_socketerr') { $print_it = 0; }
- case('irc_cap') { $print_it = 0; }
- case('irc_notice') {
+ given ($event) {
+ when('autoping') { $print_it = 0; }
+ when('irc_ping') { $print_it = 0; }
+ when('irc_pong') { $print_it = 0; }
+ when('irc_connected') { $print_it = 0; }
+ when('irc_snotice') { $print_it = 0; }
+ when('irc_whois') { $print_it = 0; }
+ when('irc_mode') { $print_it = 0; }
+ when('irc_topic') { $print_it = 0; }
+ when('irc_ctcp_action') { $print_it = 0; }
+ when('irc_ctcp') { $print_it = 0; }
+ when('irc_isupport') { $print_it = 0; }
+ when('irc_nick') { $print_it = 0; }
+ when('autoping') { $print_it = 0; }
+ when('irc_disconnected') { $print_it = 0; }
+ when('irc_socketerr') { $print_it = 0; }
+ when('irc_cap') { $print_it = 0; }
+ when('irc_notice') {
if (@$args[0] =~ /^NickServ/) { $print_it = 0; }
if (@$args[0] =~ /^ChanServ/) { $print_it = 0; }
if (@$args[0] =~ /\.freenode\.net/i) { $print_it = 0; }
}
- case('irc_ctcp_version') {
+ when('irc_ctcp_version') {
if (@$args[0] =~ /^freenode\-connect/) { $print_it = 0; }
}
- case(/^irc_\d+/) { $print_it = 0; }
+ when(/^irc_\d+/) { $print_it = 0; }
}
#$print_it = 1;