restructured handle_message and added GifJokes
This commit is contained in:
37
jokes.py
37
jokes.py
@@ -72,6 +72,41 @@ class DominosJoke(Joke):
|
||||
await message.reply(msg)
|
||||
|
||||
|
||||
class GifJoke(Joke):
|
||||
url: str
|
||||
|
||||
def __init__(self, url: str):
|
||||
self.url = url
|
||||
|
||||
async def respond(self, message: discord.Message, client: discord.Client, scan_res):
|
||||
await message.channel.send(self.url)
|
||||
|
||||
|
||||
class BeansJoke(GifJoke):
|
||||
@property
|
||||
def regex(self) -> re.Pattern:
|
||||
return re.compile('beans', re.IGNORECASE)
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(url='https://c.tenor.com/TjX1yORoln0AAAAM/this-is-beans-beans.gif')
|
||||
|
||||
async def respond(self, message: discord.Message, client: discord.Client, scan_res):
|
||||
await message.reply('Somebody help! I\'ve got beans in my motherboard!\n')
|
||||
await super().respond(message, client, scan_res)
|
||||
|
||||
|
||||
class NotLikeThisJoke(GifJoke):
|
||||
@property
|
||||
def regex(self) -> re.Pattern:
|
||||
return re.compile('not like this', re.IGNORECASE)
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(url='https://tenor.com/view/not-like-this-the-matrix-panic-neo-angry-gif-5216157')
|
||||
|
||||
async def respond(self, message: discord.Message, client: discord.Client, scan_res):
|
||||
await message.reply(self.url)
|
||||
|
||||
|
||||
pattern = 'NP: {<DT>?<JJ>*<NN>}'
|
||||
cp = nltk.RegexpParser(pattern)
|
||||
|
||||
@@ -103,4 +138,4 @@ def unblack(s):
|
||||
if tag.startswith('JJ') or tag.startswith('NN'):
|
||||
for text, tag, iob in tag_list[i + 1:]:
|
||||
if tag.startswith('NN'):
|
||||
return f'Or as I would say, {text.lower()}'
|
||||
return f'Or as I would say, {text.lower()}'
|
||||
|
||||
Reference in New Issue
Block a user