3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-23 04:19:27 +01:00

Tidy things up

This commit is contained in:
Pragmatic Software 2020-02-15 15:16:38 -08:00
parent 5c4e10a35c
commit fe56b9f0db
23 changed files with 3 additions and 115 deletions

View File

@ -136,7 +136,6 @@ sub update_join_watch {
$channel_data->{join_watch}++; $channel_data->{join_watch}++;
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data); $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 # PART or QUIT
# check QUIT message for netsplits, and decrement joinwatch to allow a free rejoin # check QUIT message for netsplits, and decrement joinwatch to allow a free rejoin
if ($text =~ /^QUIT .*\.net .*\.split/) { if ($text =~ /^QUIT .*\.net .*\.split/) {
@ -148,16 +147,13 @@ sub update_join_watch {
# check QUIT message for Ping timeout or Excess Flood # 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 # treat these as an extra join so they're snagged more quickly since these usually will keep flooding
$channel_data->{join_watch}++; $channel_data->{join_watch}++;
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data); $self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
} else { } else {
# some other type of QUIT or PART # 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 # reset joinwatch if they send a message
if ($channel_data->{join_watch} > 0) { if ($channel_data->{join_watch} > 0) {
$channel_data->{join_watch} = 0; $channel_data->{join_watch} = 0;
@ -263,13 +259,11 @@ sub check_flood {
foreach my $chan (@$channels) { foreach my $chan (@$channels) {
$chan = lc $chan; $chan = lc $chan;
# do not do flood processing if channel is not in bot's channel list or bot is not set as chanop for the channel # 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 $chan =~ /^#/ and not $self->{pbot}->{chanops}->can_gain_ops($chan); next if $chan =~ /^#/ and not $self->{pbot}->{chanops}->can_gain_ops($chan);
my $u = $self->{pbot}->{users}->loggedin($chan, "$nick!$user\@$host"); my $u = $self->{pbot}->{users}->loggedin($chan, "$nick!$user\@$host");
if ($chan =~ /^#/ and $mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) { if ($chan =~ /^#/ 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 # remove validation on PART or KICK so we check for ban-evasion when user returns at a later time
my $chan_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($account, $chan, 'validated'); my $chan_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($account, $chan, 'validated');
if ($chan_data->{validated} & $self->{NICKSERV_VALIDATED}) { if ($chan_data->{validated} & $self->{NICKSERV_VALIDATED}) {
@ -292,7 +286,6 @@ sub check_flood {
if ($validated & $self->{NEEDS_CHECKBAN} or not $validated & $self->{NICKSERV_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 # don't check for evasion on PART/KICK
} elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}) { } elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}) {
if (not exists $self->{whois_pending}->{$nick}) { if (not exists $self->{whois_pending}->{$nick}) {
@ -302,7 +295,6 @@ sub check_flood {
} }
} else { } else {
if ($mode == $self->{pbot}->{messagehistory}->{MSG_JOIN} && exists $self->{pbot}->{irc_capabilities}->{'extended-join'}) { if ($mode == $self->{pbot}->{messagehistory}->{MSG_JOIN} && exists $self->{pbot}->{irc_capabilities}->{'extended-join'}) {
# don't WHOIS joins if extended-join capability is active # don't WHOIS joins if extended-join capability is active
} elsif (not exists $self->{pbot}->{irc_capabilities}->{'account-notify'}) { } elsif (not exists $self->{pbot}->{irc_capabilities}->{'account-notify'}) {
if (not exists $self->{whois_pending}->{$nick}) { if (not exists $self->{whois_pending}->{$nick}) {
@ -352,7 +344,6 @@ sub check_flood {
$self->{pbot}->{messagehistory}->{database}->get_recent_messages($ancestor, $chan, $max_messages, $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}, $nick); $self->{pbot}->{messagehistory}->{database}->get_recent_messages($ancestor, $chan, $max_messages, $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}, $nick);
$msg = $nickchanges->[0]; $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 # no flood checks to be done for departure events
next; next;
} else { } else {
@ -675,7 +666,6 @@ sub address_to_mask {
} }
sub devalidate_accounts { sub devalidate_accounts {
# remove validation on accounts in $channel that match a ban/quiet $mask # remove validation on accounts in $channel that match a ban/quiet $mask
my ($self, $mask, $channel) = @_; my ($self, $mask, $channel) = @_;
my @message_accounts; my @message_accounts;
@ -727,7 +717,6 @@ sub check_bans {
} }
} else { } else {
if (not exists $self->{pbot}->{irc_capabilities}->{'account-notify'}) { if (not exists $self->{pbot}->{irc_capabilities}->{'account-notify'}) {
# mark this account as needing check-bans when nickserv account is identified # 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'); 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}) {
@ -813,7 +802,6 @@ sub check_bans {
my $u = $self->{pbot}->{users}->loggedin($baninfo->{channel}, $mask); my $u = $self->{pbot}->{users}->loggedin($baninfo->{channel}, $mask);
my $whitelisted = $self->{pbot}->{capabilities}->userhas($u, 'is-whitelisted'); my $whitelisted = $self->{pbot}->{capabilities}->userhas($u, 'is-whitelisted');
if ($self->ban_exempted($baninfo->{channel}, $baninfo->{banmask}) || $whitelisted) { if ($self->ban_exempted($baninfo->{channel}, $baninfo->{banmask}) || $whitelisted) {
#$self->{pbot}->{logger}->log("anti-flood: [check-bans] $mask [$alias] evaded $baninfo->{banmask} in $baninfo->{channel}, but allowed through whitelist\n"); #$self->{pbot}->{logger}->log("anti-flood: [check-bans] $mask [$alias] evaded $baninfo->{banmask} in $baninfo->{channel}, but allowed through whitelist\n");
next; next;
} }

View File

@ -149,10 +149,6 @@ sub get_baninfo {
$baninfo->{owner} = $self->{banlist}->{$channel}->{$mode}->{$banmask_key}->[0]; $baninfo->{owner} = $self->{banlist}->{$channel}->{$mode}->{$banmask_key}->[0];
$baninfo->{when} = $self->{banlist}->{$channel}->{$mode}->{$banmask_key}->[1]; $baninfo->{when} = $self->{banlist}->{$channel}->{$mode}->{$banmask_key}->[1];
$baninfo->{type} = $mode; $baninfo->{type} = $mode;
#$self->{pbot}->{logger}->log("get-baninfo: dump: " . Dumper($baninfo) . "\n");
#$self->{pbot}->{logger}->log("get-baninfo: $baninfo->{banmask} $baninfo->{type} in $baninfo->{channel} by $baninfo->{owner} on $baninfo->{when}\n");
push @$bans, $baninfo; push @$bans, $baninfo;
} }
} }
@ -212,7 +208,6 @@ sub track_mode {
if ($mode eq "-b") { if ($mode eq "-b") {
if ($self->{pbot}->{chanops}->{unban_timeout}->exists($channel, $target)) { $self->{pbot}->{chanops}->{unban_timeout}->remove($channel, $target); } if ($self->{pbot}->{chanops}->{unban_timeout}->exists($channel, $target)) { $self->{pbot}->{chanops}->{unban_timeout}->remove($channel, $target); }
elsif ($self->{pbot}->{chanops}->{unban_timeout}->exists($channel, "$target\$##stop_join_flood")) { elsif ($self->{pbot}->{chanops}->{unban_timeout}->exists($channel, "$target\$##stop_join_flood")) {
# freenode strips channel forwards from unban result if no ban exists with a channel forward # 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"); $self->{pbot}->{chanops}->{unban_timeout}->remove($channel, "$target\$##stop_join_flood");
} }

View File

@ -138,7 +138,6 @@ sub invite {
my ($channel, $target); my ($channel, $target);
if ($from !~ m/^#/) { if ($from !~ m/^#/) {
# from /msg # from /msg
my $usage = "Usage from /msg: invite <channel> [nick]; if you omit [nick] then you will be invited"; my $usage = "Usage from /msg: invite <channel> [nick]; if you omit [nick] then you will be invited";
return $usage if not length $arguments; return $usage if not length $arguments;
@ -146,7 +145,6 @@ sub invite {
return "$channel is not a channel; $usage" if $channel !~ m/^#/; return "$channel is not a channel; $usage" if $channel !~ m/^#/;
$target = $nick if not defined $target; $target = $nick if not defined $target;
} else { } else {
# in channel # in channel
return "Usage: invite [channel] <nick>" if not length $arguments; return "Usage: invite [channel] <nick>" if not length $arguments;
@ -168,7 +166,6 @@ sub generic_mode_user {
my ($flag, $mode_char) = $mode_flag =~ m/(.)(.)/; my ($flag, $mode_char) = $mode_flag =~ m/(.)(.)/;
if ($channel !~ m/^#/) { if ($channel !~ m/^#/) {
# from message # from message
$channel = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist}); $channel = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist});
if (not defined $channel) { return "Usage from message: $mode_name <channel> [nick]"; } if (not defined $channel) { return "Usage from message: $mode_name <channel> [nick]"; }
@ -271,7 +268,6 @@ sub mode {
my $target = $targets[$arg++] // ""; my $target = $targets[$arg++] // "";
if (($mode eq 'v' or $mode eq 'o') and $target =~ m/\*/) { if (($mode eq 'v' or $mode eq 'o') and $target =~ m/\*/) {
# wildcard used; find all matching nicks; test against whitelist, etc # wildcard used; find all matching nicks; test against whitelist, etc
my $q_target = lc quotemeta $target; my $q_target = lc quotemeta $target;
$q_target =~ s/\\\*/.*/g; $q_target =~ s/\\\*/.*/g;
@ -295,7 +291,6 @@ sub mode {
my $nick_data = $self->{pbot}->{nicklist}->{nicklist}->{$channel}->{$n}; my $nick_data = $self->{pbot}->{nicklist}->{nicklist}->{$channel}->{$n};
if ($modifier eq '-') { if ($modifier eq '-') {
# removing mode -- check against whitelist, etc # removing mode -- check against whitelist, etc
next if $nick_data->{nick} eq $self->{pbot}->{registry}->get_value('irc', 'botnick'); next if $nick_data->{nick} eq $self->{pbot}->{registry}->get_value('irc', 'botnick');
my $u = $self->{pbot}->{users}->loggedin($channel, $nick_data->{hostmask}); my $u = $self->{pbot}->{users}->loggedin($channel, $nick_data->{hostmask});
@ -320,7 +315,6 @@ sub mode {
} }
} }
} else { } else {
# no wildcard used; explicit mode requested - no whitelist checking # no wildcard used; explicit mode requested - no whitelist checking
$new_modes .= $mode; $new_modes .= $mode;
$new_targets .= "$target " if length $target; $new_targets .= "$target " if length $target;
@ -624,12 +618,10 @@ sub kick_user {
my ($channel, $victim, $reason); my ($channel, $victim, $reason);
if (not $from =~ /^#/) { if (not $from =~ /^#/) {
# used in private message # used in private message
if (not $arguments =~ s/^(^#\S+) (\S+)\s*//) { return "Usage from private message: kick <channel> <nick> [reason]"; } if (not $arguments =~ s/^(^#\S+) (\S+)\s*//) { return "Usage from private message: kick <channel> <nick> [reason]"; }
($channel, $victim) = ($1, $2); ($channel, $victim) = ($1, $2);
} else { } else {
# used in channel # used in channel
if ($arguments =~ s/^(#\S+)\s+(\S+)\s*//) { ($channel, $victim) = ($1, $2); } if ($arguments =~ s/^(#\S+)\s+(\S+)\s*//) { ($channel, $victim) = ($1, $2); }
elsif ($arguments =~ s/^(\S+)\s*//) { ($victim, $channel) = ($1, exists $stuff->{admin_channel_override} ? $stuff->{admin_channel_override} : $from); } elsif ($arguments =~ s/^(\S+)\s*//) { ($victim, $channel) = ($1, exists $stuff->{admin_channel_override} ? $stuff->{admin_channel_override} : $from); }
@ -657,7 +649,6 @@ sub kick_user {
my @nicks = split /,/, $victim; my @nicks = split /,/, $victim;
foreach my $n (@nicks) { foreach my $n (@nicks) {
if ($n =~ m/\*/) { if ($n =~ m/\*/) {
# wildcard used; find all matching nicks; test against whitelist, etc # wildcard used; find all matching nicks; test against whitelist, etc
my $q_target = lc quotemeta $n; my $q_target = lc quotemeta $n;
$q_target =~ s/\\\*/.*/g; $q_target =~ s/\\\*/.*/g;
@ -682,7 +673,6 @@ sub kick_user {
} }
} }
} else { } else {
# no wildcard used, explicit kick # no wildcard used, explicit kick
$self->{pbot}->{chanops}->add_op_command($channel, "kick $channel $n $reason"); $self->{pbot}->{chanops}->add_op_command($channel, "kick $channel $n $reason");
} }

View File

@ -166,7 +166,6 @@ sub find_factoid_with_optional_channel {
my $needs_disambig; my $needs_disambig;
if (not defined $from_trigger) { if (not defined $from_trigger) {
# cmd arg1, so insert $from as channel # cmd arg1, so insert $from as channel
$from_trigger = $from_chan; $from_trigger = $from_chan;
$from_chan = $from; $from_chan = $from;
@ -174,10 +173,8 @@ sub find_factoid_with_optional_channel {
#$needs_disambig = 1; #$needs_disambig = 1;
} else { } else {
# cmd arg1 arg2 [...?] # cmd arg1 arg2 [...?]
if ($from_chan !~ /^#/ and lc $from_chan ne 'global' and $from_chan ne '.*') { if ($from_chan !~ /^#/ and lc $from_chan ne 'global' and $from_chan ne '.*') {
# not a channel or global, so must be a keyword # not a channel or global, so must be a keyword
my $keyword = $from_chan; my $keyword = $from_chan;
$from_chan = $from; $from_chan = $from;
@ -332,7 +329,6 @@ sub factundo {
my $deleted; my $deleted;
if (not defined $trigger) { if (not defined $trigger) {
# factoid not found or some error, try to continue and load undo file if it exists # factoid not found or some error, try to continue and load undo file if it exists
$deleted = 1; $deleted = 1;
($channel, $trigger) = $self->{pbot}->{interpreter}->split_args($arglist, 2); ($channel, $trigger) = $self->{pbot}->{interpreter}->split_args($arglist, 2);
@ -541,12 +537,10 @@ sub factset {
my $owner; my $owner;
my $mask; my $mask;
if ($factoid->{'locked'}) { if ($factoid->{'locked'}) {
# check owner against full hostmask for locked factoids # check owner against full hostmask for locked factoids
$owner = $factoid->{'owner'}; $owner = $factoid->{'owner'};
$mask = "$nick!$user\@$host"; $mask = "$nick!$user\@$host";
} else { } else {
# otherwise just the nick # otherwise just the nick
($owner) = $factoid->{'owner'} =~ m/([^!]+)/; ($owner) = $factoid->{'owner'} =~ m/([^!]+)/;
$mask = $nick; $mask = $nick;
@ -704,7 +698,6 @@ sub factalias {
my ($chan, $alias, $command) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3, 0, 1); my ($chan, $alias, $command) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3, 0, 1);
if (defined $chan and not($chan eq '.*' or $chan =~ m/^#/)) { if (defined $chan and not($chan eq '.*' or $chan =~ m/^#/)) {
# $chan doesn't look like a channel, so shift everything to the right # $chan doesn't look like a channel, so shift everything to the right
# and replace $chan with $from # and replace $chan with $from
if (defined $command and length $command) { $command = "$alias $command"; } if (defined $command and length $command) { $command = "$alias $command"; }
@ -782,7 +775,6 @@ sub factadd {
my @arglist = @{$stuff->{arglist}}; my @arglist = @{$stuff->{arglist}};
if (@arglist) { if (@arglist) {
# check for -f since we allow it to be before optional channel argument # check for -f since we allow it to be before optional channel argument
if ($arglist[0] eq '-f') { if ($arglist[0] eq '-f') {
$force = 1; $force = 1;
@ -804,7 +796,6 @@ sub factadd {
# check for -url # check for -url
if ($arglist[0] eq '-url') { if ($arglist[0] eq '-url') {
# discard it # discard it
$self->{pbot}->{interpreter}->shift_arg(\@arglist); $self->{pbot}->{interpreter}->shift_arg(\@arglist);
@ -824,7 +815,6 @@ sub factadd {
if ($response->is_success) { $text = $response->decoded_content; } if ($response->is_success) { $text = $response->decoded_content; }
else { return "Failed to get URL: " . $response->status_line; } else { return "Failed to get URL: " . $response->status_line; }
} else { } else {
# check for optional "is" and discard # check for optional "is" and discard
if (lc $arglist[0] eq 'is') { $self->{pbot}->{interpreter}->shift_arg(\@arglist); } if (lc $arglist[0] eq 'is') { $self->{pbot}->{interpreter}->shift_arg(\@arglist); }
@ -1033,7 +1023,6 @@ sub factlog {
my ($channel, $trigger) = $self->find_factoid_with_optional_channel($from, $args, 'factlog', usage => $usage, exact_channel => 1); my ($channel, $trigger) = $self->find_factoid_with_optional_channel($from, $args, 'factlog', usage => $usage, exact_channel => 1);
if (not defined $trigger) { if (not defined $trigger) {
# factoid not found or some error, try to continue and load factlog file if it exists # factoid not found or some error, try to continue and load factlog file if it exists
my $arglist = $self->{pbot}->{interpreter}->make_args($args); my $arglist = $self->{pbot}->{interpreter}->make_args($args);
($channel, $trigger) = $self->{pbot}->{interpreter}->split_args($arglist, 2); ($channel, $trigger) = $self->{pbot}->{interpreter}->split_args($arglist, 2);
@ -1486,7 +1475,6 @@ sub factchange {
my $action = $factoids_data->get_data($channel, $trigger, 'action'); my $action = $factoids_data->get_data($channel, $trigger, 'action');
if (defined $url) { if (defined $url) {
# FIXME: move this to registry # FIXME: move this to registry
if ($url !~ m/^https?:\/\/(?:sprunge.us|ix.io)\/\w+$/) { return "Invalid URL: acceptable URLs are: http://sprunge.us, http://ix.io"; } if ($url !~ m/^https?:\/\/(?:sprunge.us|ix.io)\/\w+$/) { return "Invalid URL: acceptable URLs are: http://sprunge.us, http://ix.io"; }

View File

@ -86,7 +86,6 @@ sub add_factoid {
my $data; my $data;
if ($self->{factoids}->exists($channel, $trigger)) { if ($self->{factoids}->exists($channel, $trigger)) {
# only update action field if force-adding it through factadd -f # only update action field if force-adding it through factadd -f
$data = $self->{factoids}->get_data($channel, $trigger); $data = $self->{factoids}->get_data($channel, $trigger);
$data->{action} = $action; $data->{action} = $action;
@ -905,7 +904,6 @@ sub handle_action {
} }
} }
} else { } else {
# no arguments supplied, replace $args with $nick/$tonick, etc # no arguments supplied, replace $args with $nick/$tonick, etc
if ($self->{factoids}->exists($channel, $keyword, 'usage')) { if ($self->{factoids}->exists($channel, $keyword, 'usage')) {
$action = "/say " . $self->{factoids}->get_data($channel, $keyword, 'usage'); $action = "/say " . $self->{factoids}->get_data($channel, $keyword, 'usage');
@ -989,7 +987,6 @@ sub handle_action {
if (length $result) { return $ref_from . $result; } if (length $result) { return $ref_from . $result; }
else { return ""; } else { return ""; }
} elsif ($self->{factoids}->get_data($channel, $keyword, 'type') eq 'text') { } elsif ($self->{factoids}->get_data($channel, $keyword, 'type') eq 'text') {
# Don't allow user-custom /msg factoids, unless factoid triggered by admin # Don't allow user-custom /msg factoids, unless factoid triggered by admin
if ($action =~ m/^\/msg/i) { if ($action =~ m/^\/msg/i) {
my $admin = $self->{pbot}->{users}->loggedin_admin($stuff->{from}, "$stuff->{nick}!$stuff->{user}\@$stuff->{host}"); my $admin = $self->{pbot}->{users}->loggedin_admin($stuff->{from}, "$stuff->{nick}!$stuff->{user}\@$stuff->{host}");

View File

@ -150,7 +150,6 @@ sub _add_generic_handler {
elsif ($rp =~ /^\D/) { $rp = $define{lc $rp} || 0; } elsif ($rp =~ /^\D/) { $rp = $define{lc $rp} || 0; }
foreach $ev (ref $event eq "ARRAY" ? @{$event} : $event) { foreach $ev (ref $event eq "ARRAY" ? @{$event} : $event) {
# Translate numerics to names # Translate numerics to names
if ($ev =~ /^\d/) { if ($ev =~ /^\d/) {
$ev = PBot::IRC::Event->trans($ev); # pragma_ 2011/21/01 $ev = PBot::IRC::Event->trans($ev); # pragma_ 2011/21/01
@ -701,7 +700,6 @@ sub new_chat {
my ($init, $nick, $address, $port); my ($init, $nick, $address, $port);
if (ref($_[0]) =~ /Event/) { if (ref($_[0]) =~ /Event/) {
# If it's from an Event object, we can't be initiating, right? # If it's from an Event object, we can't be initiating, right?
($init, undef, undef, undef, $address, $port) = (0, $_[0]->args); ($init, undef, undef, undef, $address, $port) = (0, $_[0]->args);
$nick = $_[0]->nick; $nick = $_[0]->nick;
@ -826,7 +824,6 @@ sub parse {
my ($from, $type, $message, @stuff, $itype, $ev, @lines, $line); my ($from, $type, $message, @stuff, $itype, $ev, @lines, $line);
if (defined($self->ssl ? $self->socket->read($line, 10240) : $self->socket->recv($line, 10240, 0)) and (length($self->{_frag}) + length($line)) > 0) { if (defined($self->ssl ? $self->socket->read($line, 10240) : $self->socket->recv($line, 10240, 0)) and (length($self->{_frag}) + length($line)) > 0) {
# grab any remnant from the last go and split into lines # grab any remnant from the last go and split into lines
my $chunk = $self->{_frag} . $line; my $chunk = $self->{_frag} . $line;
@lines = split /\012/, $chunk; @lines = split /\012/, $chunk;
@ -836,7 +833,6 @@ sub parse {
$self->{_frag} = (substr($chunk, -1) ne "\012" ? pop @lines : ''); $self->{_frag} = (substr($chunk, -1) ne "\012" ? pop @lines : '');
} else { } else {
# um, if we can read, i say we should read more than 0 # um, if we can read, i say we should read more than 0
# besides, recv isn't returning undef on closed # besides, recv isn't returning undef on closed
# sockets. getting rid of this connection... # sockets. getting rid of this connection...
@ -1054,7 +1050,6 @@ sub parse {
} elsif ($line =~ /^ERROR/) { } elsif ($line =~ /^ERROR/) {
if ($line =~ /^ERROR :Closing [Ll]ink/) { # is this compatible? if ($line =~ /^ERROR :Closing [Ll]ink/) { # is this compatible?
$ev = 'done'; $ev = 'done';
$self->disconnect('error', ($line =~ /(.*)/)); $self->disconnect('error', ($line =~ /(.*)/));
@ -1074,14 +1069,12 @@ sub parse {
} }
if ($ev) { if ($ev) {
# We need to be able to fall through if the handler has # We need to be able to fall through if the handler has
# already been called (i.e., from within disconnect()). # already been called (i.e., from within disconnect()).
$self->handler($ev) unless $ev eq 'done'; $self->handler($ev) unless $ev eq 'done';
} else { } else {
# If it gets down to here, it's some exception I forgot about. # If it gets down to here, it's some exception I forgot about.
carp "Funky parse case: $line\n"; carp "Funky parse case: $line\n";
} }
@ -1317,7 +1310,6 @@ sub server {
my ($self) = shift; my ($self) = shift;
if (@_) { if (@_) {
# cases like "irc.server.com:6668" # cases like "irc.server.com:6668"
if (index($_[0], ':') > 0) { if (index($_[0], ':') > 0) {
my ($serv, $port) = split /:/, $_[0]; my ($serv, $port) = split /:/, $_[0];
@ -1390,7 +1382,6 @@ sub sl_real {
if ($self->{_utf8}) { $line = encode('UTF-8', $line); } if ($self->{_utf8}) { $line = encode('UTF-8', $line); }
my $rv = eval { my $rv = eval {
# RFC compliance can be kinda nice... # RFC compliance can be kinda nice...
my $rv = $self->ssl ? $self->socket->print("$line\015\012") : $self->socket->send("$line\015\012", 0); my $rv = $self->ssl ? $self->socket->print("$line\015\012") : $self->socket->send("$line\015\012", 0);
unless ($rv) { unless ($rv) {
@ -1487,7 +1478,6 @@ sub unignore {
} }
if (exists $self->{_ignore}->{$type}) { if (exists $self->{_ignore}->{$type}) {
# removes all specifed entries ala _Perl_Cookbook_ recipe 4.7 # removes all specifed entries ala _Perl_Cookbook_ recipe 4.7
my @temp = @{$self->{_ignore}->{$type}}; my @temp = @{$self->{_ignore}->{$type}};
@{$self->{_ignore}->{$type}} = (); @{$self->{_ignore}->{$type}} = ();
@ -1581,7 +1571,6 @@ sub _default {
$self->sl("PONG " . (CORE::join ' ', $event->args)); $self->sl("PONG " . (CORE::join ' ', $event->args));
} elsif ($event->type eq "disconnect") { } elsif ($event->type eq "disconnect") {
# I violate OO tenets. (It's consensual, of course.) # I violate OO tenets. (It's consensual, of course.)
unless (keys %{$self->parent->{_connhash}} > 0) { die "No active connections left, exiting...\n"; } unless (keys %{$self->parent->{_connhash}} > 0) { die "No active connections left, exiting...\n"; }
} }

View File

@ -80,7 +80,6 @@ sub _getline {
if ($block) { # Block mode (GET) if ($block) { # Block mode (GET)
return $input; return $input;
} else { # Line mode (CHAT) } else { # Line mode (CHAT)
# We're returning \n's 'cause DCC's need 'em # We're returning \n's 'cause DCC's need 'em
my @lines = split /\012/, $frag, -1; my @lines = split /\012/, $frag, -1;
@ -89,7 +88,6 @@ sub _getline {
return (@lines); return (@lines);
} }
} else { } else {
# um, if we can read, i say we should read more than 0 # um, if we can read, i say we should read more than 0
# besides, recv isn't returning undef on closed # besides, recv isn't returning undef on closed
# sockets. getting rid of this connection... # sockets. getting rid of this connection...
@ -110,7 +108,6 @@ sub _getline {
return; return;
} }
} else { } else {
# Error, lets scrap this connection # Error, lets scrap this connection
warn "recv() returned undef, socket error in _getline()\n" if $self->{_debug}; warn "recv() returned undef, socket error in _getline()\n" if $self->{_debug};
@ -450,7 +447,6 @@ sub parse {
$self->{_bin} += 4; $self->{_bin} += 4;
unless (defined $size) { unless (defined $size) {
# Dang! The other end unexpectedly canceled. # Dang! The other end unexpectedly canceled.
carp(($self->peer)[1] . " connection to " . ($self->peer)[0] . " lost"); carp(($self->peer)[1] . " connection to " . ($self->peer)[0] . " lost");
$self->{_fh}->close; $self->{_fh}->close;
@ -567,7 +563,6 @@ sub new {
my ($sock, $self); my ($sock, $self);
if ($type) { if ($type) {
# we're initiating # we're initiating
$sock = new IO::Socket::INET( $sock = new IO::Socket::INET(
@ -610,7 +605,6 @@ sub new {
} }
} else { # we're connecting } else { # we're connecting
$address = &PBot::IRC::DCC::Connection::fixaddr($address); # pragma_ 2011/21/01 $address = &PBot::IRC::DCC::Connection::fixaddr($address); # pragma_ 2011/21/01
return if $port < 1024 or not defined $address; return if $port < 1024 or not defined $address;
@ -760,7 +754,6 @@ sub parse {
$self->{_parent}->{_time} = time; $self->{_parent}->{_time} = time;
if ($self->{_parent}->{_type} eq 'SEND') { if ($self->{_parent}->{_type} eq 'SEND') {
# ok, to get the ball rolling, we send them the first packet. # ok, to get the ball rolling, we send them the first packet.
my $buf; my $buf;
unless (defined $self->{_parent}->{_fh}->read($buf, $self->{_parent}->{_blocksize})) { return; } unless (defined $self->{_parent}->{_fh}->read($buf, $self->{_parent}->{_blocksize})) { return; }

View File

@ -118,7 +118,6 @@ sub from {
my @part; my @part;
if (@_) { if (@_) {
# avoid certain irritating and spurious warnings from this line... # avoid certain irritating and spurious warnings from this line...
{ {
local $^W; local $^W;

View File

@ -426,7 +426,6 @@ sub on_departure {
my $message_account = $self->{pbot}->{messagehistory}->get_message_account($nick, $user, $host); my $message_account = $self->{pbot}->{messagehistory}->get_message_account($nick, $user, $host);
if ($text =~ m/^QUIT/) { if ($text =~ m/^QUIT/) {
# QUIT messages must be dispatched to each channel the user is on # QUIT messages must be dispatched to each channel the user is on
my $channels = $self->{pbot}->{nicklist}->get_channels($nick); my $channels = $self->{pbot}->{nicklist}->get_channels($nick);
foreach my $chan (@$channels) { foreach my $chan (@$channels) {
@ -547,13 +546,11 @@ sub on_topic {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
if (not length $event->{event}->{to}->[0]) { if (not length $event->{event}->{to}->[0]) {
# on join # on join
my (undef, $channel, $topic) = $event->{event}->args; my (undef, $channel, $topic) = $event->{event}->args;
$self->{pbot}->{logger}->log("Topic for $channel: $topic\n"); $self->{pbot}->{logger}->log("Topic for $channel: $topic\n");
$self->{pbot}->{channels}->{channels}->set($channel, 'TOPIC', $topic, 1); $self->{pbot}->{channels}->{channels}->set($channel, 'TOPIC', $topic, 1);
} else { } else {
# user changing topic # user changing topic
my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host); my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host);
my $channel = $event->{event}->{to}->[0]; my $channel = $event->{event}->{to}->[0];

View File

@ -145,7 +145,6 @@ sub process_line {
} }
foreach $command (@commands) { foreach $command (@commands) {
# check if user is ignored (and command isn't `login`) # check if user is ignored (and command isn't `login`)
if ($command !~ /^login / && defined $from && $pbot->{ignorelist}->check_ignore($nick, $user, $host, $from)) { if ($command !~ /^login / && defined $from && $pbot->{ignorelist}->check_ignore($nick, $user, $host, $from)) {
if (not $pbot->{users}->loggedin_admin($from, "$nick!$user\@$host")) { if (not $pbot->{users}->loggedin_admin($from, "$nick!$user\@$host")) {
@ -209,7 +208,6 @@ sub interpret {
push @{$stuff->{commands}}, $stuff->{command}; push @{$stuff->{commands}}, $stuff->{command};
if ($self->arglist_size($cmdlist) >= 4 and lc $cmdlist->[0] eq 'tell' and (lc $cmdlist->[2] eq 'about' or lc $cmdlist->[2] eq 'the')) { if ($self->arglist_size($cmdlist) >= 4 and lc $cmdlist->[0] eq 'tell' and (lc $cmdlist->[2] eq 'about' or lc $cmdlist->[2] eq 'the')) {
# tell nick about/the cmd [args] # tell nick about/the cmd [args]
$stuff->{nickoverride} = $cmdlist->[1]; $stuff->{nickoverride} = $cmdlist->[1];
($keyword, $arguments) = $self->split_args($cmdlist, 2, 3, 1); ($keyword, $arguments) = $self->split_args($cmdlist, 2, 3, 1);
@ -223,7 +221,6 @@ sub interpret {
delete $stuff->{force_nickoverride}; delete $stuff->{force_nickoverride};
} }
} else { } else {
# normal command # normal command
($keyword, $arguments) = $self->split_args($cmdlist, 2, 0, 1); ($keyword, $arguments) = $self->split_args($cmdlist, 2, 0, 1);
$arguments = "" if not defined $arguments; $arguments = "" if not defined $arguments;
@ -379,7 +376,6 @@ sub extract_bracketed {
if ($i >= @chars) { if ($i >= @chars) {
if ($extracting) { if ($extracting) {
# reached end, but unbalanced brackets... reset to beginning and ignore them # reached end, but unbalanced brackets... reset to beginning and ignore them
$i = $bracket_pos; $i = $bracket_pos;
$bracket_level = 0; $bracket_level = 0;
@ -389,7 +385,6 @@ sub extract_bracketed {
$token = ''; $token = '';
$result = ''; $result = '';
} else { } else {
# add final token and exit # add final token and exit
$rest .= $token if $extracted; $rest .= $token if $extracted;
last; last;
@ -532,7 +527,6 @@ sub split_line {
if ($i >= @chars) { if ($i >= @chars) {
if (defined $quote) { if (defined $quote) {
# reached end, but unbalanced quote... reset to beginning of quote and ignore it # reached end, but unbalanced quote... reset to beginning of quote and ignore it
$i = $pos; $i = $pos;
$ignore_quote = 1; $ignore_quote = 1;
@ -540,7 +534,6 @@ sub split_line {
$last_ch = ' '; $last_ch = ' ';
$token = $last_token; $token = $last_token;
} else { } else {
# add final token and exit # add final token and exit
push @args, $token if length $token; push @args, $token if length $token;
last; last;
@ -566,14 +559,12 @@ sub split_line {
if (defined $quote) { if (defined $quote) {
if ($ch eq $quote and (not defined $next_ch or $next_ch =~ /[\s,:;})\].+=]/)) { if ($ch eq $quote and (not defined $next_ch or $next_ch =~ /[\s,:;})\].+=]/)) {
# closing quote # closing quote
$token .= $ch unless $opts{strip_quotes}; $token .= $ch unless $opts{strip_quotes};
push @args, $token; push @args, $token;
$quote = undef; $quote = undef;
$token = ''; $token = '';
} else { } else {
# still within quoted argument # still within quoted argument
$token .= $ch; $token .= $ch;
} }
@ -582,12 +573,10 @@ sub split_line {
if (($last_ch =~ /[\s:{(\[.+=]/) and not defined $quote and ($ch eq "'" or $ch eq '"')) { if (($last_ch =~ /[\s:{(\[.+=]/) and not defined $quote and ($ch eq "'" or $ch eq '"')) {
if ($ignore_quote) { if ($ignore_quote) {
# treat unbalanced quote as part of this argument # treat unbalanced quote as part of this argument
$token .= $ch; $token .= $ch;
$ignore_quote = 0; $ignore_quote = 0;
} else { } else {
# begin potential quoted argument # begin potential quoted argument
$pos = $i - 1; $pos = $i - 1;
$quote = $ch; $quote = $ch;
@ -699,7 +688,6 @@ sub split_args {
# join the get rest as a string # join the get rest as a string
my $rest; my $rest;
if ($preserve_quotes) { if ($preserve_quotes) {
# get from second half of args, which contains quotes # get from second half of args, which contains quotes
$rest = join ' ', @$args[@$args / 2 + $i .. @$args - 1]; $rest = join ' ', @$args[@$args / 2 + $i .. @$args - 1];
} else { } else {

View File

@ -99,7 +99,6 @@ sub lagging {
my $self = shift; 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 # 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 $elapsed = tv_interval($self->{ping_send_time});
return $elapsed >= $self->{pbot}->{registry}->get_value('lagchecker', 'lag_threshold'); return $elapsed >= $self->{pbot}->{registry}->get_value('lagchecker', 'lag_threshold');
@ -119,7 +118,6 @@ sub lagcheck {
my ($self, $from, $nick, $user, $host, $arguments) = @_; 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 # 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 $elapsed = tv_interval($self->{ping_send_time});
my $lag_total = $elapsed; my $lag_total = $elapsed;

View File

@ -295,7 +295,6 @@ sub recall_message {
my $message; my $message;
if ($recall_history =~ /^\d+$/) { if ($recall_history =~ /^\d+$/) {
# integral history # integral history
if (defined $account) { if (defined $account) {
my $max_messages = $self->{database}->get_max_messages($account, $recall_channel); my $max_messages = $self->{database}->get_max_messages($account, $recall_channel);
@ -324,7 +323,6 @@ sub recall_message {
if (not defined $message) { return "No message found at index $recall_history in channel $recall_channel."; } if (not defined $message) { return "No message found at index $recall_history in channel $recall_channel."; }
} else { } else {
# regex history # regex history
$message = $self->{database}->recall_message_by_text($account, $recall_channel, $recall_history, '(?:recall|mock|ftfy|fix)'); $message = $self->{database}->recall_message_by_text($account, $recall_channel, $recall_history, '(?:recall|mock|ftfy|fix)');

View File

@ -495,7 +495,6 @@ sub get_message_account {
$self->{pbot}->{logger}->log("2: distance match: $host vs $thost == " . ($distance / $length) . "\n"); $self->{pbot}->{logger}->log("2: distance match: $host vs $thost == " . ($distance / $length) . "\n");
$match = 1; $match = 1;
} else { } else {
# handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net # handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net
if (defined $hostip) { if (defined $hostip) {
if ($hostip eq $thost) { if ($hostip eq $thost) {
@ -632,7 +631,6 @@ sub get_message_account {
$self->{pbot}->{logger}->log("7: distance match: $host vs $thost == " . ($distance / $length) . "\n"); $self->{pbot}->{logger}->log("7: distance match: $host vs $thost == " . ($distance / $length) . "\n");
$match = 1; $match = 1;
} else { } else {
# handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net # handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net
if (defined $hostip) { if (defined $hostip) {
if ($hostip eq $thost) { if ($hostip eq $thost) {
@ -1374,7 +1372,6 @@ sub link_aliases {
$ids{$row->{id}} = {id => $row->{id}, type => $self->{alias_type}->{STRONG}}; # don't force linking $ids{$row->{id}} = {id => $row->{id}, type => $self->{alias_type}->{STRONG}}; # don't force linking
$self->{pbot}->{logger}->log("found STRONG matching id $row->{id} ($row->{hostmask}) for nick [$nick]\n") if $debug_link >= 2; $self->{pbot}->{logger}->log("found STRONG matching id $row->{id} ($row->{hostmask}) for nick [$nick]\n") if $debug_link >= 2;
} else { } else {
# handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net # handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net
if (defined $hostip) { if (defined $hostip) {
if ($hostip eq $thost) { if ($hostip eq $thost) {
@ -1567,7 +1564,6 @@ sub get_also_known_as {
my $rows = $sth->fetchall_arrayref({}); my $rows = $sth->fetchall_arrayref({});
foreach my $row (@$rows) { foreach my $row (@$rows) {
# next if $row->{type} == $self->{alias_type}->{WEAK}; # next if $row->{type} == $self->{alias_type}->{WEAK};
$ids{$row->{alias}} = {id => $id, type => $row->{type}}; $ids{$row->{alias}} = {id => $id, type => $row->{type}};
$self->{pbot}->{logger}->log("[$id] 1) Adding $row->{alias} -> $id [type $row->{type}]\n") if $debug; $self->{pbot}->{logger}->log("[$id] 1) Adding $row->{alias} -> $id [type $row->{type}]\n") if $debug;
@ -1788,7 +1784,6 @@ sub get_message_account_id {
}; };
$self->{pbot}->{logger}->log($@) if $@; $self->{pbot}->{logger}->log($@) if $@;
#$self->{pbot}->{logger}->log("get_message_account_id: returning id [". (defined $id ? $id: 'undef') . "] for mask [$mask]\n"); #$self->{pbot}->{logger}->log("get_message_account_id: returning id [". (defined $id ? $id: 'undef') . "] for mask [$mask]\n");
return $id; return $id;
} }
@ -1799,7 +1794,6 @@ sub commit_message_history {
return if not $self->{dbh}; 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"); # $self->{pbot}->{logger}->log("Commiting $self->{new_entries} messages to SQLite\n");
eval { $self->{dbh}->commit(); }; eval { $self->{dbh}->commit(); };

View File

@ -253,7 +253,6 @@ sub connect {
my ($self, $server) = @_; my ($self, $server) = @_;
if ($self->{connected}) { if ($self->{connected}) {
# TODO: disconnect, clean-up, etc # TODO: disconnect, clean-up, etc
} }

View File

@ -81,7 +81,6 @@ sub execute_process {
} }
if ($stuff->{pid} == 0) { if ($stuff->{pid} == 0) {
# child # child
close $reader; close $reader;
@ -116,12 +115,10 @@ sub execute_process {
# end child # end child
exit 0; exit 0;
} else { } else {
# parent # parent
close $writer; close $writer;
$self->add_process($stuff->{pid}, $stuff); $self->add_process($stuff->{pid}, $stuff);
$self->{pbot}->{select_handler}->add_reader($reader, sub { $self->process_pipe_reader($stuff->{pid}, @_) }); $self->{pbot}->{select_handler}->add_reader($reader, sub { $self->process_pipe_reader($stuff->{pid}, @_) });
# return empty string since reader will handle the output when child is finished # return empty string since reader will handle the output when child is finished
return ""; return "";
} }
@ -152,7 +149,6 @@ sub process_pipe_reader {
if (defined $stuff->{nickoverride}) { $self->{pbot}->{interpreter}->handle_result($stuff, $stuff->{result}); } if (defined $stuff->{nickoverride}) { $self->{pbot}->{interpreter}->handle_result($stuff, $stuff->{result}); }
else { else {
# don't override nick if already set # don't override nick if already set
if ( exists $stuff->{special} if ( exists $stuff->{special}
and $stuff->{special} ne 'code-factoid' and $stuff->{special} ne 'code-factoid'
@ -163,22 +159,18 @@ sub process_pipe_reader {
$stuff->{no_nickoverride} = 0; $stuff->{no_nickoverride} = 0;
$stuff->{force_nickoverride} = 1; $stuff->{force_nickoverride} = 1;
} else { } else {
# extract nick-like thing from module result # extract nick-like thing from module result
if ($stuff->{result} =~ s/^(\S+): //) { if ($stuff->{result} =~ s/^(\S+): //) {
my $nick = $1; my $nick = $1;
if (lc $nick eq "usage") { if (lc $nick eq "usage") {
# put it back on result if it's a usage message # put it back on result if it's a usage message
$stuff->{result} = "$nick: $stuff->{result}"; $stuff->{result} = "$nick: $stuff->{result}";
} else { } else {
my $present = $self->{pbot}->{nicklist}->is_present($stuff->{channel}, $nick); my $present = $self->{pbot}->{nicklist}->is_present($stuff->{channel}, $nick);
if ($present) { if ($present) {
# nick is present in channel # nick is present in channel
$stuff->{nickoverride} = $present; $stuff->{nickoverride} = $present;
} else { } else {
# nick not present, put it back on result # nick not present, put it back on result
$stuff->{result} = "$nick: $stuff->{result}"; $stuff->{result} = "$nick: $stuff->{result}";
} }

View File

@ -167,7 +167,6 @@ sub regfind {
foreach my $item_key (sort $registry->get_keys($section_key)) { foreach my $item_key (sort $registry->get_keys($section_key)) {
next if $item_key eq '_name'; next if $item_key eq '_name';
if ($registry->get_data($section_key, $item_key, 'private')) { if ($registry->get_data($section_key, $item_key, 'private')) {
# do not match on value if private # do not match on value if private
next if $item_key !~ /$arguments/i; next if $item_key !~ /$arguments/i;
} else { } else {

View File

@ -64,7 +64,6 @@ sub on_tick_handler {
if ($self->{enabled}) { if ($self->{enabled}) {
if ($#{$self->{handlers}} > -1) { if ($#{$self->{handlers}} > -1) {
# call handlers supplied via register() if timeout for each has elapsed # call handlers supplied via register() if timeout for each has elapsed
foreach my $func (@{$self->{handlers}}) { foreach my $func (@{$self->{handlers}}) {
if (defined $func->{last}) { if (defined $func->{last}) {
@ -85,7 +84,6 @@ sub on_tick_handler {
} }
} }
} else { } else {
# call default overridable handler if timeout has elapsed # call default overridable handler if timeout has elapsed
if (defined $self->{last}) { if (defined $self->{last}) {
$self->{last} -= $max_seconds if $seconds < $self->{last}; # handle wrap-around $self->{last} -= $max_seconds if $seconds < $self->{last}; # handle wrap-around

View File

@ -147,13 +147,11 @@ sub find_user_account {
foreach my $chan (sort $sort $self->{users}->get_keys) { foreach my $chan (sort $sort $self->{users}->get_keys) {
if (($channel !~ m/^#/ and $any_channel) or $channel =~ m/^$chan$/i) { if (($channel !~ m/^#/ and $any_channel) or $channel =~ m/^$chan$/i) {
if (not $self->{users}->exists($chan, $hostmask)) { if (not $self->{users}->exists($chan, $hostmask)) {
# find hostmask by account name or wildcard # find hostmask by account name or wildcard
foreach my $mask ($self->{users}->get_keys($chan)) { foreach my $mask ($self->{users}->get_keys($chan)) {
if (lc $self->{users}->get_data($chan, $mask, 'name') eq $hostmask) { return ($chan, $mask); } if (lc $self->{users}->get_data($chan, $mask, 'name') eq $hostmask) { return ($chan, $mask); }
if ($mask =~ /[*?]/) { if ($mask =~ /[*?]/) {
# contains * or ? so it's converted to a regex # contains * or ? so it's converted to a regex
my $mask_quoted = quotemeta $mask; my $mask_quoted = quotemeta $mask;
$mask_quoted =~ s/\\\*/.*?/g; $mask_quoted =~ s/\\\*/.*?/g;
@ -191,14 +189,12 @@ sub find_user {
if (($channel !~ m/^#/ and $any_channel) or $channel =~ m/^$channel_regex$/i) { if (($channel !~ m/^#/ and $any_channel) or $channel =~ m/^$channel_regex$/i) {
foreach my $hostmask_regex ($self->{users}->get_keys($channel_regex)) { foreach my $hostmask_regex ($self->{users}->get_keys($channel_regex)) {
if ($hostmask_regex =~ m/[*?]/) { if ($hostmask_regex =~ m/[*?]/) {
# contains * or ? so it's converted to a regex # contains * or ? so it's converted to a regex
my $hostmask_quoted = quotemeta $hostmask_regex; my $hostmask_quoted = quotemeta $hostmask_regex;
$hostmask_quoted =~ s/\\\*/.*?/g; $hostmask_quoted =~ s/\\\*/.*?/g;
$hostmask_quoted =~ s/\\\?/./g; $hostmask_quoted =~ s/\\\?/./g;
if ($hostmask =~ m/^$hostmask_quoted$/i) { return $self->{users}->get_data($channel_regex, $hostmask_regex); } if ($hostmask =~ m/^$hostmask_quoted$/i) { return $self->{users}->get_data($channel_regex, $hostmask_regex); }
} else { } else {
# direct comparison # direct comparison
if ($hostmask eq lc $hostmask_regex) { return $self->{users}->get_data($channel_regex, $hostmask_regex); } if ($hostmask eq lc $hostmask_regex) { return $self->{users}->get_data($channel_regex, $hostmask_regex); }
} }
@ -514,7 +510,6 @@ sub mycmd {
my ($existing_channel, $existing_hostmask) = $self->find_user_account($channel, $name); my ($existing_channel, $existing_hostmask) = $self->find_user_account($channel, $name);
if ($existing_hostmask ne lc $name) { if ($existing_hostmask ne lc $name) {
# user exists by name # user exists by name
return "There is already an user account named $name but its hostmask ($existing_hostmask) does not match your hostmask ($hostmask). Ask an admin for help."; return "There is already an user account named $name but its hostmask ($existing_hostmask) does not match your hostmask ($hostmask). Ask an admin for help.";
} }

View File

@ -24,7 +24,6 @@ sub validate_string {
}; };
if ($@) { if ($@) {
# not a json string # not a json string
$string = substr $string, 0, $max_length unless $max_length <= 0; $string = substr $string, 0, $max_length unless $max_length <= 0;
} }

View File

@ -181,7 +181,6 @@ sub grab_quotegrab {
my $message; my $message;
if ($grab_history =~ /^\d+$/) { if ($grab_history =~ /^\d+$/) {
# integral history # integral history
my $max_messages = $self->{pbot}->{messagehistory}->{database}->get_max_messages($account, $channel); my $max_messages = $self->{pbot}->{messagehistory}->{database}->get_max_messages($account, $channel);
if ($grab_history < 1 || $grab_history > $max_messages) { return "Please choose a history between 1 and $max_messages"; } if ($grab_history < 1 || $grab_history > $max_messages) { return "Please choose a history between 1 and $max_messages"; }
@ -190,7 +189,6 @@ sub grab_quotegrab {
$message = $self->{pbot}->{messagehistory}->{database}->recall_message_by_count($account, $channel, $grab_history, 'grab'); $message = $self->{pbot}->{messagehistory}->{database}->recall_message_by_count($account, $channel, $grab_history, 'grab');
} else { } else {
# regex history # regex history
$message = $self->{pbot}->{messagehistory}->{database}->recall_message_by_text($account, $channel, $grab_history, 'grab'); $message = $self->{pbot}->{messagehistory}->{database}->recall_message_by_text($account, $channel, $grab_history, 'grab');
@ -229,7 +227,6 @@ sub grab_quotegrab {
($grab_nick) = split /\+/, $grab_nicks, 2; ($grab_nick) = split /\+/, $grab_nicks, 2;
if ($text =~ s/^(NICKCHANGE)\b/changed nick to/ or $text =~ s/^(KICKED|QUIT)\b/lc "$1"/e or $text =~ s/^(JOIN|PART)\b/lc "$1ed"/e) { if ($text =~ s/^(NICKCHANGE)\b/changed nick to/ or $text =~ s/^(KICKED|QUIT)\b/lc "$1"/e or $text =~ s/^(JOIN|PART)\b/lc "$1ed"/e) {
# fix ugly "[nick] quit Quit: Leaving." messages # fix ugly "[nick] quit Quit: Leaving." messages
$text =~ s/^(quit) (.*)/$1 ($2)/; $text =~ s/^(quit) (.*)/$1 ($2)/;
return "Quote grabbed: $quotegrab->{id}: $grab_nick $text"; return "Quote grabbed: $quotegrab->{id}: $grab_nick $text";
@ -325,7 +322,6 @@ sub show_random_quotegrab {
if (defined $channel_search and $channel_search !~ /^#/) { if (defined $channel_search and $channel_search !~ /^#/) {
if ($channel_search eq $nick) { $channel_search = undef; } if ($channel_search eq $nick) { $channel_search = undef; }
elsif ($channel_search =~ m/^\./) { elsif ($channel_search =~ m/^\./) {
# do nothing # do nothing
} else { } else {
return "$channel_search is not a valid channel."; return "$channel_search is not a valid channel.";

View File

@ -98,10 +98,8 @@ sub check_queue {
my ($time, $channel, $nick, $user, $host, $msg) = @{$self->{queue}->[0]}; my ($time, $channel, $nick, $user, $host, $msg) = @{$self->{queue}->[0]};
if ($now >= $time) { if ($now >= $time) {
# if nick is still present in channel, send the message # if nick is still present in channel, send the message
if ($self->{pbot}->{nicklist}->is_present($channel, $nick)) { if ($self->{pbot}->{nicklist}->is_present($channel, $nick)) {
# ensure they're not banned (+z allows us to see +q/+b messages as normal ones) # ensure they're not banned (+z allows us to see +q/+b messages as normal ones)
my $banned = $self->{pbot}->{bantracker}->is_banned($nick, $user, $host, $channel); my $banned = $self->{pbot}->{bantracker}->is_banned($nick, $user, $host, $channel);
$self->{pbot}->{logger} $self->{pbot}->{logger}

View File

@ -319,7 +319,6 @@ sub check_reminders {
} }
foreach my $reminder (@$reminders) { foreach my $reminder (@$reminders) {
# ensures we get the current nick of the person # ensures we get the current nick of the person
my $hostmask = $self->{pbot}->{messagehistory}->{database}->find_most_recent_hostmask($reminder->{account}); my $hostmask = $self->{pbot}->{messagehistory}->{database}->find_most_recent_hostmask($reminder->{account});
my ($nick) = $hostmask =~ /^([^!]+)!/; my ($nick) = $hostmask =~ /^([^!]+)!/;

View File

@ -1561,7 +1561,6 @@ sub choosecategory {
} }
if (++$state->{counter} > $state->{max_count}) { if (++$state->{counter} > $state->{max_count}) {
# $state->{players}->[$state->{current_player}]->{missedinputs}++; # $state->{players}->[$state->{current_player}]->{missedinputs}++;
my $name = $state->{players}->[$state->{current_player}]->{name}; my $name = $state->{players}->[$state->{current_player}]->{name};
my $category = $state->{category_options}->[rand(@{$state->{category_options}} - 2)]; my $category = $state->{category_options}->[rand(@{$state->{category_options}} - 2)];