Mercurial > hg > lolscript
changeset 34:c2e67df94367 draft
use generalised lol character classes
Too many jokers thought they could escape the lol by using Cyrillic.
You can run, but you must lol.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Fri, 14 Jul 2017 13:54:39 -0400 |
parents | a077996a8136 |
children | cf9c8bd9a51b |
files | teh-lol.pl |
diffstat | 1 files changed, 24 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/teh-lol.pl +++ b/teh-lol.pl @@ -48,6 +48,17 @@ close(FILE); } +## Advanced lollists have attempted alternative lols, so let's catch +## those too. +my $l = "[lI1|]"; +my $o = "[oо0]"; + +# | counts as a word boundary, so now we need generalised word +# boundaries to exclude | +my $b = "(?:\b|\|)"; + + + sub check_lol { my @xchat_args = @{$_[0]}; my $chatter = $xchat_args[0]; @@ -62,17 +73,20 @@ ## Match stuff like "lol", "loool" and "lololol". Also mimic ## punctuation. - if ($msg =~ /\b(l ## Starting l, capture it in $1 - - ((?:o|(?<!l)lo)+) ## either a single "o" or an "o" - ## followed by a bunch of "lolo", - ## capture it in $2 + if ($msg =~ /$b( + ## Starting l, capture it in $1 + $l - l) ## closing l + ## either a single "o" or an "o" followed by a bunch + ## of "lolo", capture it in $2 + ((?:$o|(?<!$l)$l$o)+) - ([\.!?]+|\b) ## Final punctuation or word - ## boundary, capture it in $3 - /ix + ## closing l + $l) + + ## Final punctuation or word boundary, capture it in $3 + ([\.!?]+|$b) + /ix #Two minutes of not saying anything in the channel counts as #idling, so don't pester when idling. @@ -147,7 +161,7 @@ ## Allow "lol stuff" and e.g. "JordiGH: lol stuff" to be part of a ## lolcombo - my $islol = $msg =~ /^\s*($nick.?\s*)?l((o|(?<!l)lo)+)l\b/i; + my $islol = $msg =~ /^\s*($nick.?\s*)?$l(($o|(?<!$l)$l$o)+)$l$b/i; if(not $islol) { my $combo = $combo_count{$chan};