diff --git a/app/dragon-bot.py b/app/dragon-bot.py index 39f57701..282eafd0 100644 --- a/app/dragon-bot.py +++ b/app/dragon-bot.py @@ -127,8 +127,6 @@ async def on_message(message): embed_description="[Direct Link]({})".format(user.avatar_url.replace('.webp', '.png')) ) ) - if message.content.startswith('!meme'): - await client.send_message(message.channel, meme_gen.parse_message(message.content)) if message.content.startswith('!birb'): await client.send_message( @@ -239,6 +237,11 @@ async def on_message(message): 'You can only use this command in NSFW channels' ) + if message.content.startswith('!meme'): + await client.delete_message(message) + await client.send_message(message.channel, meme_gen.parse_message(message.content)) + + if message.content.startswith('!weather'): await client.send_message( message.channel, diff --git a/app/help_methods.py b/app/help_methods.py index 0c39e438..dc44087c 100644 --- a/app/help_methods.py +++ b/app/help_methods.py @@ -96,7 +96,7 @@ def get_help_message(method): ], 'meme': [ 'Generates a meme on the fly!', - '\nUsage: !meme doge top text; bottom text' + '\n\nUsage: !meme doge top text; bottom text' ], 'homepage': [ 'This function now outputs the SWEET-ASS picture of the day.', diff --git a/app/meme_gen.py b/app/meme_gen.py index 5d0efc27..780df1c9 100644 --- a/app/meme_gen.py +++ b/app/meme_gen.py @@ -1,10 +1,13 @@ -import os, requests +import os +import requests + +import help_methods supported_templates = sorted(list(map(lambda x: x.split('/')[-1], requests.get('https://memegen.link/api/templates/').json().values()))) def parse_message(message): - if len(message.split()) < 2: - return get_templates() + if len(message.split()) <= 2: + return get_meme_help() escaped_chars = {'_' : '__', ' ' : '_', '-' : '--', '?' : '~q', '%' : '~p', '#' : '~h', '/' : '~s', '\'\'' : '\"'} @@ -39,6 +42,8 @@ def get_meme_url(template, upper, lower, usesTemplate): meme = '{}/{}/{}/{}.{}'.format(base_URL, template, upper, lower, default_format) return meme -def get_templates(): - return "You must supply a valid template for the meme. Templates are one of the following: \n```" + ', '.join(supported_templates) + '```' - +def get_meme_help(): + return "{}\nYou must supply a valid template for the meme. Templates are one of the following: \n```{}```".format( + help_methods.get_help_message('meme'), + ', '.join(supported_templates) + )