get rid of itertools, reply with the matched case
This commit is contained in:
parent
a86757425c
commit
a74f7cd8c1
10
bot.py
10
bot.py
|
|
@ -1,7 +1,6 @@
|
||||||
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
|
||||||
|
|
@ -321,12 +320,9 @@ 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]
|
||||||
cases = {
|
query = re.match(fr'(?i)gnu(\/|\+){word}', msg)
|
||||||
f'{gnu}{sep}{word}'
|
if query:
|
||||||
for gnu, sep in itertools.product(('gnu', 'GNU'), '/+')
|
return MessageResponse(match, f'YES! {query.match(0)}')
|
||||||
}
|
|
||||||
if msg in cases:
|
|
||||||
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)}!")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue