mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-24 11:42:35 +01:00
Remove unnecessary ${} around some objects from previous commit
This commit is contained in:
parent
30e3c5ce35
commit
1cce945412
@ -53,8 +53,8 @@ sub get_banlist {
|
||||
delete $self->{banlist}->{$channel};
|
||||
|
||||
$self->{pbot}->{logger}->log("Retrieving banlist for $channel.\n");
|
||||
${conn}->sl("mode $channel +b");
|
||||
${conn}->sl("mode $channel +q");
|
||||
$conn->sl("mode $channel +b");
|
||||
$conn->sl("mode $channel +q");
|
||||
}
|
||||
|
||||
sub get_baninfo {
|
||||
|
@ -347,8 +347,8 @@ sub add_regex {
|
||||
|
||||
if(not defined $keyword) {
|
||||
$text = "";
|
||||
foreach my $trigger (sort keys %{ ${factoids}->{$from} }) {
|
||||
if(${factoids}->{$from}->{$trigger}->{type} eq 'regex') {
|
||||
foreach my $trigger (sort keys %{ $factoids->{$from} }) {
|
||||
if($factoids->{$from}->{$trigger}->{type} eq 'regex') {
|
||||
$text .= $trigger . " ";
|
||||
}
|
||||
}
|
||||
@ -412,12 +412,12 @@ sub factrem {
|
||||
return "/msg $nick $from_trigger not found in channel $from_chan.";
|
||||
}
|
||||
|
||||
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 [not factoid]\n");
|
||||
return "/msg $nick $trigger is not a factoid.";
|
||||
}
|
||||
|
||||
my ($owner) = ${factoids}->{$channel}->{$trigger}->{'owner'} =~ m/([^!]+)/;
|
||||
my ($owner) = $factoids->{$channel}->{$trigger}->{'owner'} =~ m/([^!]+)/;
|
||||
|
||||
if((lc $nick ne lc $owner) and (not $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host"))) {
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host attempted to remove $trigger [not owner]\n");
|
||||
@ -425,11 +425,11 @@ sub factrem {
|
||||
return "/msg $nick You are not the owner of '$trigger' for $chan";
|
||||
}
|
||||
|
||||
if(exists ${factoids}->{$channel}->{$trigger}->{'locked'} and ${factoids}->{$channel}->{$trigger}->{'locked'} != 0) {
|
||||
if(exists $factoids->{$channel}->{$trigger}->{'locked'} and $factoids->{$channel}->{$trigger}->{'locked'} != 0) {
|
||||
return "$trigger is locked; unlock before deleting.";
|
||||
}
|
||||
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host removed [$channel][$trigger][" . ${factoids}->{$channel}->{$trigger}->{action} . "]\n");
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host removed [$channel][$trigger][" . $factoids->{$channel}->{$trigger}->{action} . "]\n");
|
||||
$self->{pbot}->{factoids}->remove_factoid($channel, $trigger);
|
||||
return "/msg $nick $trigger removed from " . ($channel eq '.*' ? 'the global channel' : $channel) . ".";
|
||||
}
|
||||
@ -442,8 +442,8 @@ sub histogram {
|
||||
my $factoid_count = 0;
|
||||
|
||||
foreach my $command (keys %{ $factoids }) {
|
||||
if(exists ${factoids}->{$command}{text}) {
|
||||
$hash{${factoids}->{$command}{owner}}++;
|
||||
if(exists $factoids->{$command}{text}) {
|
||||
$hash{$factoids->{$command}{owner}}++;
|
||||
$factoid_count++;
|
||||
}
|
||||
}
|
||||
@ -478,9 +478,9 @@ sub factshow {
|
||||
return "/msg $nick '$trig' not found in channel '$chan'";
|
||||
}
|
||||
|
||||
my $result = "$trigger: " . ${factoids}->{$channel}->{$trigger}->{action};
|
||||
my $result = "$trigger: " . $factoids->{$channel}->{$trigger}->{action};
|
||||
|
||||
if(${factoids}->{$channel}->{$trigger}->{type} eq 'module') {
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'module') {
|
||||
$result .= ' [module]';
|
||||
}
|
||||
|
||||
@ -504,24 +504,24 @@ sub factinfo {
|
||||
return "'$trig' not found in channel '$chan'";
|
||||
}
|
||||
|
||||
my $created_ago = ago(gettimeofday - ${factoids}->{$channel}->{$trigger}->{created_on});
|
||||
my $ref_ago = ago(gettimeofday - ${factoids}->{$channel}->{$trigger}->{last_referenced_on}) if defined ${factoids}->{$channel}->{$trigger}->{last_referenced_on};
|
||||
my $created_ago = ago(gettimeofday - $factoids->{$channel}->{$trigger}->{created_on});
|
||||
my $ref_ago = ago(gettimeofday - $factoids->{$channel}->{$trigger}->{last_referenced_on}) if defined $factoids->{$channel}->{$trigger}->{last_referenced_on};
|
||||
|
||||
$chan = ($channel eq '.*' ? 'global channel' : $channel);
|
||||
|
||||
# factoid
|
||||
if(${factoids}->{$channel}->{$trigger}->{type} eq 'text') {
|
||||
return "$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]" : "") . ")";
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'text') {
|
||||
return "$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') {
|
||||
return "$trigger: Module loaded by " . ${factoids}->{$channel}->{$trigger}->{owner} . " for $chan on " . localtime(${factoids}->{$channel}->{$trigger}->{created_on}) . " [$created_ago] -> http://code.google.com/p/pbot2-pl/source/browse/trunk/modules/" . ${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]" : "") . ")";
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'module') {
|
||||
return "$trigger: Module loaded by " . $factoids->{$channel}->{$trigger}->{owner} . " for $chan on " . localtime($factoids->{$channel}->{$trigger}->{created_on}) . " [$created_ago] -> http://code.google.com/p/pbot2-pl/source/browse/trunk/modules/" . $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') {
|
||||
return "$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]" : "") . ")";
|
||||
if($factoids->{$channel}->{$trigger}->{type} eq 'regex') {
|
||||
return "$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]" : "") . ")";
|
||||
}
|
||||
|
||||
return "/msg $nick $trigger is not a factoid or a module";
|
||||
@ -544,9 +544,9 @@ sub top20 {
|
||||
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') {
|
||||
$text .= "$command (${factoids}->{$chan}->{$command}{ref_count}) ";
|
||||
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') {
|
||||
$text .= "$command ($factoids->{$chan}->{$command}{ref_count}) ";
|
||||
$i++;
|
||||
last if $i >= 20;
|
||||
}
|
||||
@ -561,9 +561,9 @@ sub top20 {
|
||||
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} }) {
|
||||
my $ago = ago(gettimeofday - ${factoids}->{$chan}->{$command}->{created_on});
|
||||
$text .= " $command [$ago by ${factoids}->{$chan}->{$command}->{owner}]\n";
|
||||
foreach my $command (sort { $factoids->{$chan}->{$b}{created_on} <=> $factoids->{$chan}->{$a}{created_on} } keys %{ $factoids->{$chan} }) {
|
||||
my $ago = ago(gettimeofday - $factoids->{$chan}->{$command}->{created_on});
|
||||
$text .= " $command [$ago by $factoids->{$chan}->{$command}->{owner}]\n";
|
||||
$i++;
|
||||
last if $i >= 50;
|
||||
}
|
||||
@ -576,12 +576,12 @@ sub top20 {
|
||||
my $user = lc $args;
|
||||
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) {
|
||||
$user .= " (${factoids}->{$chan}->{$command}{ref_user})";
|
||||
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) {
|
||||
$user .= " ($factoids->{$chan}->{$command}{ref_user})";
|
||||
}
|
||||
my $ago = ${factoids}->{$chan}->{$command}{last_referenced_on} ? ago(gettimeofday - ${factoids}->{$chan}->{$command}{last_referenced_on}) : "unknown";
|
||||
my $ago = $factoids->{$chan}->{$command}{last_referenced_on} ? ago(gettimeofday - $factoids->{$chan}->{$command}{last_referenced_on}) : "unknown";
|
||||
$text .= " $command [$ago]\n";
|
||||
$i++;
|
||||
last if $i >= 20;
|
||||
@ -608,9 +608,9 @@ sub count {
|
||||
|
||||
eval {
|
||||
foreach my $command (keys %{ $factoids }) {
|
||||
$total++ if exists ${factoids}->{$command}{text};
|
||||
$total++ if exists $factoids->{$command}{text};
|
||||
my $regex = qr/^\Q$arguments\E$/;
|
||||
if(${factoids}->{$command}{owner} =~ /$regex/i && exists ${factoids}->{$command}{text}) {
|
||||
if($factoids->{$command}{owner} =~ /$regex/i && exists $factoids->{$command}{text}) {
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -685,10 +685,10 @@ sub factfind {
|
||||
eval {
|
||||
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 && ${factoids}->{$chan}->{$trigger}->{ref_user} =~ /$by/i) {
|
||||
next if($arguments ne "" && ${factoids}->{$chan}->{$trigger}->{action} !~ /$arguments/i && $trigger !~ /$arguments/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 && $factoids->{$chan}->{$trigger}->{ref_user} =~ /$by/i) {
|
||||
next if($arguments ne "" && $factoids->{$chan}->{$trigger}->{action} !~ /$arguments/i && $trigger !~ /$arguments/i);
|
||||
|
||||
$i++;
|
||||
|
||||
@ -708,7 +708,7 @@ sub factfind {
|
||||
|
||||
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}";
|
||||
return "found one factoid submitted for " . ($last_chan eq '.*' ? 'global channel' : $last_chan) . " " . $argtype . ": $last_trigger is $factoids->{$last_chan}->{$last_trigger}->{action}";
|
||||
} else {
|
||||
return "found $i factoids " . $argtype . ": $text" unless $i == 0;
|
||||
|
||||
@ -747,21 +747,21 @@ sub factchange {
|
||||
return "/msg $nick $keyword not found in channel $from.";
|
||||
}
|
||||
|
||||
if(not $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host") and exists ${factoids}->{$channel}->{$trigger}->{'locked'} and ${factoids}->{$channel}->{$trigger}->{'locked'} != 0) {
|
||||
if(not $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host") and exists $factoids->{$channel}->{$trigger}->{'locked'} and $factoids->{$channel}->{$trigger}->{'locked'} != 0) {
|
||||
return "$trigger is locked and cannot be changed.";
|
||||
}
|
||||
|
||||
my $ret = eval {
|
||||
use re::engine::RE2 -strict => 1;
|
||||
if(not ${factoids}->{$channel}->{$trigger}->{action} =~ s|$tochange|$changeto|) {
|
||||
if(not $factoids->{$channel}->{$trigger}->{action} =~ s|$tochange|$changeto|) {
|
||||
$self->{pbot}->{logger}->log("($from) $nick!$user\@$host: failed to change '$trigger' 's$delim$tochange$delim$changeto$delim\n");
|
||||
return "/msg $nick Change $trigger failed.";
|
||||
} else {
|
||||
$self->{pbot}->{logger}->log("($from) $nick!$user\@$host: changed '$trigger' 's/$tochange/$changeto/\n");
|
||||
${factoids}->{$channel}->{$trigger}->{edited_by} = "$nick!$user\@$host";
|
||||
${factoids}->{$channel}->{$trigger}->{edited_on} = gettimeofday;
|
||||
$factoids->{$channel}->{$trigger}->{edited_by} = "$nick!$user\@$host";
|
||||
$factoids->{$channel}->{$trigger}->{edited_on} = gettimeofday;
|
||||
$self->{pbot}->{factoids}->save_factoids();
|
||||
return "Changed: $trigger is " . ${factoids}->{$channel}->{$trigger}->{action};
|
||||
return "Changed: $trigger is " . $factoids->{$channel}->{$trigger}->{action};
|
||||
}
|
||||
};
|
||||
return "/msg $nick Change $trigger: $@" if $@;
|
||||
@ -778,11 +778,11 @@ sub load_module {
|
||||
return "/msg $nick Usage: load <command> <module>";
|
||||
}
|
||||
|
||||
if(not exists(${factoids}->{$keyword})) {
|
||||
${factoids}->{$keyword}{module} = $module;
|
||||
${factoids}->{$keyword}{enabled} = 1;
|
||||
${factoids}->{$keyword}{owner} = $nick;
|
||||
${factoids}->{$keyword}{created_on} = time();
|
||||
if(not exists($factoids->{$keyword})) {
|
||||
$factoids->{$keyword}{module} = $module;
|
||||
$factoids->{$keyword}{enabled} = 1;
|
||||
$factoids->{$keyword}{owner} = $nick;
|
||||
$factoids->{$keyword}{created_on} = time();
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host loaded $keyword => $module\n");
|
||||
$self->{pbot}->{factoids}->save_factoids();
|
||||
return "/msg $nick Loaded $keyword => $module";
|
||||
@ -798,12 +798,12 @@ sub unload_module {
|
||||
|
||||
if(not defined $arguments) {
|
||||
return "/msg $nick Usage: unload <module>";
|
||||
} elsif(not exists ${factoids}->{$arguments}) {
|
||||
} elsif(not exists $factoids->{$arguments}) {
|
||||
return "/msg $nick $arguments not found.";
|
||||
} elsif(not exists ${factoids}->{$arguments}{module}) {
|
||||
} elsif(not exists $factoids->{$arguments}{module}) {
|
||||
return "/msg $nick $arguments is not a module.";
|
||||
} else {
|
||||
delete ${factoids}->{$arguments};
|
||||
delete $factoids->{$arguments};
|
||||
$self->{pbot}->{factoids}->save_factoids();
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host unloaded module $arguments\n");
|
||||
return "/msg $nick $arguments unloaded.";
|
||||
@ -817,10 +817,10 @@ sub enable_command {
|
||||
|
||||
if(not defined $arguments) {
|
||||
return "/msg $nick Usage: enable <command>";
|
||||
} elsif(not exists ${factoids}->{$arguments}) {
|
||||
} elsif(not exists $factoids->{$arguments}) {
|
||||
return "/msg $nick $arguments not found.";
|
||||
} else {
|
||||
${factoids}->{$arguments}{enabled} = 1;
|
||||
$factoids->{$arguments}{enabled} = 1;
|
||||
$self->{pbot}->{factoids}->save_factoids();
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host enabled $arguments\n");
|
||||
return "/msg $nick $arguments enabled.";
|
||||
@ -834,10 +834,10 @@ sub disable_command {
|
||||
|
||||
if(not defined $arguments) {
|
||||
return "/msg $nick Usage: disable <command>";
|
||||
} elsif(not exists ${factoids}->{$arguments}) {
|
||||
} elsif(not exists $factoids->{$arguments}) {
|
||||
return "/msg $nick $arguments not found.";
|
||||
} else {
|
||||
${factoids}->{$arguments}{enabled} = 0;
|
||||
$factoids->{$arguments}{enabled} = 0;
|
||||
$self->{pbot}->{factoids}->save_factoids();
|
||||
$self->{pbot}->{logger}->log("$nick!$user\@$host disabled $arguments\n");
|
||||
return "/msg $nick $arguments disabled.";
|
||||
|
22
PBot/IRC.pm
22
PBot/IRC.pm
@ -71,7 +71,7 @@ sub schedulequeue {
|
||||
sub addconn {
|
||||
my ($self, $conn) = @_;
|
||||
|
||||
$self->addfh( ${conn}->socket, ${conn}->can('parse'), ($_[2] || 'r'), $conn);
|
||||
$self->addfh( $conn->socket, $conn->can('parse'), ($_[2] || 'r'), $conn);
|
||||
}
|
||||
|
||||
# Adds a filehandle to the select loop. Tasty and flavorful.
|
||||
@ -171,11 +171,11 @@ sub do_one_loop {
|
||||
my $conn = $self->{_connhash}->{$sock};
|
||||
$conn or next;
|
||||
|
||||
# ${conn}->[0] is a code reference to a handler sub.
|
||||
# ${conn}->[1] is optionally an object which the
|
||||
# $conn->[0] is a code reference to a handler sub.
|
||||
# $conn->[1] is optionally an object which the
|
||||
# handler sub may be a method of.
|
||||
|
||||
${conn}->[0]->(${conn}->[1] ? (${conn}->[1], $sock) : $sock);
|
||||
$conn->[0]->($conn->[1] ? ($conn->[1], $sock) : $sock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,7 +194,7 @@ sub newconn {
|
||||
my $self = shift;
|
||||
my $conn = PBot::IRC::Connection->new($self, @_); # pragma_ 2011/01/21
|
||||
|
||||
return if ${conn}->error;
|
||||
return if $conn->error;
|
||||
return $conn;
|
||||
}
|
||||
|
||||
@ -237,7 +237,7 @@ sub dequeue_output_event {
|
||||
sub removeconn {
|
||||
my ($self, $conn) = @_;
|
||||
|
||||
$self->removefh( ${conn}->socket );
|
||||
$self->removefh( $conn->socket );
|
||||
}
|
||||
|
||||
# Given a filehandle, removes it from all select lists. You get the picture.
|
||||
@ -295,11 +295,11 @@ and we'll be happy to help you out with bringing your bots into the modern era.
|
||||
use Net::IRC;
|
||||
|
||||
$irc = new Net::IRC;
|
||||
$conn = ${irc}->newconn(Nick => 'some_nick',
|
||||
$conn = $irc->newconn(Nick => 'some_nick',
|
||||
Server => 'some.irc.server.com',
|
||||
Port => 6667,
|
||||
Ircname => 'Some witty comment.');
|
||||
${irc}->start;
|
||||
$irc->start;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
@ -416,7 +416,7 @@ To that end, say something like this:
|
||||
|
||||
$irc = new Net::IRC;
|
||||
|
||||
$conn = ${irc}->newconn(Nick => 'some_nick',
|
||||
$conn = $irc->newconn(Nick => 'some_nick',
|
||||
Server => 'some.irc.server.com');
|
||||
|
||||
...or something similar. Acceptable parameters to newconn() are:
|
||||
@ -531,7 +531,7 @@ When you've set up all your handlers, the following command will put your
|
||||
program in an infinite loop, grabbing input from all open connections and
|
||||
passing it off to the proper handlers:
|
||||
|
||||
${irc}->start;
|
||||
$irc->start;
|
||||
|
||||
Note that new connections can be added and old ones dropped from within your
|
||||
handlers even after you call this. Just don't expect any code below the call
|
||||
@ -610,7 +610,7 @@ B<Optional:> A string containing any combination of the letters r, w or e
|
||||
conditions you're expecting on that filehandle. For example, this line
|
||||
select()s $fh (a filehandle, of course) for both reading and writing:
|
||||
|
||||
${irc}->addfh( $fh, \&callback, "rw" );
|
||||
$irc->addfh( $fh, \&callback, "rw" );
|
||||
|
||||
=back
|
||||
|
||||
|
@ -38,14 +38,14 @@ sub initialize {
|
||||
sub on_connect {
|
||||
my ($self, $conn) = @_;
|
||||
$self->{pbot}->{logger}->log("Connected!\n");
|
||||
${conn}->{connected} = 1;
|
||||
$conn->{connected} = 1;
|
||||
}
|
||||
|
||||
sub on_disconnect {
|
||||
my ($self, $conn, $event) = @_;
|
||||
$self->{pbot}->{logger}->log("Disconnected, attempting to reconnect...\n");
|
||||
${conn}->connect();
|
||||
if(not ${conn}->connected) {
|
||||
$conn->connect();
|
||||
if(not $conn->connected) {
|
||||
sleep(5);
|
||||
$self->on_disconnect($self, $conn, $event);
|
||||
}
|
||||
@ -91,14 +91,14 @@ sub on_notice {
|
||||
|
||||
if($nick eq "NickServ" && $text =~ m/This nickname is registered/) {
|
||||
$self->{pbot}->{logger}->log("Identifying with NickServ . . .\n");
|
||||
${conn}->privmsg("nickserv", "identify " . $self->{pbot}->{registry}->get_value('irc', 'identify_password'));
|
||||
$conn->privmsg("nickserv", "identify " . $self->{pbot}->{registry}->get_value('irc', 'identify_password'));
|
||||
}
|
||||
|
||||
if($nick eq "NickServ" && $text =~ m/You are now identified/) {
|
||||
foreach my $chan (keys %{ $self->{pbot}->{channels}->{channels}->hash }) {
|
||||
if($self->{pbot}->{channels}->{channels}->hash->{$chan}{enabled}) {
|
||||
$self->{pbot}->{logger}->log("Joining channel: $chan\n");
|
||||
${conn}->join($chan);
|
||||
$conn->join($chan);
|
||||
}
|
||||
}
|
||||
$self->{pbot}->{joined_channels} = 1;
|
||||
@ -153,7 +153,7 @@ sub on_mode {
|
||||
}
|
||||
elsif($mode eq "+b") {
|
||||
$self->{pbot}->{logger}->log("Got banned in $channel, attempting unban.");
|
||||
${conn}->privmsg("chanserv", "unban $channel");
|
||||
$conn->privmsg("chanserv", "unban $channel");
|
||||
}
|
||||
}
|
||||
else { # bot not targeted
|
||||
|
@ -13,7 +13,7 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 585,
|
||||
BUILD_REVISION => 586,
|
||||
BUILD_DATE => "2014-05-18",
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user