Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ignore Guests completely
My understanding is that the numbers are changing all the time, so
it's not useful for both `.seen` and `.tell`.
  • Loading branch information
AlexDaniel committed Aug 16, 2019
1 parent a0ae907 commit ed910fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions xbin/Tellable.p6
Expand Up @@ -49,8 +49,11 @@ sub normalize-weirdly($_ is copy) {
$_;
}

sub guest-like($nick) { so $nick ~~ /^Guest\d/ }

#| listen for messages
multi method irc-privmsg-channel($msg) {
return $.NEXT if guest-like $msg.nick;
my $normalized = normalize-weirdly $msg.nick;
$db-seen.read-write: {
.{$normalized} = {
Expand Down Expand Up @@ -110,6 +113,7 @@ multi method irc-to-me($msg where { m:r/^ \s* [seen \s+]?
my %seen := $db-seen.read;
my $entry = %seen{normalize-weirdly $who};
without $entry {
return I haven't seen any guests around if guest-like $who;
return I haven't seen $who around
~ maybe , did you mean %s?, did-you-mean-seen $who, %seen
}
Expand All @@ -125,6 +129,7 @@ multi method irc-to-me($msg where { m:r/^ \s* [[to|tell|ask] \s+]?
return I'll pass that message to your doctor if $who eq $msg.nick and not %*ENV<TESTABLE>;
my %seen := $db-seen.read;
without %seen{$normalized} {
return Can't pass messages to guests if guest-like $who;
return I haven't seen $who around
~ maybe , did you mean %s?, did-you-mean-seen $who, %seen
}
Expand Down
7 changes: 7 additions & 0 deletions xt/tellable.t
Expand Up @@ -48,6 +48,10 @@ $t.test(‘no such nickname (seen)’,
.seen nobody,
{$t.our-nick}, I haven't seen nobody around);

$t.test(seeing guests,
.seen Guest35100,
{$t.our-nick}, I haven't seen any guests around);

# TODO it kinda works but for some reason not with long nicks
#$t.test(‘.seen autocorrect’,
# “.seen x{$t.our-nick}”,
Expand Down Expand Up @@ -172,6 +176,9 @@ $t.test(‘passing messages to the bot itself’,
.tell {$t.bot-nick} I love you,
{$t.our-nick}, Thanks for the message);

$t.test(passing messages to guests,
.tell Guest35100 who are you?,
{$t.our-nick}, Can't pass messages to guests);

# Tell normalization

Expand Down

0 comments on commit ed910fa

Please sign in to comment.