Merge pull request #14 from isidentical/patch-2
get rid of itertools, reply with the matched case
This commit is contained in:
commit
d5e3738eed
10
bot.py
10
bot.py
|
|
@ -1,7 +1,6 @@
|
|||
import argparse
|
||||
import asyncio
|
||||
import datetime
|
||||
import itertools
|
||||
import json
|
||||
import random
|
||||
import re
|
||||
|
|
@ -321,12 +320,9 @@ def msg_ping(match: Match[str]) -> Response:
|
|||
@handle_message(r'.*\b(nano|linux|windows|emacs)\b', flags=re.IGNORECASE)
|
||||
def msg_gnu_please(match: Match[str]) -> Response:
|
||||
msg, word = match[3], match[4]
|
||||
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)}')
|
||||
query = re.match(fr'gnu[/+]{word}', msg, flags=re.IGNORECASE)
|
||||
if query:
|
||||
return MessageResponse(match, f'YES! {query.match(0)}')
|
||||
else:
|
||||
return MessageResponse(match, f"Um please, it's GNU/{esc(word)}!")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue