From 05574b02ce704070fe11f0ee03aeb5a339b4a6c5 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 15 May 2020 13:12:39 -0700 Subject: [PATCH] slightly rate limit the GNU annoy-command --- bot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 7ba88aa..aa52c69 100644 --- a/bot.py +++ b/bot.py @@ -542,9 +542,13 @@ def msg_ping(match: Match[str]) -> Response: return MessageResponse(match, f'PONG {esc(rest)}') -@handle_message(r'.*\b(nano|linux|windows|emacs)\b', flags=re.IGNORECASE) +@handle_message( + r'.*\b(?Pnano|linux|windows|emacs)\b', flags=re.IGNORECASE, +) def msg_gnu_please(match: Match[str]) -> Response: - msg, word = match[3], match[4] + if random.randrange(0, 100) < 90: + return Response() + msg, word = match['msg'], match['word'] query = re.search(f'gnu[/+]{word}', msg, flags=re.IGNORECASE) if query: return MessageResponse(match, f'YES! {query[0]}')