Implement extra commands

master
Nikola Forró 6 years ago
parent 06499d8516
commit 84485b1cbc

@ -50,11 +50,14 @@ class DiscordClient(discord.Client):
self.logger.info('Logged in as {0}'.format(self.user.name)) self.logger.info('Logged in as {0}'.format(self.user.name))
async def on_message(self, message): async def on_message(self, message):
server = message.server.id if message.server else None
for pattern, action in self.supported_commands: for pattern, action in self.supported_commands:
m = pattern.match(message.content) m = pattern.match(message.content)
if m: if m:
server = message.server.id if message.server else None
await action(server, message.author.id, message, **m.groupdict()) await action(server, message.author.id, message, **m.groupdict())
for cmd, resp in self.config['Extra Commands'].items():
if cmd == message.content:
await self.send_message(message.channel, resp)
async def _cooldown_failure(self, server, user, message, **kwargs): async def _cooldown_failure(self, server, user, message, **kwargs):
await self.send_message(message.channel, await self.send_message(message.channel,

@ -96,6 +96,9 @@ class TwitchClient(irc.bot.SingleServerIRCBot):
m = pattern.match(message) m = pattern.match(message)
if m: if m:
action(tags, send_response, **m.groupdict()) action(tags, send_response, **m.groupdict())
for cmd, resp in self.config['Extra Commands'].items():
if cmd == message:
send_response(resp)
def _add_quote(self, tags, send_response, user, id, text, game, date, **kwargs): def _add_quote(self, tags, send_response, user, id, text, game, date, **kwargs):
if text[0] == text[-1] == '"': if text[0] == text[-1] == '"':

@ -25,3 +25,6 @@ channel_ids = UC5970RJMoEcRNZl0MNp8tlQ,UCHNjavmkFUf2n0uzWSgj16w
[Quotes] [Quotes]
api_url = https://ladylilia.com/quotes/api api_url = https://ladylilia.com/quotes/api
api_key = __QUOTES_API_KEY__ api_key = __QUOTES_API_KEY__
[Extra Commands]
;!command = Response Text

Loading…
Cancel
Save