mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 11:12:42 +01:00
Minor whitespace syntax clean-up throughout
This commit is contained in:
parent
00618c5502
commit
925a5e57bd
@ -28,7 +28,7 @@ use Text::CSV;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -236,11 +236,11 @@ sub whitelist {
|
||||
my ($channel, $mask) = $self->{pbot}->{interpreter}->split_args($arglist, 2);
|
||||
return "Usage: whitelist remove <channel> <mask>" if not defined $channel or not defined $mask;
|
||||
|
||||
if(not defined $self->{whitelist}->hash->{$channel}) {
|
||||
if (not defined $self->{whitelist}->hash->{$channel}) {
|
||||
return "No whitelists for channel $channel";
|
||||
}
|
||||
|
||||
if(not defined $self->{whitelist}->hash->{$channel}->{$mask}) {
|
||||
if (not defined $self->{whitelist}->hash->{$channel}->{$mask}) {
|
||||
return "No such whitelist $mask for channel $channel";
|
||||
}
|
||||
|
||||
@ -262,29 +262,29 @@ sub update_join_watch {
|
||||
|
||||
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($account, $channel, 'join_watch');
|
||||
|
||||
if($mode == $self->{pbot}->{messagehistory}->{MSG_JOIN}) {
|
||||
if ($mode == $self->{pbot}->{messagehistory}->{MSG_JOIN}) {
|
||||
$channel_data->{join_watch}++;
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
} elsif($mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) {
|
||||
} elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) {
|
||||
# PART or QUIT
|
||||
# check QUIT message for netsplits, and decrement joinwatch to allow a free rejoin
|
||||
if($text =~ /^QUIT .*\.net .*\.split/) {
|
||||
if($channel_data->{join_watch} > 0) {
|
||||
if ($text =~ /^QUIT .*\.net .*\.split/) {
|
||||
if ($channel_data->{join_watch} > 0) {
|
||||
$channel_data->{join_watch}--;
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
}
|
||||
}
|
||||
# check QUIT message for Ping timeout or Excess Flood
|
||||
elsif($text =~ /^QUIT Excess Flood/ or $text =~ /^QUIT Max SendQ exceeded/ or $text =~ /^QUIT Ping timeout/) {
|
||||
elsif ($text =~ /^QUIT Excess Flood/ or $text =~ /^QUIT Max SendQ exceeded/ or $text =~ /^QUIT Ping timeout/) {
|
||||
# treat these as an extra join so they're snagged more quickly since these usually will keep flooding
|
||||
$channel_data->{join_watch}++;
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
} else {
|
||||
# some other type of QUIT or PART
|
||||
}
|
||||
} elsif($mode == $self->{pbot}->{messagehistory}->{MSG_CHAT}) {
|
||||
} elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_CHAT}) {
|
||||
# reset joinwatch if they send a message
|
||||
if($channel_data->{join_watch} > 0) {
|
||||
if ($channel_data->{join_watch} > 0) {
|
||||
$channel_data->{join_watch} = 0;
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
}
|
||||
@ -329,7 +329,7 @@ sub check_flood {
|
||||
|
||||
$self->{pbot}->{messagehistory}->{database}->update_hostmask_data($mask, { last_seen => scalar gettimeofday });
|
||||
|
||||
if($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}) {
|
||||
if ($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}) {
|
||||
$self->{pbot}->{logger}->log(sprintf("%-18s | %-65s | %s\n", "NICKCHANGE", $mask, $text));
|
||||
|
||||
my ($newnick) = $text =~ m/NICKCHANGE (.*)/;
|
||||
@ -341,7 +341,7 @@ sub check_flood {
|
||||
}
|
||||
|
||||
# do not do flood processing for bot messages
|
||||
if($nick eq $self->{pbot}->{registry}->get_value('irc', 'botnick')) {
|
||||
if ($nick eq $self->{pbot}->{registry}->get_value('irc', 'botnick')) {
|
||||
$self->{channels}->{$channel}->{last_spoken_nick} = $nick;
|
||||
return;
|
||||
}
|
||||
@ -362,7 +362,7 @@ sub check_flood {
|
||||
# handle QUIT events
|
||||
# (these events come from $channel nick!user@host, not a specific channel or nick,
|
||||
# so they need to be dispatched to all channels the nick has been seen on)
|
||||
if($mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE} and $text =~ /^QUIT/) {
|
||||
if ($mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE} and $text =~ /^QUIT/) {
|
||||
my $channels = $self->{pbot}->{nicklist}->get_channels($nick);
|
||||
foreach my $chan (@$channels) {
|
||||
next if $chan !~ m/^#/;
|
||||
@ -382,7 +382,7 @@ sub check_flood {
|
||||
|
||||
my $channels;
|
||||
|
||||
if($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}) {
|
||||
if ($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}) {
|
||||
$channels = $self->{pbot}->{nicklist}->get_channels($oldnick);
|
||||
} else {
|
||||
$self->update_join_watch($account, $channel, $text, $mode);
|
||||
@ -394,31 +394,31 @@ sub check_flood {
|
||||
# do not do flood processing if channel is not in bot's channel list or bot is not set as chanop for the channel
|
||||
next if $channel =~ /^#/ and not $self->{pbot}->{chanops}->can_gain_ops($channel);
|
||||
|
||||
if($channel =~ /^#/ and $mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) {
|
||||
if ($channel =~ /^#/ and $mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) {
|
||||
# remove validation on PART or KICK so we check for ban-evasion when user returns at a later time
|
||||
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($account, $channel, 'validated');
|
||||
if($channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {
|
||||
if ($channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {
|
||||
$channel_data->{validated} &= ~$self->{NICKSERV_VALIDATED};
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
if($self->whitelisted($channel, "$nick!$user\@$host", 'antiflood')) {
|
||||
if ($self->whitelisted($channel, "$nick!$user\@$host", 'antiflood')) {
|
||||
next;
|
||||
}
|
||||
|
||||
if($max_messages > $self->{pbot}->{registry}->get_value('messagehistory', 'max_messages')) {
|
||||
if ($max_messages > $self->{pbot}->{registry}->get_value('messagehistory', 'max_messages')) {
|
||||
$self->{pbot}->{logger}->log("Warning: max_messages greater than max_messages limit; truncating.\n");
|
||||
$max_messages = $self->{pbot}->{registry}->get_value('messagehistory', 'max_messages');
|
||||
}
|
||||
|
||||
# check for ban evasion if channel begins with # (not private message) and hasn't yet been validated against ban evasion
|
||||
if($channel =~ m/^#/) {
|
||||
if ($channel =~ m/^#/) {
|
||||
my $validated = $self->{pbot}->{messagehistory}->{database}->get_channel_data($account, $channel, 'validated')->{'validated'};
|
||||
|
||||
if ($validated & $self->{NEEDS_CHECKBAN} or not $validated & $self->{NICKSERV_VALIDATED}) {
|
||||
if($mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) {
|
||||
if ($mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) {
|
||||
# don't check for evasion on PART/KICK
|
||||
} elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}) {
|
||||
if (not exists $self->{whois_pending}->{$nick}) {
|
||||
@ -444,7 +444,7 @@ sub check_flood {
|
||||
}
|
||||
|
||||
# do not do flood enforcement for this event if bot is lagging
|
||||
if($self->{pbot}->{lagchecker}->lagging) {
|
||||
if ($self->{pbot}->{lagchecker}->lagging) {
|
||||
$self->{pbot}->{logger}->log("Disregarding enforcement of anti-flood due to lag: " . $self->{pbot}->{lagchecker}->lagstring . "\n");
|
||||
$self->{channels}->{$channel}->{last_spoken_nick} = $nick;
|
||||
return;
|
||||
@ -463,20 +463,20 @@ sub check_flood {
|
||||
}
|
||||
|
||||
# check for chat/join/private message flooding
|
||||
if($max_messages > 0 and $self->{pbot}->{messagehistory}->{database}->get_max_messages($account, $channel, $mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE} ? $nick : undef) >= $max_messages) {
|
||||
if ($max_messages > 0 and $self->{pbot}->{messagehistory}->{database}->get_max_messages($account, $channel, $mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE} ? $nick : undef) >= $max_messages) {
|
||||
my $msg;
|
||||
if($mode == $self->{pbot}->{messagehistory}->{MSG_CHAT}) {
|
||||
if ($mode == $self->{pbot}->{messagehistory}->{MSG_CHAT}) {
|
||||
$msg = $self->{pbot}->{messagehistory}->{database}->recall_message_by_count($account, $channel, $max_messages - 1)
|
||||
}
|
||||
elsif($mode == $self->{pbot}->{messagehistory}->{MSG_JOIN}) {
|
||||
elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_JOIN}) {
|
||||
my $joins = $self->{pbot}->{messagehistory}->{database}->get_recent_messages($account, $channel, $max_messages, $self->{pbot}->{messagehistory}->{MSG_JOIN});
|
||||
$msg = $joins->[0];
|
||||
}
|
||||
elsif($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}) {
|
||||
elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}) {
|
||||
my $nickchanges = $self->{pbot}->{messagehistory}->{database}->get_recent_messages($ancestor, $channel, $max_messages, $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}, $nick);
|
||||
$msg = $nickchanges->[0];
|
||||
}
|
||||
elsif($mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) {
|
||||
elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) {
|
||||
# no flood checks to be done for departure events
|
||||
next;
|
||||
}
|
||||
@ -493,14 +493,14 @@ sub check_flood {
|
||||
}
|
||||
|
||||
if ($last->{timestamp} - $msg->{timestamp} <= $max_time) {
|
||||
if($mode == $self->{pbot}->{messagehistory}->{MSG_JOIN}) {
|
||||
if ($mode == $self->{pbot}->{messagehistory}->{MSG_JOIN}) {
|
||||
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($account, $channel, 'offenses', 'last_offense', 'join_watch');
|
||||
#$self->{pbot}->{logger}->log("$account offenses $channel_data->{offenses}, join watch $channel_data->{join_watch}, max messages $max_messages\n");
|
||||
if($channel_data->{join_watch} >= $max_messages) {
|
||||
if ($channel_data->{join_watch} >= $max_messages) {
|
||||
$channel_data->{offenses}++;
|
||||
$channel_data->{last_offense} = gettimeofday;
|
||||
|
||||
if($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
if ($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
my $timeout = $self->{pbot}->{registry}->get_array_value('antiflood', 'join_flood_punishment', $channel_data->{offenses} - 1);
|
||||
my $duration = duration($timeout);
|
||||
my $banmask = address_to_mask($host);
|
||||
@ -516,8 +516,8 @@ sub check_flood {
|
||||
$channel_data->{join_watch} = $max_messages - 2; # give them a chance to rejoin
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
}
|
||||
} elsif($mode == $self->{pbot}->{messagehistory}->{MSG_CHAT}) {
|
||||
if($channel =~ /^#/) { #channel flood (opposed to private message or otherwise)
|
||||
} elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_CHAT}) {
|
||||
if ($channel =~ /^#/) { #channel flood (opposed to private message or otherwise)
|
||||
# don't increment offenses again if already banned
|
||||
if ($self->{pbot}->{chanops}->has_ban_timeout($channel, "*!$user\@" . address_to_mask($host))) {
|
||||
$self->{pbot}->{logger}->log("$nick $channel flood offense disregarded due to existing ban\n");
|
||||
@ -529,7 +529,7 @@ sub check_flood {
|
||||
$channel_data->{last_offense} = gettimeofday;
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
|
||||
if($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
if ($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
my $length = $self->{pbot}->{registry}->get_array_value('antiflood', 'chat_flood_punishment', $channel_data->{offenses} - 1);
|
||||
|
||||
$self->{pbot}->{chanops}->ban_user_timed("*!$user\@" . address_to_mask($host), $channel, $length);
|
||||
@ -557,7 +557,7 @@ sub check_flood {
|
||||
$self->{pbot}->{conn}->privmsg($nick, "You have used too many commands in too short a time period, you have been ignored for $length.");
|
||||
}
|
||||
next;
|
||||
} elsif($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE} and $self->{nickflood}->{$ancestor}->{changes} >= $max_messages) {
|
||||
} elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE} and $self->{nickflood}->{$ancestor}->{changes} >= $max_messages) {
|
||||
next if $channel !~ /^#/;
|
||||
($nick) = $text =~ m/NICKCHANGE (.*)/;
|
||||
|
||||
@ -565,7 +565,7 @@ sub check_flood {
|
||||
$self->{nickflood}->{$ancestor}->{changes} = $max_messages - 2; # allow 1 more change (to go back to original nick)
|
||||
$self->{nickflood}->{$ancestor}->{timestamp} = gettimeofday;
|
||||
|
||||
if($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
if ($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
my $length = $self->{pbot}->{registry}->get_array_value('antiflood', 'nick_flood_punishment', $self->{nickflood}->{$ancestor}->{offenses} - 1);
|
||||
$self->{pbot}->{chanops}->ban_user_timed("*!$user\@" . address_to_mask($host), $channel, $length);
|
||||
$length = duration($length);
|
||||
@ -577,12 +577,12 @@ sub check_flood {
|
||||
}
|
||||
|
||||
# check for enter abuse
|
||||
if($mode == $self->{pbot}->{messagehistory}->{MSG_CHAT} and $channel =~ m/^#/) {
|
||||
if ($mode == $self->{pbot}->{messagehistory}->{MSG_CHAT} and $channel =~ m/^#/) {
|
||||
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($account, $channel, 'enter_abuse', 'enter_abuses', 'offenses');
|
||||
my $other_offenses = delete $channel_data->{offenses};
|
||||
my $debug_enter_abuse = $self->{pbot}->{registry}->get_value('antiflood', 'debug_enter_abuse');
|
||||
|
||||
if(defined $self->{channels}->{$channel}->{last_spoken_nick} and $nick eq $self->{channels}->{$channel}->{last_spoken_nick}) {
|
||||
if (defined $self->{channels}->{$channel}->{last_spoken_nick} and $nick eq $self->{channels}->{$channel}->{last_spoken_nick}) {
|
||||
my $messages = $self->{pbot}->{messagehistory}->{database}->get_recent_messages($account, $channel, 2, $self->{pbot}->{messagehistory}->{MSG_CHAT});
|
||||
|
||||
my $enter_abuse_threshold = $self->{pbot}->{registry}->get_value($channel, 'enter_abuse_threshold');
|
||||
@ -593,12 +593,12 @@ sub check_flood {
|
||||
$enter_abuse_time_threshold = $self->{pbot}->{registry}->get_value('antiflood', 'enter_abuse_time_threshold') if not defined $enter_abuse_time_threshold;
|
||||
$enter_abuse_max_offenses = $self->{pbot}->{registry}->get_value('antiflood', 'enter_abuse_max_offenses') if not defined $enter_abuse_max_offenses;
|
||||
|
||||
if($messages->[1]->{timestamp} - $messages->[0]->{timestamp} <= $enter_abuse_time_threshold) {
|
||||
if(++$channel_data->{enter_abuse} >= $enter_abuse_threshold - 1) {
|
||||
if ($messages->[1]->{timestamp} - $messages->[0]->{timestamp} <= $enter_abuse_time_threshold) {
|
||||
if (++$channel_data->{enter_abuse} >= $enter_abuse_threshold - 1) {
|
||||
$channel_data->{enter_abuse} = $enter_abuse_threshold / 2 - 1;
|
||||
$channel_data->{enter_abuses}++;
|
||||
if($channel_data->{enter_abuses} >= $enter_abuse_max_offenses) {
|
||||
if($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
if ($channel_data->{enter_abuses} >= $enter_abuse_max_offenses) {
|
||||
if ($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
if ($self->{pbot}->{chanops}->has_ban_timeout($channel, "*!$user\@" . address_to_mask($host))) {
|
||||
$self->{pbot}->{logger}->log("$nick $channel enter abuse offense disregarded due to existing ban\n");
|
||||
next;
|
||||
@ -617,7 +617,7 @@ sub check_flood {
|
||||
} else {
|
||||
$self->{pbot}->{logger}->log("$nick $channel enter abuses counter incremented to " . $channel_data->{enter_abuses} . "\n") if $debug_enter_abuse;
|
||||
if ($channel_data->{enter_abuses} == $enter_abuse_max_offenses - 1 && $channel_data->{enter_abuse} == $enter_abuse_threshold / 2 - 1) {
|
||||
if($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
if ($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
$self->{pbot}->{conn}->privmsg($channel, "$nick: Please stop abusing the enter key. Feel free to type longer messages and to take a moment to think of anything else to say before you hit that enter key.");
|
||||
}
|
||||
}
|
||||
@ -627,7 +627,7 @@ sub check_flood {
|
||||
}
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
} else {
|
||||
if($channel_data->{enter_abuse} > 0) {
|
||||
if ($channel_data->{enter_abuse} > 0) {
|
||||
$self->{pbot}->{logger}->log("$nick $channel more than $enter_abuse_time_threshold seconds since last message, enter abuse counter reset\n") if $debug_enter_abuse;
|
||||
$channel_data->{enter_abuse} = 0;
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
@ -636,7 +636,7 @@ sub check_flood {
|
||||
} else {
|
||||
$self->{channels}->{$channel}->{last_spoken_nick} = $nick;
|
||||
$self->{pbot}->{logger}->log("last spoken nick set to $nick\n") if $debug_enter_abuse;
|
||||
if($channel_data->{enter_abuse} > 0) {
|
||||
if ($channel_data->{enter_abuse} > 0) {
|
||||
$self->{pbot}->{logger}->log("$nick $channel enter abuse counter reset\n") if $debug_enter_abuse;
|
||||
$channel_data->{enter_abuse} = 0;
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
@ -674,12 +674,12 @@ sub unbanme {
|
||||
foreach my $nickserv_account (@nickserv_accounts) {
|
||||
my $baninfos = $self->{pbot}->{bantracker}->get_baninfo("$anick!$auser\@$ahost", $channel, $nickserv_account);
|
||||
|
||||
if(defined $baninfos) {
|
||||
if (defined $baninfos) {
|
||||
foreach my $baninfo (@$baninfos) {
|
||||
if($self->whitelisted($baninfo->{channel}, $baninfo->{banmask}, 'ban') || $self->whitelisted($baninfo->{channel}, "$nick!$user\@$host", 'user')) {
|
||||
if ($self->whitelisted($baninfo->{channel}, $baninfo->{banmask}, 'ban') || $self->whitelisted($baninfo->{channel}, "$nick!$user\@$host", 'user')) {
|
||||
$self->{pbot}->{logger}->log("anti-flood: [unbanme] $anick!$auser\@$ahost banned as $baninfo->{banmask} in $baninfo->{channel}, but allowed through whitelist\n");
|
||||
} else {
|
||||
if($channel eq lc $baninfo->{channel}) {
|
||||
if ($channel eq lc $baninfo->{channel}) {
|
||||
my $mode = $baninfo->{type} eq "+b" ? "banned" : "quieted";
|
||||
$self->{pbot}->{logger}->log("anti-flood: [unbanme] $anick!$auser\@$ahost $mode as $baninfo->{banmask} in $baninfo->{channel} by $baninfo->{owner}, unbanme rejected\n");
|
||||
return "/msg $nick You have been $mode as $baninfo->{banmask} by $baninfo->{owner}, unbanme will not work until it is removed.";
|
||||
@ -758,20 +758,20 @@ sub address_to_mask {
|
||||
my $address = shift;
|
||||
my $banmask;
|
||||
|
||||
if($address =~ m/^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/) {
|
||||
if ($address =~ m/^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/) {
|
||||
my ($a, $b, $c, $d) = ($1, $2, $3, $4);
|
||||
given ($a) {
|
||||
when ($_ <= 127) { $banmask = "$a.*"; }
|
||||
when ($_ <= 191) { $banmask = "$a.$b.*"; }
|
||||
default { $banmask = "$a.$b.$c.*"; }
|
||||
}
|
||||
} elsif($address =~ m{^gateway/([^/]+)/([^/]+)/}) {
|
||||
} elsif ($address =~ m{^gateway/([^/]+)/([^/]+)/}) {
|
||||
$banmask = "gateway/$1/$2/*";
|
||||
} elsif($address =~ m{^nat/([^/]+)/}) {
|
||||
} elsif ($address =~ m{^nat/([^/]+)/}) {
|
||||
$banmask = "nat/$1/*";
|
||||
} elsif($address =~ m/^([^:]+):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)$/) {
|
||||
} elsif ($address =~ m/^([^:]+):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)$/) {
|
||||
$banmask = "$1:$2:*";
|
||||
} elsif($address =~ m/[^.]+\.([^.]+\.[a-zA-Z]+)$/) {
|
||||
} elsif ($address =~ m/[^.]+\.([^.]+\.[a-zA-Z]+)$/) {
|
||||
$banmask = "*.$1";
|
||||
} else {
|
||||
$banmask = $address;
|
||||
@ -787,7 +787,7 @@ sub devalidate_accounts {
|
||||
|
||||
#$self->{pbot}->{logger}->log("Devalidating accounts for $mask in $channel\n");
|
||||
|
||||
if($mask =~ m/^\$a:(.*)/) {
|
||||
if ($mask =~ m/^\$a:(.*)/) {
|
||||
my $ban_account = lc $1;
|
||||
@message_accounts = $self->{pbot}->{messagehistory}->{database}->find_message_accounts_by_nickserv($ban_account);
|
||||
} else {
|
||||
@ -796,7 +796,7 @@ sub devalidate_accounts {
|
||||
|
||||
foreach my $account (@message_accounts) {
|
||||
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($account, $channel, 'validated');
|
||||
if(defined $channel_data and $channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {
|
||||
if (defined $channel_data and $channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {
|
||||
$channel_data->{validated} &= ~$self->{NICKSERV_VALIDATED};
|
||||
#$self->{pbot}->{logger}->log("Devalidating account $account\n");
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
@ -833,7 +833,7 @@ sub check_bans {
|
||||
if (not exists $self->{pbot}->{capabilities}->{'account-notify'}) {
|
||||
# mark this account as needing check-bans when nickserv account is identified
|
||||
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($message_account, $channel, 'validated');
|
||||
if(not $channel_data->{validated} & $self->{NEEDS_CHECKBAN}) {
|
||||
if (not $channel_data->{validated} & $self->{NEEDS_CHECKBAN}) {
|
||||
$channel_data->{validated} |= $self->{NEEDS_CHECKBAN};
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($message_account, $channel, $channel_data);
|
||||
}
|
||||
@ -880,7 +880,7 @@ sub check_bans {
|
||||
my $tnickserv = defined $nickserv ? $nickserv : "[undefined]";
|
||||
$self->{pbot}->{logger}->log("anti-flood: [check-bans] checking blacklist for $alias in channel $channel using gecos '$tgecos' and nickserv '$tnickserv'\n") if $debug_checkban >= 5;
|
||||
if ($self->{pbot}->{blacklist}->check_blacklist($alias, $channel, $nickserv, $gecos)) {
|
||||
if($self->whitelisted($channel, $mask, 'user')) {
|
||||
if ($self->whitelisted($channel, $mask, 'user')) {
|
||||
$self->{pbot}->{logger}->log("anti-flood: [check-bans] $mask [$alias] blacklisted in $channel, but allowed through whitelist\n");
|
||||
next;
|
||||
}
|
||||
@ -899,12 +899,12 @@ sub check_bans {
|
||||
$self->{pbot}->{logger}->log("anti-flood: [check-bans] checking for bans in $channel on $alias using nickserv " . (defined $nickserv ? $nickserv : "[undefined]") . "\n") if $debug_checkban >= 2;
|
||||
my $baninfos = $self->{pbot}->{bantracker}->get_baninfo($alias, $channel, $nickserv);
|
||||
|
||||
if(defined $baninfos) {
|
||||
if (defined $baninfos) {
|
||||
foreach my $baninfo (@$baninfos) {
|
||||
if(time - $baninfo->{when} < 5) {
|
||||
if (time - $baninfo->{when} < 5) {
|
||||
$self->{pbot}->{logger}->log("anti-flood: [check-bans] $mask [$alias] evaded $baninfo->{banmask} in $baninfo->{channel}, but within 5 seconds of establishing ban; giving another chance\n");
|
||||
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($message_account, $channel, 'validated');
|
||||
if($channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {
|
||||
if ($channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {
|
||||
$channel_data->{validated} &= ~$self->{NICKSERV_VALIDATED};
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($message_account, $channel, $channel_data);
|
||||
}
|
||||
@ -912,7 +912,7 @@ sub check_bans {
|
||||
next;
|
||||
}
|
||||
|
||||
if($self->whitelisted($baninfo->{channel}, $baninfo->{banmask}, 'ban') || $self->whitelisted($baninfo->{channel}, $mask, 'user')) {
|
||||
if ($self->whitelisted($baninfo->{channel}, $baninfo->{banmask}, 'ban') || $self->whitelisted($baninfo->{channel}, $mask, 'user')) {
|
||||
#$self->{pbot}->{logger}->log("anti-flood: [check-bans] $mask [$alias] evaded $baninfo->{banmask} in $baninfo->{channel}, but allowed through whitelist\n");
|
||||
next;
|
||||
}
|
||||
@ -927,17 +927,17 @@ sub check_bans {
|
||||
$banmask_regex =~ s/\\\*/.*/g;
|
||||
$banmask_regex =~ s/\\\?/./g;
|
||||
|
||||
if($mask =~ /^$banmask_regex$/i) {
|
||||
if ($mask =~ /^$banmask_regex$/i) {
|
||||
$self->{pbot}->{logger}->log("anti-flood: [check-bans] Hostmask ($mask) matches $baninfo->{type} banmask ($banmask_regex), disregarding\n");
|
||||
next;
|
||||
}
|
||||
|
||||
if(defined $nickserv and $baninfo->{type} eq '+q' and $baninfo->{banmask} =~ /^\$a:(.*)/ and lc $1 eq $nickserv and $nickserv eq $current_nickserv_account) {
|
||||
if (defined $nickserv and $baninfo->{type} eq '+q' and $baninfo->{banmask} =~ /^\$a:(.*)/ and lc $1 eq $nickserv and $nickserv eq $current_nickserv_account) {
|
||||
$self->{pbot}->{logger}->log("anti-flood: [check-bans] Hostmask ($mask) matches quiet on account ($nickserv), disregarding\n");
|
||||
next;
|
||||
}
|
||||
|
||||
if(not defined $bans) {
|
||||
if (not defined $bans) {
|
||||
$bans = [];
|
||||
}
|
||||
|
||||
@ -950,7 +950,7 @@ sub check_bans {
|
||||
}
|
||||
|
||||
GOT_BAN:
|
||||
if(defined $bans) {
|
||||
if (defined $bans) {
|
||||
foreach my $baninfo (@$bans) {
|
||||
my $banmask;
|
||||
|
||||
@ -972,7 +972,7 @@ sub check_bans {
|
||||
|
||||
$self->{pbot}->{logger}->log("anti-flood: [check-bans] $mask evaded $baninfo->{banmask} banned in $baninfo->{channel} by $baninfo->{owner}, banning $banmask\n");
|
||||
my ($bannick) = $mask =~ m/^([^!]+)/;
|
||||
if($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
if ($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
|
||||
if ($self->{pbot}->{chanops}->has_ban_timeout($baninfo->{channel}, $banmask)) {
|
||||
$self->{pbot}->{logger}->log("anti-flood: [check-bans] $banmask already banned in $channel, disregarding\n");
|
||||
return;
|
||||
@ -1001,7 +1001,7 @@ sub check_bans {
|
||||
$self->{pbot}->{chanops}->ban_user_timed($banmask, $baninfo->{channel}, 60 * 60 * 24 * 14);
|
||||
}
|
||||
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($message_account, $channel, 'validated');
|
||||
if($channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {
|
||||
if ($channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {
|
||||
$channel_data->{validated} &= ~$self->{NICKSERV_VALIDATED};
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($message_account, $channel, $channel_data);
|
||||
}
|
||||
@ -1011,7 +1011,7 @@ sub check_bans {
|
||||
|
||||
unless ($do_not_validate) {
|
||||
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($message_account, $channel, 'validated');
|
||||
if(not $channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {
|
||||
if (not $channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {
|
||||
$channel_data->{validated} |= $self->{NICKSERV_VALIDATED};
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($message_account, $channel, $channel_data);
|
||||
}
|
||||
@ -1026,21 +1026,21 @@ sub check_nickserv_accounts {
|
||||
|
||||
$account = lc $account;
|
||||
|
||||
if(not defined $hostmask) {
|
||||
if (not defined $hostmask) {
|
||||
($message_account, $hostmask) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($nick);
|
||||
|
||||
if(not defined $message_account) {
|
||||
if (not defined $message_account) {
|
||||
$self->{pbot}->{logger}->log("No message account found for nick $nick.\n");
|
||||
($message_account) = $self->{pbot}->{messagehistory}->{database}->find_message_accounts_by_nickserv($account);
|
||||
|
||||
if(not $message_account) {
|
||||
if (not $message_account) {
|
||||
$self->{pbot}->{logger}->log("No message account found for nickserv $account.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
($message_account) = $self->{pbot}->{messagehistory}->{database}->find_message_accounts_by_mask($hostmask);
|
||||
if(not $message_account) {
|
||||
if (not $message_account) {
|
||||
$self->{pbot}->{logger}->log("No message account found for hostmask $hostmask.\n");
|
||||
return;
|
||||
}
|
||||
@ -1168,7 +1168,7 @@ sub adjust_offenses {
|
||||
my $id = delete $channel_data->{id};
|
||||
my $channel = delete $channel_data->{channel};
|
||||
my $last_offense = delete $channel_data->{last_offense};
|
||||
if(gettimeofday - $last_offense >= 60 * 60 * 3) {
|
||||
if (gettimeofday - $last_offense >= 60 * 60 * 3) {
|
||||
$channel_data->{enter_abuses}--;
|
||||
#$self->{pbot}->{logger}->log("[adjust-offenses] [$id][$channel] decreasing enter abuse offenses to $channel_data->{enter_abuses}\n");
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($id, $channel, $channel_data);
|
||||
@ -1176,10 +1176,10 @@ sub adjust_offenses {
|
||||
}
|
||||
|
||||
foreach my $account (keys %{ $self->{nickflood} }) {
|
||||
if($self->{nickflood}->{$account}->{offenses} and gettimeofday - $self->{nickflood}->{$account}->{timestamp} >= 60 * 60) {
|
||||
if ($self->{nickflood}->{$account}->{offenses} and gettimeofday - $self->{nickflood}->{$account}->{timestamp} >= 60 * 60) {
|
||||
$self->{nickflood}->{$account}->{offenses}--;
|
||||
|
||||
if($self->{nickflood}->{$account}->{offenses} <= 0) {
|
||||
if ($self->{nickflood}->{$account}->{offenses} <= 0) {
|
||||
delete $self->{nickflood}->{$account};
|
||||
} else {
|
||||
$self->{nickflood}->{$account}->{timestamp} = gettimeofday;
|
||||
|
@ -163,11 +163,11 @@ sub antispam_cmd {
|
||||
my ($namespace, $keyword) = $self->{pbot}->{interpreter}->split_args($arglist, 2);
|
||||
return "Usage: antispam remove <namespace> <regex>" if not defined $namespace or not defined $keyword;
|
||||
|
||||
if(not defined $self->{keywords}->hash->{$namespace}) {
|
||||
if (not defined $self->{keywords}->hash->{$namespace}) {
|
||||
return "No entries for namespace $namespace";
|
||||
}
|
||||
|
||||
if(not defined $self->{keywords}->hash->{$namespace}->{$keyword}) {
|
||||
if (not defined $self->{keywords}->hash->{$namespace}->{$keyword}) {
|
||||
return "No such entry for namespace $namespace";
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ $Data::Dumper::Sortkeys = 1;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to BanTracker should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ sub get_baninfo {
|
||||
|
||||
foreach my $mode (keys %{ $self->{banlist}->{$channel} }) {
|
||||
foreach my $banmask (keys %{ $self->{banlist}->{$channel}->{$mode} }) {
|
||||
if($banmask =~ m/^\$a:(.*)/) {
|
||||
if ($banmask =~ m/^\$a:(.*)/) {
|
||||
$ban_account = lc $1;
|
||||
} else {
|
||||
$ban_account = "";
|
||||
@ -155,7 +155,7 @@ sub get_baninfo {
|
||||
}
|
||||
|
||||
if ($banned) {
|
||||
if(not defined $bans) {
|
||||
if (not defined $bans) {
|
||||
$bans = [];
|
||||
}
|
||||
|
||||
@ -214,25 +214,25 @@ sub track_mode {
|
||||
$target = lc $target;
|
||||
$channel = lc $channel;
|
||||
|
||||
if($mode eq "+b" or $mode eq "+q") {
|
||||
if ($mode eq "+b" or $mode eq "+q") {
|
||||
$self->{pbot}->{logger}->log("ban-tracker: $target " . ($mode eq '+b' ? 'banned' : 'quieted') . " by $source in $channel.\n");
|
||||
$self->{banlist}->{$channel}->{$mode}->{$target} = [ $source, gettimeofday ];
|
||||
$self->{pbot}->{antiflood}->devalidate_accounts($target, $channel);
|
||||
}
|
||||
elsif($mode eq "-b" or $mode eq "-q") {
|
||||
elsif ($mode eq "-b" or $mode eq "-q") {
|
||||
$self->{pbot}->{logger}->log("ban-tracker: $target " . ($mode eq '-b' ? 'unbanned' : 'unquieted') . " by $source in $channel.\n");
|
||||
delete $self->{banlist}->{$channel}->{$mode eq "-b" ? "+b" : "+q"}->{$target};
|
||||
|
||||
if($mode eq "-b") {
|
||||
if($self->{pbot}->{chanops}->{unban_timeout}->find_index($channel, $target)) {
|
||||
if ($mode eq "-b") {
|
||||
if ($self->{pbot}->{chanops}->{unban_timeout}->find_index($channel, $target)) {
|
||||
$self->{pbot}->{chanops}->{unban_timeout}->remove($channel, $target);
|
||||
} elsif($self->{pbot}->{chanops}->{unban_timeout}->find_index($channel, "$target\$##stop_join_flood")) {
|
||||
} elsif ($self->{pbot}->{chanops}->{unban_timeout}->find_index($channel, "$target\$##stop_join_flood")) {
|
||||
# freenode strips channel forwards from unban result if no ban exists with a channel forward
|
||||
$self->{pbot}->{chanops}->{unban_timeout}->remove($channel, "$target\$##stop_join_flood");
|
||||
}
|
||||
}
|
||||
elsif($mode eq "-q") {
|
||||
if($self->{pbot}->{chanops}->{unmute_timeout}->find_index($channel, $target)) {
|
||||
elsif ($mode eq "-q") {
|
||||
if ($self->{pbot}->{chanops}->{unmute_timeout}->find_index($channel, $target)) {
|
||||
$self->{pbot}->{chanops}->{unmute_timeout}->remove($channel, $target);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use Carp ();
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -77,9 +77,9 @@ sub load_blacklist {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
|
||||
if(not defined $filename) {
|
||||
if (not defined $filename) {
|
||||
Carp::carp "No blacklist path specified -- skipping loading of blacklist";
|
||||
return;
|
||||
}
|
||||
@ -98,11 +98,11 @@ sub load_blacklist {
|
||||
|
||||
my ($channel, $hostmask) = split(/\s+/, $line);
|
||||
|
||||
if(not defined $hostmask || not defined $channel) {
|
||||
if (not defined $hostmask || not defined $channel) {
|
||||
Carp::croak "Syntax error around line $i of $filename\n";
|
||||
}
|
||||
|
||||
if(exists $self->{blacklist}->{$channel}->{$hostmask}) {
|
||||
if (exists $self->{blacklist}->{$channel}->{$hostmask}) {
|
||||
Carp::croak "Duplicate blacklist entry [$hostmask][$channel] found in $filename around line $i\n";
|
||||
}
|
||||
|
||||
@ -117,9 +117,9 @@ sub save_blacklist {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
|
||||
if(not defined $filename) {
|
||||
if (not defined $filename) {
|
||||
Carp::carp "No blacklist path specified -- skipping saving of blacklist\n";
|
||||
return;
|
||||
}
|
||||
@ -213,7 +213,7 @@ sub blacklist {
|
||||
|
||||
$channel = '.*' if not defined $channel;
|
||||
|
||||
if(exists $self->{blacklist}->{$channel} and not exists $self->{blacklist}->{$channel}->{$mask}) {
|
||||
if (exists $self->{blacklist}->{$channel} and not exists $self->{blacklist}->{$channel}->{$mask}) {
|
||||
$self->{pbot}->{logger}->log("$nick attempt to remove nonexistent [$mask][$channel] from blacklist\n");
|
||||
return "/say $mask not found in blacklist for channel $channel (use `blacklist list` to display blacklist)";
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ no if $] >= 5.018, warnings => "experimental::smartmatch";
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to BotAdminCommands should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
|
||||
my $pbot = delete $conf{pbot};
|
||||
if(not defined $pbot) {
|
||||
if (not defined $pbot) {
|
||||
Carp::croak("Missing pbot reference to BotAdminCommands");
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ sub login {
|
||||
$arguments = $2;
|
||||
}
|
||||
|
||||
if($self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host")) {
|
||||
if ($self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host")) {
|
||||
return "/msg $nick You are already logged into channel $channel.";
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ sub login {
|
||||
sub logout {
|
||||
my $self = shift;
|
||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||
return "/msg $nick Uh, you aren't logged into channel $from." if(not $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host"));
|
||||
return "/msg $nick Uh, you aren't logged into channel $from." if (not $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host"));
|
||||
$self->{pbot}->{admins}->logout($from, "$nick!$user\@$host");
|
||||
return "/msg $nick Good-bye, $nick.";
|
||||
}
|
||||
@ -116,7 +116,7 @@ sub adminadd {
|
||||
|
||||
my ($name, $channel, $hostmask, $level, $password) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 5);
|
||||
|
||||
if(not defined $name or not defined $channel or not defined $hostmask or not defined $level
|
||||
if (not defined $name or not defined $channel or not defined $hostmask or not defined $level
|
||||
or not defined $password) {
|
||||
return "/msg $nick Usage: adminadd <name> <channel> <hostmask> <level> <password>";
|
||||
}
|
||||
@ -143,7 +143,7 @@ sub adminrem {
|
||||
|
||||
my ($channel, $hostmask) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||
|
||||
if(not defined $channel or not defined $hostmask) {
|
||||
if (not defined $channel or not defined $hostmask) {
|
||||
return "/msg $nick Usage: adminrem <channel> <hostmask/name>";
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ sub adminrem {
|
||||
}
|
||||
}
|
||||
|
||||
if($self->{pbot}->{admins}->remove_admin($channel, $hostmask)) {
|
||||
if ($self->{pbot}->{admins}->remove_admin($channel, $hostmask)) {
|
||||
return "Admin removed.";
|
||||
} else {
|
||||
return "No such admin found.";
|
||||
@ -175,7 +175,7 @@ sub adminset {
|
||||
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($channel, $hostmask, $key, $value) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 4);
|
||||
|
||||
if(not defined $channel or not defined $hostmask) {
|
||||
if (not defined $channel or not defined $hostmask) {
|
||||
return "Usage: adminset <channel> <hostmask/name> [key] [value]";
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ sub adminunset {
|
||||
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($channel, $hostmask, $key) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3);
|
||||
|
||||
if(not defined $channel or not defined $hostmask) {
|
||||
if (not defined $channel or not defined $hostmask) {
|
||||
return "Usage: adminunset <channel> <hostmask/name> <key>";
|
||||
}
|
||||
|
||||
@ -286,19 +286,19 @@ sub export {
|
||||
my $self = shift;
|
||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||
|
||||
if(not defined $arguments) {
|
||||
if (not defined $arguments) {
|
||||
return "/msg $nick Usage: export <modules|factoids|admins>";
|
||||
}
|
||||
|
||||
if($arguments =~ /^modules$/i) {
|
||||
if ($arguments =~ /^modules$/i) {
|
||||
return "/msg $nick Coming soon.";
|
||||
}
|
||||
|
||||
if($arguments =~ /^factoids$/i) {
|
||||
if ($arguments =~ /^factoids$/i) {
|
||||
return $self->{pbot}->{factoids}->export_factoids;
|
||||
}
|
||||
|
||||
if($arguments =~ /^admins$/i) {
|
||||
if ($arguments =~ /^admins$/i) {
|
||||
return "/msg $nick Coming soon.";
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use PBot::BotAdminCommands;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -37,8 +37,8 @@ sub initialize {
|
||||
my $export_site = delete $conf{export_site};
|
||||
my $export_timeout = delete $conf{export_timeout};
|
||||
|
||||
if(not defined $export_timeout) {
|
||||
if(defined $export_path) {
|
||||
if (not defined $export_timeout) {
|
||||
if (defined $export_path) {
|
||||
$export_timeout = 300; # every 5 minutes
|
||||
} else {
|
||||
$export_timeout = -1;
|
||||
@ -81,7 +81,7 @@ sub remove_admin {
|
||||
delete $self->{admins}->hash->{$channel};
|
||||
}
|
||||
|
||||
if(defined $admin) {
|
||||
if (defined $admin) {
|
||||
$self->{pbot}->{logger}->log("Removed level $admin->{level} admin [$admin->{name}] [$hostmask] from channel [$channel]\n");
|
||||
$self->save_admins;
|
||||
return 1;
|
||||
@ -95,9 +95,9 @@ sub load_admins {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->{admins}->filename; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->{admins}->filename; }
|
||||
|
||||
if(not defined $filename) {
|
||||
if (not defined $filename) {
|
||||
Carp::carp "No admins path specified -- skipping loading of admins";
|
||||
return;
|
||||
}
|
||||
@ -116,7 +116,7 @@ sub load_admins {
|
||||
my $level = $self->{admins}->hash->{$channel}->{$hostmask}->{level};
|
||||
my $password = $self->{admins}->hash->{$channel}->{$hostmask}->{password};
|
||||
|
||||
if(not defined $name or not defined $level or not defined $password) {
|
||||
if (not defined $name or not defined $level or not defined $password) {
|
||||
Carp::croak "Syntax error around line $i of $filename\n";
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ sub export_admins {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->export_path; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->export_path; }
|
||||
|
||||
return if not defined $filename;
|
||||
return;
|
||||
@ -163,7 +163,7 @@ sub find_admin {
|
||||
return undef;
|
||||
};
|
||||
|
||||
if($@) {
|
||||
if ($@) {
|
||||
$self->{pbot}->{logger}->log("Error in find_admin parameters: $@\n");
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ sub loggedin {
|
||||
|
||||
my $admin = $self->find_admin($channel, $hostmask);
|
||||
|
||||
if(defined $admin && $admin->{loggedin}) {
|
||||
if (defined $admin && $admin->{loggedin}) {
|
||||
return $admin;
|
||||
} else {
|
||||
return undef;
|
||||
@ -187,12 +187,12 @@ sub login {
|
||||
|
||||
my $admin = $self->find_admin($channel, $hostmask);
|
||||
|
||||
if(not defined $admin) {
|
||||
if (not defined $admin) {
|
||||
$self->{pbot}->{logger}->log("Attempt to login non-existent [$channel][$hostmask] failed\n");
|
||||
return "You do not have an account in $channel.";
|
||||
}
|
||||
|
||||
if($admin->{password} ne $password) {
|
||||
if ($admin->{password} ne $password) {
|
||||
$self->{pbot}->{logger}->log("Bad login password for [$channel][$hostmask]\n");
|
||||
return "I don't think so.";
|
||||
}
|
||||
@ -215,20 +215,20 @@ sub logout {
|
||||
sub export_path {
|
||||
my $self = shift;
|
||||
|
||||
if(@_) { $self->{export_path} = shift; }
|
||||
if (@_) { $self->{export_path} = shift; }
|
||||
return $self->{export_path};
|
||||
}
|
||||
|
||||
sub export_timeout {
|
||||
my $self = shift;
|
||||
|
||||
if(@_) { $self->{export_timeout} = shift; }
|
||||
if (@_) { $self->{export_timeout} = shift; }
|
||||
return $self->{export_timeout};
|
||||
}
|
||||
|
||||
sub export_site {
|
||||
my $self = shift;
|
||||
if(@_) { $self->{export_site} = shift; }
|
||||
if (@_) { $self->{export_site} = shift; }
|
||||
return $self->{export_site};
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ sub admins {
|
||||
sub filename {
|
||||
my $self = shift;
|
||||
|
||||
if(@_) { $self->{filename} = shift; }
|
||||
if (@_) { $self->{filename} = shift; }
|
||||
return $self->{filename};
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ sub unban_user {
|
||||
$channel = $temp;
|
||||
}
|
||||
|
||||
if(not defined $target) {
|
||||
if (not defined $target) {
|
||||
return "/msg $nick Usage: unban <nick/mask> [[channel] [false value to use unban queue]]";
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ sub unmute_user {
|
||||
$channel = $temp;
|
||||
}
|
||||
|
||||
if(not defined $target) {
|
||||
if (not defined $target) {
|
||||
return "/msg $nick Usage: unmute <nick/mask> [[channel] [false value to use unban queue]]";
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ use PBot::ChanOpCommands;
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ sub gain_ops {
|
||||
return if exists $self->{op_requested}->{$channel};
|
||||
return if not $self->can_gain_ops($channel);
|
||||
|
||||
if(not exists $self->{is_opped}->{$channel}) {
|
||||
if (not exists $self->{is_opped}->{$channel}) {
|
||||
$self->{pbot}->{conn}->privmsg("chanserv", "op $channel");
|
||||
$self->{op_requested}->{$channel} = scalar gettimeofday;
|
||||
} else {
|
||||
@ -109,11 +109,11 @@ sub perform_op_commands {
|
||||
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
||||
|
||||
$self->{pbot}->{logger}->log("Performing op commands...\n");
|
||||
while(my $command = shift @{ $self->{op_commands}->{$channel} }) {
|
||||
if($command =~ /^mode (.*?) (.*)/i) {
|
||||
while (my $command = shift @{ $self->{op_commands}->{$channel} }) {
|
||||
if ($command =~ /^mode (.*?) (.*)/i) {
|
||||
$self->{pbot}->{conn}->mode($1, $2);
|
||||
$self->{pbot}->{logger}->log(" executing mode [$1] [$2]\n");
|
||||
} elsif($command =~ /^kick (.*?) (.*?) (.*)/i) {
|
||||
} elsif ($command =~ /^kick (.*?) (.*?) (.*)/i) {
|
||||
$self->{pbot}->{conn}->kick($1, $2, $3) unless $1 =~ /\Q$botnick\E/i;
|
||||
$self->{pbot}->{logger}->log(" executing kick on $1 $2 $3\n");
|
||||
}
|
||||
@ -421,7 +421,7 @@ sub check_unban_timeouts {
|
||||
|
||||
foreach my $channel (keys %{ $self->{unban_timeout}->hash }) {
|
||||
foreach my $mask (keys %{ $self->{unban_timeout}->hash->{$channel} }) {
|
||||
if($self->{unban_timeout}->hash->{$channel}->{$mask}{timeout} < $now) {
|
||||
if ($self->{unban_timeout}->hash->{$channel}->{$mask}{timeout} < $now) {
|
||||
$self->{unban_timeout}->hash->{$channel}->{$mask}{timeout} = $now + 7200;
|
||||
$self->unban_user($mask, $channel);
|
||||
}
|
||||
@ -438,7 +438,7 @@ sub check_unmute_timeouts {
|
||||
|
||||
foreach my $channel (keys %{ $self->{unmute_timeout}->hash }) {
|
||||
foreach my $mask (keys %{ $self->{unmute_timeout}->hash->{$channel} }) {
|
||||
if($self->{unmute_timeout}->hash->{$channel}->{$mask}{timeout} < $now) {
|
||||
if ($self->{unmute_timeout}->hash->{$channel}->{$mask}{timeout} < $now) {
|
||||
$self->{unmute_timeout}->hash->{$channel}->{$mask}{timeout} = $now + 7200;
|
||||
$self->unmute_user($mask, $channel);
|
||||
}
|
||||
@ -451,7 +451,7 @@ sub check_opped_timeouts {
|
||||
my $now = gettimeofday();
|
||||
|
||||
foreach my $channel (keys %{ $self->{is_opped} }) {
|
||||
if($self->{is_opped}->{$channel}{timeout} < $now) {
|
||||
if ($self->{is_opped}->{$channel}{timeout} < $now) {
|
||||
unless (exists $self->{pbot}->{channels}->{channels}->hash->{$channel}
|
||||
and exists $self->{pbot}->{channels}->{channels}->hash->{$channel}{permop}
|
||||
and $self->{pbot}->{channels}->{channels}->hash->{$channel}{permop}) {
|
||||
|
@ -16,7 +16,7 @@ use Carp ();
|
||||
use PBot::HashObject;
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak ("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ sub set {
|
||||
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($channel, $key, $value) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3);
|
||||
|
||||
if(not defined $channel) {
|
||||
if (not defined $channel) {
|
||||
return "Usage: chanset <channel> [key [value]]";
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ sub unset {
|
||||
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($channel, $key) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||
|
||||
if(not defined $channel or not defined $key) {
|
||||
if (not defined $channel or not defined $key) {
|
||||
return "Usage: chanunset <channel> <key>";
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ sub unset {
|
||||
sub add {
|
||||
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
||||
|
||||
if(not defined $arguments or not length $arguments) {
|
||||
if (not defined $arguments or not length $arguments) {
|
||||
return "Usage: chanadd <channel>";
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ sub add {
|
||||
sub remove {
|
||||
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
||||
|
||||
if(not defined $arguments or not length $arguments) {
|
||||
if (not defined $arguments or not length $arguments) {
|
||||
return "Usage: chanrem <channel>";
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ use Carp ();
|
||||
use Text::ParseWords qw(shellwords);
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to Commands should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ sub initialize {
|
||||
$self->SUPER::initialize(%conf);
|
||||
|
||||
my $pbot = delete $conf{pbot};
|
||||
if(not defined $pbot) {
|
||||
if (not defined $pbot) {
|
||||
Carp::croak("Missing pbot reference to PBot::Commands");
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ sub initialize {
|
||||
sub register {
|
||||
my ($self, $subref, $name, $level) = @_;
|
||||
|
||||
if((not defined $subref) || (not defined $name) || (not defined $level)) {
|
||||
if ((not defined $subref) || (not defined $name) || (not defined $level)) {
|
||||
Carp::croak("Missing parameters to Commands::register");
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ sub register {
|
||||
sub unregister {
|
||||
my ($self, $name) = @_;
|
||||
|
||||
if(not defined $name) {
|
||||
if (not defined $name) {
|
||||
Carp::croak("Missing name parameter to Commands::unregister");
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ use Storable;
|
||||
use PBot::Utils::SafeFilename;
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to FactoidCommands should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
|
||||
my $pbot = delete $conf{pbot};
|
||||
if(not defined $pbot) {
|
||||
if (not defined $pbot) {
|
||||
Carp::croak("Missing pbot reference to FactoidCommands");
|
||||
}
|
||||
|
||||
@ -100,13 +100,13 @@ sub call_factoid {
|
||||
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($chan, $keyword, $args) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3);
|
||||
|
||||
if(not defined $chan or not defined $keyword) {
|
||||
if (not defined $chan or not defined $keyword) {
|
||||
return "Usage: fact <channel> <keyword> [arguments]";
|
||||
}
|
||||
|
||||
my ($channel, $trigger) = $self->{pbot}->{factoids}->find_factoid($chan, $keyword, $args, 1, 1);
|
||||
|
||||
if(not defined $trigger) {
|
||||
if (not defined $trigger) {
|
||||
return "No such factoid '$keyword' exists for channel '$chan'";
|
||||
}
|
||||
|
||||
@ -538,19 +538,19 @@ sub factset {
|
||||
my $level = 0;
|
||||
my $meta_level = 0;
|
||||
|
||||
if(defined $admininfo) {
|
||||
if (defined $admininfo) {
|
||||
$level = $admininfo->{level};
|
||||
}
|
||||
|
||||
if(defined $key) {
|
||||
if(defined $factoid_metadata_levels{$key}) {
|
||||
if (defined $key) {
|
||||
if (defined $factoid_metadata_levels{$key}) {
|
||||
$meta_level = $factoid_metadata_levels{$key};
|
||||
}
|
||||
|
||||
if($meta_level > 0) {
|
||||
if($level == 0) {
|
||||
if ($meta_level > 0) {
|
||||
if ($level == 0) {
|
||||
return "You must login to set '$key'";
|
||||
} elsif($level < $meta_level) {
|
||||
} elsif ($level < $meta_level) {
|
||||
return "You must be at least level $meta_level to set '$key'";
|
||||
}
|
||||
}
|
||||
@ -622,18 +622,18 @@ sub factunset {
|
||||
my $level = 0;
|
||||
my $meta_level = 0;
|
||||
|
||||
if(defined $admininfo) {
|
||||
if (defined $admininfo) {
|
||||
$level = $admininfo->{level};
|
||||
}
|
||||
|
||||
if(defined $factoid_metadata_levels{$key}) {
|
||||
if (defined $factoid_metadata_levels{$key}) {
|
||||
$meta_level = $factoid_metadata_levels{$key};
|
||||
}
|
||||
|
||||
if($meta_level > 0) {
|
||||
if($level == 0) {
|
||||
if ($meta_level > 0) {
|
||||
if ($level == 0) {
|
||||
return "You must login to unset '$key'";
|
||||
} elsif($level < $meta_level) {
|
||||
} elsif ($level < $meta_level) {
|
||||
return "You must be at least level $meta_level to unset '$key'";
|
||||
}
|
||||
}
|
||||
@ -654,12 +654,12 @@ sub factunset {
|
||||
|
||||
my $oldvalue;
|
||||
|
||||
if(defined $owner_channel) {
|
||||
if (defined $owner_channel) {
|
||||
my $factoid = $self->{pbot}->{factoids}->{factoids}->hash->{$owner_channel}->{$owner_trigger};
|
||||
|
||||
my ($owner) = $factoid->{'owner'} =~ m/([^!]+)/;
|
||||
|
||||
if(lc $nick ne lc $owner and $level == 0) {
|
||||
if (lc $nick ne lc $owner and $level == 0) {
|
||||
return "You are not the owner of $trigger.";
|
||||
}
|
||||
$oldvalue = $self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{$key};
|
||||
@ -681,16 +681,16 @@ sub list {
|
||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||
my $text;
|
||||
|
||||
if(not defined $arguments) {
|
||||
if (not defined $arguments) {
|
||||
return "Usage: list <modules|factoids|commands|admins>";
|
||||
}
|
||||
|
||||
if($arguments =~ /^modules$/i) {
|
||||
if ($arguments =~ /^modules$/i) {
|
||||
$from = '.*' if not defined $from or $from !~ /^#/;
|
||||
$text = "Loaded modules for channel $from: ";
|
||||
foreach my $channel (sort keys %{ $self->{pbot}->{factoids}->{factoids}->hash }) {
|
||||
foreach my $command (sort keys %{ $self->{pbot}->{factoids}->{factoids}->hash->{$channel} }) {
|
||||
if($self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$command}->{type} eq 'module') {
|
||||
if ($self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$command}->{type} eq 'module') {
|
||||
$text .= "$command ";
|
||||
}
|
||||
}
|
||||
@ -698,7 +698,7 @@ sub list {
|
||||
return $text;
|
||||
}
|
||||
|
||||
if($arguments =~ /^commands$/i) {
|
||||
if ($arguments =~ /^commands$/i) {
|
||||
$text = "Registered commands: ";
|
||||
foreach my $command (sort { $a->{name} cmp $b->{name} } @{ $self->{pbot}->{commands}->{handlers} }) {
|
||||
$text .= "$command->{name} ";
|
||||
@ -707,16 +707,16 @@ sub list {
|
||||
return $text;
|
||||
}
|
||||
|
||||
if($arguments =~ /^factoids$/i) {
|
||||
if ($arguments =~ /^factoids$/i) {
|
||||
return "For a list of factoids see " . $self->{pbot}->{factoids}->export_site;
|
||||
}
|
||||
|
||||
if($arguments =~ /^admins$/i) {
|
||||
if ($arguments =~ /^admins$/i) {
|
||||
$text = "Admins: ";
|
||||
my $last_channel = "";
|
||||
my $sep = "";
|
||||
foreach my $channel (sort keys %{ $self->{pbot}->{admins}->{admins}->hash }) {
|
||||
if($last_channel ne $channel) {
|
||||
if ($last_channel ne $channel) {
|
||||
$text .= $sep . "Channel " . ($channel eq ".*" ? "all" : $channel) . ": ";
|
||||
$last_channel = $channel;
|
||||
$sep = "";
|
||||
@ -740,19 +740,19 @@ sub factmove {
|
||||
|
||||
my $usage = "Usage: factmove <source channel> <source factoid> <target channel/factoid> [target factoid]";
|
||||
|
||||
if(not defined $target_channel) {
|
||||
if (not defined $target_channel) {
|
||||
return $usage;
|
||||
}
|
||||
|
||||
if($target_channel !~ /^#/ and $target_channel ne '.*') {
|
||||
if(defined $target) {
|
||||
if ($target_channel !~ /^#/ and $target_channel ne '.*') {
|
||||
if (defined $target) {
|
||||
return "Unexpected argument '$target' when renaming to '$target_channel'. Perhaps '$target_channel' is missing #s? $usage";
|
||||
}
|
||||
|
||||
$target = $target_channel;
|
||||
$target_channel = $src_channel;
|
||||
} else {
|
||||
if(not defined $target) {
|
||||
if (not defined $target) {
|
||||
$target = $source;
|
||||
}
|
||||
}
|
||||
@ -767,7 +767,7 @@ sub factmove {
|
||||
|
||||
my ($found_src_channel, $found_source) = $self->{pbot}->{factoids}->find_factoid($src_channel, $source, undef, 1, 1);
|
||||
|
||||
if(not defined $found_src_channel) {
|
||||
if (not defined $found_src_channel) {
|
||||
return "Source factoid $source not found in channel $src_channel";
|
||||
}
|
||||
|
||||
@ -775,24 +775,24 @@ sub factmove {
|
||||
|
||||
my ($owner) = $factoids->{$found_src_channel}->{$found_source}->{'owner'} =~ m/([^!]+)/;
|
||||
|
||||
if((lc $nick ne lc $owner) and (not $self->{pbot}->{admins}->loggedin($found_src_channel, "$nick!$user\@$host"))) {
|
||||
if ((lc $nick ne lc $owner) and (not $self->{pbot}->{admins}->loggedin($found_src_channel, "$nick!$user\@$host"))) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host attempted to move [$found_src_channel] $found_source (not owner)\n");
|
||||
my $chan = ($found_src_channel eq '.*' ? 'the global channel' : $found_src_channel);
|
||||
return "You are not the owner of $found_source for $chan";
|
||||
}
|
||||
|
||||
if($factoids->{$found_src_channel}->{$found_source}->{'locked'}) {
|
||||
if ($factoids->{$found_src_channel}->{$found_source}->{'locked'}) {
|
||||
return "/say $found_source is locked; unlock before moving.";
|
||||
}
|
||||
|
||||
my ($found_target_channel, $found_target) = $self->{pbot}->{factoids}->find_factoid($target_channel, $target, undef, 1, 1);
|
||||
|
||||
if(defined $found_target_channel) {
|
||||
if (defined $found_target_channel) {
|
||||
return "Target factoid $target already exists in channel $target_channel";
|
||||
}
|
||||
|
||||
my ($overchannel, $overtrigger) = $self->{pbot}->{factoids}->find_factoid('.*', $target, undef, 1, 1);
|
||||
if(defined $overtrigger and $self->{pbot}->{factoids}->{factoids}->hash->{'.*'}->{$overtrigger}->{'nooverride'}) {
|
||||
if (defined $overtrigger and $self->{pbot}->{factoids}->{factoids}->hash->{'.*'}->{$overtrigger}->{'nooverride'}) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host attempt to override $target\n");
|
||||
return "/say $target already exists for the global channel and cannot be overridden for " . ($target_channel eq '.*' ? 'the global channel' : $target_channel) . ".";
|
||||
}
|
||||
@ -812,7 +812,7 @@ sub factmove {
|
||||
$found_src_channel = 'global' if $found_src_channel eq '.*';
|
||||
$target_channel = 'global' if $target_channel eq '.*';
|
||||
|
||||
if($src_channel eq $target_channel) {
|
||||
if ($src_channel eq $target_channel) {
|
||||
$self->log_factoid($target_channel, $target, "$nick!$user\@$host", "renamed from $found_source to $target");
|
||||
return "[$found_src_channel] $found_source renamed to $target";
|
||||
} else {
|
||||
@ -856,13 +856,13 @@ sub factalias {
|
||||
|
||||
my ($channel, $alias_trigger) = $self->{pbot}->{factoids}->find_factoid($chan, $alias, undef, 1, 1);
|
||||
|
||||
if(defined $alias_trigger) {
|
||||
if (defined $alias_trigger) {
|
||||
$self->{pbot}->{logger}->log("attempt to overwrite existing command\n");
|
||||
return "'$alias_trigger' already exists for channel $channel";
|
||||
}
|
||||
|
||||
my ($overchannel, $overtrigger) = $self->{pbot}->{factoids}->find_factoid('.*', $alias, undef, 1, 1);
|
||||
if(defined $overtrigger and $self->{pbot}->{factoids}->{factoids}->hash->{'.*'}->{$overtrigger}->{'nooverride'}) {
|
||||
if (defined $overtrigger and $self->{pbot}->{factoids}->{factoids}->hash->{'.*'}->{$overtrigger}->{'nooverride'}) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host attempt to override $alias\n");
|
||||
return "/say $alias already exists for the global channel and cannot be overridden for " . ($chan eq '.*' ? 'the global channel' : $chan) . ".";
|
||||
}
|
||||
@ -886,23 +886,23 @@ sub add_regex {
|
||||
|
||||
$from = '.*' if not defined $from or $from !~ /^#/;
|
||||
|
||||
if(not defined $keyword) {
|
||||
if (not defined $keyword) {
|
||||
$text = "";
|
||||
foreach my $trigger (sort keys %{ $factoids->{$from} }) {
|
||||
if($factoids->{$from}->{$trigger}->{type} eq 'regex') {
|
||||
if ($factoids->{$from}->{$trigger}->{type} eq 'regex') {
|
||||
$text .= $trigger . " ";
|
||||
}
|
||||
}
|
||||
return "Stored regexs for channel $from: $text";
|
||||
}
|
||||
|
||||
if(not defined $text) {
|
||||
if (not defined $text) {
|
||||
return "Usage: regex <regex> <command>";
|
||||
}
|
||||
|
||||
my ($channel, $trigger) = $self->{pbot}->{factoids}->find_factoid($from, $keyword, undef, 1, 1);
|
||||
|
||||
if(defined $trigger) {
|
||||
if (defined $trigger) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host attempt to overwrite $trigger\n");
|
||||
return "/say $trigger already exists for channel $channel.";
|
||||
}
|
||||
@ -930,7 +930,7 @@ sub factadd {
|
||||
}
|
||||
}
|
||||
|
||||
if(not defined $from_chan or not defined $text or not defined $keyword) {
|
||||
if (not defined $from_chan or not defined $text or not defined $keyword) {
|
||||
return "Usage: factadd [channel] <keyword> <factoid>";
|
||||
}
|
||||
|
||||
@ -950,13 +950,13 @@ sub factadd {
|
||||
my $keyword_text = $keyword =~ / / ? "\"$keyword\"" : $keyword;
|
||||
|
||||
my ($channel, $trigger) = $self->{pbot}->{factoids}->find_factoid($from_chan, $keyword, undef, 1, 1);
|
||||
if(defined $trigger) {
|
||||
if (defined $trigger) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host attempt to overwrite $keyword\n");
|
||||
return "/say $keyword_text already exists for " . ($from_chan eq '.*' ? 'the global channel' : $from_chan) . ".";
|
||||
}
|
||||
|
||||
($channel, $trigger) = $self->{pbot}->{factoids}->find_factoid('.*', $keyword, undef, 1, 1);
|
||||
if(defined $trigger and $self->{pbot}->{factoids}->{factoids}->hash->{'.*'}->{$trigger}->{'nooverride'}) {
|
||||
if (defined $trigger and $self->{pbot}->{factoids}->{factoids}->hash->{'.*'}->{$trigger}->{'nooverride'}) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host attempt to override $keyword_text\n");
|
||||
return "/say $keyword_text already exists for the global channel and cannot be overridden for " . ($from_chan eq '.*' ? 'the global channel' : $from_chan) . ".";
|
||||
}
|
||||
@ -991,7 +991,7 @@ sub factrem {
|
||||
|
||||
my $trigger_text = $trigger =~ / / ? "\"$trigger\"" : $trigger;;
|
||||
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'module') {
|
||||
if ($factoids->{$channel}->{$trigger}->{type} eq 'module') {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host attempted to remove $trigger_text [not factoid]\n");
|
||||
return "/say $trigger_text is not a factoid.";
|
||||
}
|
||||
@ -1002,13 +1002,13 @@ sub factrem {
|
||||
|
||||
my ($owner) = $factoids->{$channel}->{$trigger}->{'owner'} =~ m/([^!]+)/;
|
||||
|
||||
if((lc $nick ne lc $owner) and (not $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host"))) {
|
||||
if ((lc $nick ne lc $owner) and (not $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host"))) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host attempted to remove $trigger_text [not owner]\n");
|
||||
my $chan = ($channel eq '.*' ? 'the global channel' : $channel);
|
||||
return "You are not the owner of $trigger_text for $chan";
|
||||
}
|
||||
|
||||
if($factoids->{$channel}->{$trigger}->{'locked'}) {
|
||||
if ($factoids->{$channel}->{$trigger}->{'locked'}) {
|
||||
return "/say $trigger_text is locked; unlock before deleting.";
|
||||
}
|
||||
|
||||
@ -1027,7 +1027,7 @@ sub histogram {
|
||||
|
||||
foreach my $channel (keys %$factoids) {
|
||||
foreach my $command (keys %{ $factoids->{$channel} }) {
|
||||
if($factoids->{$channel}->{$command}->{type} eq 'text') {
|
||||
if ($factoids->{$channel}->{$command}->{type} eq 'text') {
|
||||
$hash{$factoids->{$channel}->{$command}->{owner}}++;
|
||||
$factoid_count++;
|
||||
}
|
||||
@ -1065,7 +1065,7 @@ sub factshow {
|
||||
|
||||
my $result = "$trigger_text: " . $factoids->{$channel}->{$trigger}->{action};
|
||||
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'module') {
|
||||
if ($factoids->{$channel}->{$trigger}->{type} eq 'module') {
|
||||
$result .= ' [module]';
|
||||
}
|
||||
|
||||
@ -1170,19 +1170,19 @@ sub factinfo {
|
||||
$chan = ($channel eq '.*' ? 'global channel' : $channel);
|
||||
|
||||
# factoid
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'text') {
|
||||
if ($factoids->{$channel}->{$trigger}->{type} eq 'text') {
|
||||
return "/say $trigger: Factoid submitted by " . $factoids->{$channel}->{$trigger}->{owner} . " for $chan on " . localtime($factoids->{$channel}->{$trigger}->{created_on}) . " [$created_ago], " . (defined $factoids->{$channel}->{$trigger}->{edited_by} ? "last edited by $factoids->{$channel}->{$trigger}->{edited_by} on " . localtime($factoids->{$channel}->{$trigger}->{edited_on}) . " [" . ago(gettimeofday - $factoids->{$channel}->{$trigger}->{edited_on}) . "], " : "") . "referenced " . $factoids->{$channel}->{$trigger}->{ref_count} . " times (last by " . $factoids->{$channel}->{$trigger}->{ref_user} . (exists $factoids->{$channel}->{$trigger}->{last_referenced_on} ? " on " . localtime($factoids->{$channel}->{$trigger}->{last_referenced_on}) . " [$ref_ago]" : "") . ")";
|
||||
}
|
||||
|
||||
# module
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'module') {
|
||||
if ($factoids->{$channel}->{$trigger}->{type} eq 'module') {
|
||||
my $module_repo = $self->{pbot}->{registry}->get_value('general', 'module_repo');
|
||||
$module_repo .= "$factoids->{$channel}->{$trigger}->{workdir}/" if exists $factoids->{$channel}->{$trigger}->{workdir};
|
||||
return "/say $trigger: Module loaded by " . $factoids->{$channel}->{$trigger}->{owner} . " for $chan on " . localtime($factoids->{$channel}->{$trigger}->{created_on}) . " [$created_ago] -> $module_repo" . $factoids->{$channel}->{$trigger}->{action} . ", used " . $factoids->{$channel}->{$trigger}->{ref_count} . " times (last by " . $factoids->{$channel}->{$trigger}->{ref_user} . (exists $factoids->{$channel}->{$trigger}->{last_referenced_on} ? " on " . localtime($factoids->{$channel}->{$trigger}->{last_referenced_on}) . " [$ref_ago]" : "") . ")";
|
||||
}
|
||||
|
||||
# regex
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'regex') {
|
||||
if ($factoids->{$channel}->{$trigger}->{type} eq 'regex') {
|
||||
return "/say $trigger: Regex created by " . $factoids->{$channel}->{$trigger}->{owner} . " for $chan on " . localtime($factoids->{$channel}->{$trigger}->{created_on}) . " [$created_ago], " . (defined $factoids->{$channel}->{$trigger}->{edited_by} ? "last edited by $factoids->{$channel}->{$trigger}->{edited_by} on " . localtime($factoids->{$channel}->{$trigger}->{edited_on}) . " [" . ago(gettimeofday - $factoids->{$channel}->{$trigger}->{edited_on}) . "], " : "") . " used " . $factoids->{$channel}->{$trigger}->{ref_count} . " times (last by " . $factoids->{$channel}->{$trigger}->{ref_user} . (exists $factoids->{$channel}->{$trigger}->{last_referenced_on} ? " on " . localtime($factoids->{$channel}->{$trigger}->{last_referenced_on}) . " [$ref_ago]" : "") . ")";
|
||||
}
|
||||
|
||||
@ -1199,15 +1199,15 @@ sub top20 {
|
||||
|
||||
my ($channel, $args) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||
|
||||
if(not defined $channel) {
|
||||
if (not defined $channel) {
|
||||
return "Usage: top20 <channel> [nick or 'recent']";
|
||||
}
|
||||
|
||||
if(not defined $args) {
|
||||
if (not defined $args) {
|
||||
foreach my $chan (sort keys %{ $factoids }) {
|
||||
next if lc $chan ne lc $channel;
|
||||
foreach my $command (sort {$factoids->{$chan}->{$b}{ref_count} <=> $factoids->{$chan}->{$a}{ref_count}} keys %{ $factoids->{$chan} }) {
|
||||
if($factoids->{$chan}->{$command}{ref_count} > 0 and $factoids->{$chan}->{$command}{type} eq 'text') {
|
||||
if ($factoids->{$chan}->{$command}{ref_count} > 0 and $factoids->{$chan}->{$command}{type} eq 'text') {
|
||||
$text .= "$command ($factoids->{$chan}->{$command}{ref_count}) ";
|
||||
$i++;
|
||||
last if $i >= 20;
|
||||
@ -1218,7 +1218,7 @@ sub top20 {
|
||||
return $text;
|
||||
}
|
||||
} else {
|
||||
if(lc $args eq "recent") {
|
||||
if (lc $args eq "recent") {
|
||||
foreach my $chan (sort keys %{ $factoids }) {
|
||||
next if lc $chan ne lc $channel;
|
||||
foreach my $command (sort { $factoids->{$chan}->{$b}{created_on} <=> $factoids->{$chan}->{$a}{created_on} } keys %{ $factoids->{$chan} }) {
|
||||
@ -1239,8 +1239,8 @@ sub top20 {
|
||||
foreach my $chan (sort keys %{ $factoids }) {
|
||||
next if lc $chan ne lc $channel;
|
||||
foreach my $command (sort { ($factoids->{$chan}->{$b}{last_referenced_on} || 0) <=> ($factoids->{$chan}->{$a}{last_referenced_on} || 0) } keys %{ $factoids->{$chan} }) {
|
||||
if($factoids->{$chan}->{$command}{ref_user} =~ /\Q$args\E/i) {
|
||||
if($user ne lc $factoids->{$chan}->{$command}{ref_user} && not $user =~ /$factoids->{$chan}->{$command}{ref_user}/i) {
|
||||
if ($factoids->{$chan}->{$command}{ref_user} =~ /\Q$args\E/i) {
|
||||
if ($user ne lc $factoids->{$chan}->{$command}{ref_user} && not $user =~ /$factoids->{$chan}->{$command}{ref_user}/i) {
|
||||
$user .= " ($factoids->{$chan}->{$command}{ref_user})";
|
||||
}
|
||||
my $ago = $factoids->{$chan}->{$command}{last_referenced_on} ? ago(gettimeofday - $factoids->{$chan}->{$command}{last_referenced_on}) : "unknown";
|
||||
@ -1266,14 +1266,14 @@ sub count {
|
||||
return "Usage: count <nick|factoids>";
|
||||
}
|
||||
|
||||
$arguments = ".*" if($arguments =~ /^factoids$/);
|
||||
$arguments = ".*" if ($arguments =~ /^factoids$/);
|
||||
|
||||
eval {
|
||||
foreach my $channel (keys %{ $factoids }) {
|
||||
foreach my $command (keys %{ $factoids->{$channel} }) {
|
||||
next if $factoids->{$channel}->{$command}->{type} ne 'text';
|
||||
$total++;
|
||||
if($factoids->{$channel}->{$command}->{owner} =~ /^\Q$arguments\E$/i) {
|
||||
if ($factoids->{$channel}->{$command}->{owner} =~ /^\Q$arguments\E$/i) {
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -1283,7 +1283,7 @@ sub count {
|
||||
|
||||
return "I have $i factoids." if $arguments eq ".*";
|
||||
|
||||
if($i > 0) {
|
||||
if ($i > 0) {
|
||||
my $percent = int($i / $total * 100);
|
||||
$percent = 1 if $percent == 0;
|
||||
return "/say $arguments has submitted $i factoids out of $total ($percent"."%)";
|
||||
@ -1299,7 +1299,7 @@ sub factfind {
|
||||
|
||||
my $usage = "Usage: factfind [-channel channel] [-owner regex] [-editby regex] [-refby regex] [-regex] [text]";
|
||||
|
||||
if(not defined $arguments) {
|
||||
if (not defined $arguments) {
|
||||
return $usage;
|
||||
}
|
||||
|
||||
@ -1323,38 +1323,38 @@ sub factfind {
|
||||
|
||||
my $argtype = undef;
|
||||
|
||||
if($owner ne '.*') {
|
||||
if ($owner ne '.*') {
|
||||
$argtype = "owned by $owner";
|
||||
}
|
||||
|
||||
if($refby ne '.*') {
|
||||
if(not defined $argtype) {
|
||||
if ($refby ne '.*') {
|
||||
if (not defined $argtype) {
|
||||
$argtype = "last referenced by $refby";
|
||||
} else {
|
||||
$argtype .= " and last referenced by $refby";
|
||||
}
|
||||
}
|
||||
|
||||
if($editby ne '.*') {
|
||||
if(not defined $argtype) {
|
||||
if ($editby ne '.*') {
|
||||
if (not defined $argtype) {
|
||||
$argtype = "last edited by $editby";
|
||||
} else {
|
||||
$argtype .= " and last edited by $editby";
|
||||
}
|
||||
}
|
||||
|
||||
if($arguments ne "") {
|
||||
if ($arguments ne "") {
|
||||
my $unquoted_args = $arguments;
|
||||
$unquoted_args =~ s/(?:\\(?!\\))//g;
|
||||
$unquoted_args =~ s/(?:\\\\)/\\/g;
|
||||
if(not defined $argtype) {
|
||||
if (not defined $argtype) {
|
||||
$argtype = "with text containing '$unquoted_args'";
|
||||
} else {
|
||||
$argtype .= " and with text containing '$unquoted_args'";
|
||||
}
|
||||
}
|
||||
|
||||
if(not defined $argtype) {
|
||||
if (not defined $argtype) {
|
||||
return $usage;
|
||||
}
|
||||
|
||||
@ -1375,15 +1375,15 @@ sub factfind {
|
||||
foreach my $chan (sort keys %{ $factoids }) {
|
||||
next if defined $channel and $chan !~ /^$channel$/i;
|
||||
foreach my $trigger (sort keys %{ $factoids->{$chan} }) {
|
||||
if($factoids->{$chan}->{$trigger}->{type} eq 'text' or $factoids->{$chan}->{$trigger}->{type} eq 'regex') {
|
||||
if($factoids->{$chan}->{$trigger}->{owner} =~ /^$owner$/i
|
||||
if ($factoids->{$chan}->{$trigger}->{type} eq 'text' or $factoids->{$chan}->{$trigger}->{type} eq 'regex') {
|
||||
if ($factoids->{$chan}->{$trigger}->{owner} =~ /^$owner$/i
|
||||
&& $factoids->{$chan}->{$trigger}->{ref_user} =~ /^$refby$/i
|
||||
&& (exists $factoids->{$chan}->{$trigger}->{edited_by} ? $factoids->{$chan}->{$trigger}->{edited_by} =~ /^$editby$/i : 1)) {
|
||||
next if($arguments ne "" && $factoids->{$chan}->{$trigger}->{action} !~ /$regex/i && $trigger !~ /$regex/i);
|
||||
next if ($arguments ne "" && $factoids->{$chan}->{$trigger}->{action} !~ /$regex/i && $trigger !~ /$regex/i);
|
||||
|
||||
$i++;
|
||||
|
||||
if($chan ne $last_chan) {
|
||||
if ($chan ne $last_chan) {
|
||||
$text .= $chan eq '.*' ? "[global channel] " : "[$chan] ";
|
||||
$last_chan = $chan;
|
||||
}
|
||||
@ -1401,7 +1401,7 @@ sub factfind {
|
||||
|
||||
return "/msg $nick $arguments: $@" if $@;
|
||||
|
||||
if($i == 1) {
|
||||
if ($i == 1) {
|
||||
chop $text;
|
||||
return "Found one factoid submitted for " . ($last_chan eq '.*' ? 'global channel' : $last_chan) . " " . $argtype . ": $last_trigger is $factoids->{$last_chan}->{$last_trigger}->{action}";
|
||||
} else {
|
||||
@ -1568,11 +1568,11 @@ sub load_module {
|
||||
my $factoids = $self->{pbot}->{factoids}->{factoids}->hash;
|
||||
my ($keyword, $module) = $arguments =~ /^(.*?)\s+(.*)$/ if defined $arguments;
|
||||
|
||||
if(not defined $module) {
|
||||
if (not defined $module) {
|
||||
return "Usage: load <keyword> <module>";
|
||||
}
|
||||
|
||||
if(not exists($factoids->{'.*'}->{$keyword})) {
|
||||
if (not exists($factoids->{'.*'}->{$keyword})) {
|
||||
$self->{pbot}->{factoids}->add_factoid('module', '.*', "$nick!$user\@$host", $keyword, $module);
|
||||
$factoids->{'.*'}->{$keyword}->{add_nick} = 1;
|
||||
$factoids->{'.*'}->{$keyword}->{nooverride} = 1;
|
||||
@ -1589,11 +1589,11 @@ sub unload_module {
|
||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||
my $factoids = $self->{pbot}->{factoids}->{factoids}->hash;
|
||||
|
||||
if(not defined $arguments) {
|
||||
if (not defined $arguments) {
|
||||
return "Usage: unload <keyword>";
|
||||
} elsif(not exists $factoids->{'.*'}->{$arguments}) {
|
||||
} elsif (not exists $factoids->{'.*'}->{$arguments}) {
|
||||
return "/say $arguments not found.";
|
||||
} elsif($factoids->{'.*'}->{$arguments}{type} ne 'module') {
|
||||
} elsif ($factoids->{'.*'}->{$arguments}{type} ne 'module') {
|
||||
return "/say $arguments is not a module.";
|
||||
} else {
|
||||
delete $factoids->{'.*'}->{$arguments};
|
||||
|
@ -18,10 +18,10 @@ use Text::Balanced qw(extract_delimited);
|
||||
use JSON;
|
||||
|
||||
# automatically reap children processes in background
|
||||
$SIG{CHLD} = sub { while(waitpid(-1, WNOHANG) > 0) {} };
|
||||
$SIG{CHLD} = sub { while (waitpid(-1, WNOHANG) > 0) {} };
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to Commands should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
|
||||
my $pbot = delete $conf{pbot};
|
||||
if(not defined $pbot) {
|
||||
if (not defined $pbot) {
|
||||
Carp::croak("Missing pbot reference to PBot::FactoidModuleLauncher");
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ sub execute_module {
|
||||
|
||||
my @factoids = $self->{pbot}->{factoids}->find_factoid($stuff->{from}, $stuff->{keyword}, undef, 2, 2);
|
||||
|
||||
if(not @factoids or not $factoids[0]) {
|
||||
if (not @factoids or not $factoids[0]) {
|
||||
$stuff->{checkflood} = 1;
|
||||
$self->{pbot}->{interpreter}->handle_result($stuff, "/msg $stuff->{nick} Failed to find module for '$stuff->{keyword}' in channel $stuff->{from}\n");
|
||||
return;
|
||||
@ -86,7 +86,7 @@ sub execute_module {
|
||||
if ($self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{modulelauncher_subpattern} =~ m/s\/(.*?)\/(.*)\/(.*)/) {
|
||||
my ($p1, $p2, $p3) = ($1, $2, $3);
|
||||
my ($a, $b, $c, $d, $e, $f, $g, $h, $i, $before, $after);
|
||||
if($p3 eq 'g') {
|
||||
if ($p3 eq 'g') {
|
||||
$stuff->{arguments} =~ s/$p1/$p2/g;
|
||||
($a, $b, $c, $d, $e, $f, $g, $h, $i, $before, $after) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $`, $');
|
||||
} else {
|
||||
@ -113,12 +113,12 @@ sub execute_module {
|
||||
$self->{arguments} = "";
|
||||
|
||||
my $lr;
|
||||
while(1) {
|
||||
while (1) {
|
||||
my ($e, $r, $p) = extract_delimited($argsbuf, "'", "[^']+");
|
||||
|
||||
$lr = $r if not defined $lr;
|
||||
|
||||
if(defined $e) {
|
||||
if (defined $e) {
|
||||
$e =~ s/\\([^\w])/$1/g;
|
||||
$e =~ s/'/'\\''/g;
|
||||
$e =~ s/^'\\''/'/;
|
||||
@ -135,7 +135,7 @@ sub execute_module {
|
||||
pipe(my $reader, my $writer);
|
||||
my $pid = fork;
|
||||
|
||||
if(not defined $pid) {
|
||||
if (not defined $pid) {
|
||||
$self->{pbot}->{logger}->log("Could not fork module: $!\n");
|
||||
close $reader;
|
||||
close $writer;
|
||||
@ -146,7 +146,7 @@ sub execute_module {
|
||||
|
||||
# FIXME -- add check to ensure $module exists
|
||||
|
||||
if($pid == 0) { # start child block
|
||||
if ($pid == 0) { # start child block
|
||||
close $reader;
|
||||
|
||||
# don't quit the IRC client when the child dies
|
||||
@ -154,12 +154,12 @@ sub execute_module {
|
||||
*PBot::IRC::Connection::DESTROY = sub { return; };
|
||||
use warnings;
|
||||
|
||||
if(not chdir $module_dir) {
|
||||
if (not chdir $module_dir) {
|
||||
$self->{pbot}->{logger}->log("Could not chdir to '$module_dir': $!\n");
|
||||
Carp::croak("Could not chdir to '$module_dir': $!");
|
||||
}
|
||||
|
||||
if(exists $self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{workdir}) {
|
||||
if (exists $self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{workdir}) {
|
||||
chdir $self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{workdir};
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ use PBot::Utils::Indefinite;
|
||||
use PBot::Utils::ValidateString;
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to Factoids should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ sub remove_factoid {
|
||||
|
||||
delete $self->{factoids}->hash->{$channel}->{$trigger};
|
||||
|
||||
if(not scalar keys %{ $self->{factoids}->hash->{$channel} }) {
|
||||
if (not scalar keys %{ $self->{factoids}->hash->{$channel} }) {
|
||||
delete $self->{factoids}->hash->{$channel};
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ sub export_factoids {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->export_path; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->export_path; }
|
||||
return if not defined $filename;
|
||||
|
||||
open FILE, "> $filename" or return "Could not open export path.";
|
||||
@ -197,9 +197,9 @@ sub export_factoids {
|
||||
$table_id++;
|
||||
|
||||
foreach my $trigger (sort keys %{ $self->{factoids}->hash->{$channel} }) {
|
||||
if($self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'text') {
|
||||
if ($self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'text') {
|
||||
$i++;
|
||||
if($i % 2) {
|
||||
if ($i % 2) {
|
||||
print FILE "<tr bgcolor=\"#dddddd\">\n";
|
||||
} else {
|
||||
print FILE "<tr>\n";
|
||||
@ -219,7 +219,7 @@ sub export_factoids {
|
||||
$action = encode_entities($action);
|
||||
}
|
||||
|
||||
if(exists $self->{factoids}->hash->{$channel}->{$trigger}->{action_with_args}) {
|
||||
if (exists $self->{factoids}->hash->{$channel}->{$trigger}->{action_with_args}) {
|
||||
my $with_args = $self->{factoids}->hash->{$channel}->{$trigger}->{action_with_args};
|
||||
$with_args =~ s/(.*?)http(s?:\/\/[^ ]+)/encode_entities($1) . "<a href='http" . encode_entities($2) . "'>http" . encode_entities($2) . "<\/a>"/ge;
|
||||
$with_args =~ s/(.*)<\/a>(.*$)/"$1<\/a>" . encode_entities($2)/e;
|
||||
@ -228,7 +228,7 @@ sub export_factoids {
|
||||
print FILE "<td width=100%><b>" . encode_entities($trigger) . "</b> is $action</td>\n";
|
||||
}
|
||||
|
||||
if(exists $self->{factoids}->hash->{$channel}->{$trigger}->{edited_by}) {
|
||||
if (exists $self->{factoids}->hash->{$channel}->{$trigger}->{edited_by}) {
|
||||
print FILE "<td>" . $self->{factoids}->hash->{$channel}->{$trigger}->{edited_by} . "</td>\n";
|
||||
print FILE "<td>" . encode_entities(strftime "%Y/%m/%d %H:%M:%S", localtime $self->{factoids}->hash->{$channel}->{$trigger}->{edited_on}) . "</td>\n";
|
||||
} else {
|
||||
@ -238,7 +238,7 @@ sub export_factoids {
|
||||
|
||||
print FILE "<td>" . encode_entities($self->{factoids}->hash->{$channel}->{$trigger}->{ref_user}) . "</td>\n";
|
||||
|
||||
if(exists $self->{factoids}->hash->{$channel}->{$trigger}->{last_referenced_on}) {
|
||||
if (exists $self->{factoids}->hash->{$channel}->{$trigger}->{last_referenced_on}) {
|
||||
print FILE "<td>" . encode_entities(strftime "%Y/%m/%d %H:%M:%S", localtime $self->{factoids}->hash->{$channel}->{$trigger}->{last_referenced_on}) . "</td>\n";
|
||||
} else {
|
||||
print FILE "<td></td>\n";
|
||||
@ -256,7 +256,7 @@ sub export_factoids {
|
||||
print FILE "<script type='text/javascript'>\n";
|
||||
$table_id--;
|
||||
print FILE '$(document).ready(function() {' . "\n";
|
||||
while($table_id > 0) {
|
||||
while ($table_id > 0) {
|
||||
print FILE '$("#table' . $table_id . '").tablesorter();' . "\n";
|
||||
print FILE '$("#table' . $table_id . '").tableFilter();' . "\n";
|
||||
$table_id--;
|
||||
@ -297,8 +297,8 @@ sub find_factoid {
|
||||
return undef if $self->{pbot}->{commands}->exists($keyword);
|
||||
# check factoids
|
||||
foreach my $channel (sort keys %{ $self->{factoids}->hash }) {
|
||||
if($exact_channel) {
|
||||
if(defined $exact_trigger && $exact_trigger == 1) {
|
||||
if ($exact_channel) {
|
||||
if (defined $exact_trigger && $exact_trigger == 1) {
|
||||
next unless $from eq lc $channel;
|
||||
} else {
|
||||
next unless $from eq lc $channel or $channel eq '.*';
|
||||
@ -306,12 +306,12 @@ sub find_factoid {
|
||||
}
|
||||
|
||||
foreach my $trigger (keys %{ $self->{factoids}->hash->{$channel} }) {
|
||||
if($keyword =~ m/^\Q$trigger\E$/i) {
|
||||
if ($keyword =~ m/^\Q$trigger\E$/i) {
|
||||
$self->{pbot}->{logger}->log("return $channel: $trigger\n") if $debug;
|
||||
|
||||
if($find_alias && $self->{factoids}->hash->{$channel}->{$trigger}->{action} =~ /^\/call\s+(.*)$/) {
|
||||
if ($find_alias && $self->{factoids}->hash->{$channel}->{$trigger}->{action} =~ /^\/call\s+(.*)$/) {
|
||||
my $command;
|
||||
if(length $arguments) {
|
||||
if (length $arguments) {
|
||||
$command = "$1 $arguments";
|
||||
} else {
|
||||
$command = $1;
|
||||
@ -330,19 +330,19 @@ sub find_factoid {
|
||||
}
|
||||
|
||||
# then check regex factoids
|
||||
if(not $exact_trigger) {
|
||||
if (not $exact_trigger) {
|
||||
foreach my $channel (sort keys %{ $self->{factoids}->hash }) {
|
||||
if($exact_channel) {
|
||||
if ($exact_channel) {
|
||||
next unless $from eq lc $channel or $channel eq '.*';
|
||||
}
|
||||
|
||||
foreach my $trigger (sort keys %{ $self->{factoids}->hash->{$channel} }) {
|
||||
if($self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'regex') {
|
||||
if ($self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'regex') {
|
||||
$self->{pbot}->{logger}->log("checking regex $string =~ m/$trigger/i\n") if $debug >= 2;
|
||||
if($string =~ m/$trigger/i) {
|
||||
if ($string =~ m/$trigger/i) {
|
||||
$self->{pbot}->{logger}->log("return regex $channel: $trigger\n") if $debug;
|
||||
|
||||
if($find_alias) {
|
||||
if ($find_alias) {
|
||||
my $command = $self->{factoids}->hash->{$channel}->{$trigger}->{action};
|
||||
($keyword, $arguments) = split /\s+/, $command, 2;
|
||||
$string = $keyword . (length $arguments ? " $arguments" : "");
|
||||
@ -374,7 +374,7 @@ sub find_factoid {
|
||||
return @results;
|
||||
};
|
||||
|
||||
if($@) {
|
||||
if ($@) {
|
||||
$self->{pbot}->{logger}->log("find_factoid: bad regex: $@\n");
|
||||
return undef;
|
||||
}
|
||||
@ -419,7 +419,7 @@ sub expand_factoid_vars {
|
||||
my $debug = 0;
|
||||
my $depth = 0;
|
||||
while (1) {
|
||||
last if ++$depth >= 100;
|
||||
last if ++$depth >= 1000;
|
||||
|
||||
my $offset = 0;
|
||||
my $matches = 0;
|
||||
@ -1104,7 +1104,7 @@ sub handle_action {
|
||||
return "/say $keyword_text is $action";
|
||||
}
|
||||
}
|
||||
} elsif($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'regex') {
|
||||
} elsif ($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'regex') {
|
||||
my $result = eval {
|
||||
my $string = "$stuff->{original_keyword}" . (defined $stuff->{arguments} ? " $stuff->{arguments}" : "");
|
||||
my $cmd;
|
||||
@ -1133,7 +1133,7 @@ sub handle_action {
|
||||
return $self->{pbot}->{interpreter}->interpret($stuff);
|
||||
};
|
||||
|
||||
if($@) {
|
||||
if ($@) {
|
||||
$self->{pbot}->{logger}->log("Regex fail: $@\n");
|
||||
return "";
|
||||
}
|
||||
@ -1152,19 +1152,19 @@ sub handle_action {
|
||||
sub export_path {
|
||||
my $self = shift;
|
||||
|
||||
if(@_) { $self->{export_path} = shift; }
|
||||
if (@_) { $self->{export_path} = shift; }
|
||||
return $self->{export_path};
|
||||
}
|
||||
|
||||
sub logger {
|
||||
my $self = shift;
|
||||
if(@_) { $self->{logger} = shift; }
|
||||
if (@_) { $self->{logger} = shift; }
|
||||
return $self->{logger};
|
||||
}
|
||||
|
||||
sub export_site {
|
||||
my $self = shift;
|
||||
if(@_) { $self->{export_site} = shift; }
|
||||
if (@_) { $self->{export_site} = shift; }
|
||||
return $self->{export_site};
|
||||
}
|
||||
|
||||
@ -1176,7 +1176,7 @@ sub factoids {
|
||||
sub filename {
|
||||
my $self = shift;
|
||||
|
||||
if(@_) { $self->{filename} = shift; }
|
||||
if (@_) { $self->{filename} = shift; }
|
||||
return $self->{filename};
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ use Text::Levenshtein qw(fastdistance);
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to HashObject should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -40,9 +40,9 @@ sub initialize {
|
||||
sub load_hash_add {
|
||||
my ($self, $index_key, $hash, $i, $filename) = @_;
|
||||
|
||||
if(defined $hash) {
|
||||
if(exists $self->hash->{$index_key}) {
|
||||
if($i) {
|
||||
if (defined $hash) {
|
||||
if (exists $self->hash->{$index_key}) {
|
||||
if ($i) {
|
||||
Carp::croak "Duplicate hash '$index_key' found in $filename around line $i\n";
|
||||
} else {
|
||||
return undef;
|
||||
@ -61,16 +61,16 @@ sub load {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->filename; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->filename; }
|
||||
|
||||
if(not defined $filename) {
|
||||
if (not defined $filename) {
|
||||
Carp::carp "No $self->{name} filename specified -- skipping loading from file";
|
||||
return;
|
||||
}
|
||||
|
||||
$self->{pbot}->{logger}->log("Loading $self->{name} objects from $filename ...\n");
|
||||
|
||||
if(not open(FILE, "< $filename")) {
|
||||
if (not open(FILE, "< $filename")) {
|
||||
Carp::carp "Couldn't open $filename: $!\n";
|
||||
Carp::carp "Skipping loading from file.\n";
|
||||
return;
|
||||
@ -85,12 +85,12 @@ sub load {
|
||||
$line =~ s/^\s+//;
|
||||
$line =~ s/\s+$//;
|
||||
|
||||
if($line =~ /^\[(.*)\]$/) {
|
||||
if ($line =~ /^\[(.*)\]$/) {
|
||||
$index_key = $1;
|
||||
next;
|
||||
}
|
||||
|
||||
if($line eq '') {
|
||||
if ($line eq '') {
|
||||
# store the old hash
|
||||
$self->load_hash_add($index_key, $hash, $i, $filename);
|
||||
|
||||
@ -101,7 +101,7 @@ sub load {
|
||||
|
||||
my ($key, $value) = split /\:/, $line, 2;
|
||||
|
||||
if(not defined $key or not defined $value) {
|
||||
if (not defined $key or not defined $value) {
|
||||
Carp::croak "Error around line $i of $filename\n";
|
||||
}
|
||||
|
||||
@ -122,9 +122,9 @@ sub save {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->filename; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->filename; }
|
||||
|
||||
if(not defined $filename) {
|
||||
if (not defined $filename) {
|
||||
Carp::carp "No $self->{name} filename specified -- skipping saving to file.\n";
|
||||
return;
|
||||
}
|
||||
@ -152,7 +152,7 @@ sub find_hash {
|
||||
|
||||
my $result = eval {
|
||||
foreach my $index (keys %{ $self->hash }) {
|
||||
if($keyword =~ m/^\Q$index\E$/i) {
|
||||
if ($keyword =~ m/^\Q$index\E$/i) {
|
||||
return $index;
|
||||
}
|
||||
}
|
||||
@ -160,7 +160,7 @@ sub find_hash {
|
||||
return undef;
|
||||
};
|
||||
|
||||
if($@) {
|
||||
if ($@) {
|
||||
$self->{pbot}->{logger}->log("find_hash: bad regex: $@\n");
|
||||
return undef;
|
||||
}
|
||||
@ -182,7 +182,7 @@ sub levenshtein_matches {
|
||||
|
||||
# print "Percentage: ", $distance / $length, "\n";
|
||||
|
||||
if($length != 0 && $distance / $length < 0.50) {
|
||||
if ($length != 0 && $distance / $length < 0.50) {
|
||||
$result .= $comma . $index;
|
||||
$comma = ", ";
|
||||
}
|
||||
@ -198,24 +198,24 @@ sub set {
|
||||
|
||||
my $hash_index = $self->find_hash($index);
|
||||
|
||||
if(not $hash_index) {
|
||||
if (not $hash_index) {
|
||||
my $result = "No such $self->{name} object '$index'; similiar matches: ";
|
||||
$result .= $self->levenshtein_matches($index);
|
||||
return $result;
|
||||
}
|
||||
|
||||
if(not defined $key) {
|
||||
if (not defined $key) {
|
||||
my $result = "[$self->{name}] $hash_index keys: ";
|
||||
my $comma = '';
|
||||
foreach my $k (sort keys %{ $self->hash->{$hash_index} }) {
|
||||
$result .= $comma . "$k => " . $self->hash->{$hash_index}{$k};
|
||||
$comma = "; ";
|
||||
}
|
||||
$result .= "none" if($comma eq '');
|
||||
$result .= "none" if ($comma eq '');
|
||||
return $result;
|
||||
}
|
||||
|
||||
if(not defined $value) {
|
||||
if (not defined $value) {
|
||||
$value = $self->hash->{$hash_index}{$key};
|
||||
} else {
|
||||
$self->hash->{$hash_index}{$key} = $value;
|
||||
@ -230,7 +230,7 @@ sub unset {
|
||||
|
||||
my $hash_index = $self->find_hash($index);
|
||||
|
||||
if(not $hash_index) {
|
||||
if (not $hash_index) {
|
||||
my $result = "No such $self->{name} object '$index'; similiar matches: ";
|
||||
$result .= $self->levenshtein_matches($index);
|
||||
return $result;
|
||||
@ -245,7 +245,7 @@ sub unset {
|
||||
sub add {
|
||||
my ($self, $index_key, $hash) = @_;
|
||||
|
||||
if($self->load_hash_add($index_key, $hash, 0)) {
|
||||
if ($self->load_hash_add($index_key, $hash, 0)) {
|
||||
$self->save();
|
||||
} else {
|
||||
return "Error occurred adding new $self->{name} object.";
|
||||
@ -259,7 +259,7 @@ sub remove {
|
||||
|
||||
my $hash_index = $self->find_hash($index);
|
||||
|
||||
if(not $hash_index) {
|
||||
if (not $hash_index) {
|
||||
my $result = "No such $self->{name} object '$index'; similiar matches: ";
|
||||
$result .= $self->levenshtein_matches($index);
|
||||
return $result;
|
||||
@ -281,7 +281,7 @@ sub hash {
|
||||
sub filename {
|
||||
my $self = shift;
|
||||
|
||||
if(@_) { $self->{filename} = shift; }
|
||||
if (@_) { $self->{filename} = shift; }
|
||||
return $self->{filename};
|
||||
}
|
||||
|
||||
|
12
PBot/IRC.pm
12
PBot/IRC.pm
@ -125,9 +125,9 @@ sub do_one_loop {
|
||||
|
||||
$time = time(); # no use calling time() all the time.
|
||||
|
||||
if(!$self->outputqueue->is_empty) {
|
||||
if (!$self->outputqueue->is_empty) {
|
||||
my $outputevent = undef;
|
||||
while(defined($outputevent = $self->outputqueue->head)
|
||||
while (defined($outputevent = $self->outputqueue->head)
|
||||
&& $outputevent->time <= $time) {
|
||||
$outputevent = $self->outputqueue->dequeue();
|
||||
$outputevent->content->{coderef}->(@{$outputevent->content->{args}});
|
||||
@ -141,13 +141,13 @@ sub do_one_loop {
|
||||
return if $caller eq 'PBot::IRC::flush_output_queue'; # pragma_ 2011/01/21
|
||||
|
||||
# Check the queue for scheduled events to run.
|
||||
if(!$self->schedulequeue->is_empty) {
|
||||
if (!$self->schedulequeue->is_empty) {
|
||||
my $scheduledevent = undef;
|
||||
while(defined($scheduledevent = $self->schedulequeue->head) && $scheduledevent->time <= $time) {
|
||||
while (defined($scheduledevent = $self->schedulequeue->head) && $scheduledevent->time <= $time) {
|
||||
$scheduledevent = $self->schedulequeue->dequeue();
|
||||
$scheduledevent->content->{coderef}->(@{$scheduledevent->content->{args}});
|
||||
}
|
||||
if(!$self->schedulequeue->is_empty()
|
||||
if (!$self->schedulequeue->is_empty()
|
||||
&& $nexttimer
|
||||
&& $self->schedulequeue->head->time < $nexttimer) {
|
||||
$nexttimer = $self->schedulequeue->head->time;
|
||||
@ -183,7 +183,7 @@ sub do_one_loop {
|
||||
sub flush_output_queue {
|
||||
my $self = shift;
|
||||
|
||||
while(!$self->outputqueue->is_empty()) {
|
||||
while (!$self->outputqueue->is_empty()) {
|
||||
$self->do_one_loop();
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ use Carp;
|
||||
# sometimes even perl is braindead...
|
||||
|
||||
eval 'use Time::HiRes qw(time)';
|
||||
if(!$@) {
|
||||
if (!$@) {
|
||||
sub time ();
|
||||
use subs 'time';
|
||||
require Time::HiRes;
|
||||
@ -264,10 +264,10 @@ sub connect {
|
||||
$self->quit("Changing servers");
|
||||
}
|
||||
|
||||
if($self->ssl) {
|
||||
if ($self->ssl) {
|
||||
require IO::Socket::SSL;
|
||||
|
||||
if($self->ssl_ca_file) {
|
||||
if ($self->ssl_ca_file) {
|
||||
$self->socket(IO::Socket::SSL->new(PeerAddr => $self->server,
|
||||
PeerPort => $self->port,
|
||||
Proto => "tcp",
|
||||
@ -275,7 +275,7 @@ sub connect {
|
||||
SSL_verify_mode => IO::Socket::SSL->SSL_VERIFY_PEER,
|
||||
SSL_ca_file => $self->ssl_ca_file,
|
||||
));
|
||||
} elsif($self->ssl_ca_path) {
|
||||
} elsif ($self->ssl_ca_path) {
|
||||
$self->socket(IO::Socket::SSL->new(PeerAddr => $self->server,
|
||||
PeerPort => $self->port,
|
||||
Proto => "tcp",
|
||||
@ -300,7 +300,7 @@ sub connect {
|
||||
));
|
||||
}
|
||||
|
||||
if(!$self->socket) {
|
||||
if (!$self->socket) {
|
||||
carp (sprintf "Can't connect to %s:%s!",
|
||||
$self->server, $self->port);
|
||||
$self->error(1);
|
||||
@ -502,7 +502,7 @@ sub handler {
|
||||
print STDERR "Trying to handle event '$ev'.\n" if $self->{_debug};
|
||||
|
||||
|
||||
if($self->{_debug}) {
|
||||
if ($self->{_debug}) {
|
||||
use Data::Dumper;
|
||||
print STDERR "ev: ", Dumper($ev), "\nevent: ", Dumper($event), "\n";
|
||||
}
|
||||
@ -842,7 +842,7 @@ sub notice {
|
||||
|
||||
my ($buf, $length, $line) = (CORE::join("", @_), $self->{_maxlinelen});
|
||||
|
||||
while(length($buf) > 0) {
|
||||
while (length($buf) > 0) {
|
||||
($line, $buf) = unpack("a$length a*", $buf);
|
||||
$self->sl("NOTICE $to :$line");
|
||||
}
|
||||
@ -941,7 +941,7 @@ sub parse {
|
||||
$type = lc $type;
|
||||
|
||||
# fix splitting of IPv6 hostnames in modes -- pragma- 2013/07/30
|
||||
if($type eq "mode" and $#stuff > -1 and length $line) {
|
||||
if ($type eq "mode" and $#stuff > -1 and length $line) {
|
||||
my @other_stuff = split /\s+/, $line;
|
||||
$stuff[$#stuff] .= ':' . shift @other_stuff;
|
||||
push @stuff, @other_stuff;
|
||||
@ -1236,12 +1236,12 @@ sub privmsg {
|
||||
my $line;
|
||||
|
||||
if (ref($to) =~ /^(GLOB|IO::Socket)/) {
|
||||
while(length($buf) > 0) {
|
||||
while (length($buf) > 0) {
|
||||
($line, $buf) = unpack("a$length a*", $buf);
|
||||
send($to, $line . "\012", 0);
|
||||
}
|
||||
} else {
|
||||
while(length($buf) > 0) {
|
||||
while (length($buf) > 0) {
|
||||
($line, $buf) = unpack("a$length a*", $buf);
|
||||
if (ref $to eq 'ARRAY') {
|
||||
$self->sl("PRIVMSG ", CORE::join(',', @$to), " :$line");
|
||||
@ -1303,10 +1303,10 @@ sub schedule {
|
||||
my $time = shift;
|
||||
my $coderef = shift;
|
||||
|
||||
unless($coderef) {
|
||||
unless ($coderef) {
|
||||
croak 'Not enough arguments to Connection->schedule()';
|
||||
}
|
||||
unless(ref($coderef) eq 'CODE') {
|
||||
unless (ref($coderef) eq 'CODE') {
|
||||
croak 'Second argument to schedule() isn\'t a coderef';
|
||||
}
|
||||
|
||||
@ -1320,10 +1320,10 @@ sub schedule_output_event {
|
||||
my $time = shift;
|
||||
my $coderef = shift;
|
||||
|
||||
unless($coderef) {
|
||||
unless ($coderef) {
|
||||
croak 'Not enough arguments to Connection->schedule()';
|
||||
}
|
||||
unless(ref($coderef) eq 'CODE') {
|
||||
unless (ref($coderef) eq 'CODE') {
|
||||
croak 'Second argument to schedule() isn\'t a coderef';
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ sub new {
|
||||
|
||||
$fh = defined $handle ? $handle : IO::File->new(">$filename");
|
||||
|
||||
unless(defined $fh) {
|
||||
unless (defined $fh) {
|
||||
carp "Can't open $filename for writing: $!";
|
||||
$sock = new IO::Socket::INET( Proto => "tcp",
|
||||
PeerAddr => "$address:$port" ) and
|
||||
@ -254,7 +254,7 @@ sub parse {
|
||||
my $line = $self->_getline($_[0], 'BLOCKS');
|
||||
|
||||
next unless defined $line;
|
||||
unless(print {$self->{_fh}} $line) {
|
||||
unless (print {$self->{_fh}} $line) {
|
||||
carp ("Error writing to " . $self->{_filename} . ": $!");
|
||||
close $self->{_fh};
|
||||
$self->{_parent}->parent->removeconn($self);
|
||||
@ -482,7 +482,7 @@ sub parse {
|
||||
return;
|
||||
}
|
||||
|
||||
unless($self->{_socket}->send($buf)) {
|
||||
unless ($self->{_socket}->send($buf)) {
|
||||
|
||||
if ($self->{_debug}) {
|
||||
warn "send() failed horribly in DCC SEND"
|
||||
|
@ -69,7 +69,7 @@ sub args {
|
||||
my $self = shift;
|
||||
my $args = shift;
|
||||
|
||||
if($args) {
|
||||
if ($args) {
|
||||
my (@q, $i, $ct) = @{$args}; # This line is solemnly dedicated to \mjd.
|
||||
|
||||
$self->{'args'} = [ ];
|
||||
|
@ -34,11 +34,11 @@ sub dequeue {
|
||||
my $event = shift;
|
||||
my $result;
|
||||
|
||||
if(!$event) { # we got passed nothing, so return the first event
|
||||
if (!$event) { # we got passed nothing, so return the first event
|
||||
$event = $self->head();
|
||||
delete $self->queue->{$event->id};
|
||||
$result = $event;
|
||||
} elsif(!ref($event)) { # we got passed an id
|
||||
} elsif (!ref($event)) { # we got passed an id
|
||||
$result = $self->queue->{$event};
|
||||
delete $self->queue->{$event};
|
||||
} else { # we got passed an actual event object
|
||||
|
@ -16,7 +16,7 @@ use PBot::IgnoreListCommands;
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ sub add {
|
||||
my $self = shift;
|
||||
my ($hostmask, $channel, $length) = @_;
|
||||
|
||||
if($length < 0) {
|
||||
if ($length < 0) {
|
||||
$self->{ignore_list}->{$hostmask}->{$channel} = -1;
|
||||
} else {
|
||||
$self->{ignore_list}->{$hostmask}->{$channel} = gettimeofday + $length;
|
||||
@ -79,9 +79,9 @@ sub load_ignores {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
|
||||
if(not defined $filename) {
|
||||
if (not defined $filename) {
|
||||
Carp::carp "No ignorelist path specified -- skipping loading of ignorelist";
|
||||
return;
|
||||
}
|
||||
@ -100,11 +100,11 @@ sub load_ignores {
|
||||
|
||||
my ($hostmask, $channel, $length) = split(/\s+/, $line);
|
||||
|
||||
if(not defined $hostmask || not defined $channel || not defined $length) {
|
||||
if (not defined $hostmask || not defined $channel || not defined $length) {
|
||||
Carp::croak "Syntax error around line $i of $filename\n";
|
||||
}
|
||||
|
||||
if(exists ${ $self->{ignore_list} }{$hostmask}{$channel}) {
|
||||
if (exists ${ $self->{ignore_list} }{$hostmask}{$channel}) {
|
||||
Carp::croak "Duplicate ignore [$hostmask][$channel] found in $filename around line $i\n";
|
||||
}
|
||||
|
||||
@ -119,9 +119,9 @@ sub save_ignores {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
|
||||
if(not defined $filename) {
|
||||
if (not defined $filename) {
|
||||
Carp::carp "No ignorelist path specified -- skipping saving of ignorelist\n";
|
||||
return;
|
||||
}
|
||||
@ -148,25 +148,25 @@ sub check_ignore {
|
||||
|
||||
my $now = gettimeofday;
|
||||
|
||||
if(defined $channel) { # do not execute following if text is coming from STDIN ($channel undef)
|
||||
if($channel =~ /^#/) {
|
||||
if (defined $channel) { # do not execute following if text is coming from STDIN ($channel undef)
|
||||
if ($channel =~ /^#/) {
|
||||
$self->{ignore_flood_counter}->{$channel}++;
|
||||
}
|
||||
|
||||
if(not exists $self->{last_timestamp}->{$channel}) {
|
||||
if (not exists $self->{last_timestamp}->{$channel}) {
|
||||
$self->{last_timestamp}->{$channel} = $now;
|
||||
} elsif($now - $self->{last_timestamp}->{$channel} >= 30) {
|
||||
} elsif ($now - $self->{last_timestamp}->{$channel} >= 30) {
|
||||
$self->{last_timestamp}->{$channel} = $now;
|
||||
if(exists $self->{ignore_flood_counter}->{$channel} and $self->{ignore_flood_counter}->{$channel} > 0) {
|
||||
if (exists $self->{ignore_flood_counter}->{$channel} and $self->{ignore_flood_counter}->{$channel} > 0) {
|
||||
$self->{ignore_flood_counter}->{$channel} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
=cut
|
||||
if(exists $self->{ignore_flood_counter}->{$channel} and $self->{ignore_flood_counter}->{$channel} > 5) {
|
||||
if (exists $self->{ignore_flood_counter}->{$channel} and $self->{ignore_flood_counter}->{$channel} > 5) {
|
||||
$self->{commands}->ignore_user("", "floodcontrol", "", "", ".* $channel 300");
|
||||
$self->{ignore_flood_counter}->{$channel} = 0;
|
||||
if($channel =~ /^#/) {
|
||||
if ($channel =~ /^#/) {
|
||||
$pbot->{conn}->me($channel, "has been overwhelmed.");
|
||||
$pbot->{conn}->me($channel, "lies down and falls asleep.");
|
||||
return 1;
|
||||
@ -183,7 +183,7 @@ sub check_ignore {
|
||||
$ignored_channel_escaped =~ s/\\(\.|\*)/$1/g;
|
||||
$ignored_escaped =~ s/\\(\.|\*)/$1/g;
|
||||
|
||||
if(($channel =~ /$ignored_channel_escaped/i) && ($hostmask =~ /$ignored_escaped/i)) {
|
||||
if (($channel =~ /$ignored_channel_escaped/i) && ($hostmask =~ /$ignored_escaped/i)) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host message ignored in channel $channel (matches [$ignored] host and [$ignored_channel] channel)\n") unless $silent;
|
||||
return 1;
|
||||
}
|
||||
@ -198,12 +198,12 @@ sub check_ignore_timeouts {
|
||||
|
||||
foreach my $hostmask (keys %{ $self->{ignore_list} }) {
|
||||
foreach my $channel (keys %{ $self->{ignore_list}->{$hostmask} }) {
|
||||
next if($self->{ignore_list}->{$hostmask}->{$channel} == -1); #permanent ignore
|
||||
next if ($self->{ignore_list}->{$hostmask}->{$channel} == -1); #permanent ignore
|
||||
|
||||
if($self->{ignore_list}->{$hostmask}->{$channel} < $now) {
|
||||
if ($self->{ignore_list}->{$hostmask}->{$channel} < $now) {
|
||||
$self->{pbot}->{logger}->log("Unignoring $hostmask in channel $channel.\n");
|
||||
$self->remove($hostmask, $channel);
|
||||
if($hostmask eq ".*") {
|
||||
if ($hostmask eq ".*") {
|
||||
$self->{pbot}->{conn}->me($channel, "awakens.");
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use Carp ();
|
||||
use PBot::Utils::ParseDate;
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to IgnoreListCommands should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
|
||||
my $pbot = delete $conf{pbot};
|
||||
if(not defined $pbot) {
|
||||
if (not defined $pbot) {
|
||||
Carp::croak("Missing pbot reference to IgnoreListCommands");
|
||||
}
|
||||
|
||||
@ -52,11 +52,11 @@ sub ignore_user {
|
||||
|
||||
my ($target, $channel, $length) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3);
|
||||
|
||||
if(not defined $target) {
|
||||
if (not defined $target) {
|
||||
return "/msg $nick Usage: ignore host [channel] [timeout]";
|
||||
}
|
||||
|
||||
if($target =~ /^list$/i) {
|
||||
if ($target =~ /^list$/i) {
|
||||
my $text = "Ignored: ";
|
||||
my $sep = "";
|
||||
|
||||
@ -69,11 +69,11 @@ sub ignore_user {
|
||||
return "/msg $nick $text";
|
||||
}
|
||||
|
||||
if(not defined $channel) {
|
||||
if (not defined $channel) {
|
||||
$channel = ".*"; # all channels
|
||||
}
|
||||
|
||||
if(not defined $length) {
|
||||
if (not defined $length) {
|
||||
$length = -1; # permanently
|
||||
} else {
|
||||
my $error;
|
||||
@ -98,15 +98,15 @@ sub unignore_user {
|
||||
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($target, $channel) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||
|
||||
if(not defined $target) {
|
||||
if (not defined $target) {
|
||||
return "/msg $nick Usage: unignore host [channel]";
|
||||
}
|
||||
|
||||
if(not defined $channel) {
|
||||
if (not defined $channel) {
|
||||
$channel = ".*";
|
||||
}
|
||||
|
||||
if(exists $self->{pbot}->{ignorelist}->{ignore_list}->{$target} and not exists $self->{pbot}->{ignorelist}->{ignore_list}->{$target}->{$channel}) {
|
||||
if (exists $self->{pbot}->{ignorelist}->{ignore_list}->{$target} and not exists $self->{pbot}->{ignorelist}->{ignore_list}->{$target}->{$channel}) {
|
||||
$self->{pbot}->{logger}->log("$nick attempt to remove nonexistent [$target][$channel] from ignore list\n");
|
||||
return "/msg $nick [$target][$channel] not found in ignore list (use `ignore list` to list ignores)";
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ use Carp ();
|
||||
use PBot::Utils::ValidateString;
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ sub interpret {
|
||||
$self->{pbot}->{logger}->log(Dumper $stuff);
|
||||
}
|
||||
|
||||
return "Too many levels of recursion, aborted." if(++$stuff->{interpret_depth} > $self->{pbot}->{registry}->get_value('interpreter', 'max_recursion'));
|
||||
return "Too many levels of recursion, aborted." if (++$stuff->{interpret_depth} > $self->{pbot}->{registry}->get_value('interpreter', 'max_recursion'));
|
||||
|
||||
if (not defined $stuff->{nick} || not defined $stuff->{user} || not defined $stuff->{host} || not defined $stuff->{command}) {
|
||||
$pbot->{logger}->log("Error 1, bad parameters to interpret_command\n");
|
||||
@ -308,7 +308,7 @@ sub interpret {
|
||||
}
|
||||
}
|
||||
|
||||
if(not defined $keyword) {
|
||||
if (not defined $keyword) {
|
||||
$pbot->{logger}->log("Error 2, no keyword\n");
|
||||
return undef;
|
||||
}
|
||||
@ -430,9 +430,9 @@ sub truncate_result {
|
||||
my ($self, $from, $nick, $text, $original_result, $result, $paste) = @_;
|
||||
my $max_msg_len = $self->{pbot}->{registry}->get_value('irc', 'max_msg_len');
|
||||
|
||||
if(length $result > $max_msg_len) {
|
||||
if (length $result > $max_msg_len) {
|
||||
my $link;
|
||||
if($paste) {
|
||||
if ($paste) {
|
||||
$original_result = substr $original_result, 0, 8000;
|
||||
$link = $self->{pbot}->{webpaste}->paste("[" . (defined $from ? $from : "stdin") . "] <$nick> $text\n\n$original_result");
|
||||
} else {
|
||||
@ -518,7 +518,7 @@ sub handle_result {
|
||||
my ($cmd, $args) = $self->split_args($cmdlist, 2);
|
||||
if (not $self->{pbot}->{commands}->exists($cmd)) {
|
||||
my ($chan, $trigger) = $self->{pbot}->{factoids}->find_factoid($stuff->{from}, $cmd, $args, 1, 0, 1);
|
||||
if(defined $trigger) {
|
||||
if (defined $trigger) {
|
||||
if ($stuff->{preserve_whitespace} == 0) {
|
||||
$stuff->{preserve_whitespace} = $self->{pbot}->{factoids}->{factoids}->hash->{$chan}->{$trigger}->{preserve_whitespace};
|
||||
$stuff->{preserve_whitespace} = 0 if not defined $stuff->{preserve_whitespace};
|
||||
|
@ -20,7 +20,7 @@ use Time::Duration;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to LagChecker should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ sub on_pong {
|
||||
|
||||
my $lag_history_max = $self->{pbot}->{registry}->get_value('lagchecker', 'lag_history_max');
|
||||
|
||||
while($len > $lag_history_max) {
|
||||
while ($len > $lag_history_max) {
|
||||
shift @{ $self->{lag_history} };
|
||||
$len--;
|
||||
}
|
||||
@ -116,7 +116,7 @@ sub on_pong {
|
||||
sub lagging {
|
||||
my $self = shift;
|
||||
|
||||
if(defined $self->{pong_received} and $self->{pong_received} == 0) {
|
||||
if (defined $self->{pong_received} and $self->{pong_received} == 0) {
|
||||
# a ping has been sent (pong_received is not undef) and no pong has been received yet
|
||||
my $elapsed = tv_interval($self->{ping_send_time});
|
||||
return $elapsed >= $self->{pbot}->{registry}->get_value('lagchecker', 'lag_threshold');
|
||||
@ -136,7 +136,7 @@ sub lagstring {
|
||||
sub lagcheck {
|
||||
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
||||
|
||||
if(defined $self->{pong_received} and $self->{pong_received} == 0) {
|
||||
if (defined $self->{pong_received} and $self->{pong_received} == 0) {
|
||||
# a ping has been sent (pong_received is not undef) and no pong has been received yet
|
||||
my $elapsed = tv_interval($self->{ping_send_time});
|
||||
my $lag_total = $elapsed;
|
||||
|
@ -10,7 +10,7 @@ use strict;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to Logger should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ sub new {
|
||||
|
||||
my $log_file = delete $conf{log_file};
|
||||
|
||||
if(defined $log_file) {
|
||||
if (defined $log_file) {
|
||||
open PLOG_FILE, ">>$log_file" or Carp::croak "Couldn't open log file: $!\n" if defined $log_file;
|
||||
PLOG_FILE->autoflush(1);
|
||||
}
|
||||
@ -38,7 +38,7 @@ sub log {
|
||||
|
||||
$text =~ s/(\P{PosixGraph})/my $ch = $1; if ($ch =~ m{[\s]}) { $ch } else { sprintf "\\x%02X", ord $ch }/ge;
|
||||
|
||||
if(defined $self->{log_file}) {
|
||||
if (defined $self->{log_file}) {
|
||||
print PLOG_FILE "$time :: $text";
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ use Carp ();
|
||||
use PBot::MessageHistory_SQLite;
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ sub list_also_known_as {
|
||||
|
||||
my $usage = "Usage: aka [-hingr] <nick>; -h show hostmasks; -i show ids; -n show nickserv accounts; -g show gecos, -r show relationships";
|
||||
|
||||
if(not length $arguments) {
|
||||
if (not length $arguments) {
|
||||
return $usage;
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ sub list_also_known_as {
|
||||
|
||||
my %akas = $self->{database}->get_also_known_as(@$args[0], $dont_use_aliases_table);
|
||||
|
||||
if(%akas) {
|
||||
if (%akas) {
|
||||
my $result = "@$args[0] also known as:\n";
|
||||
|
||||
my %nicks;
|
||||
@ -215,14 +215,14 @@ sub list_also_known_as {
|
||||
sub recall_message {
|
||||
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
||||
|
||||
if(not defined $from) {
|
||||
if (not defined $from) {
|
||||
$self->{pbot}->{logger}->log("Command missing ~from parameter!\n");
|
||||
return "";
|
||||
}
|
||||
|
||||
my $usage = 'Usage: recall [nick [history [channel]]] [-c,channel <channel>] [-t,text,h,history <history>] [-b,before <context before>] [-a,after <context after>] [-x,context <nick>] [-n,count <count>] [+ ...]';
|
||||
|
||||
if(not defined $arguments or not length $arguments) {
|
||||
if (not defined $arguments or not length $arguments) {
|
||||
return $usage;
|
||||
}
|
||||
|
||||
@ -322,10 +322,10 @@ sub recall_message {
|
||||
|
||||
my ($account, $found_nick);
|
||||
|
||||
if(defined $recall_nick) {
|
||||
if (defined $recall_nick) {
|
||||
($account, $found_nick) = $self->{database}->find_message_account_by_nick($recall_nick);
|
||||
|
||||
if(not defined $account) {
|
||||
if (not defined $account) {
|
||||
return "I don't know anybody named $recall_nick.";
|
||||
}
|
||||
|
||||
@ -334,9 +334,9 @@ sub recall_message {
|
||||
|
||||
my $message;
|
||||
|
||||
if($recall_history =~ /^\d+$/) {
|
||||
if ($recall_history =~ /^\d+$/) {
|
||||
# integral history
|
||||
if(defined $account) {
|
||||
if (defined $account) {
|
||||
my $max_messages = $self->{database}->get_max_messages($account, $recall_channel);
|
||||
if ($recall_history < 1 || $recall_history > $max_messages) {
|
||||
if ($max_messages == 0) {
|
||||
@ -364,15 +364,15 @@ sub recall_message {
|
||||
$recall_history--;
|
||||
$message = $self->{database}->recall_message_by_count($account, $recall_channel, $recall_history, '(?:recall|mock)');
|
||||
|
||||
if(not defined $message) {
|
||||
if (not defined $message) {
|
||||
return "No message found at index $recall_history in channel $recall_channel.";
|
||||
}
|
||||
} else {
|
||||
# regex history
|
||||
$message = $self->{database}->recall_message_by_text($account, $recall_channel, $recall_history, '(?:recall|mock)');
|
||||
|
||||
if(not defined $message) {
|
||||
if(defined $account) {
|
||||
if (not defined $message) {
|
||||
if (defined $account) {
|
||||
return "No message for nick $found_nick in channel $recall_channel containing \"$recall_history\"";
|
||||
} else {
|
||||
return "No message in channel $recall_channel containing \"$recall_history\".";
|
||||
@ -385,7 +385,7 @@ sub recall_message {
|
||||
if (defined $recall_context) {
|
||||
($context_account) = $self->{database}->find_message_account_by_nick($recall_context);
|
||||
|
||||
if(not defined $context_account) {
|
||||
if (not defined $context_account) {
|
||||
return "I don't know anybody named $recall_context.";
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use Text::Levenshtein qw/fastdistance/;
|
||||
use Time::Duration;
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ sub end {
|
||||
|
||||
$self->{pbot}->{logger}->log("Closing message history SQLite database\n");
|
||||
|
||||
if(exists $self->{dbh} and defined $self->{dbh}) {
|
||||
if (exists $self->{dbh} and defined $self->{dbh}) {
|
||||
$self->{dbh}->commit() if $self->{new_entries};
|
||||
$self->{dbh}->disconnect();
|
||||
delete $self->{dbh};
|
||||
@ -290,7 +290,7 @@ sub add_message_account {
|
||||
my $id;
|
||||
my ($nick, $user, $host) = $mask =~ m/^([^!]+)!([^@]+)@(.*)/;
|
||||
|
||||
if(defined $link_id and $link_type == $self->{alias_type}->{STRONG}) {
|
||||
if (defined $link_id and $link_type == $self->{alias_type}->{STRONG}) {
|
||||
$id = $link_id;
|
||||
} else {
|
||||
$id = $self->get_new_account_id();
|
||||
@ -302,7 +302,7 @@ sub add_message_account {
|
||||
$sth->execute($mask, $id, scalar gettimeofday, $nick, $user, $host);
|
||||
$self->{new_entries}++;
|
||||
|
||||
if((not defined $link_id) || ((defined $link_id) && ($link_type == $self->{alias_type}->{WEAK}))) {
|
||||
if ((not defined $link_id) || ((defined $link_id) && ($link_type == $self->{alias_type}->{WEAK}))) {
|
||||
$sth = $self->{dbh}->prepare('INSERT INTO Accounts VALUES (?, ?, ?)');
|
||||
$sth->execute($id, $mask, "");
|
||||
$self->{new_entries}++;
|
||||
@ -987,7 +987,7 @@ sub recall_message_by_count {
|
||||
|
||||
my $messages;
|
||||
|
||||
if(defined $id) {
|
||||
if (defined $id) {
|
||||
$messages = eval {
|
||||
if (defined $use_aliases) {
|
||||
my %akas = $self->get_also_known_as($use_aliases);
|
||||
@ -1041,7 +1041,7 @@ sub recall_message_by_count {
|
||||
|
||||
$self->{pbot}->{logger}->log($@) if $@;
|
||||
|
||||
if(defined $ignore_command) {
|
||||
if (defined $ignore_command) {
|
||||
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
||||
my $bot_trigger = $self->{pbot}->{registry}->get_value('general', 'trigger');
|
||||
foreach my $message (@$messages) {
|
||||
@ -1064,7 +1064,7 @@ sub recall_message_by_text {
|
||||
|
||||
my $messages;
|
||||
|
||||
if(defined $id) {
|
||||
if (defined $id) {
|
||||
$messages = eval {
|
||||
my $sth = $self->{dbh}->prepare('SELECT id, msg, mode, timestamp, channel FROM Messages WHERE id = ? AND channel = ? AND msg REGEXP ? ORDER BY timestamp DESC LIMIT 10');
|
||||
$sth->execute($id, $channel, $regex);
|
||||
@ -1080,7 +1080,7 @@ sub recall_message_by_text {
|
||||
|
||||
$self->{pbot}->{logger}->log($@) if $@;
|
||||
|
||||
if(defined $ignore_command) {
|
||||
if (defined $ignore_command) {
|
||||
my $bot_trigger = $self->{pbot}->{registry}->get_value('general', 'trigger');
|
||||
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
||||
foreach my $message (@$messages) {
|
||||
@ -1175,7 +1175,7 @@ sub get_channel_data {
|
||||
my $channel_data = eval {
|
||||
my $sql = 'SELECT ';
|
||||
|
||||
if(not @columns) {
|
||||
if (not @columns) {
|
||||
$sql .= '*';
|
||||
} else {
|
||||
my $comma = '';
|
||||
@ -1782,7 +1782,7 @@ sub commit_message_history {
|
||||
|
||||
return if not $self->{dbh};
|
||||
|
||||
if($self->{new_entries} > 0) {
|
||||
if ($self->{new_entries} > 0) {
|
||||
# $self->{pbot}->{logger}->log("Commiting $self->{new_entries} messages to SQLite\n");
|
||||
eval {
|
||||
$self->{dbh}->commit();
|
||||
|
@ -46,7 +46,7 @@ use PBot::Plugins;
|
||||
use PBot::WebPaste;
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to PBot should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ sub random_nick {
|
||||
sub connect {
|
||||
my ($self, $server) = @_;
|
||||
|
||||
if($self->{connected}) {
|
||||
if ($self->{connected}) {
|
||||
# TODO: disconnect, clean-up, etc
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ sub do_one_loop {
|
||||
|
||||
sub start {
|
||||
my $self = shift;
|
||||
while(1) {
|
||||
while (1) {
|
||||
$self->connect() if not $self->{connected};
|
||||
$self->do_one_loop() if $self->{connected};
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use File::Basename;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ sub on_nickchange {
|
||||
my ($nick, $user, $host, $newnick) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args);
|
||||
|
||||
my $bad_nicks = $self->{pbot}->{registry}->get_value('antiaway', 'bad_nicks');
|
||||
if($newnick =~ m/$bad_nicks/i) {
|
||||
if ($newnick =~ m/$bad_nicks/i) {
|
||||
my $kick_msg = $self->{pbot}->{registry}->get_value('antiaway', 'kick_msg');
|
||||
my $channels = $self->{pbot}->{nicklist}->get_channels($newnick);
|
||||
foreach my $chan (@$channels) {
|
||||
@ -62,7 +62,7 @@ sub on_action {
|
||||
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
|
||||
|
||||
my $bad_actions = $self->{pbot}->{registry}->get_value('antiaway', 'bad_actions');
|
||||
if($msg =~ m/$bad_actions/i) {
|
||||
if ($msg =~ m/$bad_actions/i) {
|
||||
$self->{pbot}->{logger}->log("$nick $msg matches bad away actions regex, kicking...\n");
|
||||
my $kick_msg = $self->{pbot}->{registry}->get_value('antiaway', 'kick_msg');
|
||||
$self->{pbot}->{chanops}->add_op_command($channel, "kick $channel $nick $kick_msg");
|
||||
|
@ -24,7 +24,7 @@ use PBot::Utils::ValidateString;
|
||||
use POSIX qw(strftime);
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to Quotegrabs should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ sub export_quotegrabs {
|
||||
|
||||
my $last_channel = "";
|
||||
foreach my $quotegrab (sort { $$a{channel} cmp $$b{channel} or $$a{nick} cmp $$b{nick} } @$quotegrabs) {
|
||||
if(not $quotegrab->{channel} =~ /^$last_channel$/i) {
|
||||
if (not $quotegrab->{channel} =~ /^$last_channel$/i) {
|
||||
print FILE "<a href='#" . encode_entities($quotegrab->{channel}) . "'>" . encode_entities($quotegrab->{channel}) . "</a><br>\n";
|
||||
$last_channel = $quotegrab->{channel};
|
||||
}
|
||||
@ -85,7 +85,7 @@ sub export_quotegrabs {
|
||||
|
||||
$last_channel = "";
|
||||
foreach my $quotegrab (sort { $$a{channel} cmp $$b{channel} or lc $$a{nick} cmp lc $$b{nick} } @$quotegrabs) {
|
||||
if(not $quotegrab->{channel} =~ /^$last_channel$/i) {
|
||||
if (not $quotegrab->{channel} =~ /^$last_channel$/i) {
|
||||
print FILE "</tbody>\n</table>\n" if $had_table;
|
||||
print FILE "<a name='" . encode_entities($quotegrab->{channel}) . "'></a>\n";
|
||||
print FILE "<hr><h3>" . encode_entities($quotegrab->{channel}) . "</h3><hr>\n";
|
||||
@ -104,7 +104,7 @@ sub export_quotegrabs {
|
||||
$last_channel = $quotegrab->{channel};
|
||||
$i++;
|
||||
|
||||
if($i % 2) {
|
||||
if ($i % 2) {
|
||||
print FILE "<tr bgcolor=\"#dddddd\">\n";
|
||||
} else {
|
||||
print FILE "<tr>\n";
|
||||
@ -119,7 +119,7 @@ sub export_quotegrabs {
|
||||
my $nick;
|
||||
$text = $quotegrab->{text};
|
||||
|
||||
if($text =~ s/^\/me\s+//) {
|
||||
if ($text =~ s/^\/me\s+//) {
|
||||
$nick = "* $nicks[0]";
|
||||
} else {
|
||||
$nick = "<$nicks[0]>";
|
||||
@ -138,7 +138,7 @@ sub export_quotegrabs {
|
||||
print FILE "<script type='text/javascript'>\n";
|
||||
$table_id--;
|
||||
print FILE '$(document).ready(function() {' . "\n";
|
||||
while($table_id > 0) {
|
||||
while ($table_id > 0) {
|
||||
print FILE '$("#table' . $table_id . '").tablesorter();' . "\n";
|
||||
print FILE '$("#table' . $table_id . '").tableFilter();' . "\n";
|
||||
$table_id--;
|
||||
@ -153,12 +153,12 @@ sub export_quotegrabs {
|
||||
sub grab_quotegrab {
|
||||
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
||||
|
||||
if(not defined $from) {
|
||||
if (not defined $from) {
|
||||
$self->{pbot}->{logger}->log("Command missing ~from parameter!\n");
|
||||
return "";
|
||||
}
|
||||
|
||||
if(not defined $arguments or not length $arguments) {
|
||||
if (not defined $arguments or not length $arguments) {
|
||||
return "Usage: grab <nick> [history [channel]] [+ <nick> [history [channel]] ...] -- where [history] is an optional argument that is a regex (without whitespace) of the text within the message; e.g., to grab a message containing 'pizza', use `grab nick pizza`; you can chain grabs with + to grab multiple messages";
|
||||
}
|
||||
|
||||
@ -174,13 +174,13 @@ sub grab_quotegrab {
|
||||
$grab_history = $nick eq $grab_nick ? 2 : 1 if not defined $grab_history; # skip grab command if grabbing self without arguments
|
||||
$channel = $from if not defined $channel;
|
||||
|
||||
if(not $channel =~ m/^#/) {
|
||||
if (not $channel =~ m/^#/) {
|
||||
return "'$channel' is not a valid channel; usage: grab <nick> [[history] channel] (you must specify a history parameter before the channel parameter)";
|
||||
}
|
||||
|
||||
my ($account, $found_nick) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($grab_nick);
|
||||
|
||||
if(not defined $account) {
|
||||
if (not defined $account) {
|
||||
return "I don't know anybody named $grab_nick";
|
||||
}
|
||||
|
||||
@ -190,10 +190,10 @@ sub grab_quotegrab {
|
||||
|
||||
my $message;
|
||||
|
||||
if($grab_history =~ /^\d+$/) {
|
||||
if ($grab_history =~ /^\d+$/) {
|
||||
# integral history
|
||||
my $max_messages = $self->{pbot}->{messagehistory}->{database}->get_max_messages($account, $channel);
|
||||
if($grab_history < 1 || $grab_history > $max_messages) {
|
||||
if ($grab_history < 1 || $grab_history > $max_messages) {
|
||||
return "Please choose a history between 1 and $max_messages";
|
||||
}
|
||||
|
||||
@ -204,14 +204,14 @@ sub grab_quotegrab {
|
||||
# regex history
|
||||
$message = $self->{pbot}->{messagehistory}->{database}->recall_message_by_text($account, $channel, $grab_history, 'grab');
|
||||
|
||||
if(not defined $message) {
|
||||
if (not defined $message) {
|
||||
return "No such message for nick $grab_nick in channel $channel containing text '$grab_history'";
|
||||
}
|
||||
}
|
||||
|
||||
$self->{pbot}->{logger}->log("$nick ($from) grabbed <$grab_nick/$channel> $message->{msg}\n");
|
||||
|
||||
if(not defined $grab_nicks) {
|
||||
if (not defined $grab_nicks) {
|
||||
$grab_nicks = $grab_nick;
|
||||
} else {
|
||||
$grab_nicks .= "+$grab_nick";
|
||||
@ -219,10 +219,10 @@ sub grab_quotegrab {
|
||||
|
||||
my $text = $message->{msg};
|
||||
|
||||
if(not defined $grab_text) {
|
||||
if (not defined $grab_text) {
|
||||
$grab_text = $text;
|
||||
} else {
|
||||
if($text =~ s/^\/me\s+//) {
|
||||
if ($text =~ s/^\/me\s+//) {
|
||||
$grab_text .= " * $grab_nick $text";
|
||||
} else {
|
||||
$grab_text .= " <$grab_nick> $text";
|
||||
@ -240,7 +240,7 @@ sub grab_quotegrab {
|
||||
|
||||
$quotegrab->{id} = $self->{database}->add_quotegrab($quotegrab);
|
||||
|
||||
if(not defined $quotegrab->{id}) {
|
||||
if (not defined $quotegrab->{id}) {
|
||||
return "Failed to grab quote.";
|
||||
}
|
||||
|
||||
@ -267,11 +267,11 @@ sub delete_quotegrab {
|
||||
|
||||
my $quotegrab = $self->{database}->get_quotegrab($arguments);
|
||||
|
||||
if(not defined $quotegrab) {
|
||||
if (not defined $quotegrab) {
|
||||
return "/msg $nick No quotegrab matching id $arguments found.";
|
||||
}
|
||||
|
||||
if(not $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host") and $quotegrab->{grabbed_by} ne "$nick!$user\@$host") {
|
||||
if (not $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host") and $quotegrab->{grabbed_by} ne "$nick!$user\@$host") {
|
||||
return "You are not the grabber of this quote.";
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ sub delete_quotegrab {
|
||||
|
||||
my ($first_nick) = split /\+/, $quotegrab->{nick}, 2;
|
||||
|
||||
if($text =~ s/^\/me\s+//) {
|
||||
if ($text =~ s/^\/me\s+//) {
|
||||
return "Deleted $arguments: * $first_nick $text";
|
||||
} else {
|
||||
return "Deleted $arguments: <$first_nick> $text";
|
||||
@ -294,7 +294,7 @@ sub show_quotegrab {
|
||||
|
||||
my $quotegrab = $self->{database}->get_quotegrab($arguments);
|
||||
|
||||
if(not defined $quotegrab) {
|
||||
if (not defined $quotegrab) {
|
||||
return "/msg $nick No quotegrab matching id $arguments found.";
|
||||
}
|
||||
|
||||
@ -303,7 +303,7 @@ sub show_quotegrab {
|
||||
my $text = $quotegrab->{text};
|
||||
my ($first_nick) = split /\+/, $quotegrab->{nick}, 2;
|
||||
|
||||
if($text =~ s/^\/me\s+//) {
|
||||
if ($text =~ s/^\/me\s+//) {
|
||||
return "$arguments: grabbed by $quotegrab->{grabbed_by} in $quotegrab->{channel} on " . localtime($timestamp) . " [$ago] * $first_nick $text";
|
||||
} else {
|
||||
return "$arguments: grabbed by $quotegrab->{grabbed_by} in $quotegrab->{channel} on " . localtime($timestamp) . " [$ago] <$first_nick> $text";
|
||||
@ -315,14 +315,14 @@ sub show_random_quotegrab {
|
||||
my @quotes = ();
|
||||
my ($nick_search, $channel_search, $text_search);
|
||||
|
||||
if(not defined $from) {
|
||||
if (not defined $from) {
|
||||
$self->{pbot}->{logger}->log("Command missing ~from parameter!\n");
|
||||
return "";
|
||||
}
|
||||
|
||||
my $usage = 'Usage: rq [nick [channel [text]]] [-c,--channel <channel>] [-t,--text <text>]';
|
||||
|
||||
if(defined $arguments) {
|
||||
if (defined $arguments) {
|
||||
my $getopt_error;
|
||||
local $SIG{__WARN__} = sub {
|
||||
$getopt_error = shift;
|
||||
@ -340,13 +340,13 @@ sub show_random_quotegrab {
|
||||
$channel_search = shift @$args if not defined $channel_search;
|
||||
$text_search = shift @$args if not defined $text_search;
|
||||
|
||||
if($nick_search =~ m/^#/) {
|
||||
if ($nick_search =~ m/^#/) {
|
||||
my $tmp = $channel_search;
|
||||
$channel_search = $nick_search;
|
||||
$nick_search = $tmp;
|
||||
}
|
||||
|
||||
if(not defined $channel_search) {
|
||||
if (not defined $channel_search) {
|
||||
$channel_search = $from;
|
||||
}
|
||||
}
|
||||
@ -355,18 +355,18 @@ sub show_random_quotegrab {
|
||||
|
||||
my $quotegrab = $self->{database}->get_random_quotegrab($nick_search, $channel_search, $text_search);
|
||||
|
||||
if(not defined $quotegrab) {
|
||||
if (not defined $quotegrab) {
|
||||
my $result = "No quotes grabbed ";
|
||||
|
||||
if(defined $nick_search) {
|
||||
if (defined $nick_search) {
|
||||
$result .= "for nick $nick_search ";
|
||||
}
|
||||
|
||||
if(defined $channel_search) {
|
||||
if (defined $channel_search) {
|
||||
$result .= "in channel $channel_search ";
|
||||
}
|
||||
|
||||
if(defined $text_search) {
|
||||
if (defined $text_search) {
|
||||
$result .= "matching text '$text_search' ";
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ sub show_random_quotegrab {
|
||||
my $text = $quotegrab->{text};
|
||||
my ($first_nick) = split /\+/, $quotegrab->{nick}, 2;
|
||||
|
||||
if($text =~ s/^\/me\s+//) {
|
||||
if ($text =~ s/^\/me\s+//) {
|
||||
return "$quotegrab->{id}: " . (($channel_search eq '.*' or $quotegrab->{channel} ne $from) ? "[$quotegrab->{channel}] " : "") . "* $first_nick $text";
|
||||
} else {
|
||||
return "$quotegrab->{id}: " . (($channel_search eq '.*' or $quotegrab->{channel} ne $from) ? "[$quotegrab->{channel}] " : "") . "<$first_nick> $text";
|
||||
|
@ -20,7 +20,7 @@ use Getopt::Long qw(GetOptionsFromString);
|
||||
use POSIX qw(strftime);
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ sub load_quotegrabs {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
return if not defined $filename;
|
||||
|
||||
$self->{pbot}->{logger}->log("Loading quotegrabs from $filename ...\n");
|
||||
@ -65,7 +65,7 @@ sub load_quotegrabs {
|
||||
chomp $line;
|
||||
$i++;
|
||||
my ($nick, $channel, $timestamp, $grabbed_by, $text) = split(/\s+/, $line, 5);
|
||||
if(not defined $nick || not defined $channel || not defined $timestamp
|
||||
if (not defined $nick || not defined $channel || not defined $timestamp
|
||||
|| not defined $grabbed_by || not defined $text) {
|
||||
die "Syntax error around line $i of $filename\n";
|
||||
}
|
||||
@ -87,7 +87,7 @@ sub save_quotegrabs {
|
||||
my $self = shift;
|
||||
my $filename;
|
||||
|
||||
if(@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
if (@_) { $filename = shift; } else { $filename = $self->{filename}; }
|
||||
return if not defined $filename;
|
||||
|
||||
open(FILE, "> $filename") or die "Couldn't open $filename: $!\n";
|
||||
@ -112,7 +112,7 @@ sub add_quotegrab {
|
||||
sub delete_quotegrab {
|
||||
my ($self, $id) = @_;
|
||||
|
||||
if($id < 1 || $id > $#{ $self->{quotegrabs} } + 1) {
|
||||
if ($id < 1 || $id > $#{ $self->{quotegrabs} } + 1) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ sub delete_quotegrab {
|
||||
sub get_quotegrab {
|
||||
my ($self, $id) = @_;
|
||||
|
||||
if($id < 1 || $id > $#{ $self->{quotegrabs} } + 1) {
|
||||
if ($id < 1 || $id > $#{ $self->{quotegrabs} } + 1) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -147,19 +147,19 @@ sub get_random_quotegrab {
|
||||
eval {
|
||||
for(my $i = 0; $i <= $#{ $self->{quotegrabs} }; $i++) {
|
||||
my $hash = $self->{quotegrabs}[$i];
|
||||
if($hash->{channel} =~ /$channel/i && $hash->{nick} =~ /$nick/i && $hash->{text} =~ /$text/i) {
|
||||
if ($hash->{channel} =~ /$channel/i && $hash->{nick} =~ /$nick/i && $hash->{text} =~ /$text/i) {
|
||||
$hash->{id} = $i + 1;
|
||||
push @quotes, $hash;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if($@) {
|
||||
if ($@) {
|
||||
$self->{pbot}->{logger}->log("Error in show_random_quotegrab parameters: $@\n");
|
||||
return undef;
|
||||
}
|
||||
|
||||
if($#quotes < 0) {
|
||||
if ($#quotes < 0) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ use DBI;
|
||||
use Carp qw(shortmess);
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ sub end {
|
||||
|
||||
$self->{pbot}->{logger}->log("Closing quotegrabs SQLite database\n");
|
||||
|
||||
if(exists $self->{dbh} and defined $self->{dbh}) {
|
||||
if (exists $self->{dbh} and defined $self->{dbh}) {
|
||||
$self->{dbh}->disconnect();
|
||||
delete $self->{dbh};
|
||||
}
|
||||
@ -119,21 +119,21 @@ sub get_random_quotegrab {
|
||||
my $where = 'WHERE ';
|
||||
my $and = '';
|
||||
|
||||
if(defined $nick) {
|
||||
if (defined $nick) {
|
||||
$sql .= $where . 'nick LIKE ? ';
|
||||
push @params, "$nick";
|
||||
$where = '';
|
||||
$and = 'AND ';
|
||||
}
|
||||
|
||||
if(defined $channel) {
|
||||
if (defined $channel) {
|
||||
$sql .= $where . $and . 'channel LIKE ? ';
|
||||
push @params, $channel;
|
||||
$where = '';
|
||||
$and = 'AND ';
|
||||
}
|
||||
|
||||
if(defined $text) {
|
||||
if (defined $text) {
|
||||
$sql .= $where . $and . 'text LIKE ? ';
|
||||
push @params, "%$text%";
|
||||
}
|
||||
|
@ -314,7 +314,11 @@ sub remindme {
|
||||
}
|
||||
}
|
||||
|
||||
print "alarm: $alarm\n";
|
||||
|
||||
my ($length, $error) = parsedate($alarm);
|
||||
|
||||
print "length: $length, error: $error!\n";
|
||||
return $error if $error;
|
||||
|
||||
# I don't know how I feel about enforcing arbitrary time restrictions
|
||||
|
@ -60,7 +60,7 @@ SQL
|
||||
sub end {
|
||||
my $self = shift;
|
||||
|
||||
if(exists $self->{dbh} and defined $self->{dbh}) {
|
||||
if (exists $self->{dbh} and defined $self->{dbh}) {
|
||||
$self->{pbot}->{logger}->log("Closing stats SQLite database\n");
|
||||
$self->{dbh}->disconnect();
|
||||
delete $self->{dbh};
|
||||
@ -115,7 +115,7 @@ sub get_player_data {
|
||||
my $player_data = eval {
|
||||
my $sql = 'SELECT ';
|
||||
|
||||
if(not @columns) {
|
||||
if (not @columns) {
|
||||
$sql .= '*';
|
||||
} else {
|
||||
my $comma = '';
|
||||
|
@ -62,7 +62,7 @@ sub show_url_titles {
|
||||
return 0 if not defined $nickserv or not length $nickserv;
|
||||
}
|
||||
|
||||
if($self->{pbot}->{registry}->get_value('general', 'show_url_titles')
|
||||
if ($self->{pbot}->{registry}->get_value('general', 'show_url_titles')
|
||||
and not $self->{pbot}->{registry}->get_value($channel, 'no_url_titles')
|
||||
and not grep { $channel =~ /$_/i } $self->{pbot}->{registry}->get_value('general', 'show_url_titles_ignore_channels')
|
||||
and grep { $channel =~ /$_/i } $self->{pbot}->{registry}->get_value('general', 'show_url_titles_channels')) {
|
||||
|
@ -17,7 +17,7 @@ use Module::Refresh;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ use strict;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to Registerable should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -44,12 +44,12 @@ sub execute {
|
||||
my $self = shift;
|
||||
my $ref = shift;
|
||||
|
||||
if(not defined $ref) {
|
||||
if (not defined $ref) {
|
||||
Carp::croak("Missing reference parameter to Registerable::execute");
|
||||
}
|
||||
|
||||
foreach my $func (@{ $self->{handlers} }) {
|
||||
if($ref == $func || $ref == $func->{subref}) {
|
||||
if ($ref == $func || $ref == $func->{subref}) {
|
||||
return &{ $func->{subref} }(@_);
|
||||
}
|
||||
}
|
||||
@ -60,7 +60,7 @@ sub register {
|
||||
my $self = shift;
|
||||
my $subref;
|
||||
|
||||
if(@_) {
|
||||
if (@_) {
|
||||
$subref = shift;
|
||||
} else {
|
||||
Carp::croak("Must pass subroutine reference to register()");
|
||||
@ -76,7 +76,7 @@ sub unregister {
|
||||
my $self = shift;
|
||||
my $ref;
|
||||
|
||||
if(@_) {
|
||||
if (@_) {
|
||||
$ref = shift;
|
||||
} else {
|
||||
Carp::croak("Must pass subroutine reference to unregister()");
|
||||
|
@ -20,7 +20,7 @@ use PBot::DualIndexHashObject;
|
||||
use PBot::RegistryCommands;
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be item/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ sub remove {
|
||||
|
||||
delete $self->{registry}->hash->{$section}->{$item};
|
||||
|
||||
if(not scalar keys %{ $self->{registry}->hash->{$section} }) {
|
||||
if (not scalar keys %{ $self->{registry}->hash->{$section} }) {
|
||||
delete $self->{registry}->hash->{$section};
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ sub set {
|
||||
|
||||
my $result = $self->{registry}->set($section, $item, $key, $value, 1);
|
||||
|
||||
if(defined $key and $key eq 'value' and defined $value and $oldvalue ne $value) {
|
||||
if (defined $key and $key eq 'value' and defined $value and $oldvalue ne $value) {
|
||||
$self->process_trigger($section, $item, $value);
|
||||
}
|
||||
|
||||
@ -151,8 +151,8 @@ sub unset {
|
||||
sub get_value {
|
||||
my ($self, $section, $item, $as_text) = @_;
|
||||
|
||||
if(exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{$item}) {
|
||||
if(not $as_text and $self->{registry}->hash->{$section}->{$item}->{type} eq 'array') {
|
||||
if (exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{$item}) {
|
||||
if (not $as_text and $self->{registry}->hash->{$section}->{$item}->{type} eq 'array') {
|
||||
return split /\s*,\s*/, $self->{registry}->hash->{$section}->{$item}->{value};
|
||||
} else {
|
||||
return $self->{registry}->hash->{$section}->{$item}->{value};
|
||||
@ -164,8 +164,8 @@ sub get_value {
|
||||
sub get_array_value {
|
||||
my ($self, $section, $item, $index) = @_;
|
||||
|
||||
if(exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{$item}) {
|
||||
if($self->{registry}->hash->{$section}->{$item}->{type} eq 'array') {
|
||||
if (exists $self->{registry}->hash->{$section} and exists $self->{registry}->hash->{$section}->{$item}) {
|
||||
if ($self->{registry}->hash->{$section}->{$item}->{type} eq 'array') {
|
||||
my @array = split /\s*,\s*/, $self->{registry}->hash->{$section}->{$item}->{value};
|
||||
return $array[$index >= $#array ? $#array : $index];
|
||||
} else {
|
||||
@ -185,7 +185,7 @@ sub process_trigger {
|
||||
my $self = shift;
|
||||
my ($section, $item) = @_;
|
||||
|
||||
if(exists $self->{triggers}->{$section} and exists $self->{triggers}->{$section}->{$item}) {
|
||||
if (exists $self->{triggers}->{$section} and exists $self->{triggers}->{$section}->{$item}) {
|
||||
return &{ $self->{triggers}->{$section}->{$item} }(@_);
|
||||
}
|
||||
return undef;
|
||||
|
@ -15,7 +15,7 @@ use strict;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ sub regset {
|
||||
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($section, $item, $key, $value) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 4);
|
||||
|
||||
if(not defined $section or not defined $item) {
|
||||
if (not defined $section or not defined $item) {
|
||||
return "Usage: regset <section> <item> [key [value]]";
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ sub regunset {
|
||||
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($section, $item, $key) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3);
|
||||
|
||||
if(not defined $section or not defined $item or not defined $key) {
|
||||
if (not defined $section or not defined $item or not defined $key) {
|
||||
return "Usage: regunset <section> <item> <key>"
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ sub regadd {
|
||||
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($section, $item, $value) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3);
|
||||
|
||||
if(not defined $section or not defined $item or not defined $value) {
|
||||
if (not defined $section or not defined $item or not defined $value) {
|
||||
return "Usage: regadd <section> <item> <value>";
|
||||
}
|
||||
|
||||
@ -87,15 +87,15 @@ sub regrem {
|
||||
my ($from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($section, $item) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||
|
||||
if(not defined $section or not defined $item) {
|
||||
if (not defined $section or not defined $item) {
|
||||
return "Usage: regrem <section> <item>";
|
||||
}
|
||||
|
||||
if(not exists $self->{pbot}->{registry}->{registry}->hash->{$section}) {
|
||||
if (not exists $self->{pbot}->{registry}->{registry}->hash->{$section}) {
|
||||
return "No such registry section $section.";
|
||||
}
|
||||
|
||||
if(not exists $self->{pbot}->{registry}->{registry}->hash->{$section}->{$item}) {
|
||||
if (not exists $self->{pbot}->{registry}->{registry}->hash->{$section}->{$item}) {
|
||||
return "No such item $item in section $section.";
|
||||
}
|
||||
|
||||
@ -111,25 +111,25 @@ sub regshow {
|
||||
|
||||
my ($section, $item) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||
|
||||
if(not defined $section or not defined $item) {
|
||||
if (not defined $section or not defined $item) {
|
||||
return "Usage: regshow <section> <item>";
|
||||
}
|
||||
|
||||
if(not exists $registry->{$section}) {
|
||||
if (not exists $registry->{$section}) {
|
||||
return "No such registry section $section.";
|
||||
}
|
||||
|
||||
if(not exists $registry->{$section}->{$item}) {
|
||||
if (not exists $registry->{$section}->{$item}) {
|
||||
return "No such registry item $item in section $section.";
|
||||
}
|
||||
|
||||
if($registry->{$section}->{$item}->{private}) {
|
||||
if ($registry->{$section}->{$item}->{private}) {
|
||||
return "[$section] $item: <private>";
|
||||
}
|
||||
|
||||
my $result = "[$section] $item: $registry->{$section}->{$item}->{value}";
|
||||
|
||||
if($registry->{$section}->{$item}->{type} eq 'array') {
|
||||
if ($registry->{$section}->{$item}->{type} eq 'array') {
|
||||
$result .= ' [array]';
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ sub regfind {
|
||||
|
||||
my $usage = "Usage: regfind [-showvalues] [-section section] <regex>";
|
||||
|
||||
if(not defined $arguments) {
|
||||
if (not defined $arguments) {
|
||||
return $usage;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ sub regfind {
|
||||
$arguments =~ s/\s+$//;
|
||||
$arguments =~ s/\s+/ /g;
|
||||
|
||||
if($arguments eq "") {
|
||||
if ($arguments eq "") {
|
||||
return $usage;
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ sub regfind {
|
||||
foreach my $section_key (sort keys %{ $registry }) {
|
||||
next if defined $section and $section_key !~ /^$section$/i;
|
||||
foreach my $item_key (sort keys %{ $registry->{$section_key} }) {
|
||||
if($registry->{$section_key}->{$item_key}->{private}) {
|
||||
if ($registry->{$section_key}->{$item_key}->{private}) {
|
||||
# do not match on value if private
|
||||
next if $item_key !~ /$arguments/i;
|
||||
} else {
|
||||
@ -177,12 +177,12 @@ sub regfind {
|
||||
|
||||
$i++;
|
||||
|
||||
if($section_key ne $last_section) {
|
||||
if ($section_key ne $last_section) {
|
||||
$text .= "[$section_key]\n";
|
||||
$last_section = $section_key;
|
||||
}
|
||||
if($showvalues) {
|
||||
if($registry->{$section_key}->{$item_key}->{private}) {
|
||||
if ($showvalues) {
|
||||
if ($registry->{$section_key}->{$item_key}->{private}) {
|
||||
$text .= " $item_key = <private>\n";
|
||||
} else {
|
||||
$text .= " $item_key = $registry->{$section_key}->{$item_key}->{value}" . ($registry->{$section_key}->{$item_key}->{type} eq 'array' ? " [array]\n" : "\n");
|
||||
@ -197,9 +197,9 @@ sub regfind {
|
||||
|
||||
return "/msg $nick $arguments: $@" if $@;
|
||||
|
||||
if($i == 1) {
|
||||
if ($i == 1) {
|
||||
chop $text;
|
||||
if($registry->{$last_section}->{$last_item}->{private}) {
|
||||
if ($registry->{$last_section}->{$last_item}->{private}) {
|
||||
return "Found one registry entry: [$last_section] $last_item: <private>";
|
||||
} else {
|
||||
return "Found one registry entry: [$last_section] $last_item: $registry->{$last_section}->{$last_item}->{value}" . ($registry->{$last_section}->{$last_item}->{type} eq 'array' ? ' [array]' : '');
|
||||
@ -217,37 +217,37 @@ sub regchange {
|
||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||
my ($section, $item, $delim, $tochange, $changeto, $modifier);
|
||||
|
||||
if(defined $arguments) {
|
||||
if($arguments =~ /^([^\s]+) ([^\s]+)\s+s(.)/) {
|
||||
if (defined $arguments) {
|
||||
if ($arguments =~ /^([^\s]+) ([^\s]+)\s+s(.)/) {
|
||||
$section = $1;
|
||||
$item = $2;
|
||||
$delim = $3;
|
||||
}
|
||||
|
||||
if($arguments =~ /$delim(.*?)$delim(.*)$delim(.*)?$/) {
|
||||
if ($arguments =~ /$delim(.*?)$delim(.*)$delim(.*)?$/) {
|
||||
$tochange = $1;
|
||||
$changeto = $2;
|
||||
$modifier = $3;
|
||||
}
|
||||
}
|
||||
|
||||
if(not defined $section or not defined $item or not defined $changeto) {
|
||||
if (not defined $section or not defined $item or not defined $changeto) {
|
||||
return "Usage: regchange <section> <item> s/<pattern>/<replacement>/";
|
||||
}
|
||||
|
||||
my $registry = $self->{pbot}->{registry}->{registry}->hash;
|
||||
|
||||
if(not exists $registry->{$section}) {
|
||||
if (not exists $registry->{$section}) {
|
||||
return "No such registry section $section.";
|
||||
}
|
||||
|
||||
if(not exists $registry->{$section}->{$item}) {
|
||||
if (not exists $registry->{$section}->{$item}) {
|
||||
return "No such registry item $item in section $section.";
|
||||
}
|
||||
|
||||
my $ret = eval {
|
||||
use re::engine::RE2 -strict => 1;
|
||||
if(not $registry->{$section}->{$item}->{value} =~ s|$tochange|$changeto|) {
|
||||
if (not $registry->{$section}->{$item}->{value} =~ s|$tochange|$changeto|) {
|
||||
$self->{pbot}->{logger}->log("($from) $nick!$user\@$host: failed to change [$section] $item 's$delim$tochange$delim$changeto$delim$modifier\n");
|
||||
return "/msg $nick Change [$section] $item failed.";
|
||||
} else {
|
||||
|
@ -33,7 +33,7 @@ sub log
|
||||
|
||||
# DBI feeds us pieces at a time, so accumulate a complete line
|
||||
# before outputing
|
||||
if($self->{buf} =~ tr/\n//) {
|
||||
if ($self->{buf} =~ tr/\n//) {
|
||||
$self->log_message;
|
||||
$self->{buf} = '';
|
||||
}
|
||||
@ -53,7 +53,7 @@ sub log_message {
|
||||
|
||||
sub close {
|
||||
my $self = shift;
|
||||
if($self->{buf}) {
|
||||
if ($self->{buf}) {
|
||||
$self->log_message;
|
||||
$self->{buf} = '';
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ use IO::Select;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to SelectHandler should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -52,13 +52,13 @@ sub do_select {
|
||||
foreach my $fh (@ready) {
|
||||
my $ret = sysread($fh, my $buf, $length);
|
||||
|
||||
if(not defined $ret) {
|
||||
if (not defined $ret) {
|
||||
$self->{pbot}->{logger}->log("Error with $fh: $!\n");
|
||||
$self->remove_reader($fh);
|
||||
next;
|
||||
}
|
||||
|
||||
if($ret == 0) {
|
||||
if ($ret == 0) {
|
||||
if (length $self->{buffers}->{$fh}) {
|
||||
$self->{readers}->{$fh}->($self->{buffers}->{$fh});
|
||||
}
|
||||
@ -68,7 +68,7 @@ sub do_select {
|
||||
|
||||
$self->{buffers}->{$fh} .= $buf;
|
||||
|
||||
if(not exists $self->{readers}->{$fh}) {
|
||||
if (not exists $self->{readers}->{$fh}) {
|
||||
$self->{pbot}->{logger}->log("Error: no reader for $fh\n");
|
||||
} else {
|
||||
if ($ret < $length) {
|
||||
|
@ -11,7 +11,7 @@ use POSIX qw(tcgetpgrp getpgrp); # to check whether process is in background or
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to StdinReader should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ sub stdin_reader {
|
||||
|
||||
my ($from, $text);
|
||||
|
||||
if($input =~ m/^~([^ ]+)\s+(.*)/) {
|
||||
if ($input =~ m/^~([^ ]+)\s+(.*)/) {
|
||||
$from = $1;
|
||||
$text = $self->{pbot}->{registry}->get_value('irc', 'botnick') . " $2";
|
||||
} else {
|
||||
|
@ -35,7 +35,7 @@ $SIG{ALRM} = sub {
|
||||
};
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to Timer should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -87,14 +87,14 @@ sub on_tick_handler {
|
||||
# print "-----\n";
|
||||
# print "on tick handler for $self->{name}\n";
|
||||
|
||||
if($self->{enabled}) {
|
||||
if($#{ $self->{handlers} } > -1) {
|
||||
if ($self->{enabled}) {
|
||||
if ($#{ $self->{handlers} } > -1) {
|
||||
# call handlers supplied via register() if timeout for each has elapsed
|
||||
foreach my $func (@{ $self->{handlers} }) {
|
||||
if(defined $func->{last}) {
|
||||
if (defined $func->{last}) {
|
||||
$func->{last} -= $max_seconds if $seconds < $func->{last}; # handle wrap-around of $seconds
|
||||
|
||||
if($seconds - $func->{last} >= $func->{timeout}) {
|
||||
if ($seconds - $func->{last} >= $func->{timeout}) {
|
||||
$func->{last} = $seconds;
|
||||
$elapsed = 1;
|
||||
}
|
||||
@ -103,19 +103,19 @@ sub on_tick_handler {
|
||||
$elapsed = 1;
|
||||
}
|
||||
|
||||
if($elapsed) {
|
||||
if ($elapsed) {
|
||||
&{ $func->{subref} }($self);
|
||||
$elapsed = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# call default overridable handler if timeout has elapsed
|
||||
if(defined $self->{last}) {
|
||||
if (defined $self->{last}) {
|
||||
# print "$self->{name} last = $self->{last}, seconds: $seconds, timeout: $self->{timeout} " . ($seconds - $self->{last}) . "\n";
|
||||
|
||||
$self->{last} -= $max_seconds if $seconds < $self->{last}; # handle wrap-around
|
||||
|
||||
if($seconds - $self->{last} >= $self->{timeout}) {
|
||||
if ($seconds - $self->{last} >= $self->{timeout}) {
|
||||
$elapsed = 1;
|
||||
$self->{last} = $seconds;
|
||||
}
|
||||
@ -125,7 +125,7 @@ sub on_tick_handler {
|
||||
$self->{last} = $seconds;
|
||||
}
|
||||
|
||||
if($elapsed) {
|
||||
if ($elapsed) {
|
||||
$self->on_tick();
|
||||
$elapsed = 0;
|
||||
}
|
||||
@ -157,11 +157,11 @@ sub register {
|
||||
|
||||
# print "-- Registering timer $ref [$id] at $timeout seconds\n";
|
||||
|
||||
if($timeout < $min_timeout) {
|
||||
if ($timeout < $min_timeout) {
|
||||
$min_timeout = $timeout;
|
||||
}
|
||||
|
||||
if($self->{enabled}) {
|
||||
if ($self->{enabled}) {
|
||||
alarm $min_timeout;
|
||||
}
|
||||
}
|
||||
@ -170,7 +170,7 @@ sub unregister {
|
||||
my $self = shift;
|
||||
my $id;
|
||||
|
||||
if(@_) {
|
||||
if (@_) {
|
||||
$id = shift;
|
||||
} else {
|
||||
Carp::croak("Must pass timer id to unregister()");
|
||||
@ -183,7 +183,7 @@ sub update_interval {
|
||||
my ($self, $id, $interval) = @_;
|
||||
|
||||
foreach my $h (@{ $self->{handlers} }) {
|
||||
if($h->{id} eq $id) {
|
||||
if ($h->{id} eq $id) {
|
||||
$h->{timeout} = $interval;
|
||||
last;
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ sub parsedate {
|
||||
|
||||
my $parse = Time::ParseDate::parsedate($input, NOW => $now);
|
||||
|
||||
print "parsedate: now => $now, input => $input, parse => $parse\n";
|
||||
|
||||
if (not defined $parse) {
|
||||
$input =~ s/\s+$//;
|
||||
return (0, "I don't know what '$input' means. I expected a time duration like '5 minutes' or '24 hours' or 'next tuesday'.\n");
|
||||
|
@ -18,7 +18,7 @@ use LWP::UserAgent;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
if(ref($_[1]) eq 'HASH') {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ sub paste_ixio {
|
||||
my %post = ('f:1' => $text);
|
||||
my $response = $ua->post("http://ix.io", \%post);
|
||||
|
||||
if(not $response->is_success) {
|
||||
if (not $response->is_success) {
|
||||
return "error pasting: " . $response->status_line;
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ sub paste_ptpb {
|
||||
my %post = ( 'c' => $text, 'submit' => 'Submit' );
|
||||
my $response = $ua->post("https://ptpb.pw/?u=1", \%post);
|
||||
|
||||
if(not $response->is_success) {
|
||||
if (not $response->is_success) {
|
||||
return "error pasting: " . $response->status_line;
|
||||
}
|
||||
|
||||
|
@ -34,20 +34,20 @@ $text = $response->content;
|
||||
|
||||
$acro =~ s/\+/ /g;
|
||||
|
||||
if($text =~ m/No result found/)
|
||||
if ($text =~ m/No result found/)
|
||||
{
|
||||
print "Sorry, couldn't figure out what '$acro' stood for.\n";
|
||||
die;
|
||||
}
|
||||
|
||||
$entries = 1;
|
||||
$entries = $1 if($text =~ m/"2">(.*?) results? found/gi);
|
||||
$entries = $1 if ($text =~ m/"2">(.*?) results? found/gi);
|
||||
|
||||
print "$acro ($entries entries): ";
|
||||
|
||||
$acro="";
|
||||
|
||||
while($text =~ m/<td width=.*?>(.*?)<\/td>/gsi)
|
||||
while ($text =~ m/<td width=.*?>(.*?)<\/td>/gsi)
|
||||
{
|
||||
$acro = "$acro$1; ";
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use Time::Duration;
|
||||
|
||||
my ($ago) = @ARGV;
|
||||
|
||||
if(not defined $ago) {
|
||||
if (not defined $ago) {
|
||||
print "Usage: ago <seconds>\n";
|
||||
exit 0;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ my $RESULTS_SPECIFIED = 2;
|
||||
|
||||
my $search = join ' ', @ARGV;
|
||||
|
||||
if(not length $search) {
|
||||
if (not length $search) {
|
||||
print "Usage: c11std [-list] [-n#] [-section <section>] [search text] -- 'section' must be in the form of X.YpZ where X and Y are section/chapter and, optionally, pZ is paragraph. If both 'section' and 'search text' are specified, then the search space will be within the specified section. You may use -n # to skip to the #th match. To list only the section numbers containing 'search text', add -list.\n";
|
||||
exit 0;
|
||||
}
|
||||
@ -25,10 +25,10 @@ my ($section, $paragraph, $section_specified, $paragraph_specified, $match, $lis
|
||||
$section_specified = 0;
|
||||
$paragraph_specified = 0;
|
||||
|
||||
if($search =~ s/-section\s*([A-Z0-9\.p]+)//i or $search =~ s/\b([A-Z0-9]+\.[0-9\.p]+)//i) {
|
||||
if ($search =~ s/-section\s*([A-Z0-9\.p]+)//i or $search =~ s/\b([A-Z0-9]+\.[0-9\.p]+)//i) {
|
||||
$section = $1;
|
||||
|
||||
if($section =~ s/p(\d+)//i) {
|
||||
if ($section =~ s/p(\d+)//i) {
|
||||
$paragraph = $1;
|
||||
$paragraph_specified = $USER_SPECIFIED;
|
||||
} else {
|
||||
@ -40,18 +40,18 @@ if($search =~ s/-section\s*([A-Z0-9\.p]+)//i or $search =~ s/\b([A-Z0-9]+\.[0-9\
|
||||
$section_specified = 1;
|
||||
}
|
||||
|
||||
if($search =~ s/-n\s*(\d+)//) {
|
||||
if ($search =~ s/-n\s*(\d+)//) {
|
||||
$match = $1;
|
||||
} else {
|
||||
$match = 1;
|
||||
}
|
||||
|
||||
if($search =~ s/-list//i) {
|
||||
if ($search =~ s/-list//i) {
|
||||
$list_only = 1;
|
||||
$list_titles = 1; # Added here instead of removing -titles option
|
||||
}
|
||||
|
||||
if($search =~ s/-titles//i) {
|
||||
if ($search =~ s/-titles//i) {
|
||||
$list_only = 1;
|
||||
$list_titles = 1;
|
||||
}
|
||||
@ -59,12 +59,12 @@ if($search =~ s/-titles//i) {
|
||||
$search =~ s/^\s+//;
|
||||
$search =~ s/\s+$//;
|
||||
|
||||
if(not defined $section) {
|
||||
if (not defined $section) {
|
||||
$section = "1.";
|
||||
$paragraph = 1;
|
||||
}
|
||||
|
||||
if($list_only and not length $search) {
|
||||
if ($list_only and not length $search) {
|
||||
print "You must specify some search text to use with -list.\n";
|
||||
exit 0;
|
||||
}
|
||||
@ -86,7 +86,7 @@ my $matches = 0;
|
||||
my $this_section;
|
||||
my $comma = "";
|
||||
|
||||
if($list_only) {
|
||||
if ($list_only) {
|
||||
$result = "Sections containing '$search':\n ";
|
||||
}
|
||||
|
||||
@ -94,28 +94,28 @@ my $qsearch = quotemeta $search;
|
||||
$qsearch =~ s/\\ / /g;
|
||||
$qsearch =~ s/\s+/\\s+/g;
|
||||
|
||||
while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
while ($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
$this_section = $1;
|
||||
|
||||
print "----------------------------------\n" if $debug >= 2;
|
||||
print "Processing section [$this_section]\n" if $debug;
|
||||
|
||||
|
||||
if($section_specified and $this_section !~ m/^$section/i) {
|
||||
if ($section_specified and $this_section !~ m/^$section/i) {
|
||||
print "No section match, skipping.\n" if $debug >= 4;
|
||||
next;
|
||||
}
|
||||
|
||||
my $section_text;
|
||||
|
||||
if($text =~ m/(.*?)^(?=\s{0,4}(?!FOOTNOTE)[0-9A-Z]+\.)/msg) {
|
||||
if ($text =~ m/(.*?)^(?=\s{0,4}(?!FOOTNOTE)[0-9A-Z]+\.)/msg) {
|
||||
$section_text = $1;
|
||||
} else {
|
||||
print "No section text, end of file marker found.\n" if $debug >= 4;
|
||||
last;
|
||||
}
|
||||
|
||||
if($section =~ /FOOTNOTE/i) {
|
||||
if ($section =~ /FOOTNOTE/i) {
|
||||
$section_text =~ s/^\s{4}//ms;
|
||||
$section_text =~ s/^\s{4}FOOTNOTE.*//msi;
|
||||
$section_text =~ s/^\d.*//ms;
|
||||
@ -127,13 +127,13 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
|
||||
print "$this_section [$section_title]\n" if $debug >= 2;
|
||||
|
||||
while($section_text =~ m/^(\d+)\s(.*?)^(?=\d)/msgic or $section_text =~ m/^(\d+)\s(.*)/msgi) {
|
||||
while ($section_text =~ m/^(\d+)\s(.*?)^(?=\d)/msgic or $section_text =~ m/^(\d+)\s(.*)/msgi) {
|
||||
my $p = $1 ;
|
||||
my $t = $2;
|
||||
|
||||
print "paragraph $p: [$t]\n" if $debug >= 3;
|
||||
|
||||
if($paragraph_specified == $USER_SPECIFIED and not length $search and $p == $paragraph) {
|
||||
if ($paragraph_specified == $USER_SPECIFIED and not length $search and $p == $paragraph) {
|
||||
$result = $t if not $found;
|
||||
$found_paragraph = $p;
|
||||
$found_section = $this_section;
|
||||
@ -142,17 +142,17 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
last;
|
||||
}
|
||||
|
||||
if(length $search) {
|
||||
if (length $search) {
|
||||
eval {
|
||||
if($t =~ m/\b$qsearch\b/mis or $section_title =~ m/\b$qsearch\b/mis) {
|
||||
if ($t =~ m/\b$qsearch\b/mis or $section_title =~ m/\b$qsearch\b/mis) {
|
||||
$matches++;
|
||||
if($matches >= $match) {
|
||||
if($list_only) {
|
||||
if ($matches >= $match) {
|
||||
if ($list_only) {
|
||||
$result .= sprintf("%s%-15s", $comma, $this_section."p".$p);
|
||||
$result .= " $section_title" if $list_titles;
|
||||
$comma = ",\n ";
|
||||
} else {
|
||||
if(not $found) {
|
||||
if (not $found) {
|
||||
$result = $t;
|
||||
$found_section = $this_section;
|
||||
$found_section_title = $section_title;
|
||||
@ -165,7 +165,7 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
}
|
||||
};
|
||||
|
||||
if($@) {
|
||||
if ($@) {
|
||||
print "Error in search regex; you may need to escape characters such as *, ?, ., etc.\n";
|
||||
exit 0;
|
||||
}
|
||||
@ -174,8 +174,8 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
|
||||
last if $found && $paragraph_specified == $USER_SPECIFIED;
|
||||
|
||||
if($paragraph_specified == $USER_SPECIFIED) {
|
||||
if(length $search) {
|
||||
if ($paragraph_specified == $USER_SPECIFIED) {
|
||||
if (length $search) {
|
||||
print "No such text '$search' in paragraph $paragraph of section $section of n1570.\n";
|
||||
} else {
|
||||
print "No such paragraph $paragraph in section $section of n1570.\n";
|
||||
@ -183,7 +183,7 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if(defined $section_specified and not length $search) {
|
||||
if (defined $section_specified and not length $search) {
|
||||
$found = 1;
|
||||
$found_section = $this_section;
|
||||
$found_section_title = $section_title;
|
||||
@ -193,9 +193,9 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
}
|
||||
}
|
||||
|
||||
if(not $found and $comma eq "") {
|
||||
if (not $found and $comma eq "") {
|
||||
$search =~ s/\\s\+/ /g;
|
||||
if($section_specified) {
|
||||
if ($section_specified) {
|
||||
print "No such text '$search' found within section '$section' in C11 Draft Standard (n1570).\n" if length $search;
|
||||
print "No such section '$section' in C11 Draft Standard (n1570).\n" if not length $search;
|
||||
exit 0;
|
||||
@ -214,17 +214,17 @@ $result =~ s/\s+/ /g;
|
||||
$result =~ s/[\n\r]/ /g;
|
||||
=cut
|
||||
|
||||
if($matches > 1 and not $list_only) {
|
||||
if ($matches > 1 and not $list_only) {
|
||||
print "Displaying $match of $matches matches: ";
|
||||
}
|
||||
|
||||
if($comma eq "") {
|
||||
if ($comma eq "") {
|
||||
=cut
|
||||
print $found_section;
|
||||
print "p" . $found_paragraph if $paragraph_specified;
|
||||
=cut
|
||||
# print "\nhttp://blackshell.com/~msmud/n1570.html\#$found_section";
|
||||
print "\nhttp://www.iso-9899.info/n1570.html\#$found_section";
|
||||
print "http://www.iso-9899.info/n1570.html\#$found_section";
|
||||
print "p" . $found_paragraph if $paragraph_specified;
|
||||
print "\n\n";
|
||||
print "[", $found_section_title, "]\n\n" if length $found_section_title;
|
||||
|
@ -24,7 +24,7 @@ if (not length $code) {
|
||||
my $output;
|
||||
|
||||
my $force;
|
||||
if($code =~ s/^-f\s+//) {
|
||||
if ($code =~ s/^-f\s+//) {
|
||||
$force = 1;
|
||||
}
|
||||
|
||||
@ -46,18 +46,18 @@ use constant {
|
||||
my $state = NORMAL;
|
||||
my $escaped = 0;
|
||||
|
||||
while($code =~ m/(.)/gs) {
|
||||
while ($code =~ m/(.)/gs) {
|
||||
my $ch = $1;
|
||||
|
||||
given ($ch) {
|
||||
when ('\\') {
|
||||
if($escaped == 0) {
|
||||
if ($escaped == 0) {
|
||||
$escaped = 1;
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
if($state == NORMAL) {
|
||||
if ($state == NORMAL) {
|
||||
when ($_ eq '"' and not $escaped) {
|
||||
$state = DOUBLE_QUOTED;
|
||||
}
|
||||
@ -72,13 +72,13 @@ while($code =~ m/(.)/gs) {
|
||||
}
|
||||
}
|
||||
|
||||
if($state == DOUBLE_QUOTED) {
|
||||
if ($state == DOUBLE_QUOTED) {
|
||||
when ($_ eq '"' and not $escaped) {
|
||||
$state = NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
if($state == SINGLE_QUOTED) {
|
||||
if ($state == SINGLE_QUOTED) {
|
||||
when ($_ eq "'" and not $escaped) {
|
||||
$state = NORMAL;
|
||||
}
|
||||
@ -99,18 +99,18 @@ my $parens = 0;
|
||||
$escaped = 0;
|
||||
my $cpp = 0; # preprocessor
|
||||
|
||||
while($code =~ m/(.)/msg) {
|
||||
while ($code =~ m/(.)/msg) {
|
||||
my $ch = $1;
|
||||
my $pos = pos $code;
|
||||
|
||||
print "adding newlines, ch = [$ch], parens: $parens, cpp: $cpp, single: $single_quote, double: $double_quote, escaped: $escaped, pos: $pos\n" if $debug >= 10;
|
||||
|
||||
if($ch eq '\\') {
|
||||
if ($ch eq '\\') {
|
||||
$escaped = not $escaped;
|
||||
} elsif($ch eq '#' and not $cpp and not $escaped and not $single_quote and not $double_quote) {
|
||||
} elsif ($ch eq '#' and not $cpp and not $escaped and not $single_quote and not $double_quote) {
|
||||
$cpp = 1;
|
||||
|
||||
if($code =~ m/include\s*[<"]([^>"]*)[>"]/msg) {
|
||||
if ($code =~ m/include\s*[<"]([^>"]*)[>"]/msg) {
|
||||
my $match = $1;
|
||||
$pos = pos $code;
|
||||
substr ($code, $pos, 0) = "\n";
|
||||
@ -119,41 +119,41 @@ while($code =~ m/(.)/msg) {
|
||||
} else {
|
||||
pos $code = $pos;
|
||||
}
|
||||
} elsif($ch eq '"') {
|
||||
} elsif ($ch eq '"') {
|
||||
$double_quote = not $double_quote unless $escaped or $single_quote;
|
||||
$escaped = 0;
|
||||
} elsif($ch eq '(' and not $single_quote and not $double_quote) {
|
||||
} elsif ($ch eq '(' and not $single_quote and not $double_quote) {
|
||||
$parens++;
|
||||
} elsif($ch eq ')' and not $single_quote and not $double_quote) {
|
||||
} elsif ($ch eq ')' and not $single_quote and not $double_quote) {
|
||||
$parens--;
|
||||
$parens = 0 if $parens < 0;
|
||||
} elsif($ch eq ';' and not $cpp and not $single_quote and not $double_quote and $parens == 0) {
|
||||
if(not substr($code, $pos, 1) =~ m/[\n\r]/) {
|
||||
} elsif ($ch eq ';' and not $cpp and not $single_quote and not $double_quote and $parens == 0) {
|
||||
if (not substr($code, $pos, 1) =~ m/[\n\r]/) {
|
||||
substr ($code, $pos, 0) = "\n";
|
||||
pos $code = $pos + 1;
|
||||
}
|
||||
} elsif($ch eq "'") {
|
||||
} elsif ($ch eq "'") {
|
||||
$single_quote = not $single_quote unless $escaped or $double_quote;
|
||||
$escaped = 0;
|
||||
} elsif($ch eq 'n' and $escaped) {
|
||||
if(not $single_quote and not $double_quote) {
|
||||
} elsif ($ch eq 'n' and $escaped) {
|
||||
if (not $single_quote and not $double_quote) {
|
||||
print "added newline\n" if $debug >= 10;
|
||||
substr ($code, $pos - 2, 2) = "\n";
|
||||
pos $code = $pos;
|
||||
$cpp = 0;
|
||||
}
|
||||
$escaped = 0;
|
||||
} elsif($ch eq '{' and not $cpp and not $single_quote and not $double_quote) {
|
||||
if(not substr($code, $pos, 1) =~ m/[\n\r]/) {
|
||||
} elsif ($ch eq '{' and not $cpp and not $single_quote and not $double_quote) {
|
||||
if (not substr($code, $pos, 1) =~ m/[\n\r]/) {
|
||||
substr ($code, $pos, 0) = "\n";
|
||||
pos $code = $pos + 1;
|
||||
}
|
||||
} elsif($ch eq '}' and not $cpp and not $single_quote and not $double_quote) {
|
||||
if(not substr($code, $pos, 1) =~ m/[\n\r;]/) {
|
||||
} elsif ($ch eq '}' and not $cpp and not $single_quote and not $double_quote) {
|
||||
if (not substr($code, $pos, 1) =~ m/[\n\r;]/) {
|
||||
substr ($code, $pos, 0) = "\n";
|
||||
pos $code = $pos + 1;
|
||||
}
|
||||
} elsif($ch eq "\n" and $cpp and not $single_quote and not $double_quote) {
|
||||
} elsif ($ch eq "\n" and $cpp and not $single_quote and not $double_quote) {
|
||||
$cpp = 0;
|
||||
} else {
|
||||
$escaped = 0;
|
||||
@ -168,7 +168,7 @@ $white_code =~ s/(?:\"((?:\\\"|(?!\").)*)\")/'"' . ('-' x length $1) . '"'/ge;
|
||||
$white_code =~ s/(?:\'((?:\\\'|(?!\').)*)\')/"'" . ('-' x length $1) . "'"/ge;
|
||||
|
||||
my $precode;
|
||||
if($white_code =~ m/#include/) {
|
||||
if ($white_code =~ m/#include/) {
|
||||
$precode = $code;
|
||||
} else {
|
||||
$precode = $prelude . $code;
|
||||
@ -180,16 +180,16 @@ print "--- precode: [$precode]\n" if $debug;
|
||||
|
||||
my $lang = 'C89';
|
||||
|
||||
if($lang eq 'C89' or $lang eq 'C99' or $lang eq 'C11' or $lang eq 'C++') {
|
||||
if ($lang eq 'C89' or $lang eq 'C99' or $lang eq 'C11' or $lang eq 'C++') {
|
||||
my $prelude = '';
|
||||
while($precode =~ s/^\s*(#.*\n{1,2})//g) {
|
||||
while ($precode =~ s/^\s*(#.*\n{1,2})//g) {
|
||||
$prelude .= $1;
|
||||
}
|
||||
|
||||
if($precode =~ m/^\s*(#.*)/ms) {
|
||||
if ($precode =~ m/^\s*(#.*)/ms) {
|
||||
my $line = $1;
|
||||
|
||||
if($line !~ m/\n/) {
|
||||
if ($line !~ m/\n/) {
|
||||
$warn_unterminated_define = 1;
|
||||
}
|
||||
}
|
||||
@ -203,7 +203,7 @@ if($lang eq 'C89' or $lang eq 'C99' or $lang eq 'C11' or $lang eq 'C++') {
|
||||
$preprecode =~ s/(?:\'((?:\\\'|(?!\').)*)\')/"'" . ('-' x length $1) . "'"/ge;
|
||||
|
||||
# strip C and C++ style comments
|
||||
if($lang eq 'C89') {
|
||||
if ($lang eq 'C89') {
|
||||
$preprecode =~ s#/\*[^*]*\*+([^/*][^*]*\*+)*/# #gs;
|
||||
$preprecode =~ s#|//([^\\]|[^\n][\n]?)*?\n|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#defined $2 ? $2 : ""#gse;
|
||||
} else {
|
||||
@ -218,7 +218,7 @@ if($lang eq 'C89' or $lang eq 'C99' or $lang eq 'C11' or $lang eq 'C++') {
|
||||
my $func_regex = qr/^([ *\w]+)\s+([ ()*\w]+)\s*\(([^;{]*)\s*\)\s*({.*|<%.*|\?\?<.*)/ims;
|
||||
|
||||
# look for potential functions to extract
|
||||
while($preprecode =~ /$func_regex/ms) {
|
||||
while ($preprecode =~ /$func_regex/ms) {
|
||||
my ($pre_ret, $pre_ident, $pre_params, $pre_potential_body) = ($1, $2, $3, $4);
|
||||
|
||||
print "looking for functions, found [$pre_ret][$pre_ident][$pre_params][$pre_potential_body], has main: $has_main\n" if $debug >= 1;
|
||||
@ -245,7 +245,7 @@ if($lang eq 'C89' or $lang eq 'C99' or $lang eq 'C11' or $lang eq 'C++') {
|
||||
$ret =~ s/^\s+//;
|
||||
$ret =~ s/\s+$//;
|
||||
|
||||
if(not length $ret or $ret eq "else" or $ret eq "while" or $ret eq "if" or $ret eq "for" or $ident eq "for" or $ident eq "while" or $ident eq "if") {
|
||||
if (not length $ret or $ret eq "else" or $ret eq "while" or $ret eq "if" or $ret eq "for" or $ident eq "for" or $ident eq "while" or $ident eq "if") {
|
||||
$precode .= "$ret $ident ($params) $potential_body";
|
||||
next;
|
||||
} else {
|
||||
@ -259,8 +259,8 @@ if($lang eq 'C89' or $lang eq 'C99' or $lang eq 'C11' or $lang eq 'C++') {
|
||||
|
||||
my @extract = extract_bracketed($potential_body, '{}');
|
||||
my $body;
|
||||
if(not defined $extract[0]) {
|
||||
if($debug == 0) {
|
||||
if (not defined $extract[0]) {
|
||||
if ($debug == 0) {
|
||||
print "error: unmatched brackets\n";
|
||||
} else {
|
||||
print "error: unmatched brackets for function '$ident';\n";
|
||||
@ -284,7 +284,7 @@ if($lang eq 'C89' or $lang eq 'C99' or $lang eq 'C11' or $lang eq 'C++') {
|
||||
|
||||
$precode =~ s/^{(.*)}$/$1/s;
|
||||
|
||||
if(not $has_main and not $got_nomain) {
|
||||
if (not $has_main and not $got_nomain) {
|
||||
$code = "$prelude\n$code" . "int main(void) {\n$precode\n;\n}\n";
|
||||
} else {
|
||||
print "code: [$code]; precode: [$precode]\n" if $debug;
|
||||
@ -316,7 +316,7 @@ close $fh;
|
||||
#my ($ret, $result) = execute(10, "gcc -std=c89 -pedantic -Werror -Wno-unused -fsyntax-only -fno-diagnostics-show-option -fno-diagnostics-show-caret code.c");
|
||||
my ($ret, $result) = execute(10, "gcc -std=c11 -pedantic -Werror -Wno-implicit -Wno-unused -fsyntax-only -fno-diagnostics-show-option -fno-diagnostics-show-caret code.c");
|
||||
|
||||
if(not $force and $ret != 0) {
|
||||
if (not $force and $ret != 0) {
|
||||
$output = $result;
|
||||
|
||||
#print STDERR "output: [$output]\n";
|
||||
@ -388,7 +388,7 @@ if(not $force and $ret != 0) {
|
||||
# don't error about undeclared objects
|
||||
$output =~ s/error: '[^']+' undeclared\s*//g;
|
||||
|
||||
if(length $output) {
|
||||
if (length $output) {
|
||||
print "$output\n";
|
||||
exit 0;
|
||||
} else {
|
||||
@ -404,7 +404,7 @@ close $fh;
|
||||
|
||||
$output = `./c2eng.pl code2eng.c` if not defined $output;
|
||||
|
||||
if(not $has_function and not $has_main) {
|
||||
if (not $has_function and not $has_main) {
|
||||
$output =~ s/Let .main. be a function taking no arguments and returning int.\s*When called, the function will.\s*(do nothing.)?//i;
|
||||
$output =~ s/\s*Return 0.\s*End of function .main..\s*//;
|
||||
$output =~ s/\s*Finally, return 0.$//;
|
||||
@ -412,14 +412,14 @@ if(not $has_function and not $has_main) {
|
||||
$output =~ s/\s*Do nothing.\s*$//;
|
||||
$output =~ s/^\s*(.)/\U$1/;
|
||||
$output =~ s/\.\s+(\S)/. \U$1/g;
|
||||
} elsif($has_function and not $has_main) {
|
||||
} elsif ($has_function and not $has_main) {
|
||||
$output =~ s/\s*Let `main` be a function taking no arguments and returning int.\s*When called, the function will do nothing.//;
|
||||
$output =~ s/\s*Finally, return 0.$//;
|
||||
$output =~ s/\s*and then return 0.$/./;
|
||||
}
|
||||
|
||||
$output =~ s/\s+/ /;
|
||||
if(not $output) {
|
||||
if (not $output) {
|
||||
$output = "Does not compute; I only understand valid C11 code.\n";
|
||||
}
|
||||
|
||||
@ -439,7 +439,7 @@ sub execute {
|
||||
local $SIG{ALRM} = sub { kill 'TERM', $pid; die "$result [Timed-out]\n"; };
|
||||
alarm($timeout);
|
||||
|
||||
while(my $line = <$fh>) {
|
||||
while (my $line = <$fh>) {
|
||||
$result .= $line;
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ sub execute {
|
||||
|
||||
alarm 0;
|
||||
|
||||
if($@ =~ /Timed-out/) {
|
||||
if ($@ =~ /Timed-out/) {
|
||||
return (-1, $@);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ my $RESULTS_SPECIFIED = 2;
|
||||
|
||||
my $search = join ' ', @ARGV;
|
||||
|
||||
if(not length $search) {
|
||||
if (not length $search) {
|
||||
print "Usage: c99std [-list] [-n#] [-section <section>] [search text] -- 'section' must be in the form of X.YpZ where X and Y are section/chapter and, optionally, pZ is paragraph. If both 'section' and 'search text' are specified, then the search space will be within the specified section. You may use -n # to skip to the #th match. To list only the section numbers containing 'search text', add -list.\n";
|
||||
exit 0;
|
||||
}
|
||||
@ -25,10 +25,10 @@ my ($section, $paragraph, $section_specified, $paragraph_specified, $match, $lis
|
||||
$section_specified = 0;
|
||||
$paragraph_specified = 0;
|
||||
|
||||
if($search =~ s/-section\s*([A-Z0-9\.p]+)//i or $search =~ s/\b([A-Z0-9]+\.[0-9\.p]+)//i) {
|
||||
if ($search =~ s/-section\s*([A-Z0-9\.p]+)//i or $search =~ s/\b([A-Z0-9]+\.[0-9\.p]+)//i) {
|
||||
$section = $1;
|
||||
|
||||
if($section =~ s/p(\d+)//i) {
|
||||
if ($section =~ s/p(\d+)//i) {
|
||||
$paragraph = $1;
|
||||
$paragraph_specified = $USER_SPECIFIED;
|
||||
} else {
|
||||
@ -40,18 +40,18 @@ if($search =~ s/-section\s*([A-Z0-9\.p]+)//i or $search =~ s/\b([A-Z0-9]+\.[0-9\
|
||||
$section_specified = 1;
|
||||
}
|
||||
|
||||
if($search =~ s/-n\s*(\d+)//) {
|
||||
if ($search =~ s/-n\s*(\d+)//) {
|
||||
$match = $1;
|
||||
} else {
|
||||
$match = 1;
|
||||
}
|
||||
|
||||
if($search =~ s/-list//i) {
|
||||
if ($search =~ s/-list//i) {
|
||||
$list_only = 1;
|
||||
$list_titles = 1; # Added here instead of removing -titles option
|
||||
}
|
||||
|
||||
if($search =~ s/-titles//i) {
|
||||
if ($search =~ s/-titles//i) {
|
||||
$list_only = 1;
|
||||
$list_titles = 1;
|
||||
}
|
||||
@ -59,12 +59,12 @@ if($search =~ s/-titles//i) {
|
||||
$search =~ s/^\s+//;
|
||||
$search =~ s/\s+$//;
|
||||
|
||||
if(not defined $section) {
|
||||
if (not defined $section) {
|
||||
$section = "1.";
|
||||
$paragraph = 1;
|
||||
}
|
||||
|
||||
if($list_only and not length $search) {
|
||||
if ($list_only and not length $search) {
|
||||
print "You must specify some search text to use with -list.\n";
|
||||
exit 0;
|
||||
}
|
||||
@ -86,7 +86,7 @@ my $matches = 0;
|
||||
my $this_section;
|
||||
my $comma = "";
|
||||
|
||||
if($list_only) {
|
||||
if ($list_only) {
|
||||
$result = "Sections containing '$search':\n ";
|
||||
}
|
||||
|
||||
@ -94,27 +94,27 @@ my $qsearch = quotemeta $search;
|
||||
$qsearch =~ s/\\ / /g;
|
||||
$qsearch =~ s/\s+/\\s+/g;
|
||||
|
||||
while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
while ($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
$this_section = $1;
|
||||
|
||||
print "----------------------------------\n" if $debug >= 2;
|
||||
print "Processing section [$this_section]\n" if $debug;
|
||||
|
||||
if($section_specified and $this_section !~ m/^$section/i) {
|
||||
if ($section_specified and $this_section !~ m/^$section/i) {
|
||||
print "No section match, skipping.\n" if $debug >= 4;
|
||||
next;
|
||||
}
|
||||
|
||||
my $section_text;
|
||||
|
||||
if($text =~ m/(.*?)^(?=\s{0,4}(?!FOOTNOTE)[0-9A-Z]+\.)/msg) {
|
||||
if ($text =~ m/(.*?)^(?=\s{0,4}(?!FOOTNOTE)[0-9A-Z]+\.)/msg) {
|
||||
$section_text = $1;
|
||||
} else {
|
||||
print "No section text, end of file marker found.\n" if $debug >= 4;
|
||||
last;
|
||||
}
|
||||
|
||||
if($section =~ /FOOTNOTE/i) {
|
||||
if ($section =~ /FOOTNOTE/i) {
|
||||
$section_text =~ s/^\s{4}//ms;
|
||||
$section_text =~ s/^\s{4}FOOTNOTE.*//msi;
|
||||
$section_text =~ s/^\d.*//ms;
|
||||
@ -126,13 +126,13 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
|
||||
print "$this_section [$section_title]\n" if $debug >= 2;
|
||||
|
||||
while($section_text =~ m/^(\d+)\s(.*?)^(?=\d)/msgic or $section_text =~ m/^(\d+)\s(.*)/msgi) {
|
||||
while ($section_text =~ m/^(\d+)\s(.*?)^(?=\d)/msgic or $section_text =~ m/^(\d+)\s(.*)/msgi) {
|
||||
my $p = $1 ;
|
||||
my $t = $2;
|
||||
|
||||
print "paragraph $p: [$t]\n" if $debug >= 3;
|
||||
|
||||
if($paragraph_specified == $USER_SPECIFIED and not length $search and $p == $paragraph) {
|
||||
if ($paragraph_specified == $USER_SPECIFIED and not length $search and $p == $paragraph) {
|
||||
$result = $t if not $found;
|
||||
$found_paragraph = $p;
|
||||
$found_section = $this_section;
|
||||
@ -141,17 +141,17 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
last;
|
||||
}
|
||||
|
||||
if(length $search) {
|
||||
if (length $search) {
|
||||
eval {
|
||||
if($t =~ m/\b$qsearch\b/mis or $section_title =~ m/\b$qsearch\b/mis) {
|
||||
if ($t =~ m/\b$qsearch\b/mis or $section_title =~ m/\b$qsearch\b/mis) {
|
||||
$matches++;
|
||||
if($matches >= $match) {
|
||||
if($list_only) {
|
||||
if ($matches >= $match) {
|
||||
if ($list_only) {
|
||||
$result .= sprintf("%s%-15s", $comma, $this_section."p".$p);
|
||||
$result .= " $section_title" if $list_titles;
|
||||
$comma = ",\n ";
|
||||
} else {
|
||||
if(not $found) {
|
||||
if (not $found) {
|
||||
$result = $t;
|
||||
$found_section = $this_section;
|
||||
$found_section_title = $section_title;
|
||||
@ -164,7 +164,7 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
}
|
||||
};
|
||||
|
||||
if($@) {
|
||||
if ($@) {
|
||||
print "Error in search regex; you may need to escape characters such as *, ?, ., etc.\n";
|
||||
exit 0;
|
||||
}
|
||||
@ -173,8 +173,8 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
|
||||
last if $found && $paragraph_specified == $USER_SPECIFIED;
|
||||
|
||||
if($paragraph_specified == $USER_SPECIFIED) {
|
||||
if(length $search) {
|
||||
if ($paragraph_specified == $USER_SPECIFIED) {
|
||||
if (length $search) {
|
||||
print "No such text '$search' found within paragraph $paragraph of section $section of n1256.\n";
|
||||
} else {
|
||||
print "No such paragraph $paragraph in section $section of n1256.\n";
|
||||
@ -182,7 +182,7 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if(defined $section_specified and not length $search) {
|
||||
if (defined $section_specified and not length $search) {
|
||||
$found = 1;
|
||||
$found_section = $this_section;
|
||||
$found_section_title = $section_title;
|
||||
@ -192,9 +192,9 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||
}
|
||||
}
|
||||
|
||||
if(not $found and $comma eq "") {
|
||||
if (not $found and $comma eq "") {
|
||||
$search =~ s/\\s\+/ /g;
|
||||
if($section_specified) {
|
||||
if ($section_specified) {
|
||||
print "No such text '$search' found within section '$section' in C99 Draft Standard (n1256).\n" if length $search;
|
||||
print "No such section '$section' in C99 Draft Standard (n1256).\n" if not length $search;
|
||||
exit 0;
|
||||
@ -213,12 +213,12 @@ $result =~ s/\s+/ /g;
|
||||
$result =~ s/[\n\r]/ /g;
|
||||
=cut
|
||||
|
||||
if($matches > 1 and not $list_only) {
|
||||
if ($matches > 1 and not $list_only) {
|
||||
print "Displaying $match of $matches matches: ";
|
||||
}
|
||||
|
||||
if($comma eq "") {
|
||||
print "\nhttp://www.iso-9899.info/n1256.html\#$found_section";
|
||||
if ($comma eq "") {
|
||||
print "http://www.iso-9899.info/n1256.html\#$found_section";
|
||||
print "p" . $found_paragraph if $paragraph_specified;
|
||||
print "\n\n";
|
||||
print "[", $found_section_title, "]\n\n" if length $found_section_title;
|
||||
|
@ -19,7 +19,7 @@ $query =~ s/^\*/\\*/g;
|
||||
$query =~ s/\[/\\[/g;
|
||||
$query =~ s/\]/\\]/g;
|
||||
|
||||
if($query =~ /^(\d+)\.\*\?/) {
|
||||
if ($query =~ /^(\d+)\.\*\?/) {
|
||||
$match = $1;
|
||||
$query =~ s/^\d+\.\*\?//;
|
||||
}
|
||||
@ -31,19 +31,19 @@ close(FILE);
|
||||
my ($heading, $question_full, $question_link, $question_number, $question_text, $result);
|
||||
|
||||
foreach my $line (@contents) {
|
||||
if($line =~ m/^<H4>(.*?)<\/H4>/) {
|
||||
if ($line =~ m/^<H4>(.*?)<\/H4>/) {
|
||||
$heading = $1;
|
||||
next;
|
||||
}
|
||||
|
||||
if($line =~ m/<p><a href="(.*?)" rel=subdocument>(.*?)<\/a>/) {
|
||||
if ($line =~ m/<p><a href="(.*?)" rel=subdocument>(.*?)<\/a>/) {
|
||||
($question_link, $question_number) = ($1, $2);
|
||||
|
||||
if(defined $question_full) {
|
||||
if($question_full =~ m/$query/i) {
|
||||
if (defined $question_full) {
|
||||
if ($question_full =~ m/$query/i) {
|
||||
$matches++;
|
||||
$found = 1;
|
||||
if($match == $matches) {
|
||||
if ($match == $matches) {
|
||||
$question_text =~ s/\s+/ /g;
|
||||
$result = $question_text;
|
||||
}
|
||||
@ -55,7 +55,7 @@ foreach my $line (@contents) {
|
||||
next;
|
||||
}
|
||||
|
||||
if(defined $question_full) {
|
||||
if (defined $question_full) {
|
||||
$line =~ s/[\n\r]/ /g;
|
||||
$line =~ s/(<pre>|<\/pre>|<TT>|<\/TT>|<\/a>|<br>)//g;
|
||||
$line =~ s/<a href=".*?">//g;
|
||||
@ -69,8 +69,8 @@ foreach my $line (@contents) {
|
||||
}
|
||||
}
|
||||
|
||||
if($found == 1) {
|
||||
print "But there are $matches results...\n" and exit if($match > $matches);
|
||||
if ($found == 1) {
|
||||
print "But there are $matches results...\n" and exit if ($match > $matches);
|
||||
|
||||
print "$matches results, displaying #$match: " if ($matches > 1);
|
||||
|
||||
|
@ -37,7 +37,7 @@ if ($channel !~ /^#/) {
|
||||
exit;
|
||||
}
|
||||
|
||||
while($text =~ s/^\s*(is|are|the|a|an)\s+//i){};
|
||||
while ($text =~ s/^\s*(is|are|the|a|an)\s+//i){};
|
||||
$text =~ s/\s*\?*$//;
|
||||
$text =~ s/^\s+//;
|
||||
$text =~ s/\s+$//;
|
||||
@ -62,7 +62,7 @@ if (defined $ret) {
|
||||
|
||||
chomp $last_nick;
|
||||
|
||||
if(scalar gettimeofday - $last_timestamp <= 15) {
|
||||
if (scalar gettimeofday - $last_timestamp <= 15) {
|
||||
$ret = open $fh, "<", "$CJEOPARDY_DATA-$channel";
|
||||
if (defined $ret) {
|
||||
@data = <$fh>;
|
||||
|
@ -21,7 +21,7 @@ my %preludes = ( 'C' => "#include <stdio.h>\n#include <stdlib.h>\n#include <stri
|
||||
'C++' => "#include <iostream>\n#include <cstdio>\n",
|
||||
);
|
||||
|
||||
if($#ARGV <= 0) {
|
||||
if ($#ARGV <= 0) {
|
||||
print "Usage: cc [-lang=<language>] <code>\n";
|
||||
exit 0;
|
||||
}
|
||||
@ -42,14 +42,14 @@ $show_url = 1 if $code =~ s/-showurl//i;
|
||||
|
||||
my $found = 0;
|
||||
foreach my $l (@languages) {
|
||||
if(uc $lang eq uc $l) {
|
||||
if (uc $lang eq uc $l) {
|
||||
$lang = $l;
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if(not $found) {
|
||||
if (not $found) {
|
||||
print "$nick: Invalid language '$lang'. Supported languages are: @languages\n";
|
||||
exit 0;
|
||||
}
|
||||
@ -66,18 +66,18 @@ $code =~ s/#([\w\d_]+)\\n/\n#$1\n/g;
|
||||
my $precode = $preludes{$lang} . $code;
|
||||
$code = '';
|
||||
|
||||
if($lang eq "C" or $lang eq "C++") {
|
||||
if ($lang eq "C" or $lang eq "C++") {
|
||||
my $has_main = 0;
|
||||
|
||||
my $prelude = '';
|
||||
$prelude = "$1$2" if $precode =~ s/^\s*(#.*)(#.*?[>\n])//s;
|
||||
|
||||
while($precode =~ s/([ a-zA-Z0-9_*\[\]]+)\s+([a-zA-Z0-9_*]+)\s*\((.*?)\)\s*({.*)//) {
|
||||
while ($precode =~ s/([ a-zA-Z0-9_*\[\]]+)\s+([a-zA-Z0-9_*]+)\s*\((.*?)\)\s*({.*)//) {
|
||||
my ($ret, $ident, $params, $potential_body) = ($1, $2, $3, $4);
|
||||
|
||||
my @extract = extract_codeblock($potential_body, '{}');
|
||||
my $body;
|
||||
if(not defined $extract[0]) {
|
||||
if (not defined $extract[0]) {
|
||||
$output .= "<pre>error: unmatched brackets for function '$ident'; </pre>";
|
||||
$body = $extract[1];
|
||||
} else {
|
||||
@ -91,7 +91,7 @@ if($lang eq "C" or $lang eq "C++") {
|
||||
$precode =~ s/^\s+//;
|
||||
$precode =~ s/\s+$//;
|
||||
|
||||
if(not $has_main) {
|
||||
if (not $has_main) {
|
||||
$code = "$prelude\n\n$code\n\nint main(int argc, char **argv) { $precode\n;\n return 0;}\n";
|
||||
} else {
|
||||
$code = "$prelude\n\n$precode\n\n$code\n";
|
||||
@ -100,7 +100,7 @@ if($lang eq "C" or $lang eq "C++") {
|
||||
$code = $precode;
|
||||
}
|
||||
|
||||
if($lang eq "C" or $lang eq "C++") {
|
||||
if ($lang eq "C" or $lang eq "C++") {
|
||||
# $code = pretty($code);
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ $code =~ s/\s+$//;
|
||||
my %post = ( 'lang' => $lang, 'code' => $code, 'private' => 'True', 'run' => 'True', 'submit' => 'Submit' );
|
||||
my $response = $ua->post("http://codepad.org", \%post);
|
||||
|
||||
if(not $response->is_success) {
|
||||
if (not $response->is_success) {
|
||||
print "There was an error compiling the code.\n";
|
||||
die $response->status_line;
|
||||
}
|
||||
@ -121,7 +121,7 @@ my $url = $response->request->uri;
|
||||
# remove line numbers
|
||||
$text =~ s/<a style="" name="output-line-\d+">\d+<\/a>//g;
|
||||
|
||||
if($text =~ /<span class="heading">Output:<\/span>.+?<div class="code">(.*)<\/div>.+?<\/table>/si) {
|
||||
if ($text =~ /<span class="heading">Output:<\/span>.+?<div class="code">(.*)<\/div>.+?<\/table>/si) {
|
||||
$output .= "$1";
|
||||
} else {
|
||||
$output .= "<pre>No output.</pre>";
|
||||
@ -141,7 +141,7 @@ print FILE localtime() . "\n";
|
||||
print FILE "$nick: [ $url ] $output\n\n";
|
||||
close FILE;
|
||||
|
||||
if($show_url) {
|
||||
if ($show_url) {
|
||||
print "$nick: [ $url ] $output\n";
|
||||
} else {
|
||||
print "$nick: $output\n";
|
||||
@ -154,7 +154,7 @@ sub pretty {
|
||||
my $pid = open2(\*IN, \*OUT, 'astyle -Upf');
|
||||
print OUT "$code\n";
|
||||
close OUT;
|
||||
while(my $line = <IN>) {
|
||||
while (my $line = <IN>) {
|
||||
$result .= $line;
|
||||
}
|
||||
close IN;
|
||||
|
@ -12,36 +12,35 @@
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use IO::Socket;
|
||||
use IO::Socket::INET;
|
||||
use JSON;
|
||||
|
||||
my $sock = IO::Socket::INET->new(
|
||||
PeerAddr => '192.168.0.42',
|
||||
PeerPort => 9000,
|
||||
Proto => 'tcp');
|
||||
|
||||
if(not defined $sock) {
|
||||
if (not defined $sock) {
|
||||
print "Fatal error compiling: $!; try again later\n";
|
||||
die $!;
|
||||
}
|
||||
|
||||
my $nick = shift @ARGV;
|
||||
my $channel = shift @ARGV;
|
||||
my $code = join ' ', @ARGV;
|
||||
my $json = join ' ', @ARGV;
|
||||
my $h = decode_json $json;
|
||||
|
||||
#$code = "{ $code";
|
||||
$code =~ s/\s*}\s*$//;
|
||||
$h->{code} =~ s/\s*}\s*$//;
|
||||
|
||||
my $lang = "c11";
|
||||
|
||||
if($code =~ s/-lang=([^ ]+)//) {
|
||||
my $lang = $h->{lang} // "c11";
|
||||
if ($code =~ s/-lang=([^ ]+)//) {
|
||||
$lang = lc $1;
|
||||
}
|
||||
|
||||
print $sock "compile:$nick:$channel:$lang\n";
|
||||
print $sock "$code\n";
|
||||
print $sock "compile:end\n";
|
||||
$h->{lang} = $lang;
|
||||
$json = encode_json $h;
|
||||
|
||||
while(my $line = <$sock>) {
|
||||
print $sock "$json\n";
|
||||
|
||||
while (my $line = <$sock>) {
|
||||
print "$line";
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,16 @@ my $sock = IO::Socket::INET->new(
|
||||
PeerPort => 9000,
|
||||
Proto => 'tcp');
|
||||
|
||||
if(not defined $sock) {
|
||||
if (not defined $sock) {
|
||||
print "Fatal error compiling: $!; try again later\n";
|
||||
die $!;
|
||||
}
|
||||
|
||||
my $json = join ' ', @ARGV;
|
||||
my $length = length $json;
|
||||
|
||||
print STDERR "got $length bytes of argv json: [$json]\n";
|
||||
|
||||
my $h = decode_json $json;
|
||||
my $lang = $h->{lang} // "c11";
|
||||
|
||||
@ -36,9 +40,13 @@ if ($h->{code} =~ s/-lang=([^ ]+)//) {
|
||||
$h->{lang} = $lang;
|
||||
$json = encode_json $h;
|
||||
|
||||
print $sock "$json\n";
|
||||
$length = length $json;
|
||||
|
||||
while(my $line = <$sock>) {
|
||||
print STDERR "got $length bytes of json: [$json]\n";
|
||||
|
||||
syswrite($sock, "$json\n");
|
||||
|
||||
while (my $line = <$sock>) {
|
||||
print "$line";
|
||||
}
|
||||
|
||||
|
@ -73,16 +73,20 @@ sub execute {
|
||||
|
||||
local $SIG{ALRM} = sub { print "Time out\n"; kill 9, $pid; print "sent KILL to $pid\n"; die "Timed-out: $result\n"; };
|
||||
alarm($COMPILE_TIMEOUT);
|
||||
|
||||
|
||||
print "Reading...\n";
|
||||
while(my $line = <$fh>) {
|
||||
print "read [$line]\n";
|
||||
$result .= $line;
|
||||
}
|
||||
|
||||
close $fh;
|
||||
print "Done reading.\n";
|
||||
|
||||
my $ret = $? >> 8;
|
||||
alarm 0;
|
||||
#print "[$ret, $result]\n";
|
||||
|
||||
print "[$ret, $result]\n";
|
||||
return ($ret, $result);
|
||||
};
|
||||
|
||||
@ -94,6 +98,7 @@ sub execute {
|
||||
return ($ret, $result);
|
||||
} else {
|
||||
waitpid($child, 0);
|
||||
print "?: $?\n";
|
||||
my $result = $? >> 8;
|
||||
print "child exited, parent continuing [result = $result]\n";
|
||||
return (undef, $result);
|
||||
@ -247,6 +252,7 @@ sub compiler_server {
|
||||
|
||||
close $client;
|
||||
|
||||
print "timed out: $timed_out; killed: $killed\n";
|
||||
next unless ($timed_out or $killed);
|
||||
|
||||
vm_reset;
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use feature "switch";
|
||||
@ -393,7 +389,7 @@ sub execute {
|
||||
#print FILE "Sending $length bytes [$compile_json] to vm_server\n";
|
||||
|
||||
$chunk_size -= 1; # account for newline in syswrite
|
||||
|
||||
|
||||
while ($chunks_sent < $length) {
|
||||
my $chunk = substr $compile_json, $chunks_sent, $chunk_size;
|
||||
#print FILE "Sending chunk [$chunk]\n";
|
||||
@ -423,8 +419,7 @@ sub execute {
|
||||
my $got_result = 0;
|
||||
|
||||
while(my $line = <$compiler_output>) {
|
||||
|
||||
#print STDERR "Read [$line]\n";
|
||||
print STDERR "Read [$line]\n";
|
||||
|
||||
$line =~ s/[\r\n]+$//;
|
||||
last if $line =~ /^result:end$/;
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
@ -20,8 +16,6 @@ sub initialize {
|
||||
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
||||
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{default_options} .= ' -Werror' if defined $self->{nick} && $self->{nick} =~ m/marchelz/i;
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
#define _XOPEN_SOURCE 9001
|
||||
#define __USE_XOPEN
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
@ -20,7 +16,7 @@ sub initialize {
|
||||
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
||||
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{default_options} .= ' -Werror' if defined $self->{nick} && $self->{nick} =~ m/marchelz/i;
|
||||
# $self->{default_options} .= ' -Werror' if defined $self->{nick} && $self->{nick} =~ m/marchelz/i;
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
#define _XOPEN_SOURCE 9001
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
@ -20,7 +16,7 @@ sub initialize {
|
||||
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
||||
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{default_options} .= ' -Werror' if defined $self->{nick} && $self->{nick} =~ m/marchelz/i;
|
||||
# $self->{default_options} .= ' -Werror' if defined $self->{nick} && $self->{nick} =~ m/marchelz/i;
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
#define _XOPEN_SOURCE 9001
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
@ -15,10 +11,10 @@ sub initialize {
|
||||
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -Wno-unused-parameter -pedantic -Wfloat-equal -Wshadow -std=c11 -lm -Wfatal-errors -fsanitize=integer,undefined,address,alignment';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -Wno-unused-parameter -pedantic -Wfloat-equal -Wshadow -std=c11 -lm -Wfatal-errors -fsanitize=integer,undefined,alignment';
|
||||
$self->{options_paste} = '-fcaret-diagnostics';
|
||||
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
||||
$self->{cmdline} = 'clang-3.7 -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
$self->{cmdline} = 'clang -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
#define _XOPEN_SOURCE 9001
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
@ -15,10 +11,10 @@ sub initialize {
|
||||
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c89 -lm -Wfatal-errors -fsanitize=integer,undefined,alignment,address';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c89 -lm -Wfatal-errors -fsanitize=integer,undefined,alignment';
|
||||
$self->{options_paste} = '-fcaret-diagnostics';
|
||||
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
||||
$self->{cmdline} = 'clang-3.7 -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
$self->{cmdline} = 'clang -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
#define _XOPEN_SOURCE 9001
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
@ -15,10 +11,10 @@ sub initialize {
|
||||
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c99 -lm -Wfatal-errors -fsanitize=integer,undefined,alignment,address';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c99 -lm -Wfatal-errors -fsanitize=integer,undefined,alignment';
|
||||
$self->{options_paste} = '-fcaret-diagnostics';
|
||||
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
||||
$self->{cmdline} = 'clang-3.7 -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
$self->{cmdline} = 'clang -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
#define _XOPEN_SOURCE 9001
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use feature "switch";
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
|
@ -3,4 +3,4 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
~/pbot/modules/lookupbot.pl compliment $*
|
||||
~/pbot/modules/lookupbot.pl compliment "$*"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user