mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 22:09:26 +01:00
MessageHistory: recall's arguments now behave more sanely
This commit is contained in:
parent
a892e8e5c1
commit
cd22e21a6a
@ -256,9 +256,9 @@ sub recall_message {
|
|||||||
my $channel_arg = 1 if defined $recall_channel;
|
my $channel_arg = 1 if defined $recall_channel;
|
||||||
my $history_arg = 1 if defined $recall_history;
|
my $history_arg = 1 if defined $recall_history;
|
||||||
|
|
||||||
$recall_nick = shift @$args;
|
$recall_nick = shift @$args if @$args;
|
||||||
$recall_history = shift @$args if not defined $recall_history;
|
$recall_history = shift @$args if @$args and not defined $recall_history;
|
||||||
$recall_channel = shift @$args if not defined $recall_channel;
|
$recall_channel = "@$args" if @$args and not defined $recall_channel;
|
||||||
|
|
||||||
$recall_count = 1 if (not defined $recall_count) || ($recall_count <= 0);
|
$recall_count = 1 if (not defined $recall_count) || ($recall_count <= 0);
|
||||||
return "You may only select a count of up to 50 messages." if $recall_count > 50;
|
return "You may only select a count of up to 50 messages." if $recall_count > 50;
|
||||||
@ -266,6 +266,17 @@ sub recall_message {
|
|||||||
$recall_before = 0 if not defined $recall_before;
|
$recall_before = 0 if not defined $recall_before;
|
||||||
$recall_after = 0 if not defined $recall_after;
|
$recall_after = 0 if not defined $recall_after;
|
||||||
|
|
||||||
|
# imply -x if -n > 1 and no history
|
||||||
|
if ($recall_count > 1 and not defined $recall_history) {
|
||||||
|
$recall_context = $recall_nick;
|
||||||
|
}
|
||||||
|
|
||||||
|
# make -n behave like -b if -n > 1 and nick is context
|
||||||
|
if ((defined $recall_context or not defined $recall_history) and $recall_count > 1) {
|
||||||
|
$recall_before = $recall_count - 1;
|
||||||
|
$recall_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($recall_before + $recall_after > 200) {
|
if ($recall_before + $recall_after > 200) {
|
||||||
return "You may only select up to 200 lines of surrounding context.";
|
return "You may only select up to 200 lines of surrounding context.";
|
||||||
}
|
}
|
||||||
@ -275,7 +286,7 @@ sub recall_message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# swap nick and channel if recall nick looks like channel and channel wasn't specified
|
# swap nick and channel if recall nick looks like channel and channel wasn't specified
|
||||||
if(not $channel_arg and $recall_nick =~ m/^#/) {
|
if (not $channel_arg and $recall_nick =~ m/^#/) {
|
||||||
my $temp = $recall_nick;
|
my $temp = $recall_nick;
|
||||||
$recall_nick = $recall_channel;
|
$recall_nick = $recall_channel;
|
||||||
$recall_channel = $temp;
|
$recall_channel = $temp;
|
||||||
@ -284,7 +295,7 @@ sub recall_message {
|
|||||||
$recall_history = 1 if not defined $recall_history;
|
$recall_history = 1 if not defined $recall_history;
|
||||||
|
|
||||||
# swap history and channel if history looks like a channel and neither history or channel were specified
|
# swap history and channel if history looks like a channel and neither history or channel were specified
|
||||||
if(not $channel_arg and not $history_arg and $recall_history =~ m/^#/) {
|
if (not $channel_arg and not $history_arg and $recall_history =~ m/^#/) {
|
||||||
my $temp = $recall_history;
|
my $temp = $recall_history;
|
||||||
$recall_history = $recall_channel;
|
$recall_history = $recall_channel;
|
||||||
$recall_channel = $temp;
|
$recall_channel = $temp;
|
||||||
@ -301,7 +312,7 @@ sub recall_message {
|
|||||||
|
|
||||||
# another sanity check for people using it wrong
|
# another sanity check for people using it wrong
|
||||||
if ($recall_channel !~ m/^#/) {
|
if ($recall_channel !~ m/^#/) {
|
||||||
$recall_history = "$recall_channel $recall_history";
|
$recall_history = "$recall_history $recall_channel";
|
||||||
$recall_channel = $from;
|
$recall_channel = $from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user