mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-22 18:52:40 +01:00
See Changes file
This commit is contained in:
parent
d299a8fb0f
commit
a743261059
@ -53,7 +53,7 @@ sub check_flood {
|
||||
|
||||
$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;
|
||||
|
||||
|
@ -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)
|
||||
# [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.
|
||||
# Admins loads from file, uses regex hash keys.
|
||||
# Lots of misc tweaks and improvements throughout.
|
||||
|
@ -61,30 +61,47 @@ sub list {
|
||||
my $self = shift;
|
||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||
my $factoids = $self->{pbot}->factoids->factoids;
|
||||
my $botnick = $self->{pbot}->botnick;
|
||||
my $text;
|
||||
|
||||
if(not defined $arguments) {
|
||||
return "/msg $nick Usage: list <modules|factoids|commands|admins>";
|
||||
}
|
||||
|
||||
if($arguments =~/^messages\s+(.*?)\s+(.*)$/) {
|
||||
my $nick_search = $1;
|
||||
my $channel = $2;
|
||||
if($arguments =~/^messages\s+(.*)$/) {
|
||||
my ($nick_search, $channel_search, $text_search) = split / /, $1;
|
||||
|
||||
if(not exists ${ $self->{pbot}->antiflood->message_history }{$nick_search}) {
|
||||
return "/msg $nick No messages for $nick_search yet.";
|
||||
return "/msg $nick Usage: !list messages <nick regex> <channel regex> [text regex]" if not defined $channel_search;
|
||||
$text_search = '.*' if not defined $text_search;
|
||||
|
||||
my @results = eval {
|
||||
my @ret;
|
||||
foreach my $history_nick (keys %{ $self->{pbot}->antiflood->message_history }) {
|
||||
if($history_nick =~ m/$nick_search/i) {
|
||||
foreach my $history_channel (keys %{ $self->{pbot}->antiflood->message_history->{$history_nick} }) {
|
||||
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++) {
|
||||
next if $messages[$i]->{msg} =~ /^!login/;
|
||||
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: $@";
|
||||
}
|
||||
|
||||
if(not exists ${ $self->{pbot}->antiflood->message_history }{$nick_search}{$channel}) {
|
||||
return "/msg $nick No messages for $nick_search in $channel yet.";
|
||||
}
|
||||
|
||||
my @messages = @{ ${ $self->{pbot}->antiflood->message_history }{$nick_search}{$channel}{messages} };
|
||||
my $botnick = $self->{pbot}->botnick;
|
||||
|
||||
for(my $i = 0; $i <= $#messages; $i++) {
|
||||
$self->{pbot}->logger->log("" . ($i + 1) . ") " . localtime($messages[$i]->{timestamp}) . " <$nick_search> " . $messages[$i]->{msg} . "\n");
|
||||
$self->{pbot}->conn->privmsg($nick, "" . ($i + 1) . ") " . localtime($messages[$i]->{timestamp}) . " <$nick_search> " . $messages[$i]->{msg} . "\n") unless $nick =~ /\Q$botnick\E/i;
|
||||
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 "";
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use strict;
|
||||
use warnings;
|
||||
|
||||
use vars qw($VERSION);
|
||||
$VERSION = "0.6.1-beta";
|
||||
$VERSION = "0.6.2-beta";
|
||||
|
||||
# unbuffer stdout
|
||||
STDOUT->autoflush(1);
|
||||
|
@ -259,6 +259,7 @@ sub show_random_quotegrab {
|
||||
my @quotes = ();
|
||||
my $nick_search = ".*";
|
||||
my $channel_search = $from;
|
||||
my $text_search = ".*";
|
||||
|
||||
if(not defined $from) {
|
||||
$self->{pbot}->logger->log("Command missing ~from parameter!\n");
|
||||
@ -266,20 +267,20 @@ sub show_random_quotegrab {
|
||||
}
|
||||
|
||||
if(defined $arguments) {
|
||||
($nick_search, $channel_search) = split(/\s+/, $arguments, 2);
|
||||
# $self->{pbot}->logger->log("[ns: $nick_search][cs: $channel_search]\n");
|
||||
($nick_search, $channel_search, $text_search) = split /\s+/, $arguments;
|
||||
if(not defined $channel_search) {
|
||||
$channel_search = $from;
|
||||
}
|
||||
}
|
||||
|
||||
my $channel_search_quoted = quotemeta($channel_search);
|
||||
$self->{pbot}->logger->log("[ns: $nick_search][cs: $channel_search][csq: $channel_search_quoted]\n");
|
||||
|
||||
$nick_search = '.*' if not defined $nick_search;
|
||||
$channel_search = '.*' if not defined $channel_search;
|
||||
$text_search = '.*' if not defined $text_search;
|
||||
|
||||
eval {
|
||||
for(my $i = 0; $i <= $#{ $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;
|
||||
push @quotes, $hash;
|
||||
}
|
||||
@ -288,12 +289,12 @@ sub show_random_quotegrab {
|
||||
|
||||
if($@) {
|
||||
$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($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 {
|
||||
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