mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 03:02:47 +01:00
See Changes file
This commit is contained in:
parent
d299a8fb0f
commit
a743261059
@ -53,7 +53,7 @@ sub check_flood {
|
|||||||
|
|
||||||
$channel = lc $channel;
|
$channel = lc $channel;
|
||||||
|
|
||||||
$self->{pbot}->logger->log(sprintf("check flood %-48s %-16s <%10s> %s\n", "$nick!$user\@$host", "[$channel]", , $nick, $text));
|
$self->{pbot}->logger->log(sprintf("%-14s | %-65s | %s\n", $channel, "$nick!$user\@$host", $text));
|
||||||
|
|
||||||
return if $nick eq $self->{pbot}->botnick;
|
return if $nick eq $self->{pbot}->botnick;
|
||||||
|
|
||||||
|
@ -7,8 +7,11 @@
|
|||||||
# e.g., factoids need channel parameter, e.g. C factoids vs. C++ factoids (with an option to allow a factoid across all channels)
|
# e.g., factoids need channel parameter, e.g. C factoids vs. C++ factoids (with an option to allow a factoid across all channels)
|
||||||
# [for 1.0]
|
# [for 1.0]
|
||||||
#
|
#
|
||||||
# TODO: Ignorelist saves and loads from file, uses regex hash keys.
|
# TODO: Ignorelist needs to save and load from file, use regex hash keys/search parameters.
|
||||||
#
|
#
|
||||||
|
# 0.6.2-beta (03/25/10): 'list messages' command significant improved -- can use regexs search parameters.
|
||||||
|
# Added optional regex search to 'rq' quotegrab command to match against quotegrab text.
|
||||||
|
# Channel chat messages easier to read in log (from anti-flood module).
|
||||||
# 0.6.1-beta (03/23/10): Quotegrab ids properly adjusted when deleting quotegrab.
|
# 0.6.1-beta (03/23/10): Quotegrab ids properly adjusted when deleting quotegrab.
|
||||||
# Admins loads from file, uses regex hash keys.
|
# Admins loads from file, uses regex hash keys.
|
||||||
# Lots of misc tweaks and improvements throughout.
|
# Lots of misc tweaks and improvements throughout.
|
||||||
|
@ -61,30 +61,47 @@ sub list {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||||
my $factoids = $self->{pbot}->factoids->factoids;
|
my $factoids = $self->{pbot}->factoids->factoids;
|
||||||
|
my $botnick = $self->{pbot}->botnick;
|
||||||
my $text;
|
my $text;
|
||||||
|
|
||||||
if(not defined $arguments) {
|
if(not defined $arguments) {
|
||||||
return "/msg $nick Usage: list <modules|factoids|commands|admins>";
|
return "/msg $nick Usage: list <modules|factoids|commands|admins>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($arguments =~/^messages\s+(.*?)\s+(.*)$/) {
|
if($arguments =~/^messages\s+(.*)$/) {
|
||||||
my $nick_search = $1;
|
my ($nick_search, $channel_search, $text_search) = split / /, $1;
|
||||||
my $channel = $2;
|
|
||||||
|
|
||||||
if(not exists ${ $self->{pbot}->antiflood->message_history }{$nick_search}) {
|
return "/msg $nick Usage: !list messages <nick regex> <channel regex> [text regex]" if not defined $channel_search;
|
||||||
return "/msg $nick No messages for $nick_search yet.";
|
$text_search = '.*' if not defined $text_search;
|
||||||
}
|
|
||||||
|
|
||||||
if(not exists ${ $self->{pbot}->antiflood->message_history }{$nick_search}{$channel}) {
|
my @results = eval {
|
||||||
return "/msg $nick No messages for $nick_search in $channel yet.";
|
my @ret;
|
||||||
}
|
foreach my $history_nick (keys %{ $self->{pbot}->antiflood->message_history }) {
|
||||||
|
if($history_nick =~ m/$nick_search/i) {
|
||||||
my @messages = @{ ${ $self->{pbot}->antiflood->message_history }{$nick_search}{$channel}{messages} };
|
foreach my $history_channel (keys %{ $self->{pbot}->antiflood->message_history->{$history_nick} }) {
|
||||||
my $botnick = $self->{pbot}->botnick;
|
if($history_channel =~ m/$channel_search/i) {
|
||||||
|
my @messages = @{ ${ $self->{pbot}->antiflood->message_history }{$history_nick}{$history_channel}{messages} };
|
||||||
|
|
||||||
for(my $i = 0; $i <= $#messages; $i++) {
|
for(my $i = 0; $i <= $#messages; $i++) {
|
||||||
$self->{pbot}->logger->log("" . ($i + 1) . ") " . localtime($messages[$i]->{timestamp}) . " <$nick_search> " . $messages[$i]->{msg} . "\n");
|
next if $messages[$i]->{msg} =~ /^!login/;
|
||||||
$self->{pbot}->conn->privmsg($nick, "" . ($i + 1) . ") " . localtime($messages[$i]->{timestamp}) . " <$nick_search> " . $messages[$i]->{msg} . "\n") unless $nick =~ /\Q$botnick\E/i;
|
push @ret, { text => $messages[$i]->{msg}, timestamp => $messages[$i]->{timestamp}, nick => $history_nick, channel => $history_channel } if $messages[$i]->{msg} =~ m/$text_search/i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return @ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
if($@) {
|
||||||
|
$self->{pbot}->logger->log("Error in search parameters: $@\n");
|
||||||
|
return "Error in search parameters: $@";
|
||||||
|
}
|
||||||
|
|
||||||
|
my @sorted = sort { $a->{timestamp} <=> $b->{timestamp} } @results;
|
||||||
|
foreach my $msg (@sorted) {
|
||||||
|
$self->{pbot}->logger->log("[$msg->{channel}] " . localtime($msg->{timestamp}) . " <$msg->{nick}> " . $msg->{text} . "\n");
|
||||||
|
$self->{pbot}->conn->privmsg($nick, "[$msg->{channel}] " . localtime($msg->{timestamp}) . " <$msg->{nick}> " . $msg->{text} . "\n") unless $nick =~ /\Q$botnick\E/i;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use vars qw($VERSION);
|
use vars qw($VERSION);
|
||||||
$VERSION = "0.6.1-beta";
|
$VERSION = "0.6.2-beta";
|
||||||
|
|
||||||
# unbuffer stdout
|
# unbuffer stdout
|
||||||
STDOUT->autoflush(1);
|
STDOUT->autoflush(1);
|
||||||
|
@ -259,6 +259,7 @@ sub show_random_quotegrab {
|
|||||||
my @quotes = ();
|
my @quotes = ();
|
||||||
my $nick_search = ".*";
|
my $nick_search = ".*";
|
||||||
my $channel_search = $from;
|
my $channel_search = $from;
|
||||||
|
my $text_search = ".*";
|
||||||
|
|
||||||
if(not defined $from) {
|
if(not defined $from) {
|
||||||
$self->{pbot}->logger->log("Command missing ~from parameter!\n");
|
$self->{pbot}->logger->log("Command missing ~from parameter!\n");
|
||||||
@ -266,20 +267,20 @@ sub show_random_quotegrab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(defined $arguments) {
|
if(defined $arguments) {
|
||||||
($nick_search, $channel_search) = split(/\s+/, $arguments, 2);
|
($nick_search, $channel_search, $text_search) = split /\s+/, $arguments;
|
||||||
# $self->{pbot}->logger->log("[ns: $nick_search][cs: $channel_search]\n");
|
|
||||||
if(not defined $channel_search) {
|
if(not defined $channel_search) {
|
||||||
$channel_search = $from;
|
$channel_search = $from;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $channel_search_quoted = quotemeta($channel_search);
|
$nick_search = '.*' if not defined $nick_search;
|
||||||
$self->{pbot}->logger->log("[ns: $nick_search][cs: $channel_search][csq: $channel_search_quoted]\n");
|
$channel_search = '.*' if not defined $channel_search;
|
||||||
|
$text_search = '.*' if not defined $text_search;
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
for(my $i = 0; $i <= $#{ $self->{quotegrabs} }; $i++) {
|
for(my $i = 0; $i <= $#{ $self->{quotegrabs} }; $i++) {
|
||||||
my $hash = $self->{quotegrabs}[$i];
|
my $hash = $self->{quotegrabs}[$i];
|
||||||
if($hash->{channel} =~ /$channel_search_quoted/i && $hash->{nick} =~ /$nick_search/i) {
|
if($hash->{channel} =~ /$channel_search/i && $hash->{nick} =~ /$nick_search/i && $hash->{text} =~ /$text_search/i) {
|
||||||
$hash->{id} = $i + 1;
|
$hash->{id} = $i + 1;
|
||||||
push @quotes, $hash;
|
push @quotes, $hash;
|
||||||
}
|
}
|
||||||
@ -288,12 +289,12 @@ sub show_random_quotegrab {
|
|||||||
|
|
||||||
if($@) {
|
if($@) {
|
||||||
$self->{pbot}->logger->log("Error in show_random_quotegrab parameters: $@\n");
|
$self->{pbot}->logger->log("Error in show_random_quotegrab parameters: $@\n");
|
||||||
return "/msg $nick Error: $@"
|
return "/msg $nick Error in search parameters: $@"
|
||||||
}
|
}
|
||||||
|
|
||||||
if($#quotes < 0) {
|
if($#quotes < 0) {
|
||||||
if($nick_search eq ".*") {
|
if($nick_search eq ".*") {
|
||||||
return "No quotes grabbed for $channel_search yet. Use !grab to grab a quote.";
|
return "No quotes grabbed in $channel_search yet. Use !grab to grab a quote.";
|
||||||
} else {
|
} else {
|
||||||
return "No quotes grabbed for $nick_search in $channel_search yet. Use !grab to grab a quote.";
|
return "No quotes grabbed for $nick_search in $channel_search yet. Use !grab to grab a quote.";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user