small tweaks to jokes to standardize things a bit, added TODO list of jokes to implement
This commit is contained in:
35
jokes.py
35
jokes.py
@@ -4,17 +4,32 @@ import discord
|
|||||||
import nltk
|
import nltk
|
||||||
import stockquotes
|
import stockquotes
|
||||||
|
|
||||||
|
# TODO implement new jokes
|
||||||
|
# - j'accuse
|
||||||
|
# - egos
|
||||||
|
# - money is no option
|
||||||
|
# - we're young, hot, and rich
|
||||||
|
# - last name page when ordering
|
||||||
|
# - mcnulty shot and beer
|
||||||
|
# - white trash karate backflips
|
||||||
|
# - buc-ees
|
||||||
|
# - arbys
|
||||||
|
# - grease 2
|
||||||
|
# - Sweet Transvestite
|
||||||
|
# - Hopkins County Stew Contest
|
||||||
|
# - yesterday tacos
|
||||||
|
# - strip club
|
||||||
|
|
||||||
|
|
||||||
class Joke:
|
class Joke:
|
||||||
@property
|
@property
|
||||||
def regex(self) -> re.Pattern:
|
def regex(self) -> re.Pattern:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def scan(self, message: discord.Message):
|
def scan(self, message: discord.Message) -> re.Match:
|
||||||
if (match := self.regex.search(message.content)):
|
return self.regex.search(message.content)
|
||||||
return match
|
|
||||||
|
|
||||||
async def respond(self, message: discord.Message, client: discord.Client, scan_res):
|
async def respond(self, message: discord.Message, client: discord.Client, match: re.Match):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
@@ -75,7 +90,7 @@ class DominosJoke(Joke):
|
|||||||
class GifJoke(Joke):
|
class GifJoke(Joke):
|
||||||
url: str
|
url: str
|
||||||
|
|
||||||
async def respond(self, message: discord.Message, client: discord.Client, scan_res):
|
async def respond(self, message: discord.Message, client: discord.Client, match: re.Match):
|
||||||
await message.channel.send(self.url)
|
await message.channel.send(self.url)
|
||||||
|
|
||||||
|
|
||||||
@@ -86,9 +101,9 @@ class BeansJoke(GifJoke):
|
|||||||
def regex(self) -> re.Pattern:
|
def regex(self) -> re.Pattern:
|
||||||
return re.compile('beans', re.IGNORECASE)
|
return re.compile('beans', re.IGNORECASE)
|
||||||
|
|
||||||
async def respond(self, message: discord.Message, client: discord.Client, scan_res):
|
async def respond(self, message: discord.Message, client: discord.Client, match: re.Match):
|
||||||
await message.reply('Somebody help! I\'ve got beans in my motherboard!\n')
|
await message.reply('Somebody help! I\'ve got beans in my motherboard!\n')
|
||||||
await super().respond(message, client, scan_res)
|
await super().respond(message, client, match)
|
||||||
|
|
||||||
|
|
||||||
class NotLikeThisJoke(GifJoke):
|
class NotLikeThisJoke(GifJoke):
|
||||||
@@ -98,7 +113,7 @@ class NotLikeThisJoke(GifJoke):
|
|||||||
def regex(self) -> re.Pattern:
|
def regex(self) -> re.Pattern:
|
||||||
return re.compile('not like this', re.IGNORECASE)
|
return re.compile('not like this', re.IGNORECASE)
|
||||||
|
|
||||||
async def respond(self, message: discord.Message, client: discord.Client, scan_res):
|
async def respond(self, message: discord.Message, client: discord.Client, match: re.Match):
|
||||||
await message.reply(self.url)
|
await message.reply(self.url)
|
||||||
|
|
||||||
|
|
||||||
@@ -107,9 +122,9 @@ class ChiliJoke(GifJoke):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def regex(self) -> re.Pattern:
|
def regex(self) -> re.Pattern:
|
||||||
return re.compile('chil(i|ly)')
|
return re.compile('chil(i|ly)', re.IGNORECASE)
|
||||||
|
|
||||||
async def respond(self, message: discord.Message, client: discord.Client, scan_res):
|
async def respond(self, message: discord.Message, client: discord.Client, match: re.Match):
|
||||||
await message.reply(self.url)
|
await message.reply(self.url)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ class RoboPage(discord.Client):
|
|||||||
LOGGER.warning(f'No self.data attribute')
|
LOGGER.warning(f'No self.data attribute')
|
||||||
|
|
||||||
for joke in self.jokes:
|
for joke in self.jokes:
|
||||||
if (scan_res := joke.scan(message)):
|
if (m := joke.scan(message)) is not None:
|
||||||
LOGGER.info(f'{joke.__class__.__name__} detected: {message.content}, {scan_res.group()}')
|
LOGGER.info(f'{joke.__class__.__name__} detected: {message.content}, {m.group()}')
|
||||||
await joke.respond(message, self, scan_res)
|
await joke.respond(message, self, m)
|
||||||
|
|
||||||
async def handle_raw_reaction(self, payload: Union[RawReactionActionEvent, RawReactionClearEmojiEvent]):
|
async def handle_raw_reaction(self, payload: Union[RawReactionActionEvent, RawReactionClearEmojiEvent]):
|
||||||
LOGGER.info(payload)
|
LOGGER.info(payload)
|
||||||
|
|||||||
Reference in New Issue
Block a user