mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-22 20:09:43 +01:00
Tidy things up
This commit is contained in:
parent
5c4e10a35c
commit
fe56b9f0db
@ -136,7 +136,6 @@ sub update_join_watch {
|
||||
$channel_data->{join_watch}++;
|
||||
$self->{pbot}->{messagehistory}->{database}->update_channel_data($account, $channel, $channel_data);
|
||||
} 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/) {
|
||||
@ -148,16 +147,13 @@ sub update_join_watch {
|
||||
|
||||
# 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/) {
|
||||
|
||||
# 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}) {
|
||||
|
||||
# reset joinwatch if they send a message
|
||||
if ($channel_data->{join_watch} > 0) {
|
||||
$channel_data->{join_watch} = 0;
|
||||
@ -263,13 +259,11 @@ sub check_flood {
|
||||
|
||||
foreach my $chan (@$channels) {
|
||||
$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
|
||||
next if $chan =~ /^#/ and not $self->{pbot}->{chanops}->can_gain_ops($chan);
|
||||
my $u = $self->{pbot}->{users}->loggedin($chan, "$nick!$user\@$host");
|
||||
|
||||
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
|
||||
my $chan_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($account, $chan, '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 ($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}) {
|
||||
@ -302,7 +295,6 @@ sub check_flood {
|
||||
}
|
||||
} else {
|
||||
if ($mode == $self->{pbot}->{messagehistory}->{MSG_JOIN} && exists $self->{pbot}->{irc_capabilities}->{'extended-join'}) {
|
||||
|
||||
# don't WHOIS joins if extended-join capability is active
|
||||
} elsif (not exists $self->{pbot}->{irc_capabilities}->{'account-notify'}) {
|
||||
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);
|
||||
$msg = $nickchanges->[0];
|
||||
} elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) {
|
||||
|
||||
# no flood checks to be done for departure events
|
||||
next;
|
||||
} else {
|
||||
@ -675,7 +666,6 @@ sub address_to_mask {
|
||||
}
|
||||
|
||||
sub devalidate_accounts {
|
||||
|
||||
# remove validation on accounts in $channel that match a ban/quiet $mask
|
||||
my ($self, $mask, $channel) = @_;
|
||||
my @message_accounts;
|
||||
@ -727,7 +717,6 @@ sub check_bans {
|
||||
}
|
||||
} else {
|
||||
if (not exists $self->{pbot}->{irc_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}) {
|
||||
@ -813,7 +802,6 @@ sub check_bans {
|
||||
my $u = $self->{pbot}->{users}->loggedin($baninfo->{channel}, $mask);
|
||||
my $whitelisted = $self->{pbot}->{capabilities}->userhas($u, 'is-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");
|
||||
next;
|
||||
}
|
||||
|
@ -149,10 +149,6 @@ sub get_baninfo {
|
||||
$baninfo->{owner} = $self->{banlist}->{$channel}->{$mode}->{$banmask_key}->[0];
|
||||
$baninfo->{when} = $self->{banlist}->{$channel}->{$mode}->{$banmask_key}->[1];
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@ -212,7 +208,6 @@ sub track_mode {
|
||||
if ($mode eq "-b") {
|
||||
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")) {
|
||||
|
||||
# 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");
|
||||
}
|
||||
|
@ -138,7 +138,6 @@ sub invite {
|
||||
my ($channel, $target);
|
||||
|
||||
if ($from !~ m/^#/) {
|
||||
|
||||
# from /msg
|
||||
my $usage = "Usage from /msg: invite <channel> [nick]; if you omit [nick] then you will be invited";
|
||||
return $usage if not length $arguments;
|
||||
@ -146,7 +145,6 @@ sub invite {
|
||||
return "$channel is not a channel; $usage" if $channel !~ m/^#/;
|
||||
$target = $nick if not defined $target;
|
||||
} else {
|
||||
|
||||
# in channel
|
||||
return "Usage: invite [channel] <nick>" if not length $arguments;
|
||||
|
||||
@ -168,7 +166,6 @@ sub generic_mode_user {
|
||||
my ($flag, $mode_char) = $mode_flag =~ m/(.)(.)/;
|
||||
|
||||
if ($channel !~ m/^#/) {
|
||||
|
||||
# from message
|
||||
$channel = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist});
|
||||
if (not defined $channel) { return "Usage from message: $mode_name <channel> [nick]"; }
|
||||
@ -271,7 +268,6 @@ sub mode {
|
||||
my $target = $targets[$arg++] // "";
|
||||
|
||||
if (($mode eq 'v' or $mode eq 'o') and $target =~ m/\*/) {
|
||||
|
||||
# wildcard used; find all matching nicks; test against whitelist, etc
|
||||
my $q_target = lc quotemeta $target;
|
||||
$q_target =~ s/\\\*/.*/g;
|
||||
@ -295,7 +291,6 @@ sub mode {
|
||||
my $nick_data = $self->{pbot}->{nicklist}->{nicklist}->{$channel}->{$n};
|
||||
|
||||
if ($modifier eq '-') {
|
||||
|
||||
# removing mode -- check against whitelist, etc
|
||||
next if $nick_data->{nick} eq $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
||||
my $u = $self->{pbot}->{users}->loggedin($channel, $nick_data->{hostmask});
|
||||
@ -320,7 +315,6 @@ sub mode {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
# no wildcard used; explicit mode requested - no whitelist checking
|
||||
$new_modes .= $mode;
|
||||
$new_targets .= "$target " if length $target;
|
||||
@ -624,12 +618,10 @@ sub kick_user {
|
||||
my ($channel, $victim, $reason);
|
||||
|
||||
if (not $from =~ /^#/) {
|
||||
|
||||
# used in private message
|
||||
if (not $arguments =~ s/^(^#\S+) (\S+)\s*//) { return "Usage from private message: kick <channel> <nick> [reason]"; }
|
||||
($channel, $victim) = ($1, $2);
|
||||
} else {
|
||||
|
||||
# used in channel
|
||||
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); }
|
||||
@ -657,7 +649,6 @@ sub kick_user {
|
||||
my @nicks = split /,/, $victim;
|
||||
foreach my $n (@nicks) {
|
||||
if ($n =~ m/\*/) {
|
||||
|
||||
# wildcard used; find all matching nicks; test against whitelist, etc
|
||||
my $q_target = lc quotemeta $n;
|
||||
$q_target =~ s/\\\*/.*/g;
|
||||
@ -682,7 +673,6 @@ sub kick_user {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
# no wildcard used, explicit kick
|
||||
$self->{pbot}->{chanops}->add_op_command($channel, "kick $channel $n $reason");
|
||||
}
|
||||
|
@ -166,7 +166,6 @@ sub find_factoid_with_optional_channel {
|
||||
|
||||
my $needs_disambig;
|
||||
if (not defined $from_trigger) {
|
||||
|
||||
# cmd arg1, so insert $from as channel
|
||||
$from_trigger = $from_chan;
|
||||
$from_chan = $from;
|
||||
@ -174,10 +173,8 @@ sub find_factoid_with_optional_channel {
|
||||
|
||||
#$needs_disambig = 1;
|
||||
} else {
|
||||
|
||||
# cmd arg1 arg2 [...?]
|
||||
if ($from_chan !~ /^#/ and lc $from_chan ne 'global' and $from_chan ne '.*') {
|
||||
|
||||
# not a channel or global, so must be a keyword
|
||||
my $keyword = $from_chan;
|
||||
$from_chan = $from;
|
||||
@ -332,7 +329,6 @@ sub factundo {
|
||||
my $deleted;
|
||||
|
||||
if (not defined $trigger) {
|
||||
|
||||
# factoid not found or some error, try to continue and load undo file if it exists
|
||||
$deleted = 1;
|
||||
($channel, $trigger) = $self->{pbot}->{interpreter}->split_args($arglist, 2);
|
||||
@ -541,12 +537,10 @@ sub factset {
|
||||
my $owner;
|
||||
my $mask;
|
||||
if ($factoid->{'locked'}) {
|
||||
|
||||
# check owner against full hostmask for locked factoids
|
||||
$owner = $factoid->{'owner'};
|
||||
$mask = "$nick!$user\@$host";
|
||||
} else {
|
||||
|
||||
# otherwise just the nick
|
||||
($owner) = $factoid->{'owner'} =~ m/([^!]+)/;
|
||||
$mask = $nick;
|
||||
@ -704,7 +698,6 @@ sub factalias {
|
||||
my ($chan, $alias, $command) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3, 0, 1);
|
||||
|
||||
if (defined $chan and not($chan eq '.*' or $chan =~ m/^#/)) {
|
||||
|
||||
# $chan doesn't look like a channel, so shift everything to the right
|
||||
# and replace $chan with $from
|
||||
if (defined $command and length $command) { $command = "$alias $command"; }
|
||||
@ -782,7 +775,6 @@ sub factadd {
|
||||
my @arglist = @{$stuff->{arglist}};
|
||||
|
||||
if (@arglist) {
|
||||
|
||||
# check for -f since we allow it to be before optional channel argument
|
||||
if ($arglist[0] eq '-f') {
|
||||
$force = 1;
|
||||
@ -804,7 +796,6 @@ sub factadd {
|
||||
|
||||
# check for -url
|
||||
if ($arglist[0] eq '-url') {
|
||||
|
||||
# discard it
|
||||
$self->{pbot}->{interpreter}->shift_arg(\@arglist);
|
||||
|
||||
@ -824,7 +815,6 @@ sub factadd {
|
||||
if ($response->is_success) { $text = $response->decoded_content; }
|
||||
else { return "Failed to get URL: " . $response->status_line; }
|
||||
} else {
|
||||
|
||||
# check for optional "is" and discard
|
||||
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);
|
||||
|
||||
if (not defined $trigger) {
|
||||
|
||||
# factoid not found or some error, try to continue and load factlog file if it exists
|
||||
my $arglist = $self->{pbot}->{interpreter}->make_args($args);
|
||||
($channel, $trigger) = $self->{pbot}->{interpreter}->split_args($arglist, 2);
|
||||
@ -1486,7 +1475,6 @@ sub factchange {
|
||||
my $action = $factoids_data->get_data($channel, $trigger, 'action');
|
||||
|
||||
if (defined $url) {
|
||||
|
||||
# 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"; }
|
||||
|
||||
|
@ -86,7 +86,6 @@ sub add_factoid {
|
||||
|
||||
my $data;
|
||||
if ($self->{factoids}->exists($channel, $trigger)) {
|
||||
|
||||
# only update action field if force-adding it through factadd -f
|
||||
$data = $self->{factoids}->get_data($channel, $trigger);
|
||||
$data->{action} = $action;
|
||||
@ -905,7 +904,6 @@ sub handle_action {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
# no arguments supplied, replace $args with $nick/$tonick, etc
|
||||
if ($self->{factoids}->exists($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; }
|
||||
else { return ""; }
|
||||
} elsif ($self->{factoids}->get_data($channel, $keyword, 'type') eq 'text') {
|
||||
|
||||
# Don't allow user-custom /msg factoids, unless factoid triggered by admin
|
||||
if ($action =~ m/^\/msg/i) {
|
||||
my $admin = $self->{pbot}->{users}->loggedin_admin($stuff->{from}, "$stuff->{nick}!$stuff->{user}\@$stuff->{host}");
|
||||
|
@ -150,7 +150,6 @@ sub _add_generic_handler {
|
||||
elsif ($rp =~ /^\D/) { $rp = $define{lc $rp} || 0; }
|
||||
|
||||
foreach $ev (ref $event eq "ARRAY" ? @{$event} : $event) {
|
||||
|
||||
# Translate numerics to names
|
||||
if ($ev =~ /^\d/) {
|
||||
$ev = PBot::IRC::Event->trans($ev); # pragma_ 2011/21/01
|
||||
@ -701,7 +700,6 @@ sub new_chat {
|
||||
my ($init, $nick, $address, $port);
|
||||
|
||||
if (ref($_[0]) =~ /Event/) {
|
||||
|
||||
# If it's from an Event object, we can't be initiating, right?
|
||||
($init, undef, undef, undef, $address, $port) = (0, $_[0]->args);
|
||||
$nick = $_[0]->nick;
|
||||
@ -826,7 +824,6 @@ sub parse {
|
||||
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) {
|
||||
|
||||
# grab any remnant from the last go and split into lines
|
||||
my $chunk = $self->{_frag} . $line;
|
||||
@lines = split /\012/, $chunk;
|
||||
@ -836,7 +833,6 @@ sub parse {
|
||||
$self->{_frag} = (substr($chunk, -1) ne "\012" ? pop @lines : '');
|
||||
|
||||
} else {
|
||||
|
||||
# um, if we can read, i say we should read more than 0
|
||||
# besides, recv isn't returning undef on closed
|
||||
# sockets. getting rid of this connection...
|
||||
@ -1054,7 +1050,6 @@ sub parse {
|
||||
|
||||
} elsif ($line =~ /^ERROR/) {
|
||||
if ($line =~ /^ERROR :Closing [Ll]ink/) { # is this compatible?
|
||||
|
||||
$ev = 'done';
|
||||
$self->disconnect('error', ($line =~ /(.*)/));
|
||||
|
||||
@ -1074,14 +1069,12 @@ sub parse {
|
||||
}
|
||||
|
||||
if ($ev) {
|
||||
|
||||
# We need to be able to fall through if the handler has
|
||||
# already been called (i.e., from within disconnect()).
|
||||
|
||||
$self->handler($ev) unless $ev eq 'done';
|
||||
|
||||
} else {
|
||||
|
||||
# If it gets down to here, it's some exception I forgot about.
|
||||
carp "Funky parse case: $line\n";
|
||||
}
|
||||
@ -1317,7 +1310,6 @@ sub server {
|
||||
my ($self) = shift;
|
||||
|
||||
if (@_) {
|
||||
|
||||
# cases like "irc.server.com:6668"
|
||||
if (index($_[0], ':') > 0) {
|
||||
my ($serv, $port) = split /:/, $_[0];
|
||||
@ -1390,7 +1382,6 @@ sub sl_real {
|
||||
if ($self->{_utf8}) { $line = encode('UTF-8', $line); }
|
||||
|
||||
my $rv = eval {
|
||||
|
||||
# RFC compliance can be kinda nice...
|
||||
my $rv = $self->ssl ? $self->socket->print("$line\015\012") : $self->socket->send("$line\015\012", 0);
|
||||
unless ($rv) {
|
||||
@ -1487,7 +1478,6 @@ sub unignore {
|
||||
}
|
||||
|
||||
if (exists $self->{_ignore}->{$type}) {
|
||||
|
||||
# removes all specifed entries ala _Perl_Cookbook_ recipe 4.7
|
||||
my @temp = @{$self->{_ignore}->{$type}};
|
||||
@{$self->{_ignore}->{$type}} = ();
|
||||
@ -1581,7 +1571,6 @@ sub _default {
|
||||
$self->sl("PONG " . (CORE::join ' ', $event->args));
|
||||
|
||||
} elsif ($event->type eq "disconnect") {
|
||||
|
||||
# I violate OO tenets. (It's consensual, of course.)
|
||||
unless (keys %{$self->parent->{_connhash}} > 0) { die "No active connections left, exiting...\n"; }
|
||||
}
|
||||
|
@ -80,7 +80,6 @@ sub _getline {
|
||||
|
||||
if ($block) { # Block mode (GET)
|
||||
return $input;
|
||||
|
||||
} else { # Line mode (CHAT)
|
||||
# We're returning \n's 'cause DCC's need 'em
|
||||
my @lines = split /\012/, $frag, -1;
|
||||
@ -89,7 +88,6 @@ sub _getline {
|
||||
return (@lines);
|
||||
}
|
||||
} else {
|
||||
|
||||
# um, if we can read, i say we should read more than 0
|
||||
# besides, recv isn't returning undef on closed
|
||||
# sockets. getting rid of this connection...
|
||||
@ -110,7 +108,6 @@ sub _getline {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
# Error, lets scrap this connection
|
||||
|
||||
warn "recv() returned undef, socket error in _getline()\n" if $self->{_debug};
|
||||
@ -450,7 +447,6 @@ sub parse {
|
||||
$self->{_bin} += 4;
|
||||
|
||||
unless (defined $size) {
|
||||
|
||||
# Dang! The other end unexpectedly canceled.
|
||||
carp(($self->peer)[1] . " connection to " . ($self->peer)[0] . " lost");
|
||||
$self->{_fh}->close;
|
||||
@ -567,7 +563,6 @@ sub new {
|
||||
my ($sock, $self);
|
||||
|
||||
if ($type) {
|
||||
|
||||
# we're initiating
|
||||
|
||||
$sock = new IO::Socket::INET(
|
||||
@ -610,7 +605,6 @@ sub new {
|
||||
}
|
||||
|
||||
} else { # we're connecting
|
||||
|
||||
$address = &PBot::IRC::DCC::Connection::fixaddr($address); # pragma_ 2011/21/01
|
||||
return if $port < 1024 or not defined $address;
|
||||
|
||||
@ -760,7 +754,6 @@ sub parse {
|
||||
$self->{_parent}->{_time} = time;
|
||||
|
||||
if ($self->{_parent}->{_type} eq 'SEND') {
|
||||
|
||||
# ok, to get the ball rolling, we send them the first packet.
|
||||
my $buf;
|
||||
unless (defined $self->{_parent}->{_fh}->read($buf, $self->{_parent}->{_blocksize})) { return; }
|
||||
|
@ -118,7 +118,6 @@ sub from {
|
||||
my @part;
|
||||
|
||||
if (@_) {
|
||||
|
||||
# avoid certain irritating and spurious warnings from this line...
|
||||
{
|
||||
local $^W;
|
||||
|
@ -426,7 +426,6 @@ sub on_departure {
|
||||
my $message_account = $self->{pbot}->{messagehistory}->get_message_account($nick, $user, $host);
|
||||
|
||||
if ($text =~ m/^QUIT/) {
|
||||
|
||||
# QUIT messages must be dispatched to each channel the user is on
|
||||
my $channels = $self->{pbot}->{nicklist}->get_channels($nick);
|
||||
foreach my $chan (@$channels) {
|
||||
@ -547,13 +546,11 @@ sub on_topic {
|
||||
my ($self, $event_type, $event) = @_;
|
||||
|
||||
if (not length $event->{event}->{to}->[0]) {
|
||||
|
||||
# on join
|
||||
my (undef, $channel, $topic) = $event->{event}->args;
|
||||
$self->{pbot}->{logger}->log("Topic for $channel: $topic\n");
|
||||
$self->{pbot}->{channels}->{channels}->set($channel, 'TOPIC', $topic, 1);
|
||||
} else {
|
||||
|
||||
# user changing topic
|
||||
my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host);
|
||||
my $channel = $event->{event}->{to}->[0];
|
||||
|
@ -145,7 +145,6 @@ sub process_line {
|
||||
}
|
||||
|
||||
foreach $command (@commands) {
|
||||
|
||||
# check if user is ignored (and command isn't `login`)
|
||||
if ($command !~ /^login / && defined $from && $pbot->{ignorelist}->check_ignore($nick, $user, $host, $from)) {
|
||||
if (not $pbot->{users}->loggedin_admin($from, "$nick!$user\@$host")) {
|
||||
@ -209,7 +208,6 @@ sub interpret {
|
||||
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')) {
|
||||
|
||||
# tell nick about/the cmd [args]
|
||||
$stuff->{nickoverride} = $cmdlist->[1];
|
||||
($keyword, $arguments) = $self->split_args($cmdlist, 2, 3, 1);
|
||||
@ -223,7 +221,6 @@ sub interpret {
|
||||
delete $stuff->{force_nickoverride};
|
||||
}
|
||||
} else {
|
||||
|
||||
# normal command
|
||||
($keyword, $arguments) = $self->split_args($cmdlist, 2, 0, 1);
|
||||
$arguments = "" if not defined $arguments;
|
||||
@ -379,7 +376,6 @@ sub extract_bracketed {
|
||||
|
||||
if ($i >= @chars) {
|
||||
if ($extracting) {
|
||||
|
||||
# reached end, but unbalanced brackets... reset to beginning and ignore them
|
||||
$i = $bracket_pos;
|
||||
$bracket_level = 0;
|
||||
@ -389,7 +385,6 @@ sub extract_bracketed {
|
||||
$token = '';
|
||||
$result = '';
|
||||
} else {
|
||||
|
||||
# add final token and exit
|
||||
$rest .= $token if $extracted;
|
||||
last;
|
||||
@ -532,7 +527,6 @@ sub split_line {
|
||||
|
||||
if ($i >= @chars) {
|
||||
if (defined $quote) {
|
||||
|
||||
# reached end, but unbalanced quote... reset to beginning of quote and ignore it
|
||||
$i = $pos;
|
||||
$ignore_quote = 1;
|
||||
@ -540,7 +534,6 @@ sub split_line {
|
||||
$last_ch = ' ';
|
||||
$token = $last_token;
|
||||
} else {
|
||||
|
||||
# add final token and exit
|
||||
push @args, $token if length $token;
|
||||
last;
|
||||
@ -566,14 +559,12 @@ sub split_line {
|
||||
|
||||
if (defined $quote) {
|
||||
if ($ch eq $quote and (not defined $next_ch or $next_ch =~ /[\s,:;})\].+=]/)) {
|
||||
|
||||
# closing quote
|
||||
$token .= $ch unless $opts{strip_quotes};
|
||||
push @args, $token;
|
||||
$quote = undef;
|
||||
$token = '';
|
||||
} else {
|
||||
|
||||
# still within quoted argument
|
||||
$token .= $ch;
|
||||
}
|
||||
@ -582,12 +573,10 @@ sub split_line {
|
||||
|
||||
if (($last_ch =~ /[\s:{(\[.+=]/) and not defined $quote and ($ch eq "'" or $ch eq '"')) {
|
||||
if ($ignore_quote) {
|
||||
|
||||
# treat unbalanced quote as part of this argument
|
||||
$token .= $ch;
|
||||
$ignore_quote = 0;
|
||||
} else {
|
||||
|
||||
# begin potential quoted argument
|
||||
$pos = $i - 1;
|
||||
$quote = $ch;
|
||||
@ -699,7 +688,6 @@ sub split_args {
|
||||
# join the get rest as a string
|
||||
my $rest;
|
||||
if ($preserve_quotes) {
|
||||
|
||||
# get from second half of args, which contains quotes
|
||||
$rest = join ' ', @$args[@$args / 2 + $i .. @$args - 1];
|
||||
} else {
|
||||
|
@ -99,7 +99,6 @@ sub lagging {
|
||||
my $self = shift;
|
||||
|
||||
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');
|
||||
@ -119,7 +118,6 @@ sub lagcheck {
|
||||
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
||||
|
||||
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;
|
||||
|
@ -295,7 +295,6 @@ sub recall_message {
|
||||
my $message;
|
||||
|
||||
if ($recall_history =~ /^\d+$/) {
|
||||
|
||||
# integral history
|
||||
if (defined $account) {
|
||||
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."; }
|
||||
} else {
|
||||
|
||||
# regex history
|
||||
$message = $self->{database}->recall_message_by_text($account, $recall_channel, $recall_history, '(?:recall|mock|ftfy|fix)');
|
||||
|
||||
|
@ -495,7 +495,6 @@ sub get_message_account {
|
||||
$self->{pbot}->{logger}->log("2: distance match: $host vs $thost == " . ($distance / $length) . "\n");
|
||||
$match = 1;
|
||||
} else {
|
||||
|
||||
# handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net
|
||||
if (defined $hostip) {
|
||||
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");
|
||||
$match = 1;
|
||||
} else {
|
||||
|
||||
# handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net
|
||||
if (defined $hostip) {
|
||||
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
|
||||
$self->{pbot}->{logger}->log("found STRONG matching id $row->{id} ($row->{hostmask}) for nick [$nick]\n") if $debug_link >= 2;
|
||||
} else {
|
||||
|
||||
# handle cases like 99.57.140.149 vs 99-57-140-149.lightspeed.sntcca.sbcglobal.net
|
||||
if (defined $hostip) {
|
||||
if ($hostip eq $thost) {
|
||||
@ -1567,7 +1564,6 @@ sub get_also_known_as {
|
||||
my $rows = $sth->fetchall_arrayref({});
|
||||
|
||||
foreach my $row (@$rows) {
|
||||
|
||||
# next if $row->{type} == $self->{alias_type}->{WEAK};
|
||||
$ids{$row->{alias}} = {id => $id, type => $row->{type}};
|
||||
$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("get_message_account_id: returning id [". (defined $id ? $id: 'undef') . "] for mask [$mask]\n");
|
||||
return $id;
|
||||
}
|
||||
@ -1799,7 +1794,6 @@ sub commit_message_history {
|
||||
return if not $self->{dbh};
|
||||
|
||||
if ($self->{new_entries} > 0) {
|
||||
|
||||
# $self->{pbot}->{logger}->log("Commiting $self->{new_entries} messages to SQLite\n");
|
||||
eval { $self->{dbh}->commit(); };
|
||||
|
||||
|
@ -253,7 +253,6 @@ sub connect {
|
||||
my ($self, $server) = @_;
|
||||
|
||||
if ($self->{connected}) {
|
||||
|
||||
# TODO: disconnect, clean-up, etc
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,6 @@ sub execute_process {
|
||||
}
|
||||
|
||||
if ($stuff->{pid} == 0) {
|
||||
|
||||
# child
|
||||
close $reader;
|
||||
|
||||
@ -116,12 +115,10 @@ sub execute_process {
|
||||
# end child
|
||||
exit 0;
|
||||
} else {
|
||||
|
||||
# parent
|
||||
close $writer;
|
||||
$self->add_process($stuff->{pid}, $stuff);
|
||||
$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 "";
|
||||
}
|
||||
@ -152,7 +149,6 @@ sub process_pipe_reader {
|
||||
|
||||
if (defined $stuff->{nickoverride}) { $self->{pbot}->{interpreter}->handle_result($stuff, $stuff->{result}); }
|
||||
else {
|
||||
|
||||
# don't override nick if already set
|
||||
if ( exists $stuff->{special}
|
||||
and $stuff->{special} ne 'code-factoid'
|
||||
@ -163,22 +159,18 @@ sub process_pipe_reader {
|
||||
$stuff->{no_nickoverride} = 0;
|
||||
$stuff->{force_nickoverride} = 1;
|
||||
} else {
|
||||
|
||||
# extract nick-like thing from module result
|
||||
if ($stuff->{result} =~ s/^(\S+): //) {
|
||||
my $nick = $1;
|
||||
if (lc $nick eq "usage") {
|
||||
|
||||
# put it back on result if it's a usage message
|
||||
$stuff->{result} = "$nick: $stuff->{result}";
|
||||
} else {
|
||||
my $present = $self->{pbot}->{nicklist}->is_present($stuff->{channel}, $nick);
|
||||
if ($present) {
|
||||
|
||||
# nick is present in channel
|
||||
$stuff->{nickoverride} = $present;
|
||||
} else {
|
||||
|
||||
# nick not present, put it back on result
|
||||
$stuff->{result} = "$nick: $stuff->{result}";
|
||||
}
|
||||
|
@ -167,7 +167,6 @@ sub regfind {
|
||||
foreach my $item_key (sort $registry->get_keys($section_key)) {
|
||||
next if $item_key eq '_name';
|
||||
if ($registry->get_data($section_key, $item_key, 'private')) {
|
||||
|
||||
# do not match on value if private
|
||||
next if $item_key !~ /$arguments/i;
|
||||
} else {
|
||||
|
@ -64,7 +64,6 @@ sub on_tick_handler {
|
||||
|
||||
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}) {
|
||||
@ -85,7 +84,6 @@ sub on_tick_handler {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
# call default overridable handler if timeout has elapsed
|
||||
if (defined $self->{last}) {
|
||||
$self->{last} -= $max_seconds if $seconds < $self->{last}; # handle wrap-around
|
||||
|
@ -147,13 +147,11 @@ sub find_user_account {
|
||||
foreach my $chan (sort $sort $self->{users}->get_keys) {
|
||||
if (($channel !~ m/^#/ and $any_channel) or $channel =~ m/^$chan$/i) {
|
||||
if (not $self->{users}->exists($chan, $hostmask)) {
|
||||
|
||||
# find hostmask by account name or wildcard
|
||||
foreach my $mask ($self->{users}->get_keys($chan)) {
|
||||
if (lc $self->{users}->get_data($chan, $mask, 'name') eq $hostmask) { return ($chan, $mask); }
|
||||
|
||||
if ($mask =~ /[*?]/) {
|
||||
|
||||
# contains * or ? so it's converted to a regex
|
||||
my $mask_quoted = quotemeta $mask;
|
||||
$mask_quoted =~ s/\\\*/.*?/g;
|
||||
@ -191,14 +189,12 @@ sub find_user {
|
||||
if (($channel !~ m/^#/ and $any_channel) or $channel =~ m/^$channel_regex$/i) {
|
||||
foreach my $hostmask_regex ($self->{users}->get_keys($channel_regex)) {
|
||||
if ($hostmask_regex =~ m/[*?]/) {
|
||||
|
||||
# contains * or ? so it's converted to a regex
|
||||
my $hostmask_quoted = quotemeta $hostmask_regex;
|
||||
$hostmask_quoted =~ s/\\\*/.*?/g;
|
||||
$hostmask_quoted =~ s/\\\?/./g;
|
||||
if ($hostmask =~ m/^$hostmask_quoted$/i) { return $self->{users}->get_data($channel_regex, $hostmask_regex); }
|
||||
} else {
|
||||
|
||||
# direct comparison
|
||||
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);
|
||||
if ($existing_hostmask ne lc $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.";
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ sub validate_string {
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
|
||||
# not a json string
|
||||
$string = substr $string, 0, $max_length unless $max_length <= 0;
|
||||
}
|
||||
|
@ -181,7 +181,6 @@ sub grab_quotegrab {
|
||||
my $message;
|
||||
|
||||
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) { 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');
|
||||
} else {
|
||||
|
||||
# regex history
|
||||
$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;
|
||||
|
||||
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
|
||||
$text =~ s/^(quit) (.*)/$1 ($2)/;
|
||||
return "Quote grabbed: $quotegrab->{id}: $grab_nick $text";
|
||||
@ -325,7 +322,6 @@ sub show_random_quotegrab {
|
||||
if (defined $channel_search and $channel_search !~ /^#/) {
|
||||
if ($channel_search eq $nick) { $channel_search = undef; }
|
||||
elsif ($channel_search =~ m/^\./) {
|
||||
|
||||
# do nothing
|
||||
} else {
|
||||
return "$channel_search is not a valid channel.";
|
||||
|
@ -98,10 +98,8 @@ sub check_queue {
|
||||
my ($time, $channel, $nick, $user, $host, $msg) = @{$self->{queue}->[0]};
|
||||
|
||||
if ($now >= $time) {
|
||||
|
||||
# if nick is still present in channel, send the message
|
||||
if ($self->{pbot}->{nicklist}->is_present($channel, $nick)) {
|
||||
|
||||
# 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);
|
||||
$self->{pbot}->{logger}
|
||||
|
@ -319,7 +319,6 @@ sub check_reminders {
|
||||
}
|
||||
|
||||
foreach my $reminder (@$reminders) {
|
||||
|
||||
# ensures we get the current nick of the person
|
||||
my $hostmask = $self->{pbot}->{messagehistory}->{database}->find_most_recent_hostmask($reminder->{account});
|
||||
my ($nick) = $hostmask =~ /^([^!]+)!/;
|
||||
|
@ -1561,7 +1561,6 @@ sub choosecategory {
|
||||
}
|
||||
|
||||
if (++$state->{counter} > $state->{max_count}) {
|
||||
|
||||
# $state->{players}->[$state->{current_player}]->{missedinputs}++;
|
||||
my $name = $state->{players}->[$state->{current_player}]->{name};
|
||||
my $category = $state->{category_options}->[rand(@{$state->{category_options}} - 2)];
|
||||
|
Loading…
Reference in New Issue
Block a user