fix help function

This commit is contained in:
2021-06-15 00:43:38 +02:00
parent 5facd8b5a5
commit f6cbb87967
5 changed files with 17 additions and 10 deletions

View File

@@ -1 +1,10 @@
`General`
This bot is an all-purpose discord butler that's able to be customized to suit specific server needs.
Below is a list with currently implemented features and if available, commands to get more information.
`# Diceroller`
Standard diceroller which works with the 1dX notation. See `!help roll` for more information on syntax and options.
`# GIF embeds`
For servers that want to disable embeds for any reason (triggers, unwanted imagery, etc), this function will make sure that (for specific channels configured in the config) gif URLs are picked up by the bot and embedded. This whole functionality is used for a problem that shouldn't be there in the first place, but because GIFs are linked to the Embed setting in Discord, for some servers this might pose a solution.

View File

@@ -1 +0,0 @@
`Test`

View File

@@ -1,4 +1,3 @@
`!roll`
All forms of diceroll notations should work properly, including adding or detracting dice with each other, adding or detracting numbers from dicerolls, or even adding or detracting sums within brackets. Below are some examples. All forms of diceroll notations should work properly, including adding or detracting dice with each other, adding or detracting numbers from dicerolls, or even adding or detracting sums within brackets. Below are some examples.
``` ```

View File

@@ -31,9 +31,9 @@ async def on_message(message):
if message.content.startswith('!help'): if message.content.startswith('!help'):
parameters = message.content.split(' ', 1) parameters = message.content.split(' ', 1)
if len(parameters) == 2: if len(parameters) == 2:
msg = format(bothelp.help(parameters[1])) msg = bothelp.help(parameters[1])
else: else:
msg = format(bothelp.help()) msg = bothelp.help()
await message.author.send(msg) await message.author.send(msg)
# giphy and tenor both have different structures to their links # giphy and tenor both have different structures to their links
if message.content.startswith('https://tenor.com/'): if message.content.startswith('https://tenor.com/'):
@@ -83,6 +83,7 @@ async def on_message(message):
async def on_ready(): async def on_ready():
print('### Active with id %s as %s ###' % (client.user.id,client.user.name) ) print('### Active with id %s as %s ###' % (client.user.id,client.user.name) )
activity = discord.Activity(name='Listening to !help', type=discord.ActivityType.listening) activity = discord.Activity(name='Listening to !help', type=discord.ActivityType.listening)
await client.change_presence(activity=activity)
if __name__ == '__main__': if __name__ == '__main__':
client.run(env.TOKEN) client.run(env.TOKEN)

View File

@@ -1,20 +1,19 @@
keywords = ['gifbot'] keywords = ['roll']
def help(keyword=''): def help(keyword=''):
"""Filter for general help or specific keyword help.""" """Filter for general help or specific keyword help."""
if not keyword: if not keyword:
file = open('help/help.md') file = open('help/help.md')
contents = file.read() contents = file.read()
return (contents) return format((contents))
if keyword[0]: if keyword[0]:
keyword = str.lower(keyword) keyword = str.lower(keyword)
if keyword in keywords: if keyword in keywords:
document = 'help/help_' + keyword + '.md' document = 'help/help_' + keyword + '.md'
print(document)
file = open(document, 'r') file = open(document, 'r')
contents = file.read() contents = file.read()
return (contents) return format((contents))
else: else:
file = open('help/help.md') file = open('help/help.md')
contents = file.read() contents = file.read()
return (contents) return format((contents))