fixed buggy GoodBot response
This commit is contained in:
@@ -5,6 +5,12 @@ from bs4 import BeautifulSoup
|
|||||||
pattern = 'NP: {<DT>?<JJ>*<NN>}'
|
pattern = 'NP: {<DT>?<JJ>*<NN>}'
|
||||||
cp = nltk.RegexpParser(pattern)
|
cp = nltk.RegexpParser(pattern)
|
||||||
|
|
||||||
|
WORDS = set(w.lower() for w in nltk.corpus.words.words())
|
||||||
|
|
||||||
|
|
||||||
|
def valid_word(word: str):
|
||||||
|
return word.strip().lower() in WORDS
|
||||||
|
|
||||||
|
|
||||||
def get_stock_price(symbol: str):
|
def get_stock_price(symbol: str):
|
||||||
soup = BeautifulSoup(requests.get(f'https://finance.yahoo.com/quote/{symbol}').content, 'lxml')
|
soup = BeautifulSoup(requests.get(f'https://finance.yahoo.com/quote/{symbol}').content, 'lxml')
|
||||||
|
|||||||
@@ -153,7 +153,8 @@ class Jaccuse(base.Joke):
|
|||||||
class GoodBot(base.Joke):
|
class GoodBot(base.Joke):
|
||||||
@property
|
@property
|
||||||
def regex(self) -> re.Pattern:
|
def regex(self) -> re.Pattern:
|
||||||
return re.compile('(\w+) bot', re.IGNORECASE)
|
return re.compile('(\w+) bot$', re.IGNORECASE)
|
||||||
|
|
||||||
async def respond(self, message: Message, client: Client, match: re.Match):
|
async def respond(self, message: Message, client: Client, match: re.Match):
|
||||||
await message.add_reaction(utils.get(client.emojis, name='kaylon'))
|
if helpers.valid_word(match.group(1)):
|
||||||
|
await message.add_reaction(utils.get(client.emojis, name='kaylon'))
|
||||||
|
|||||||
Reference in New Issue
Block a user