slightly rate limit the GNU annoy-command

This commit is contained in:
Anthony Sottile 2020-05-15 13:12:39 -07:00
parent 7ad6dae32d
commit 05574b02ce
1 changed files with 6 additions and 2 deletions

8
bot.py
View File

@ -542,9 +542,13 @@ def msg_ping(match: Match[str]) -> Response:
return MessageResponse(match, f'PONG {esc(rest)}') return MessageResponse(match, f'PONG {esc(rest)}')
@handle_message(r'.*\b(nano|linux|windows|emacs)\b', flags=re.IGNORECASE) @handle_message(
r'.*\b(?P<word>nano|linux|windows|emacs)\b', flags=re.IGNORECASE,
)
def msg_gnu_please(match: Match[str]) -> Response: 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) query = re.search(f'gnu[/+]{word}', msg, flags=re.IGNORECASE)
if query: if query:
return MessageResponse(match, f'YES! {query[0]}') return MessageResponse(match, f'YES! {query[0]}')