Merge pull request #13 from isidentical/patch-1

support gnu+thing
This commit is contained in:
Anthony Sottile 2019-10-19 14:35:48 -07:00 committed by GitHub
commit a86757425c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

7
bot.py
View File

@ -1,6 +1,7 @@
import argparse import argparse
import asyncio import asyncio
import datetime import datetime
import itertools
import json import json
import random import random
import re import re
@ -320,7 +321,11 @@ def msg_ping(match: Match[str]) -> Response:
@handle_message(r'.*\b(nano|linux|windows|emacs)\b', flags=re.IGNORECASE) @handle_message(r'.*\b(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] msg, word = match[3], match[4]
if f'GNU/{word}' in msg or f'gnu/{word}' in msg: cases = {
f'{gnu}{sep}{word}'
for gnu, sep in itertools.product(('gnu', 'GNU'), '/+')
}
if msg in cases:
return MessageResponse(match, f'YES! GNU/{esc(word)}') return MessageResponse(match, f'YES! GNU/{esc(word)}')
else: else:
return MessageResponse(match, f"Um please, it's GNU/{esc(word)}!") return MessageResponse(match, f"Um please, it's GNU/{esc(word)}!")