From 66e4599593f735d9e8a6f54ca90a8a14d1ead11c Mon Sep 17 00:00:00 2001 From: MoistBiscuits Date: Mon, 2 Aug 2021 14:54:54 +0100 Subject: [PATCH 01/37] Added Full docstring reading of commands and parsing of data to json --- GenerateDoc.py | 148 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 GenerateDoc.py diff --git a/GenerateDoc.py b/GenerateDoc.py new file mode 100644 index 00000000..c8dc8790 --- /dev/null +++ b/GenerateDoc.py @@ -0,0 +1,148 @@ +from cogs.Announce import Announce +from os import listdir +import os +import importlib +from inspect import getmembers, isfunction, ismethod, isclass +import glob +import re +import json + +""" +KoalaBot utility function for generating bot command docs +Created By: Charlie Bowe, Aqeel Little +""" + + +class DocumentationEntry: + """Class for storing documentation entries for bot commands + """ + name = None + params = [] + desc = None + + def __init__(self,name: str,params,desc: str): + self.name = name + self.params = params + self.desc = desc + +class CogDocumentation: + """Stores a list of documentation entries for a cog + """ + name = None + docs = [] + + def __init__(self,name: str, docs): + #Change BaseCog to KoalaBot + if name == 'BaseCog': + self.name = 'KoalaBot' + else: + self.name = name + self.docs = docs + +docList = [] + + +#Get the directory of the cogs folder +dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),'cogs') +#Grab the names of all the .py files in the cogs folder +modules = [ fl for fl in listdir(dir) if fl.endswith('.py') ] + +cogs = [] +#for i in range 0 to amount of cogs + +def get_decorators(function): + # If we have no func_closure, it means we are not wrapping any other functions. + if not function.func_closure: + return [function] + decorators = [] + # Otherwise, we want to collect all of the recursive results for every closure we have. + for closure in function.func_closure: + decorators.extend(get_decorators(closure.cell_contents)) + return [function] + decorators + +def get_cog_docs(): + for i in range (0,len(modules)): + #Cut off the .py extension + modules[i] = modules[i][:-3] + #Import the library and store it in cogs + cogs.append(__import__('cogs.'+modules[i])) + + #get the refernce to the current library + #E.g. cogs.Announce + currentLib = getattr(cogs[i], modules[i]) + + #Store all of the classes of the cog in classes + classes = [ obj for obj in getmembers(currentLib) if isclass(obj[1]) ] + #print(f'Current classes: {classes} \n') + + docs = [] + for cls in classes: + if cls[0] != modules[i]: + print(f'{cls[0]} is not {modules[i]}') + + #Store the functions of each classes in class_funcs + class_funcs = [ obj for obj in getmembers(cls[1]) ] + + for obj in class_funcs: + try: + text = getattr(getattr(currentLib,modules[i]),str(obj[0])).help.splitlines() + except AttributeError: + pass + continue + except: + print("Unexpected error") + continue + + name = getattr(getattr(currentLib,modules[i]),str(obj[0])).name + + if getattr(getattr(currentLib,modules[i]),str(obj[0])).parent != None: + name = f'{getattr(getattr(currentLib,modules[i]),str(obj[0])).parent} {name}' + + desc = "" + params = [] + for line in text: + matchObj = re.match( r':param (.*): (.*)', line, re.M|re.I) + + if matchObj: + if matchObj.group(1) == 'ctx': + continue + params.append(matchObj.group(1)) + else: + desc += line + docs.append(DocumentationEntry(name,params,desc)) + + + docList.append(CogDocumentation(modules[i],docs)) + return docList + +docList = get_cog_docs() + +for cogDoc in docList: + print(f'-= {cogDoc.name} =-') + for doc in cogDoc.docs: + print(doc.name) + +def parse_docs(docList, filename): + """Pass a list of CogDocumentation objects into a json file + :param docList: List of CogDocumentation + :param filename: filename of json file + """ + data = [] + for cogDoc in docList: + cog = {} + cog['name'] = cogDoc.name + commands = [] + for docEntry in cogDoc.docs: + entry = {} + entry['command'] = docEntry.name + entry['parameters'] = docEntry.params + entry['description'] = docEntry.desc + commands.append(entry) + cog['commands'] = commands + data.append(cog) + + file = open(filename, "w") + file.write(json.dumps(data, indent=2)) + file.close() + +parse_docs(docList,'test.json') \ No newline at end of file From dcd3b2431ef1b9a447d980e51eecfb169c6573c3 Mon Sep 17 00:00:00 2001 From: MoistBiscuits Date: Tue, 3 Aug 2021 18:39:04 +0100 Subject: [PATCH 02/37] Added parsing to documentation.json as well as adjusting the doc for consistancy --- GenerateDoc.py | 125 +++++---- documentation.json | 578 ++++++++++++++++++++++++++------------ tests/test_GenerateDoc.py | 65 +++++ 3 files changed, 528 insertions(+), 240 deletions(-) create mode 100644 tests/test_GenerateDoc.py diff --git a/GenerateDoc.py b/GenerateDoc.py index c8dc8790..ed8d8d17 100644 --- a/GenerateDoc.py +++ b/GenerateDoc.py @@ -1,9 +1,5 @@ -from cogs.Announce import Announce -from os import listdir -import os -import importlib -from inspect import getmembers, isfunction, ismethod, isclass -import glob +from os import listdir, path +from inspect import getmembers, isclass import re import json @@ -12,7 +8,6 @@ Created By: Charlie Bowe, Aqeel Little """ - class DocumentationEntry: """Class for storing documentation entries for bot commands """ @@ -31,39 +26,56 @@ class CogDocumentation: name = None docs = [] + #Dictionary of cogs that have different names in the doc + docNameChanges = { + 'BaseCog': 'KoalaBot', + 'ReactForRole': 'ReactForRole (RFR)', + 'Verification': 'Verify', + 'Voting': 'Vote' + } + def __init__(self,name: str, docs): - #Change BaseCog to KoalaBot - if name == 'BaseCog': - self.name = 'KoalaBot' + + if name in self.docNameChanges.keys(): + self.name = self.docNameChanges.get(name) else: self.name = name self.docs = docs - -docList = [] - - -#Get the directory of the cogs folder -dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),'cogs') -#Grab the names of all the .py files in the cogs folder -modules = [ fl for fl in listdir(dir) if fl.endswith('.py') ] - -cogs = [] -#for i in range 0 to amount of cogs - -def get_decorators(function): - # If we have no func_closure, it means we are not wrapping any other functions. - if not function.func_closure: - return [function] - decorators = [] - # Otherwise, we want to collect all of the recursive results for every closure we have. - for closure in function.func_closure: - decorators.extend(get_decorators(closure.cell_contents)) - return [function] + decorators + +def add_cog_to_cog(add,to,docList): + addCog = None + toCog = None + + for doc in docList: + if doc.name == add: + addCog = doc + elif doc.name == to: + toCog = doc + + if(addCog != None) and (toCog != None): + docList.remove(addCog) + toCog.docs.extend(addCog.docs) + + return docList def get_cog_docs(): + """Imports all cogs in directory cogs and stores the name, params and + docstring description of bot commands + :return: CogDocumentation[] + """ + docList = [] + #Get the directory of the cogs folder + dir = path.join(path.dirname(path.realpath(__file__)),'cogs') + #Grab the names of all the .py files in the cogs folder + modules = [] + modules = [ fl for fl in listdir(dir) if fl.endswith('.py') ] + cogs = [] + + #for i in range 0 to amount of cogs for i in range (0,len(modules)): - #Cut off the .py extension - modules[i] = modules[i][:-3] + if modules[i].endswith('.py'): + modules[i] = modules[i][:-3] + #Import the library and store it in cogs cogs.append(__import__('cogs.'+modules[i])) @@ -73,26 +85,26 @@ def get_cog_docs(): #Store all of the classes of the cog in classes classes = [ obj for obj in getmembers(currentLib) if isclass(obj[1]) ] - #print(f'Current classes: {classes} \n') + #list of DocumentationEntry for each class docs = [] for cls in classes: - if cls[0] != modules[i]: - print(f'{cls[0]} is not {modules[i]}') - #Store the functions of each classes in class_funcs class_funcs = [ obj for obj in getmembers(cls[1]) ] for obj in class_funcs: try: + #Get the docstring of the function text = getattr(getattr(currentLib,modules[i]),str(obj[0])).help.splitlines() except AttributeError: + #On attribute error, function has no docstring pass continue except: print("Unexpected error") continue + #Get the name of the command object name = getattr(getattr(currentLib,modules[i]),str(obj[0])).name if getattr(getattr(currentLib,modules[i]),str(obj[0])).parent != None: @@ -101,31 +113,26 @@ def get_cog_docs(): desc = "" params = [] for line in text: - matchObj = re.match( r':param (.*): (.*)', line, re.M|re.I) + matchObj = re.match( r':(.*) (.*): (.*)', line, re.M|re.I) - if matchObj: - if matchObj.group(1) == 'ctx': + if matchObj and (matchObj.group(1) == 'param'): + if matchObj.group(2) == 'ctx': continue - params.append(matchObj.group(1)) + params.append(matchObj.group(2)) else: desc += line - docs.append(DocumentationEntry(name,params,desc)) - - + docs.append(DocumentationEntry(name,params,desc)) + docList.append(CogDocumentation(modules[i],docs)) - return docList -docList = get_cog_docs() + docList = add_cog_to_cog('IntroCog','KoalaBot',docList) -for cogDoc in docList: - print(f'-= {cogDoc.name} =-') - for doc in cogDoc.docs: - print(doc.name) + return docList -def parse_docs(docList, filename): - """Pass a list of CogDocumentation objects into a json file - :param docList: List of CogDocumentation - :param filename: filename of json file +def doc_list_to_json(docList): + """Converts a list of CogDocumentation into a json string + :param docList: List fo CogDocumentation + :return: JSON string """ data = [] for cogDoc in docList: @@ -140,9 +147,17 @@ def parse_docs(docList, filename): commands.append(entry) cog['commands'] = commands data.append(cog) + return data +def parse_docs(docList, filename): + """Pass a list of CogDocumentation objects into a json file + :param docList: List of CogDocumentation + :param filename: filename of json file + """ + data = doc_list_to_json(docList) file = open(filename, "w") file.write(json.dumps(data, indent=2)) file.close() -parse_docs(docList,'test.json') \ No newline at end of file +docList = get_cog_docs() +parse_docs(docList,'documentation.json') \ No newline at end of file diff --git a/documentation.json b/documentation.json index 11504a22..85a2a955 100644 --- a/documentation.json +++ b/documentation.json @@ -1,96 +1,131 @@ [ { - "name": "KoalaBot", + "name": "Announce", "commands": [ { - "command": "listExt", + "command": "announce addRole", "parameters": [], - "description": "Lists all enabled and disabled Koala Extensions on your server" + "description": "Add a role to list of people to send the announcement to:return:" }, { - "command": "enableExt", - "parameters": ["koala_extension"], - "description": "Enable a Koala Extension on your server" + "command": "announce", + "parameters": [], + "description": "Use k!announce create to create an announcement" }, { - "command": "disableExt", - "parameters": ["koala_extension"], - "description": "Disable a Koala Extension on your server" + "command": "announce cancel", + "parameters": [], + "description": "Cancel a pending announcement:return:" }, { - "command": "welcomeUpdateMsg", + "command": "announce changeContent", "parameters": [], - "description": "Change the customisable part of the welcome message of your server" + "description": "Change the content of the embedded message:return:" }, { - "command": "welcomeSendMsg", + "command": "announce changeTitle", "parameters": [], - "description": "Sends out the welcome message manually to all members of your server" + "description": "Change the title of the embedded message:return:" }, { - "command": "welcomeViewMsg", + "command": "announce create", "parameters": [], - "description": "Shows this server's current welcome message" + "description": "Create a new message that will be available for sending:return:" }, { - "command": "clear", - "parameters": ["amount"], - "description": "Clears a given number of messages from the channel." + "command": "announce preview", + "parameters": [], + "description": "Post a constructed embedded message to the channel where the command is invoked:return:" }, { - "command": "ping", + "command": "announce removeRole", "parameters": [], - "description": "Returns the ping of a bot" + "description": "Remove a role from a list of people to send the announcement to:return:" }, { - "command": "support", + "command": "announce send", "parameters": [], - "description": "Returns a link to the KoalaBot Support Discord Server" + "description": "Send a pending announcement:return:" } ] }, { - "name": "Announce", + "name": "KoalaBot", "commands": [ { - "command": "announce create", - "parameters": [], - "description": "Create a new message that will be available for sending" + "command": "activity", + "parameters": [ + "new_activity", + "name" + ], + "description": "Change the activity of the bot" }, { - "command": "changeTitle", - "parameters": [], - "description": "Change the title of the embedded message" + "command": "clear", + "parameters": [ + "amount" + ], + "description": "Clears a given number of messages from the given channel" }, { - "command": "changeContent", - "parameters": [], - "description": "Change the content of the embedded message" + "command": "disableExt", + "parameters": [ + "koala_extension" + ], + "description": "Disables a koala extension onto a server" }, { - "command": "addRole", + "command": "enableExt", + "parameters": [ + "koala_extension" + ], + "description": "Enables a koala extension onto a server, all grants all extensions" + }, + { + "command": "listExt", "parameters": [], - "description": "Add a role to list of people to send the announcement to" + "description": "Lists the enabled koala extensions of a server" + }, + { + "command": "loadCog", + "parameters": [ + "extension" + ], + "description": "Loads a cog from the cogs folder" }, { - "command": "removeRole", + "command": "ping", "parameters": [], - "description": "Remove a role from a list of people to send the announcement to" + "description": "Returns the ping of the bot" }, { - "command": "preview", + "command": "support", "parameters": [], - "description": "Post a constructed embedded message to the channel where the command is invoked" + "description": "KoalaBot Support server link" + }, + { + "command": "unloadCog", + "parameters": [ + "extension" + ], + "description": "Unloads a running cog" }, { - "command": "send", + "command": "welcomeSendMsg", "parameters": [], - "description": "Send a pending announcement" + "description": "Allows admins to send out their welcome message manually to all members of a guild. Has a 60 second cooldown perguild." }, { - "command": "cancel", + "command": "welcomeUpdateMsg", + "parameters": [ + "new_message" + ], + "description": "Allows admins to change their customisable part of the welcome message of a guild. Has a 60 second cooldown perguild." + }, + { + "command": "welcomeViewMsg", "parameters": [], - "description": "Cancel a pending announcement" + "description": "Shows this server's current welcome message" } ] }, @@ -98,39 +133,49 @@ "name": "ColourRole", "commands": [ { - "command": "customColour", - "parameters": ["colour_hexcode/'no'"], - "description": "Gives a user a chosen custom colour, or removes the custom colour with 'k!customColour no'" - }, - { - "command": "listProtectedRoleColours", - "parameters": [], - "description": "Lists the protected roles, whose colours are protected from being imitated by a custom colour, in a server" + "command": "addCustomColourAllowedRole", + "parameters": [ + "role_str" + ], + "description": "Adds a role, via ID, mention or name, to the list of roles allowed to have a custom colour. Needsadmin permissions to use." }, { "command": "addProtectedRoleColour", - "parameters": ["role"], - "description": "Adds a role's colour to the list of protected roles" + "parameters": [ + "role_str" + ], + "description": "Adds a role, via ID, mention or name, to the list of protected roles. Needs admin permissions touse." }, { - "command": "removeProtectedRoleColour", - "parameters": ["role"], - "description": "Removes a role's colour from the list of protected roles" + "command": "customColour", + "parameters": [ + "colour_str" + ], + "description": "For a user with the correct role to be able to change their display colour in a guild.Syntax is k!custom_colour (\"no\" / colour hex). Usage with no removes any custom colour held before.Won't accept it if the colour chosen too closely resembles a role that was protected's colour or a discordblocked colour. A role must be made and that role be added to the permissions by usage ofk!add_custom_colour_allowed_role , and the command invoker must have that role before they can use thiscommand. Has a 15 second cooldown." }, { "command": "listCustomColourAllowedRoles", "parameters": [], - "description": "Lists the roles in a server whose users are permitted to have their own custom colours" + "description": "Lists the roles in a guild which are permitted to have their own custom colours. Requires adminpermissions to use.:return: Sends a message with the mentions of the roles that are protected in a guild." }, { - "command": "addCustomColourAllowedRole", - "parameters": ["role"], - "description": "Adds a role to the list of roles allowed to have a custom colour" + "command": "listProtectedRoleColours", + "parameters": [], + "description": "Lists the protected roles, whose colours are protected from being imitated by a custom colour, in aguild. Requires admin permissions to use.:return: Sends a message with the mentions of the roles that are protected in a guild" }, { "command": "removeCustomColourAllowedRole", - "parameters": ["role_str"], - "description": "Removes a role from the list of roles allowed to have a custom colour" + "parameters": [ + "role_str" + ], + "description": "Removes a role, via ID, mention or name, from the list of roles allowed to have a custom colour.Needs admin permissions to use." + }, + { + "command": "removeProtectedRoleColour", + "parameters": [ + "role_str" + ], + "description": "Removes a role, via ID, mention or name, from the list of protected roles. Needs admin permissionsto use." } ] }, @@ -138,64 +183,73 @@ "name": "ReactForRole (RFR)", "commands": [ { - "command": "rfr create", + "command": "rfr", "parameters": [], - "description": "Create a new, blank rfr message. Default title is React for Role. Default description is Roles below!" + "description": "Group of commands for React for Role (rfr) functionality.:return:" }, { - "command": "rfr delete", - "parameters": [], - "description": "Delete an existing rfr message" + "command": "rfr addRequiredRole", + "parameters": [ + "role_str" + ], + "description": "Adds a role to perms to use rfr functionality in a server, so you can specify that you need, e.g. \"@Student\" tobe able to use rfr functionality in the server. It's server-wide permissions handling however. By default anyonecan use rfr functionality in the server. User needs to have admin perms to use.:return:" }, { - "command": "rfr addRequiredRole", - "parameters": ["role"], - "description": "Add a server-wide role required to react to/use rfr functionality. If no role is added, anyone can use rfr functionality" + "command": "rfr edit addRoles", + "parameters": [], + "description": " Adds roles to an existing rfr message. User is prompted for rfr message channel ID/name/mention, rfr message ID/ URL, emoji-role combos. Emoji-role combinations are to be given in \\\", \" \\\", \" format. can be the role ID, name or mention. `emoji` can be a custom emoji from the server, or a standard unicode emoji. \\User needs admin perms to use. :param ctx: Context of the command. :return: " }, { - "command": "rfr removeRequiredRole", - "parameters": ["role"], - "description": "Removes a server-wide role from the group of roles someone requires to use rfr functionality" + "command": "rfr create", + "parameters": [], + "description": "Creates a new rfr message in a channel of user's choice. User is prompted for (in this order)channel ID/name/mention, message title, message description. Default title and description exist, which are\"React for Role\" and \"Roles below!\" respectively. User requires admin perms to use.:return:" }, { - "command": "rfr listRequiredRoles", + "command": "rfr delete", "parameters": [], - "description": "Lists the server-specific role permissions for using rfr functionality" + "description": "Deletes an existing rfr message. User is prompted for (in this order) channel ID/name/mention, message ID/URL,Y/N confirmation. User needs admin perms to use.:return:" }, { "command": "rfr edit description", "parameters": [], - "description": "Edit the description of an existing rfr message" + "description": "Edit the description of an existing rfr message. User is prompted for rfr message channel ID/name/mention,rfr message ID/URL, new description, Y/N confirmation. User needs admin perms to use.:return:" }, { - "command": "rfr edit title", + "command": "rfr edit inline", "parameters": [], - "description": "Edit the title of an existing rfr message" + "description": "Edit the inline property of embed fields in rfr embeds. Can edit all rfr messages in a server or a specific one.User is prompted for whether they'd like inline fields or not, as well as details of the specific message ifthat option is selected. User requires admin perms:return:" }, { "command": "rfr edit thumbnail", "parameters": [], - "description": "Edit the thumbnail of an existing rfr message" + "description": "Edit the thumbnail of an existing rfr message. User is prompted for rfr message channel ID/name/mention, rfrmessage ID/URL, new thumbnail, Y/N confirmation. User needs admin perms:return:" }, { - "command": "rfr edit inline", + "command": "rfr edit title", "parameters": [], - "description": "Edit the inline property of embed fields in rfr embeds" + "description": "Edit the title of an existing rfr message. User is prompted for rfr message channel ID/name/mention,rfr message ID/URL, new title, Y/N confirmation. User needs admin perms to use.:return:" }, { - "command": "rfr edit addRoles", + "command": "rfr edit fixEmbed", "parameters": [], - "description": "Add emoji/role combos to an existing rfr message" + "description": "Cosmetic fix method if the bot ever has a moment and doesn't react with the correct emojis/has duplicates." }, { - "command": "rfr edit removeRoles", + "command": "rfr listRequiredRoles", "parameters": [], - "description": "Remove emoji/role combos from an existing rfr message" + "description": "Lists the server-specific role permissions for using rfr functionality. If list is empty, any role can use rfrfunctionality.:return:" }, { - "command": "rfr edit fixEmbed", + "command": "rfr removeRequiredRole", + "parameters": [ + "role_str" + ], + "description": "Removes a role from perms for use of rfr functionality in a server, so you can specify that you need, e.g.\"@Student\" to be able to use rfr functionality in the server. It's server-wide permissions handling however. Bydefault anyone can use rfr functionality in the server. User needs to have admin perms to use.:return:" + }, + { + "command": "rfr edit removeRoles", "parameters": [], - "description": "Cosmetic fix method if the bot ever has a moment and doesn't react with the correct emojis/has duplicates" + "description": " Removes roles from an existing rfr message. User is prompted for rfr message channel ID/name/mention, rfr message ID/URL, emojis/roles to remove. User can specify either the emoji or the role for any emoji-role combination to remove it, but it needs to be specified in the format below. \\\"/\" \\\"/\" can be the role ID, name or mention. emoji can be a custom emoji from the server, or a standard unicode emoji. \\User needs admin perms to use. :param ctx: Context of the command. :return: " } ] }, @@ -203,99 +257,160 @@ "name": "TextFilter", "commands": [ { - "command": "filter", - "parameters": ["text", "type"], - "description": "Filter a word or string of text. Type is defaulted to 'banned' which will delete the message and warn the user. Use type 'risky' to just warn the user" + "command": "filterList", + "parameters": [], + "description": "Get a list of filtered words on the current guild.:return:" }, { "command": "filterRegex", - "parameters": ["regex", "type"], - "description": "Filter a regex string. Type is defaulted to 'banned' which will delete the message and warn the user. Use type 'risky' to just warn the user" + "parameters": [ + "regex", + "filter_type", + "too_many_arguments" + ], + "description": "Adds a new regex to the filtered text list:return:" }, { - "command": "filterList", - "parameters": [], - "description": "Get a list of filtered words in the server" + "command": "filter", + "parameters": [ + "word", + "filter_type", + "too_many_arguments" + ], + "description": "Adds a new word to the filtered text list:return:" }, { - "command": "modChannelAdd", - "parameters": ["channelId"], - "description": " Add a mod channel for receiving filtered message information (User, Timestamp, Message) to be sent to" + "command": "ignoreChannel", + "parameters": [ + "channel", + "too_many_arguments" + ], + "description": "Add a new ignored channel to the database:return:" }, { - "command": "modChannelRemove", - "parameters": ["channelId"], - "description": "Remove a mod channel from the server" + "command": "ignoreUser", + "parameters": [ + "user", + "too_many_arguments" + ], + "description": "Add a new ignored user to the database:return:" + }, + { + "command": "ignoreList", + "parameters": [], + "description": "Get a list all ignored users/channels:return:" }, { "command": "modChannelList", "parameters": [], - "description": "See a list of mod channels in the server" + "description": "Get a list of filtered mod channels in the guild:return:" }, { - "command": "ignoreUser", - "parameters": ["userMention"], - "description": "Add a new ignored user for the server. This users' messages will be ignored by the Text Filter" + "command": "unignore", + "parameters": [ + "ignore", + "too_many_arguments" + ], + "description": "Remove an ignore from the guild:return:" }, { - "command": "ignoreChannel", - "parameters": ["channelMention"], - "description": "Add a new ignored channel for the server. Messages in this channel will be ignored by the Text Filter" + "command": "modChannelRemove", + "parameters": [ + "channel_id", + "too_many_arguments" + ], + "description": "Remove a mod channel from the guild:return:" }, { - "command": "ignoreList", - "parameters": [], - "description": "See a list of ignored users/channels in the server" + "command": "modChannelAdd", + "parameters": [ + "channel_id", + "too_many_arguments" + ], + "description": "Add a mod channel to the current guild:return:" }, { "command": "unfilter", - "parameters": ["text"], - "description": "Unfilter a word/string/regex of text that was previously filtered" + "parameters": [ + "word", + "too_many_arguments" + ], + "description": "Remove an existing word/test from the filter list:return:" }, { "command": "unignore", - "parameters": ["mention"], - "description": "Unignore a user/channel that was previously set as ignored" + "parameters": [ + "ignore", + "too_many_arguments" + ], + "description": "Remove an ignore from the guild:return:" + }, + { + "command": "modChannelRemove", + "parameters": [ + "channel_id", + "too_many_arguments" + ], + "description": "Remove a mod channel from the guild:return:" } ] }, { "name": "TwitchAlert", "commands": [ + { + "command": "twitchAddTeam", + "parameters": [ + "raw_channel_id", + "team_name", + "custom_live_message" + ], + "description": "Add a Twitch team to a Twitch Alert:return:" + }, { "command": "twitchAdd", - "parameters": ["channel_id", "twitch_username", "custom_live_message"], - "description": "Add a Twitch user to a Twitch Alert" + "parameters": [ + "raw_channel_id", + "twitch_username", + "custom_live_message" + ], + "description": "Add a Twitch user to a Twitch Alert:return:" }, { - "command": "twitchRemove", - "parameters": ["channel_id", "twitch_username"], - "description": "Remove a user from a Twitch Alert" + "command": "twitchEditMsg", + "parameters": [ + "raw_channel_id", + "default_live_message" + ], + "description": "Edit the default message put in a Twitch Alert Notificationleave empty for program default:return:" }, { - "command": "twitchAddTeam", - "parameters": ["channel_id", "team_name", "custom_live_message"], - "description": "Add a Twitch team to a Twitch alert" + "command": "twitchList", + "parameters": [], + "description": "Shows all current TwitchAlert users and teams in a channel:param ctx::param raw_channel_id::return:" }, { "command": "twitchRemoveTeam", - "parameters": ["channel_id", "team_name"], - "description": "Edit the default message put in a Twitch Alert Notification" + "parameters": [ + "raw_channel_id", + "team_name" + ], + "description": "Removes a team from a Twitch Alert:return:" }, { - "command": "twitchEditMsg", - "parameters": ["channel", "default_live_message"], - "description": "Edit the default message put in a Twitch Alert Notification" + "command": "twitchRemove", + "parameters": [ + "raw_channel_id", + "twitch_username" + ], + "description": "Removes a user from a Twitch Alert:return:" }, { "command": "twitchViewMsg", - "parameters": ["channel"], - "description": "Shows the current default message for Twitch Alerts" - }, - { - "command": "twitchList", - "parameters": ["channel"], - "description": "Shows all current TwitchAlert users and teams in a channel" + "parameters": [ + "raw_channel_id" + ], + "description": "Shows the current default message for Twitch Alertsleave empty for program default:return:" } ] }, @@ -303,39 +418,60 @@ "name": "Verify", "commands": [ { - "command": "verifyAdd", - "parameters": ["suffix", "role"], - "description": "Set up a role and email pair for KoalaBot to verify users with" + "command": "verifyList", + "parameters": [], + "description": "List the current verification setup for the server:return:" + }, + { + "command": "confirm", + "parameters": [ + "token" + ], + "description": "Send to KoalaBot in dms to confirm the verification of an email:return:" }, { "command": "verifyRemove", - "parameters": ["suffix", "role"], - "description": "Disable an existing verification listener" + "parameters": [ + "suffix", + "role" + ], + "description": "Disable an existing verification listener:return:" }, { - "command": "reVerify", - "parameters": ["role"], - "description": "Removes a role from all users who have it and marks them as needing to re-verify before giving it back." + "command": "verifyAdd", + "parameters": [ + "suffix", + "role" + ], + "description": "Set up a role and email pair for KoalaBot to verify users with:return:" }, { - "command": "verifyList", - "parameters": ["channelId"], - "description": "List the current verification setup for the server" + "command": "getEmails", + "parameters": [ + "user_id" + ], + "description": "See the emails a user is verified with:return:" }, { - "command": "verify", - "parameters": ["email"], - "description": "Send to KoalaBot in dms to verify an email with our system" + "command": "reVerify", + "parameters": [ + "role" + ], + "description": "Removes a role from all users who have it and marks them as needing to re-verify before giving it back:return:" }, { "command": "unVerify", - "parameters": ["email"], - "description": "Send to KoalaBot in dms to un-verify an email with our system" + "parameters": [ + "email" + ], + "description": "Send to KoalaBot in dms to un-verify an email with our system:return:" }, { - "command": "confirm", - "parameters": ["token"], - "description": "Send to KoalaBot in dms to confirm the verification of an email" + "command": "verify", + "parameters": [ + "email" + ], + "description": "Send to KoalaBot in dms to verify an email with our system:return:" } ] }, @@ -343,44 +479,89 @@ "name": "Vote", "commands": [ { - "command": "vote create", - "parameters": ["title"], - "description": "Creates a new vote" + "command": "vote addOption", + "parameters": [ + "option_string" + ], + "description": "Adds an option to the current voteseparate the title and description with a \"+\" e.g. option title+option description" }, { "command": "vote addRole", - "parameters": ["role"], - "description": "Adds a role to the list of roles the vote will be sent to" + "parameters": [ + "role" + ], + "description": "Adds a role to the list of roles the vote will be sent toIf no roles are added, the vote will go to all users in a guild (unless a target voice channel has been set)" + }, + { + "command": "vote removeOption", + "parameters": [ + "index" + ], + "description": "Removes an option from a vote based on it's index" }, { "command": "vote removeRole", - "parameters": ["role"], + "parameters": [ + "role" + ], "description": "Removes a role to the list of roles the vote will be sent to" }, { "command": "vote setChair", - "parameters": ["chair_user"], - "description": "Sets the chair of a vote (no chair defaults to message the channel)" + "parameters": [ + "chair" + ], + "description": "Sets the chair of a voteIf no chair defaults to sending the message to the channel the vote is closed in" }, { - "command": "vote setChannel", - "parameters": ["channel"], - "description": "Sets the target voice channel of a vote (Users connected to this channel will receive the vote message)" + "command": "vote setEndTime", + "parameters": [ + "time_string" + ], + "description": "Sets a specific time for the vote to end. Results will be sent to the chair or owner if you use this, not a channel.If the vote has not been sent by the end time it will close automatically once it is sent.:return:" + }, + { + "command": "vote cancel", + "parameters": [ + "title" + ], + "description": "Cancels a vote you are setting up or have sent" }, { "command": "vote addOption", - "parameters": ["option"], - "description": "Adds an option to the current vote (separate the title and description with a '+' e.g. option title+option description)" + "parameters": [ + "option_string" + ], + "description": "Adds an option to the current voteseparate the title and description with a \"+\" e.g. option title+option description" }, { - "command": "vote removeOption", - "parameters": ["index"], - "description": "Removes an option from a vote based on it's index" + "command": "vote addRole", + "parameters": [ + "role" + ], + "description": "Adds a role to the list of roles the vote will be sent toIf no roles are added, the vote will go to all users in a guild (unless a target voice channel has been set)" }, { - "command": "vote setEndTime", - "parameters": ["time_string"], - "description": "Sets a specific time for the vote to end. Results will be sent to the chair or owner if you use this, not a channel" + "command": "vote cancel", + "parameters": [ + "title" + ], + "description": "Cancels a vote you are setting up or have sent" + }, + { + "command": "vote list", + "parameters": [], + "description": "Return a list of all votes you have in this guild.:return:" + }, + { + "command": "vote checkResults", + "parameters": [], + "description": "Checks the results of a vote without closing it" + }, + { + "command": "vote close", + "parameters": [], + "description": "Ends a vote, and collects the results" }, { "command": "vote preview", @@ -388,14 +569,18 @@ "description": "Generates a preview of what users will see with the current configuration of the vote" }, { - "command": "vote cancel", - "parameters": ["title"], - "description": "Cancels a vote you are setting up or have sent" + "command": "vote removeOption", + "parameters": [ + "index" + ], + "description": "Removes an option from a vote based on it's index" }, { - "command": "vote list", - "parameters": [], - "description": "Return a list of all votes you have in this server" + "command": "vote removeRole", + "parameters": [ + "role" + ], + "description": "Removes a role to the list of roles the vote will be sent to" }, { "command": "vote send", @@ -403,15 +588,38 @@ "description": "Sends a vote to all users within the restrictions set with the current options added" }, { - "command": "vote close", - "parameters": ["title"], - "description": "Ends a vote, and collects the results" + "command": "vote setChair", + "parameters": [ + "chair" + ], + "description": "Sets the chair of a voteIf no chair defaults to sending the message to the channel the vote is closed in" }, { - "command": "vote checkResults", - "parameters": ["title"], - "description": "Checks the results of a vote without closing it" + "command": "vote setChannel", + "parameters": [ + "channel" + ], + "description": "Sets the target voice channel of a vote (Users connected to this channel will receive the vote message)If there isn't one set votes will go to all users in a guild (unless target roles have been added)" + }, + { + "command": "vote setEndTime", + "parameters": [ + "time_string" + ], + "description": "Sets a specific time for the vote to end. Results will be sent to the chair or owner if you use this, not a channel.If the vote has not been sent by the end time it will close automatically once it is sent.:return:" + }, + { + "command": "vote create", + "parameters": [ + "title" + ], + "description": "Creates a new vote" + }, + { + "command": "vote", + "parameters": [], + "description": "Use k!vote create to create a vote!" } ] } -] +] \ No newline at end of file diff --git a/tests/test_GenerateDoc.py b/tests/test_GenerateDoc.py new file mode 100644 index 00000000..e0736b9d --- /dev/null +++ b/tests/test_GenerateDoc.py @@ -0,0 +1,65 @@ +import pytest +import json +from GenerateDoc import doc_list_to_json, get_cog_docs +from pathlib import Path + +""" +Testing GenerateDoc.py + +Compares automatically generated document to a manually created one +""" + +def open__as_json(filename): + with open(filename) as json_file: + correctDocString = json.load(json_file) + autoDocString = doc_list_to_json(get_cog_docs()) + return correctDocString, autoDocString + +@pytest.mark.parametrize("filename", ['Documentation.json']) +def test_compare_cog_names(filename): + correctDocString, autoDocString = open__as_json(filename) + assert(len(correctDocString) == len(autoDocString)) + names = [doc['name'] for doc in autoDocString] + for doc in correctDocString: + assert doc['name'] in names + + +""" +@pytest.mark.parametrize("filename", ['Documentation.json']) +def test_compare_cog_command(filename): + correctDocString, autoDocString = open__as_json(filename) + assert(len(correctDocString) == len(autoDocString)) + for i in range(0, len(correctDocString)): + for j in range(0, len(correctDocString[i]['commands'])): + assert(correctDocString[i]['commands'][j] == autoDocString[i]['commands'][j]) +""" + +@pytest.mark.parametrize("filename", ['Documentation.json']) +def test_compare_cog_command_name(filename): + correctDocString, autoDocString = open__as_json(filename) + + assert(len(correctDocString) == len(autoDocString)) + for i in range(0, len(correctDocString)): + commandNames = [entry['command'] for entry in autoDocString[i]['commands']] + for command in autoDocString[i]['commands']: + assert(command['command'] in commandNames) + +@pytest.mark.parametrize("filename", ['Documentation.json']) +def test_compare_cog_command_parameters(filename): + correctDocString, autoDocString = open__as_json(filename) + + assert(len(correctDocString) == len(autoDocString)) + for i in range(0, len(correctDocString)): + params = [entry['parameters'] for entry in autoDocString[i]['commands']] + for command in autoDocString[i]['commands']: + assert(command['parameters'] in params) + +@pytest.mark.parametrize("filename", ['Documentation.json']) +def test_compare_cog_command_description(filename): + correctDocString, autoDocString = open__as_json(filename) + + assert(len(correctDocString) == len(autoDocString)) + for i in range(0, len(correctDocString)): + descriptions = [entry['description'] for entry in autoDocString[i]['commands']] + for command in autoDocString[i]['commands']: + assert(command['description'] in descriptions) From b091ffa45061e093086321540f5cb10a498ec80b Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 12:11:52 +0100 Subject: [PATCH 03/37] Added TestDocumentation.json for testing auto gen documentation --- tests/TestDocumentation.json | 418 +++++++++++++++++++++++++++++++++++ tests/test_GenerateDoc.py | 10 +- 2 files changed, 423 insertions(+), 5 deletions(-) create mode 100644 tests/TestDocumentation.json diff --git a/tests/TestDocumentation.json b/tests/TestDocumentation.json new file mode 100644 index 00000000..37437000 --- /dev/null +++ b/tests/TestDocumentation.json @@ -0,0 +1,418 @@ +[ + { + "name": "KoalaBot", + "commands": [ + { + "command": "listExt", + "parameters": [], + "description": "Lists all enabled and disabled Koala Extensions on your server" + }, + { + "command": "enableExt", + "parameters": ["koala_extension"], + "description": "Enable a Koala Extension on your server" + }, + { + "command": "disableExt", + "parameters": ["koala_extension"], + "description": "Disable a Koala Extension on your server" + }, + { + "command": "welcomeUpdateMsg", + "parameters": [], + "description": "Change the customisable part of the welcome message of your server" + }, + { + "command": "welcomeSendMsg", + "parameters": [], + "description": "Sends out the welcome message manually to all members of your server" + }, + { + "command": "welcomeViewMsg", + "parameters": [], + "description": "Shows this server's current welcome message" + }, + { + "command": "clear", + "parameters": ["amount"], + "description": "Clears a given number of messages from the channel." + }, + { + "command": "ping", + "parameters": [], + "description": "Returns the ping of a bot" + }, + { + "command": "support", + "parameters": [], + "description": "Returns a link to the KoalaBot Support Discord Server" + } + ] + }, + { + "name": "Announce", + "commands": [ + { + "command": "announce create", + "parameters": [], + "description": "Create a new message that will be available for sending" + }, + { + "command": "changeTitle", + "parameters": [], + "description": "Change the title of the embedded message" + }, + { + "command": "changeContent", + "parameters": [], + "description": "Change the content of the embedded message" + }, + { + "command": "addRole", + "parameters": [], + "description": "Add a role to list of people to send the announcement to" + }, + { + "command": "removeRole", + "parameters": [], + "description": "Remove a role from a list of people to send the announcement to" + }, + { + "command": "preview", + "parameters": [], + "description": "Post a constructed embedded message to the channel where the command is invoked" + }, + { + "command": "send", + "parameters": [], + "description": "Send a pending announcement" + }, + { + "command": "cancel", + "parameters": [], + "description": "Cancel a pending announcement" + } + ] + }, + { + "name": "ColourRole", + "commands": [ + { + "command": "customColour", + "parameters": ["colour_hexcode/'no'"], + "description": "Gives a user a chosen custom colour, or removes the custom colour with 'k!customColour no'" + }, + { + "command": "listProtectedRoleColours", + "parameters": [], + "description": "Lists the protected roles, whose colours are protected from being imitated by a custom colour, in a server" + }, + { + "command": "addProtectedRoleColour", + "parameters": ["role"], + "description": "Adds a role's colour to the list of protected roles" + }, + { + "command": "removeProtectedRoleColour", + "parameters": ["role"], + "description": "Removes a role's colour from the list of protected roles" + }, + { + "command": "listCustomColourAllowedRoles", + "parameters": [], + "description": "Lists the roles in a server whose users are permitted to have their own custom colours" + }, + { + "command": "addCustomColourAllowedRole", + "parameters": ["role"], + "description": "Adds a role to the list of roles allowed to have a custom colour" + }, + { + "command": "removeCustomColourAllowedRole", + "parameters": ["role_str"], + "description": "Removes a role from the list of roles allowed to have a custom colour" + } + ] + }, + { + "name": "ReactForRole (RFR)", + "commands": [ + { + "command": "rfr create", + "parameters": [], + "description": "Create a new, blank rfr message. Default title is React for Role. Default description is Roles below!" + }, + { + "command": "rfr delete", + "parameters": [], + "description": "Delete an existing rfr message" + }, + { + "command": "rfr addRequiredRole", + "parameters": ["role"], + "description": "Add a server-wide role required to react to/use rfr functionality. If no role is added, anyone can use rfr functionality" + }, + { + "command": "rfr removeRequiredRole", + "parameters": ["role"], + "description": "Removes a server-wide role from the group of roles someone requires to use rfr functionality" + }, + { + "command": "rfr listRequiredRoles", + "parameters": [], + "description": "Lists the server-specific role permissions for using rfr functionality" + }, + { + "command": "rfr edit description", + "parameters": [], + "description": "Edit the description of an existing rfr message" + }, + { + "command": "rfr edit title", + "parameters": [], + "description": "Edit the title of an existing rfr message" + }, + { + "command": "rfr edit thumbnail", + "parameters": [], + "description": "Edit the thumbnail of an existing rfr message" + }, + { + "command": "rfr edit inline", + "parameters": [], + "description": "Edit the inline property of embed fields in rfr embeds" + }, + { + "command": "rfr edit addRoles", + "parameters": [], + "description": "Add emoji/role combos to an existing rfr message" + }, + { + "command": "rfr edit removeRoles", + "parameters": [], + "description": "Remove emoji/role combos from an existing rfr message" + }, + { + "command": "rfr edit fixEmbed", + "parameters": [], + "description": "Cosmetic fix method if the bot ever has a moment and doesn't react with the correct emojis/has duplicates" + } + ] + }, + { + "name": "TextFilter", + "commands": [ + { + "command": "filter", + "parameters": ["text", "type"], + "description": "Filter a word or string of text. Type is defaulted to 'banned' which will delete the message and warn the user. Use type 'risky' to just warn the user" + }, + { + "command": "filterRegex", + "parameters": ["regex", "type"], + "description": "Filter a regex string. Type is defaulted to 'banned' which will delete the message and warn the user. Use type 'risky' to just warn the user" + }, + { + "command": "filterList", + "parameters": [], + "description": "Get a list of filtered words in the server" + }, + { + "command": "modChannelAdd", + "parameters": ["channelId"], + "description": " Add a mod channel for receiving filtered message information (User, Timestamp, Message) to be sent to" + }, + { + "command": "modChannelRemove", + "parameters": ["channelId"], + "description": "Remove a mod channel from the server" + }, + { + "command": "modChannelList", + "parameters": [], + "description": "See a list of mod channels in the server" + }, + { + "command": "ignoreUser", + "parameters": ["userMention"], + "description": "Add a new ignored user for the server. This users' messages will be ignored by the Text Filter" + }, + { + "command": "ignoreChannel", + "parameters": ["channelMention"], + "description": "Add a new ignored channel for the server. Messages in this channel will be ignored by the Text Filter" + }, + { + "command": "ignoreList", + "parameters": [], + "description": "See a list of ignored users/channels in the server" + }, + { + "command": "unfilter", + "parameters": ["text"], + "description": "Unfilter a word/string/regex of text that was previously filtered" + }, + { + "command": "unignore", + "parameters": ["mention"], + "description": "Unignore a user/channel that was previously set as ignored" + } + ] + }, + { + "name": "TwitchAlert", + "commands": [ + { + "command": "twitchAdd", + "parameters": ["channel_id", "twitch_username", "custom_live_message"], + "description": "Add a Twitch user to a Twitch Alert" + }, + { + "command": "twitchRemove", + "parameters": ["channel_id", "twitch_username"], + "description": "Remove a user from a Twitch Alert" + }, + { + "command": "twitchAddTeam", + "parameters": ["channel_id", "team_name", "custom_live_message"], + "description": "Add a Twitch team to a Twitch alert" + }, + { + "command": "twitchRemoveTeam", + "parameters": ["channel_id", "team_name"], + "description": "Edit the default message put in a Twitch Alert Notification" + }, + { + "command": "twitchEditMsg", + "parameters": ["channel", "default_live_message"], + "description": "Edit the default message put in a Twitch Alert Notification" + }, + { + "command": "twitchViewMsg", + "parameters": ["channel"], + "description": "Shows the current default message for Twitch Alerts" + }, + { + "command": "twitchList", + "parameters": ["channel"], + "description": "Shows all current TwitchAlert users and teams in a channel" + } + ] + }, + { + "name": "Verify", + "commands": [ + { + "command": "verifyAdd", + "parameters": ["suffix", "role"], + "description": "Set up a role and email pair for KoalaBot to verify users with" + }, + { + "command": "verifyRemove", + "parameters": ["suffix", "role"], + "description": "Disable an existing verification listener" + }, + { + "command": "reVerify", + "parameters": ["role"], + "description": "Removes a role from all users who have it and marks them as needing to re-verify before giving it back." + }, + { + "command": "verifyList", + "parameters": ["channelId"], + "description": "List the current verification setup for the server" + }, + { + "command": "verify", + "parameters": ["email"], + "description": "Send to KoalaBot in dms to verify an email with our system" + }, + { + "command": "unVerify", + "parameters": ["email"], + "description": "Send to KoalaBot in dms to un-verify an email with our system" + }, + { + "command": "confirm", + "parameters": ["token"], + "description": "Send to KoalaBot in dms to confirm the verification of an email" + } + ] + }, + { + "name": "Vote", + "commands": [ + { + "command": "vote create", + "parameters": ["title"], + "description": "Creates a new vote" + }, + { + "command": "vote addRole", + "parameters": ["role"], + "description": "Adds a role to the list of roles the vote will be sent to" + }, + { + "command": "vote removeRole", + "parameters": ["role"], + "description": "Removes a role to the list of roles the vote will be sent to" + }, + { + "command": "vote setChair", + "parameters": ["chair_user"], + "description": "Sets the chair of a vote (no chair defaults to message the channel)" + }, + { + "command": "vote setChannel", + "parameters": ["channel"], + "description": "Sets the target voice channel of a vote (Users connected to this channel will receive the vote message)" + }, + { + "command": "vote addOption", + "parameters": ["option"], + "description": "Adds an option to the current vote (separate the title and description with a '+' e.g. option title+option description)" + }, + { + "command": "vote removeOption", + "parameters": ["index"], + "description": "Removes an option from a vote based on it's index" + }, + { + "command": "vote setEndTime", + "parameters": ["time_string"], + "description": "Sets a specific time for the vote to end. Results will be sent to the chair or owner if you use this, not a channel" + }, + { + "command": "vote preview", + "parameters": [], + "description": "Generates a preview of what users will see with the current configuration of the vote" + }, + { + "command": "vote cancel", + "parameters": ["title"], + "description": "Cancels a vote you are setting up or have sent" + }, + { + "command": "vote list", + "parameters": [], + "description": "Return a list of all votes you have in this server" + }, + { + "command": "vote send", + "parameters": [], + "description": "Sends a vote to all users within the restrictions set with the current options added" + }, + { + "command": "vote close", + "parameters": ["title"], + "description": "Ends a vote, and collects the results" + }, + { + "command": "vote checkResults", + "parameters": ["title"], + "description": "Checks the results of a vote without closing it" + } + ] + } + ] + \ No newline at end of file diff --git a/tests/test_GenerateDoc.py b/tests/test_GenerateDoc.py index e0736b9d..0e518a79 100644 --- a/tests/test_GenerateDoc.py +++ b/tests/test_GenerateDoc.py @@ -15,7 +15,7 @@ def open__as_json(filename): autoDocString = doc_list_to_json(get_cog_docs()) return correctDocString, autoDocString -@pytest.mark.parametrize("filename", ['Documentation.json']) +@pytest.mark.parametrize("filename", ['tests/TestDocumentation.json']) def test_compare_cog_names(filename): correctDocString, autoDocString = open__as_json(filename) assert(len(correctDocString) == len(autoDocString)) @@ -25,7 +25,7 @@ def test_compare_cog_names(filename): """ -@pytest.mark.parametrize("filename", ['Documentation.json']) +@pytest.mark.parametrize("filename", ['tests/TestDocumentation.json']) def test_compare_cog_command(filename): correctDocString, autoDocString = open__as_json(filename) assert(len(correctDocString) == len(autoDocString)) @@ -34,7 +34,7 @@ def test_compare_cog_command(filename): assert(correctDocString[i]['commands'][j] == autoDocString[i]['commands'][j]) """ -@pytest.mark.parametrize("filename", ['Documentation.json']) +@pytest.mark.parametrize("filename", ['tests/TestDocumentation.json']) def test_compare_cog_command_name(filename): correctDocString, autoDocString = open__as_json(filename) @@ -44,7 +44,7 @@ def test_compare_cog_command_name(filename): for command in autoDocString[i]['commands']: assert(command['command'] in commandNames) -@pytest.mark.parametrize("filename", ['Documentation.json']) +@pytest.mark.parametrize("filename", ['tests/TestDocumentation.json']) def test_compare_cog_command_parameters(filename): correctDocString, autoDocString = open__as_json(filename) @@ -54,7 +54,7 @@ def test_compare_cog_command_parameters(filename): for command in autoDocString[i]['commands']: assert(command['parameters'] in params) -@pytest.mark.parametrize("filename", ['Documentation.json']) +@pytest.mark.parametrize("filename", ['tests/TestDocumentation.json']) def test_compare_cog_command_description(filename): correctDocString, autoDocString = open__as_json(filename) From 6ce1cbe1d96ad0433a520c3443bac9516034bd67 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 12:50:32 +0100 Subject: [PATCH 04/37] Added auto gen of doc as a github action on push --- .github/workflows/ci.yml | 5 + GenerateDoc.py | 36 ++- KoalaBot.py | 5 + documentation.json | 625 --------------------------------------- 4 files changed, 38 insertions(+), 633 deletions(-) delete mode 100644 documentation.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47089935..2160c08f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,3 +88,8 @@ jobs: fail_ci_if_error: true path_to_write_report: ./coverage/codecov_report.txt verbose: true + + - name: Create new json documentation + run: + from GenerateDoc import generate_doc + generate_doc() diff --git a/GenerateDoc.py b/GenerateDoc.py index ed8d8d17..67176944 100644 --- a/GenerateDoc.py +++ b/GenerateDoc.py @@ -4,7 +4,7 @@ import json """ -KoalaBot utility function for generating bot command docs +KoalaBot utility function for auto generating bot command docs Created By: Charlie Bowe, Aqeel Little """ @@ -26,7 +26,7 @@ class CogDocumentation: name = None docs = [] - #Dictionary of cogs that have different names in the doc + #Dictionary of cogs that have different names in the doc for clarity docNameChanges = { 'BaseCog': 'KoalaBot', 'ReactForRole': 'ReactForRole (RFR)', @@ -35,14 +35,21 @@ class CogDocumentation: } def __init__(self,name: str, docs): - + #If name of the cog is not the name that should be in the doc if name in self.docNameChanges.keys(): + #change it self.name = self.docNameChanges.get(name) else: self.name = name self.docs = docs def add_cog_to_cog(add,to,docList): + """Add all DocumentationEntry of one CogDocumentation to another + :param add: CogDocumentation to move and destroy + :param to: CogDocumentation to add to + :param docList: list of CogDocumentation that add and to are in + :return: new list of CogDocumentation + """ addCog = None toCog = None @@ -61,8 +68,9 @@ def add_cog_to_cog(add,to,docList): def get_cog_docs(): """Imports all cogs in directory cogs and stores the name, params and docstring description of bot commands - :return: CogDocumentation[] + :return: list of CogDocumentation """ + #List fo Cogdocumentation docList = [] #Get the directory of the cogs folder dir = path.join(path.dirname(path.realpath(__file__)),'cogs') @@ -100,31 +108,39 @@ def get_cog_docs(): #On attribute error, function has no docstring pass continue - except: - print("Unexpected error") + except Exception: + print(f'Error {Exception} when reading docstring of {obj} in {modules[i]}') continue #Get the name of the command object name = getattr(getattr(currentLib,modules[i]),str(obj[0])).name + #If function is nested, append its nested commadn to its font + #E.g. announce create if getattr(getattr(currentLib,modules[i]),str(obj[0])).parent != None: name = f'{getattr(getattr(currentLib,modules[i]),str(obj[0])).parent} {name}' desc = "" params = [] for line in text: + #Match each line to regex for checking for parameter descriptions matchObj = re.match( r':(.*) (.*): (.*)', line, re.M|re.I) + #If its a parameter if matchObj and (matchObj.group(1) == 'param'): + #Do not add it if its a ctx, as that is not useful for the doc if matchObj.group(2) == 'ctx': continue params.append(matchObj.group(2)) else: + #Else, its a description of the command, so add it to desc desc += line + #Create a new Documentation entry for the command docs.append(DocumentationEntry(name,params,desc)) docList.append(CogDocumentation(modules[i],docs)) + #Add everything in IntroCog to KoalaBot for clarity docList = add_cog_to_cog('IntroCog','KoalaBot',docList) return docList @@ -159,5 +175,9 @@ def parse_docs(docList, filename): file.write(json.dumps(data, indent=2)) file.close() -docList = get_cog_docs() -parse_docs(docList,'documentation.json') \ No newline at end of file +def generate_doc(): + """Runs the script that will automatically generate documentation.json using the docstrings + of cogs in directory cogs + """ + docList = get_cog_docs() + parse_docs(docList,'documentation.json') \ No newline at end of file diff --git a/KoalaBot.py b/KoalaBot.py index a27b84f1..7cd23237 100644 --- a/KoalaBot.py +++ b/KoalaBot.py @@ -33,6 +33,8 @@ from utils.KoalaDBManager import KoalaDBManager as DBManager from utils.KoalaUtils import error_embed +from GenerateDoc import generate_doc + # Constants logging.basicConfig(filename='KoalaBot.log') logging.getLogger().addHandler(logging.StreamHandler(sys.stdout)) @@ -110,6 +112,9 @@ def load_all_cogs(): Loads all cogs in COGS_DIR into the client """ UNRELEASED = [] + + #Auto generate documentation.json + generate_doc() for filename in os.listdir(COGS_DIR): if filename.endswith('.py') and filename not in UNRELEASED: diff --git a/documentation.json b/documentation.json deleted file mode 100644 index 85a2a955..00000000 --- a/documentation.json +++ /dev/null @@ -1,625 +0,0 @@ -[ - { - "name": "Announce", - "commands": [ - { - "command": "announce addRole", - "parameters": [], - "description": "Add a role to list of people to send the announcement to:return:" - }, - { - "command": "announce", - "parameters": [], - "description": "Use k!announce create to create an announcement" - }, - { - "command": "announce cancel", - "parameters": [], - "description": "Cancel a pending announcement:return:" - }, - { - "command": "announce changeContent", - "parameters": [], - "description": "Change the content of the embedded message:return:" - }, - { - "command": "announce changeTitle", - "parameters": [], - "description": "Change the title of the embedded message:return:" - }, - { - "command": "announce create", - "parameters": [], - "description": "Create a new message that will be available for sending:return:" - }, - { - "command": "announce preview", - "parameters": [], - "description": "Post a constructed embedded message to the channel where the command is invoked:return:" - }, - { - "command": "announce removeRole", - "parameters": [], - "description": "Remove a role from a list of people to send the announcement to:return:" - }, - { - "command": "announce send", - "parameters": [], - "description": "Send a pending announcement:return:" - } - ] - }, - { - "name": "KoalaBot", - "commands": [ - { - "command": "activity", - "parameters": [ - "new_activity", - "name" - ], - "description": "Change the activity of the bot" - }, - { - "command": "clear", - "parameters": [ - "amount" - ], - "description": "Clears a given number of messages from the given channel" - }, - { - "command": "disableExt", - "parameters": [ - "koala_extension" - ], - "description": "Disables a koala extension onto a server" - }, - { - "command": "enableExt", - "parameters": [ - "koala_extension" - ], - "description": "Enables a koala extension onto a server, all grants all extensions" - }, - { - "command": "listExt", - "parameters": [], - "description": "Lists the enabled koala extensions of a server" - }, - { - "command": "loadCog", - "parameters": [ - "extension" - ], - "description": "Loads a cog from the cogs folder" - }, - { - "command": "ping", - "parameters": [], - "description": "Returns the ping of the bot" - }, - { - "command": "support", - "parameters": [], - "description": "KoalaBot Support server link" - }, - { - "command": "unloadCog", - "parameters": [ - "extension" - ], - "description": "Unloads a running cog" - }, - { - "command": "welcomeSendMsg", - "parameters": [], - "description": "Allows admins to send out their welcome message manually to all members of a guild. Has a 60 second cooldown perguild." - }, - { - "command": "welcomeUpdateMsg", - "parameters": [ - "new_message" - ], - "description": "Allows admins to change their customisable part of the welcome message of a guild. Has a 60 second cooldown perguild." - }, - { - "command": "welcomeViewMsg", - "parameters": [], - "description": "Shows this server's current welcome message" - } - ] - }, - { - "name": "ColourRole", - "commands": [ - { - "command": "addCustomColourAllowedRole", - "parameters": [ - "role_str" - ], - "description": "Adds a role, via ID, mention or name, to the list of roles allowed to have a custom colour. Needsadmin permissions to use." - }, - { - "command": "addProtectedRoleColour", - "parameters": [ - "role_str" - ], - "description": "Adds a role, via ID, mention or name, to the list of protected roles. Needs admin permissions touse." - }, - { - "command": "customColour", - "parameters": [ - "colour_str" - ], - "description": "For a user with the correct role to be able to change their display colour in a guild.Syntax is k!custom_colour (\"no\" / colour hex). Usage with no removes any custom colour held before.Won't accept it if the colour chosen too closely resembles a role that was protected's colour or a discordblocked colour. A role must be made and that role be added to the permissions by usage ofk!add_custom_colour_allowed_role <role>, and the command invoker must have that role before they can use thiscommand. Has a 15 second cooldown." - }, - { - "command": "listCustomColourAllowedRoles", - "parameters": [], - "description": "Lists the roles in a guild which are permitted to have their own custom colours. Requires adminpermissions to use.:return: Sends a message with the mentions of the roles that are protected in a guild." - }, - { - "command": "listProtectedRoleColours", - "parameters": [], - "description": "Lists the protected roles, whose colours are protected from being imitated by a custom colour, in aguild. Requires admin permissions to use.:return: Sends a message with the mentions of the roles that are protected in a guild" - }, - { - "command": "removeCustomColourAllowedRole", - "parameters": [ - "role_str" - ], - "description": "Removes a role, via ID, mention or name, from the list of roles allowed to have a custom colour.Needs admin permissions to use." - }, - { - "command": "removeProtectedRoleColour", - "parameters": [ - "role_str" - ], - "description": "Removes a role, via ID, mention or name, from the list of protected roles. Needs admin permissionsto use." - } - ] - }, - { - "name": "ReactForRole (RFR)", - "commands": [ - { - "command": "rfr", - "parameters": [], - "description": "Group of commands for React for Role (rfr) functionality.:return:" - }, - { - "command": "rfr addRequiredRole", - "parameters": [ - "role_str" - ], - "description": "Adds a role to perms to use rfr functionality in a server, so you can specify that you need, e.g. \"@Student\" tobe able to use rfr functionality in the server. It's server-wide permissions handling however. By default anyonecan use rfr functionality in the server. User needs to have admin perms to use.:return:" - }, - { - "command": "rfr edit addRoles", - "parameters": [], - "description": " Adds roles to an existing rfr message. User is prompted for rfr message channel ID/name/mention, rfr message ID/ URL, emoji-role combos. Emoji-role combinations are to be given in \\\"<emoji>, <role>\" \\\"<emoji>, <role>\" format. <role> can be the role ID, name or mention. `emoji` can be a custom emoji from the server, or a standard unicode emoji. \\User needs admin perms to use. :param ctx: Context of the command. :return: " - }, - { - "command": "rfr create", - "parameters": [], - "description": "Creates a new rfr message in a channel of user's choice. User is prompted for (in this order)channel ID/name/mention, message title, message description. Default title and description exist, which are\"React for Role\" and \"Roles below!\" respectively. User requires admin perms to use.:return:" - }, - { - "command": "rfr delete", - "parameters": [], - "description": "Deletes an existing rfr message. User is prompted for (in this order) channel ID/name/mention, message ID/URL,Y/N confirmation. User needs admin perms to use.:return:" - }, - { - "command": "rfr edit description", - "parameters": [], - "description": "Edit the description of an existing rfr message. User is prompted for rfr message channel ID/name/mention,rfr message ID/URL, new description, Y/N confirmation. User needs admin perms to use.:return:" - }, - { - "command": "rfr edit inline", - "parameters": [], - "description": "Edit the inline property of embed fields in rfr embeds. Can edit all rfr messages in a server or a specific one.User is prompted for whether they'd like inline fields or not, as well as details of the specific message ifthat option is selected. User requires admin perms:return:" - }, - { - "command": "rfr edit thumbnail", - "parameters": [], - "description": "Edit the thumbnail of an existing rfr message. User is prompted for rfr message channel ID/name/mention, rfrmessage ID/URL, new thumbnail, Y/N confirmation. User needs admin perms:return:" - }, - { - "command": "rfr edit title", - "parameters": [], - "description": "Edit the title of an existing rfr message. User is prompted for rfr message channel ID/name/mention,rfr message ID/URL, new title, Y/N confirmation. User needs admin perms to use.:return:" - }, - { - "command": "rfr edit fixEmbed", - "parameters": [], - "description": "Cosmetic fix method if the bot ever has a moment and doesn't react with the correct emojis/has duplicates." - }, - { - "command": "rfr listRequiredRoles", - "parameters": [], - "description": "Lists the server-specific role permissions for using rfr functionality. If list is empty, any role can use rfrfunctionality.:return:" - }, - { - "command": "rfr removeRequiredRole", - "parameters": [ - "role_str" - ], - "description": "Removes a role from perms for use of rfr functionality in a server, so you can specify that you need, e.g.\"@Student\" to be able to use rfr functionality in the server. It's server-wide permissions handling however. Bydefault anyone can use rfr functionality in the server. User needs to have admin perms to use.:return:" - }, - { - "command": "rfr edit removeRoles", - "parameters": [], - "description": " Removes roles from an existing rfr message. User is prompted for rfr message channel ID/name/mention, rfr message ID/URL, emojis/roles to remove. User can specify either the emoji or the role for any emoji-role combination to remove it, but it needs to be specified in the format below. \\\"<emoji>/<role>\" \\\"<emoji>/<role>\" <role> can be the role ID, name or mention. emoji can be a custom emoji from the server, or a standard unicode emoji. \\User needs admin perms to use. :param ctx: Context of the command. :return: " - } - ] - }, - { - "name": "TextFilter", - "commands": [ - { - "command": "filterList", - "parameters": [], - "description": "Get a list of filtered words on the current guild.:return:" - }, - { - "command": "filterRegex", - "parameters": [ - "regex", - "filter_type", - "too_many_arguments" - ], - "description": "Adds a new regex to the filtered text list:return:" - }, - { - "command": "filter", - "parameters": [ - "word", - "filter_type", - "too_many_arguments" - ], - "description": "Adds a new word to the filtered text list:return:" - }, - { - "command": "ignoreChannel", - "parameters": [ - "channel", - "too_many_arguments" - ], - "description": "Add a new ignored channel to the database:return:" - }, - { - "command": "ignoreUser", - "parameters": [ - "user", - "too_many_arguments" - ], - "description": "Add a new ignored user to the database:return:" - }, - { - "command": "ignoreList", - "parameters": [], - "description": "Get a list all ignored users/channels:return:" - }, - { - "command": "modChannelList", - "parameters": [], - "description": "Get a list of filtered mod channels in the guild:return:" - }, - { - "command": "unignore", - "parameters": [ - "ignore", - "too_many_arguments" - ], - "description": "Remove an ignore from the guild:return:" - }, - { - "command": "modChannelRemove", - "parameters": [ - "channel_id", - "too_many_arguments" - ], - "description": "Remove a mod channel from the guild:return:" - }, - { - "command": "modChannelAdd", - "parameters": [ - "channel_id", - "too_many_arguments" - ], - "description": "Add a mod channel to the current guild:return:" - }, - { - "command": "unfilter", - "parameters": [ - "word", - "too_many_arguments" - ], - "description": "Remove an existing word/test from the filter list:return:" - }, - { - "command": "unignore", - "parameters": [ - "ignore", - "too_many_arguments" - ], - "description": "Remove an ignore from the guild:return:" - }, - { - "command": "modChannelRemove", - "parameters": [ - "channel_id", - "too_many_arguments" - ], - "description": "Remove a mod channel from the guild:return:" - } - ] - }, - { - "name": "TwitchAlert", - "commands": [ - { - "command": "twitchAddTeam", - "parameters": [ - "raw_channel_id", - "team_name", - "custom_live_message" - ], - "description": "Add a Twitch team to a Twitch Alert:return:" - }, - { - "command": "twitchAdd", - "parameters": [ - "raw_channel_id", - "twitch_username", - "custom_live_message" - ], - "description": "Add a Twitch user to a Twitch Alert:return:" - }, - { - "command": "twitchEditMsg", - "parameters": [ - "raw_channel_id", - "default_live_message" - ], - "description": "Edit the default message put in a Twitch Alert Notificationleave empty for program default:return:" - }, - { - "command": "twitchList", - "parameters": [], - "description": "Shows all current TwitchAlert users and teams in a channel:param ctx::param raw_channel_id::return:" - }, - { - "command": "twitchRemoveTeam", - "parameters": [ - "raw_channel_id", - "team_name" - ], - "description": "Removes a team from a Twitch Alert:return:" - }, - { - "command": "twitchRemove", - "parameters": [ - "raw_channel_id", - "twitch_username" - ], - "description": "Removes a user from a Twitch Alert:return:" - }, - { - "command": "twitchViewMsg", - "parameters": [ - "raw_channel_id" - ], - "description": "Shows the current default message for Twitch Alertsleave empty for program default:return:" - } - ] - }, - { - "name": "Verify", - "commands": [ - { - "command": "verifyList", - "parameters": [], - "description": "List the current verification setup for the server:return:" - }, - { - "command": "confirm", - "parameters": [ - "token" - ], - "description": "Send to KoalaBot in dms to confirm the verification of an email:return:" - }, - { - "command": "verifyRemove", - "parameters": [ - "suffix", - "role" - ], - "description": "Disable an existing verification listener:return:" - }, - { - "command": "verifyAdd", - "parameters": [ - "suffix", - "role" - ], - "description": "Set up a role and email pair for KoalaBot to verify users with:return:" - }, - { - "command": "getEmails", - "parameters": [ - "user_id" - ], - "description": "See the emails a user is verified with:return:" - }, - { - "command": "reVerify", - "parameters": [ - "role" - ], - "description": "Removes a role from all users who have it and marks them as needing to re-verify before giving it back:return:" - }, - { - "command": "unVerify", - "parameters": [ - "email" - ], - "description": "Send to KoalaBot in dms to un-verify an email with our system:return:" - }, - { - "command": "verify", - "parameters": [ - "email" - ], - "description": "Send to KoalaBot in dms to verify an email with our system:return:" - } - ] - }, - { - "name": "Vote", - "commands": [ - { - "command": "vote addOption", - "parameters": [ - "option_string" - ], - "description": "Adds an option to the current voteseparate the title and description with a \"+\" e.g. option title+option description" - }, - { - "command": "vote addRole", - "parameters": [ - "role" - ], - "description": "Adds a role to the list of roles the vote will be sent toIf no roles are added, the vote will go to all users in a guild (unless a target voice channel has been set)" - }, - { - "command": "vote removeOption", - "parameters": [ - "index" - ], - "description": "Removes an option from a vote based on it's index" - }, - { - "command": "vote removeRole", - "parameters": [ - "role" - ], - "description": "Removes a role to the list of roles the vote will be sent to" - }, - { - "command": "vote setChair", - "parameters": [ - "chair" - ], - "description": "Sets the chair of a voteIf no chair defaults to sending the message to the channel the vote is closed in" - }, - { - "command": "vote setEndTime", - "parameters": [ - "time_string" - ], - "description": "Sets a specific time for the vote to end. Results will be sent to the chair or owner if you use this, not a channel.If the vote has not been sent by the end time it will close automatically once it is sent.:return:" - }, - { - "command": "vote cancel", - "parameters": [ - "title" - ], - "description": "Cancels a vote you are setting up or have sent" - }, - { - "command": "vote addOption", - "parameters": [ - "option_string" - ], - "description": "Adds an option to the current voteseparate the title and description with a \"+\" e.g. option title+option description" - }, - { - "command": "vote addRole", - "parameters": [ - "role" - ], - "description": "Adds a role to the list of roles the vote will be sent toIf no roles are added, the vote will go to all users in a guild (unless a target voice channel has been set)" - }, - { - "command": "vote cancel", - "parameters": [ - "title" - ], - "description": "Cancels a vote you are setting up or have sent" - }, - { - "command": "vote list", - "parameters": [], - "description": "Return a list of all votes you have in this guild.:return:" - }, - { - "command": "vote checkResults", - "parameters": [], - "description": "Checks the results of a vote without closing it" - }, - { - "command": "vote close", - "parameters": [], - "description": "Ends a vote, and collects the results" - }, - { - "command": "vote preview", - "parameters": [], - "description": "Generates a preview of what users will see with the current configuration of the vote" - }, - { - "command": "vote removeOption", - "parameters": [ - "index" - ], - "description": "Removes an option from a vote based on it's index" - }, - { - "command": "vote removeRole", - "parameters": [ - "role" - ], - "description": "Removes a role to the list of roles the vote will be sent to" - }, - { - "command": "vote send", - "parameters": [], - "description": "Sends a vote to all users within the restrictions set with the current options added" - }, - { - "command": "vote setChair", - "parameters": [ - "chair" - ], - "description": "Sets the chair of a voteIf no chair defaults to sending the message to the channel the vote is closed in" - }, - { - "command": "vote setChannel", - "parameters": [ - "channel" - ], - "description": "Sets the target voice channel of a vote (Users connected to this channel will receive the vote message)If there isn't one set votes will go to all users in a guild (unless target roles have been added)" - }, - { - "command": "vote setEndTime", - "parameters": [ - "time_string" - ], - "description": "Sets a specific time for the vote to end. Results will be sent to the chair or owner if you use this, not a channel.If the vote has not been sent by the end time it will close automatically once it is sent.:return:" - }, - { - "command": "vote create", - "parameters": [ - "title" - ], - "description": "Creates a new vote" - }, - { - "command": "vote", - "parameters": [], - "description": "Use k!vote create <title> to create a vote!" - } - ] - } -] \ No newline at end of file From 238030f6d84385f4a73105a20ce39508a42abb25 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 12:54:38 +0100 Subject: [PATCH 05/37] Re added Documentation.json --- Documentation.json | 417 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 417 insertions(+) create mode 100644 Documentation.json diff --git a/Documentation.json b/Documentation.json new file mode 100644 index 00000000..11504a22 --- /dev/null +++ b/Documentation.json @@ -0,0 +1,417 @@ +[ + { + "name": "KoalaBot", + "commands": [ + { + "command": "listExt", + "parameters": [], + "description": "Lists all enabled and disabled Koala Extensions on your server" + }, + { + "command": "enableExt", + "parameters": ["koala_extension"], + "description": "Enable a Koala Extension on your server" + }, + { + "command": "disableExt", + "parameters": ["koala_extension"], + "description": "Disable a Koala Extension on your server" + }, + { + "command": "welcomeUpdateMsg", + "parameters": [], + "description": "Change the customisable part of the welcome message of your server" + }, + { + "command": "welcomeSendMsg", + "parameters": [], + "description": "Sends out the welcome message manually to all members of your server" + }, + { + "command": "welcomeViewMsg", + "parameters": [], + "description": "Shows this server's current welcome message" + }, + { + "command": "clear", + "parameters": ["amount"], + "description": "Clears a given number of messages from the channel." + }, + { + "command": "ping", + "parameters": [], + "description": "Returns the ping of a bot" + }, + { + "command": "support", + "parameters": [], + "description": "Returns a link to the KoalaBot Support Discord Server" + } + ] + }, + { + "name": "Announce", + "commands": [ + { + "command": "announce create", + "parameters": [], + "description": "Create a new message that will be available for sending" + }, + { + "command": "changeTitle", + "parameters": [], + "description": "Change the title of the embedded message" + }, + { + "command": "changeContent", + "parameters": [], + "description": "Change the content of the embedded message" + }, + { + "command": "addRole", + "parameters": [], + "description": "Add a role to list of people to send the announcement to" + }, + { + "command": "removeRole", + "parameters": [], + "description": "Remove a role from a list of people to send the announcement to" + }, + { + "command": "preview", + "parameters": [], + "description": "Post a constructed embedded message to the channel where the command is invoked" + }, + { + "command": "send", + "parameters": [], + "description": "Send a pending announcement" + }, + { + "command": "cancel", + "parameters": [], + "description": "Cancel a pending announcement" + } + ] + }, + { + "name": "ColourRole", + "commands": [ + { + "command": "customColour", + "parameters": ["colour_hexcode/'no'"], + "description": "Gives a user a chosen custom colour, or removes the custom colour with 'k!customColour no'" + }, + { + "command": "listProtectedRoleColours", + "parameters": [], + "description": "Lists the protected roles, whose colours are protected from being imitated by a custom colour, in a server" + }, + { + "command": "addProtectedRoleColour", + "parameters": ["role"], + "description": "Adds a role's colour to the list of protected roles" + }, + { + "command": "removeProtectedRoleColour", + "parameters": ["role"], + "description": "Removes a role's colour from the list of protected roles" + }, + { + "command": "listCustomColourAllowedRoles", + "parameters": [], + "description": "Lists the roles in a server whose users are permitted to have their own custom colours" + }, + { + "command": "addCustomColourAllowedRole", + "parameters": ["role"], + "description": "Adds a role to the list of roles allowed to have a custom colour" + }, + { + "command": "removeCustomColourAllowedRole", + "parameters": ["role_str"], + "description": "Removes a role from the list of roles allowed to have a custom colour" + } + ] + }, + { + "name": "ReactForRole (RFR)", + "commands": [ + { + "command": "rfr create", + "parameters": [], + "description": "Create a new, blank rfr message. Default title is React for Role. Default description is Roles below!" + }, + { + "command": "rfr delete", + "parameters": [], + "description": "Delete an existing rfr message" + }, + { + "command": "rfr addRequiredRole", + "parameters": ["role"], + "description": "Add a server-wide role required to react to/use rfr functionality. If no role is added, anyone can use rfr functionality" + }, + { + "command": "rfr removeRequiredRole", + "parameters": ["role"], + "description": "Removes a server-wide role from the group of roles someone requires to use rfr functionality" + }, + { + "command": "rfr listRequiredRoles", + "parameters": [], + "description": "Lists the server-specific role permissions for using rfr functionality" + }, + { + "command": "rfr edit description", + "parameters": [], + "description": "Edit the description of an existing rfr message" + }, + { + "command": "rfr edit title", + "parameters": [], + "description": "Edit the title of an existing rfr message" + }, + { + "command": "rfr edit thumbnail", + "parameters": [], + "description": "Edit the thumbnail of an existing rfr message" + }, + { + "command": "rfr edit inline", + "parameters": [], + "description": "Edit the inline property of embed fields in rfr embeds" + }, + { + "command": "rfr edit addRoles", + "parameters": [], + "description": "Add emoji/role combos to an existing rfr message" + }, + { + "command": "rfr edit removeRoles", + "parameters": [], + "description": "Remove emoji/role combos from an existing rfr message" + }, + { + "command": "rfr edit fixEmbed", + "parameters": [], + "description": "Cosmetic fix method if the bot ever has a moment and doesn't react with the correct emojis/has duplicates" + } + ] + }, + { + "name": "TextFilter", + "commands": [ + { + "command": "filter", + "parameters": ["text", "type"], + "description": "Filter a word or string of text. Type is defaulted to 'banned' which will delete the message and warn the user. Use type 'risky' to just warn the user" + }, + { + "command": "filterRegex", + "parameters": ["regex", "type"], + "description": "Filter a regex string. Type is defaulted to 'banned' which will delete the message and warn the user. Use type 'risky' to just warn the user" + }, + { + "command": "filterList", + "parameters": [], + "description": "Get a list of filtered words in the server" + }, + { + "command": "modChannelAdd", + "parameters": ["channelId"], + "description": " Add a mod channel for receiving filtered message information (User, Timestamp, Message) to be sent to" + }, + { + "command": "modChannelRemove", + "parameters": ["channelId"], + "description": "Remove a mod channel from the server" + }, + { + "command": "modChannelList", + "parameters": [], + "description": "See a list of mod channels in the server" + }, + { + "command": "ignoreUser", + "parameters": ["userMention"], + "description": "Add a new ignored user for the server. This users' messages will be ignored by the Text Filter" + }, + { + "command": "ignoreChannel", + "parameters": ["channelMention"], + "description": "Add a new ignored channel for the server. Messages in this channel will be ignored by the Text Filter" + }, + { + "command": "ignoreList", + "parameters": [], + "description": "See a list of ignored users/channels in the server" + }, + { + "command": "unfilter", + "parameters": ["text"], + "description": "Unfilter a word/string/regex of text that was previously filtered" + }, + { + "command": "unignore", + "parameters": ["mention"], + "description": "Unignore a user/channel that was previously set as ignored" + } + ] + }, + { + "name": "TwitchAlert", + "commands": [ + { + "command": "twitchAdd", + "parameters": ["channel_id", "twitch_username", "custom_live_message"], + "description": "Add a Twitch user to a Twitch Alert" + }, + { + "command": "twitchRemove", + "parameters": ["channel_id", "twitch_username"], + "description": "Remove a user from a Twitch Alert" + }, + { + "command": "twitchAddTeam", + "parameters": ["channel_id", "team_name", "custom_live_message"], + "description": "Add a Twitch team to a Twitch alert" + }, + { + "command": "twitchRemoveTeam", + "parameters": ["channel_id", "team_name"], + "description": "Edit the default message put in a Twitch Alert Notification" + }, + { + "command": "twitchEditMsg", + "parameters": ["channel", "default_live_message"], + "description": "Edit the default message put in a Twitch Alert Notification" + }, + { + "command": "twitchViewMsg", + "parameters": ["channel"], + "description": "Shows the current default message for Twitch Alerts" + }, + { + "command": "twitchList", + "parameters": ["channel"], + "description": "Shows all current TwitchAlert users and teams in a channel" + } + ] + }, + { + "name": "Verify", + "commands": [ + { + "command": "verifyAdd", + "parameters": ["suffix", "role"], + "description": "Set up a role and email pair for KoalaBot to verify users with" + }, + { + "command": "verifyRemove", + "parameters": ["suffix", "role"], + "description": "Disable an existing verification listener" + }, + { + "command": "reVerify", + "parameters": ["role"], + "description": "Removes a role from all users who have it and marks them as needing to re-verify before giving it back." + }, + { + "command": "verifyList", + "parameters": ["channelId"], + "description": "List the current verification setup for the server" + }, + { + "command": "verify", + "parameters": ["email"], + "description": "Send to KoalaBot in dms to verify an email with our system" + }, + { + "command": "unVerify", + "parameters": ["email"], + "description": "Send to KoalaBot in dms to un-verify an email with our system" + }, + { + "command": "confirm", + "parameters": ["token"], + "description": "Send to KoalaBot in dms to confirm the verification of an email" + } + ] + }, + { + "name": "Vote", + "commands": [ + { + "command": "vote create", + "parameters": ["title"], + "description": "Creates a new vote" + }, + { + "command": "vote addRole", + "parameters": ["role"], + "description": "Adds a role to the list of roles the vote will be sent to" + }, + { + "command": "vote removeRole", + "parameters": ["role"], + "description": "Removes a role to the list of roles the vote will be sent to" + }, + { + "command": "vote setChair", + "parameters": ["chair_user"], + "description": "Sets the chair of a vote (no chair defaults to message the channel)" + }, + { + "command": "vote setChannel", + "parameters": ["channel"], + "description": "Sets the target voice channel of a vote (Users connected to this channel will receive the vote message)" + }, + { + "command": "vote addOption", + "parameters": ["option"], + "description": "Adds an option to the current vote (separate the title and description with a '+' e.g. option title+option description)" + }, + { + "command": "vote removeOption", + "parameters": ["index"], + "description": "Removes an option from a vote based on it's index" + }, + { + "command": "vote setEndTime", + "parameters": ["time_string"], + "description": "Sets a specific time for the vote to end. Results will be sent to the chair or owner if you use this, not a channel" + }, + { + "command": "vote preview", + "parameters": [], + "description": "Generates a preview of what users will see with the current configuration of the vote" + }, + { + "command": "vote cancel", + "parameters": ["title"], + "description": "Cancels a vote you are setting up or have sent" + }, + { + "command": "vote list", + "parameters": [], + "description": "Return a list of all votes you have in this server" + }, + { + "command": "vote send", + "parameters": [], + "description": "Sends a vote to all users within the restrictions set with the current options added" + }, + { + "command": "vote close", + "parameters": ["title"], + "description": "Ends a vote, and collects the results" + }, + { + "command": "vote checkResults", + "parameters": ["title"], + "description": "Checks the results of a vote without closing it" + } + ] + } +] From d749b557a1fa5861e42a54b893a7da790a425d5f Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 13:04:46 +0100 Subject: [PATCH 06/37] Adjusted ci.yml to fix bug with last commit not working --- .github/workflows/ci.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2160c08f..fd2f6eb3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,12 @@ jobs: path_to_write_report: ./coverage/codecov_report.txt verbose: true - - name: Create new json documentation - run: - from GenerateDoc import generate_doc - generate_doc() + name: Create new json documentation + runs-on: ${{ matrix.os }} + if: | + (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || + (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') + steps: + - run: + from GenerateDoc import generate_doc + generate_doc() From 0e1a1a406cd722d6948c561e7996a2a75bf81735 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 13:32:04 +0100 Subject: [PATCH 07/37] Changed ci.yml again since last commit broke tests --- .github/workflows/ci.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd2f6eb3..7feace16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,12 +89,13 @@ jobs: path_to_write_report: ./coverage/codecov_report.txt verbose: true - name: Create new json documentation - runs-on: ${{ matrix.os }} - if: | - (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || - (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') - steps: - - run: - from GenerateDoc import generate_doc - generate_doc() + documentation: + runs-on: ${{ matrix.os }} + if: | + (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || + (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') + steps: + - name: Create new json documentation + run: + from GenerateDoc import generate_doc + generate_doc() From b87c399c7db44d752419cfec2d1d87689aedd796 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 13:44:01 +0100 Subject: [PATCH 08/37] adjusting ci.yml again --- .github/workflows/ci.yml | 3 ++- GenerateDoc.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7feace16..e010decb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,6 +96,7 @@ jobs: (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') steps: - name: Create new json documentation - run: + run: + python from GenerateDoc import generate_doc generate_doc() diff --git a/GenerateDoc.py b/GenerateDoc.py index 67176944..22149dcd 100644 --- a/GenerateDoc.py +++ b/GenerateDoc.py @@ -180,4 +180,7 @@ def generate_doc(): of cogs in directory cogs """ docList = get_cog_docs() - parse_docs(docList,'documentation.json') \ No newline at end of file + parse_docs(docList,'documentation.json') + +if __name__ == "__main__": + generate_doc() \ No newline at end of file From 03fe6f9da8251c5390cd4463b12776944d15eef5 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 13:46:30 +0100 Subject: [PATCH 09/37] adjusting ci.yml again --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e010decb..220d3035 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,7 +96,5 @@ jobs: (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') steps: - name: Create new json documentation - run: - python - from GenerateDoc import generate_doc - generate_doc() + run: | + py GenerateDoc.py \ No newline at end of file From bc5a25a535c94fec9a05429fca9a6ea711f46be0 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 13:48:59 +0100 Subject: [PATCH 10/37] adjusting ci.yml again --- .github/workflows/ci.yml | 2 +- GenerateDocOther.py | 112 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 GenerateDocOther.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 220d3035..85fe415c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,4 +97,4 @@ jobs: steps: - name: Create new json documentation run: | - py GenerateDoc.py \ No newline at end of file + python GenerateDocOther.py \ No newline at end of file diff --git a/GenerateDocOther.py b/GenerateDocOther.py new file mode 100644 index 00000000..92e706f6 --- /dev/null +++ b/GenerateDocOther.py @@ -0,0 +1,112 @@ +import os +import re + +class DocumentationEntry: + """Class for storing documentation entries + """ + name = None + params = [] + desc = None + + def __init__(self,name: str,params,desc: str): + self.name = name + self.params = params + self.desc = desc + + def getName(self): + return self.name + +class CogDocumentation: + """Stores a list of documentation entries for a cog + """ + name = None + docs = [] + + def __init__(self,name: str, docs): + self.name = name + self.docs = docs + + def addDoc(self,doc): + self.docs.append(doc) + + def getDocs(self): + return self.docs + +files = os.listdir(os.getcwd()+"\cogs") + +workingDir = os.path.join(os.getcwd(),"cogs") + +def get_docstrings(): + cogs=[] + for filename in files: + if (filename[-3:] != '.py'): + print(filename + " is not a python file") + break + f = open(os.path.join(workingDir, filename), "r") + find_command(f, cogs) + + f.close() + +def find_command(filename, cogs): + try: + filecontents = filename.readlines() #Gives a list of the lines in the cog file + except ValueError: #this shouldn't happen + print("End of file.") + return + + #commands=[] #list of all the commands + checkgroup = False #notes whether it found a decorator labeled @commands.group yet + for line in filecontents: + #print(line) + + if checkgroup: #if its found the decorator + for name in groupnames: + if "@" + name in line: + newline = filecontents[filecontents.index(line)+1] + foundDef = False + breakCatch = 0 + while foundDef == False: + if "def " in newline: + temp = newline[newline.index("def ")+4:] #fix this + temp = temp[:temp.index("(")] + foundDef = True + cogs[len(cogs)-1].addDoc(DocumentationEntry(temp, "", "")) + #print(temp) + #commands += temp + + else: + breakCatch+=1 + if breakCatch > 4: + break + else: + newline = filecontents[filecontents.index(newline)+1] + #commands += line[:line[line.index('"')+1:].index('"')] + else: + if "@commands.group" in line: + print("This bit runs") + #temp = line + #temp = temp[temp.index('"')+1:] + #groupnames = [temp[:temp.index('')]] + #groupnames = [line[:line[line.index('"')+1:].index('"')]] + groupnames = (re.findall(r'"(.*?)"', line)) + #print(line) + #print(groupnames) + cogs.append(CogDocumentation(groupnames[0], [])) + checkgroup = True + if "aliases" in line: + temp = line + temp = temp[temp.index('"')+1:] + temp = temp[temp.index('"')+1:] + for i in range(1, temp.count(",")): + temp = temp[temp.index('"')+1:] + groupnames += temp[:temp.index('"')] + temp = temp[temp.index('"')+1:] + #print(groupnames) + #print(commands) + for doc in cogs[len(cogs)-1].getDocs(): + print(doc.getName()) + +#help(cogs.Announce.Announce) + + +get_docstrings() \ No newline at end of file From 8e5619ba0d1ce84478c72a5f021b0ea35a167909 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 13:58:37 +0100 Subject: [PATCH 11/37] Fixed indent in ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85fe415c..79fcd51b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,4 +97,4 @@ jobs: steps: - name: Create new json documentation run: | - python GenerateDocOther.py \ No newline at end of file + python GenerateDoc.py \ No newline at end of file From 2a65fd311b936b0ee21402d33a8e5fc866d32541 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:04:41 +0100 Subject: [PATCH 12/37] Adjusted ci.yml to run on unbuntu for doc generation --- .github/workflows/ci.yml | 2 +- GenerateDoc.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79fcd51b..1d52d2e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,7 @@ jobs: verbose: true documentation: - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest if: | (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') diff --git a/GenerateDoc.py b/GenerateDoc.py index 22149dcd..b84c3ff5 100644 --- a/GenerateDoc.py +++ b/GenerateDoc.py @@ -183,4 +183,5 @@ def generate_doc(): parse_docs(docList,'documentation.json') if __name__ == "__main__": + print('Generating document.json') generate_doc() \ No newline at end of file From 95ed25ab8672354e1e213ddb229da4b12cef1233 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:07:36 +0100 Subject: [PATCH 13/37] Adjusted filepath for ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d52d2e0..48239f25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,4 +97,4 @@ jobs: steps: - name: Create new json documentation run: | - python GenerateDoc.py \ No newline at end of file + python ../../GenerateDoc.py \ No newline at end of file From c0c9aff4505d5872675b874fb8a06896cc309d4e Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:09:05 +0100 Subject: [PATCH 14/37] Adjusted filepath for ci.yml again --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48239f25..e662844f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,4 +97,4 @@ jobs: steps: - name: Create new json documentation run: | - python ../../GenerateDoc.py \ No newline at end of file + python ../GenerateDoc.py \ No newline at end of file From c77841faf0aa3630b8656da378b57532cd2a5920 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:14:44 +0100 Subject: [PATCH 15/37] Added pwd to ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e662844f..948aab08 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,4 +97,5 @@ jobs: steps: - name: Create new json documentation run: | + pwd python ../GenerateDoc.py \ No newline at end of file From 5c34167dea68e0d74fe81f297f51fa47d940d519 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:16:13 +0100 Subject: [PATCH 16/37] adjusting ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 948aab08..1d85d93a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,4 +98,4 @@ jobs: - name: Create new json documentation run: | pwd - python ../GenerateDoc.py \ No newline at end of file + python ./GenerateDoc.py \ No newline at end of file From 3b986ad9837ece34412f52cf1f80c71adba7af2d Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:17:23 +0100 Subject: [PATCH 17/37] adjusting ci.yml --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d85d93a..148eccfe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,4 +98,5 @@ jobs: - name: Create new json documentation run: | pwd - python ./GenerateDoc.py \ No newline at end of file + ls + py ./GenerateDoc.py \ No newline at end of file From 63280c2a6901f8340a2b97251f7cb637cc4a7672 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:19:51 +0100 Subject: [PATCH 18/37] adjusting ci.yml --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 148eccfe..a5f22ca2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,8 +95,12 @@ jobs: (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') steps: + - name: setup python + uses: actions/setup-python@v2 + with: + python-version: 3.8 - name: Create new json documentation run: | pwd ls - py ./GenerateDoc.py \ No newline at end of file + python ./GenerateDoc.py \ No newline at end of file From c55a58736f8ca25b27005740a8534a36bcc22bb1 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:20:50 +0100 Subject: [PATCH 19/37] adjusting ci.yml --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5f22ca2..a6358701 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,10 +95,6 @@ jobs: (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') steps: - - name: setup python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - name: Create new json documentation run: | pwd From dec8a7771eaec59f725972a0d6ad3687011c6d9b Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:23:03 +0100 Subject: [PATCH 20/37] adjusting ci.yml --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6358701..1e50bc5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,6 +95,8 @@ jobs: (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') steps: + - name: checkout repo content + uses: actions/checkout@v2 - name: Create new json documentation run: | pwd From 9575e2a9d028081354867f1cecd3263668fe860c Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:24:44 +0100 Subject: [PATCH 21/37] Adding pip install discord --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e50bc5f..e923f1fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,6 +97,9 @@ jobs: steps: - name: checkout repo content uses: actions/checkout@v2 + - name: pip + run: | + pip install discord - name: Create new json documentation run: | pwd From bf9dc01048acc3b3602381d6191280761c253be0 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:26:19 +0100 Subject: [PATCH 22/37] adjusting ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e923f1fe..cf866bca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,6 +100,7 @@ jobs: - name: pip run: | pip install discord + pip install python-dotenv - name: Create new json documentation run: | pwd From df9022b9d276c6b7e7c657d9faba975ac5f7dff1 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:27:46 +0100 Subject: [PATCH 23/37] adjusting ci.yml --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf866bca..80121ee8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,10 +97,12 @@ jobs: steps: - name: checkout repo content uses: actions/checkout@v2 - - name: pip + - name: Install dependencies run: | - pip install discord - pip install python-dotenv + python -m pip install --upgrade pip + pip install flake8 pytest + pip install pytest-cov + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Create new json documentation run: | pwd From 19a5c4e988b499f6830bcb97b7cdb6bf7a48a5ef Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:29:18 +0100 Subject: [PATCH 24/37] adjusting ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80121ee8..92210f54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,6 +102,7 @@ jobs: python -m pip install --upgrade pip pip install flake8 pytest pip install pytest-cov + pip install pysqlcipher3 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Create new json documentation run: | From b96ac357ca85f2d193fed732d554a197a650ce00 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:33:05 +0100 Subject: [PATCH 25/37] adjusting ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92210f54..701174f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,10 +99,10 @@ jobs: uses: actions/checkout@v2 - name: Install dependencies run: | + pip install pysqlcipher3 python -m pip install --upgrade pip pip install flake8 pytest pip install pytest-cov - pip install pysqlcipher3 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Create new json documentation run: | From 1454c8c48d4357febcf007bff47501cdd5c6a407 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:37:16 +0100 Subject: [PATCH 26/37] adjusting ci.yml --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 701174f6..1d4a330a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,6 +97,10 @@ jobs: steps: - name: checkout repo content uses: actions/checkout@v2 + - name: setup python + uses: actions/setup-python@v2 + with: + python-version: 3.8 - name: Install dependencies run: | pip install pysqlcipher3 From 6e3304d584206a449d967579543877cf6173be35 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:43:18 +0100 Subject: [PATCH 27/37] adjusting ci.yml --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d4a330a..17bc4025 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,6 +109,8 @@ jobs: pip install pytest-cov if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Create new json documentation + env: + ENCRYPTED: "True" run: | pwd ls From baf69e9b40165cfb1c5485ed1c9c94b0614bca8c Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:44:33 +0100 Subject: [PATCH 28/37] adjusting ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17bc4025..61c2742b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Create new json documentation env: - ENCRYPTED: "True" + ENCRYPTED: "False" run: | pwd ls From 822e0f78ac08ab782938328164efb38efa657efa Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:45:56 +0100 Subject: [PATCH 29/37] adjusting ci.yml --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61c2742b..0c356916 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,6 +111,12 @@ jobs: - name: Create new json documentation env: ENCRYPTED: "False" + BOT_OWNER: ${{ secrets.BOT_OWNER }} + DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} + GMAIL_EMAIL: ${{ secrets.GMAIL_EMAIL }} + GMAIL_PASSWORD: ${{ secrets.GMAIL_PASSWORD }} + TWITCH_SECRET: ${{ secrets.TWITCH_SECRET }} + TWITCH_TOKEN: ${{ secrets.TWITCH_TOKEN }} run: | pwd ls From a00a3c6fade15654b297c5aa600ff8ca4bf8c01e Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:55:21 +0100 Subject: [PATCH 30/37] Adding commit and push of auto gen doc --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c356916..680ca385 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,4 +120,9 @@ jobs: run: | pwd ls - python ./GenerateDoc.py \ No newline at end of file + python ./GenerateDoc.py + - name: commit changes + uses: EndBug/add-and-commit@v7 # You can change this to use a specific version + - name: git push + run: | + git push \ No newline at end of file From e78ecd985c2243986af46f28734bb9869eb14f0c Mon Sep 17 00:00:00 2001 From: MoistBiscuits <MoistBiscuits@users.noreply.github.com> Date: Wed, 4 Aug 2021 13:56:06 +0000 Subject: [PATCH 31/37] Commit from GitHub Actions (CI) --- documentation.json | 625 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 625 insertions(+) create mode 100644 documentation.json diff --git a/documentation.json b/documentation.json new file mode 100644 index 00000000..3df6853b --- /dev/null +++ b/documentation.json @@ -0,0 +1,625 @@ +[ + { + "name": "Announce", + "commands": [ + { + "command": "announce addRole", + "parameters": [], + "description": "Add a role to list of people to send the announcement to:return:" + }, + { + "command": "announce", + "parameters": [], + "description": "Use k!announce create to create an announcement" + }, + { + "command": "announce cancel", + "parameters": [], + "description": "Cancel a pending announcement:return:" + }, + { + "command": "announce changeContent", + "parameters": [], + "description": "Change the content of the embedded message:return:" + }, + { + "command": "announce changeTitle", + "parameters": [], + "description": "Change the title of the embedded message:return:" + }, + { + "command": "announce create", + "parameters": [], + "description": "Create a new message that will be available for sending:return:" + }, + { + "command": "announce preview", + "parameters": [], + "description": "Post a constructed embedded message to the channel where the command is invoked:return:" + }, + { + "command": "announce removeRole", + "parameters": [], + "description": "Remove a role from a list of people to send the announcement to:return:" + }, + { + "command": "announce send", + "parameters": [], + "description": "Send a pending announcement:return:" + } + ] + }, + { + "name": "TwitchAlert", + "commands": [ + { + "command": "twitchAddTeam", + "parameters": [ + "raw_channel_id", + "team_name", + "custom_live_message" + ], + "description": "Add a Twitch team to a Twitch Alert:return:" + }, + { + "command": "twitchAdd", + "parameters": [ + "raw_channel_id", + "twitch_username", + "custom_live_message" + ], + "description": "Add a Twitch user to a Twitch Alert:return:" + }, + { + "command": "twitchEditMsg", + "parameters": [ + "raw_channel_id", + "default_live_message" + ], + "description": "Edit the default message put in a Twitch Alert Notificationleave empty for program default:return:" + }, + { + "command": "twitchList", + "parameters": [], + "description": "Shows all current TwitchAlert users and teams in a channel:param ctx::param raw_channel_id::return:" + }, + { + "command": "twitchRemoveTeam", + "parameters": [ + "raw_channel_id", + "team_name" + ], + "description": "Removes a team from a Twitch Alert:return:" + }, + { + "command": "twitchRemove", + "parameters": [ + "raw_channel_id", + "twitch_username" + ], + "description": "Removes a user from a Twitch Alert:return:" + }, + { + "command": "twitchViewMsg", + "parameters": [ + "raw_channel_id" + ], + "description": "Shows the current default message for Twitch Alertsleave empty for program default:return:" + } + ] + }, + { + "name": "Verify", + "commands": [ + { + "command": "verifyList", + "parameters": [], + "description": "List the current verification setup for the server:return:" + }, + { + "command": "confirm", + "parameters": [ + "token" + ], + "description": "Send to KoalaBot in dms to confirm the verification of an email:return:" + }, + { + "command": "verifyRemove", + "parameters": [ + "suffix", + "role" + ], + "description": "Disable an existing verification listener:return:" + }, + { + "command": "verifyAdd", + "parameters": [ + "suffix", + "role" + ], + "description": "Set up a role and email pair for KoalaBot to verify users with:return:" + }, + { + "command": "getEmails", + "parameters": [ + "user_id" + ], + "description": "See the emails a user is verified with:return:" + }, + { + "command": "reVerify", + "parameters": [ + "role" + ], + "description": "Removes a role from all users who have it and marks them as needing to re-verify before giving it back:return:" + }, + { + "command": "unVerify", + "parameters": [ + "email" + ], + "description": "Send to KoalaBot in dms to un-verify an email with our system:return:" + }, + { + "command": "verify", + "parameters": [ + "email" + ], + "description": "Send to KoalaBot in dms to verify an email with our system:return:" + } + ] + }, + { + "name": "KoalaBot", + "commands": [ + { + "command": "activity", + "parameters": [ + "new_activity", + "name" + ], + "description": "Change the activity of the bot" + }, + { + "command": "clear", + "parameters": [ + "amount" + ], + "description": "Clears a given number of messages from the given channel" + }, + { + "command": "disableExt", + "parameters": [ + "koala_extension" + ], + "description": "Disables a koala extension onto a server" + }, + { + "command": "enableExt", + "parameters": [ + "koala_extension" + ], + "description": "Enables a koala extension onto a server, all grants all extensions" + }, + { + "command": "listExt", + "parameters": [], + "description": "Lists the enabled koala extensions of a server" + }, + { + "command": "loadCog", + "parameters": [ + "extension" + ], + "description": "Loads a cog from the cogs folder" + }, + { + "command": "ping", + "parameters": [], + "description": "Returns the ping of the bot" + }, + { + "command": "support", + "parameters": [], + "description": "KoalaBot Support server link" + }, + { + "command": "unloadCog", + "parameters": [ + "extension" + ], + "description": "Unloads a running cog" + }, + { + "command": "welcomeSendMsg", + "parameters": [], + "description": "Allows admins to send out their welcome message manually to all members of a guild. Has a 60 second cooldown perguild." + }, + { + "command": "welcomeUpdateMsg", + "parameters": [ + "new_message" + ], + "description": "Allows admins to change their customisable part of the welcome message of a guild. Has a 60 second cooldown perguild." + }, + { + "command": "welcomeViewMsg", + "parameters": [], + "description": "Shows this server's current welcome message" + } + ] + }, + { + "name": "Vote", + "commands": [ + { + "command": "vote addOption", + "parameters": [ + "option_string" + ], + "description": "Adds an option to the current voteseparate the title and description with a \"+\" e.g. option title+option description" + }, + { + "command": "vote addRole", + "parameters": [ + "role" + ], + "description": "Adds a role to the list of roles the vote will be sent toIf no roles are added, the vote will go to all users in a guild (unless a target voice channel has been set)" + }, + { + "command": "vote removeOption", + "parameters": [ + "index" + ], + "description": "Removes an option from a vote based on it's index" + }, + { + "command": "vote removeRole", + "parameters": [ + "role" + ], + "description": "Removes a role to the list of roles the vote will be sent to" + }, + { + "command": "vote setChair", + "parameters": [ + "chair" + ], + "description": "Sets the chair of a voteIf no chair defaults to sending the message to the channel the vote is closed in" + }, + { + "command": "vote setEndTime", + "parameters": [ + "time_string" + ], + "description": "Sets a specific time for the vote to end. Results will be sent to the chair or owner if you use this, not a channel.If the vote has not been sent by the end time it will close automatically once it is sent.:return:" + }, + { + "command": "vote cancel", + "parameters": [ + "title" + ], + "description": "Cancels a vote you are setting up or have sent" + }, + { + "command": "vote addOption", + "parameters": [ + "option_string" + ], + "description": "Adds an option to the current voteseparate the title and description with a \"+\" e.g. option title+option description" + }, + { + "command": "vote addRole", + "parameters": [ + "role" + ], + "description": "Adds a role to the list of roles the vote will be sent toIf no roles are added, the vote will go to all users in a guild (unless a target voice channel has been set)" + }, + { + "command": "vote cancel", + "parameters": [ + "title" + ], + "description": "Cancels a vote you are setting up or have sent" + }, + { + "command": "vote list", + "parameters": [], + "description": "Return a list of all votes you have in this guild.:return:" + }, + { + "command": "vote checkResults", + "parameters": [], + "description": "Checks the results of a vote without closing it" + }, + { + "command": "vote close", + "parameters": [], + "description": "Ends a vote, and collects the results" + }, + { + "command": "vote preview", + "parameters": [], + "description": "Generates a preview of what users will see with the current configuration of the vote" + }, + { + "command": "vote removeOption", + "parameters": [ + "index" + ], + "description": "Removes an option from a vote based on it's index" + }, + { + "command": "vote removeRole", + "parameters": [ + "role" + ], + "description": "Removes a role to the list of roles the vote will be sent to" + }, + { + "command": "vote send", + "parameters": [], + "description": "Sends a vote to all users within the restrictions set with the current options added" + }, + { + "command": "vote setChair", + "parameters": [ + "chair" + ], + "description": "Sets the chair of a voteIf no chair defaults to sending the message to the channel the vote is closed in" + }, + { + "command": "vote setChannel", + "parameters": [ + "channel" + ], + "description": "Sets the target voice channel of a vote (Users connected to this channel will receive the vote message)If there isn't one set votes will go to all users in a guild (unless target roles have been added)" + }, + { + "command": "vote setEndTime", + "parameters": [ + "time_string" + ], + "description": "Sets a specific time for the vote to end. Results will be sent to the chair or owner if you use this, not a channel.If the vote has not been sent by the end time it will close automatically once it is sent.:return:" + }, + { + "command": "vote create", + "parameters": [ + "title" + ], + "description": "Creates a new vote" + }, + { + "command": "vote", + "parameters": [], + "description": "Use k!vote create <title> to create a vote!" + } + ] + }, + { + "name": "TextFilter", + "commands": [ + { + "command": "filterList", + "parameters": [], + "description": "Get a list of filtered words on the current guild.:return:" + }, + { + "command": "filterRegex", + "parameters": [ + "regex", + "filter_type", + "too_many_arguments" + ], + "description": "Adds a new regex to the filtered text list:return:" + }, + { + "command": "filter", + "parameters": [ + "word", + "filter_type", + "too_many_arguments" + ], + "description": "Adds a new word to the filtered text list:return:" + }, + { + "command": "ignoreChannel", + "parameters": [ + "channel", + "too_many_arguments" + ], + "description": "Add a new ignored channel to the database:return:" + }, + { + "command": "ignoreUser", + "parameters": [ + "user", + "too_many_arguments" + ], + "description": "Add a new ignored user to the database:return:" + }, + { + "command": "ignoreList", + "parameters": [], + "description": "Get a list all ignored users/channels:return:" + }, + { + "command": "modChannelList", + "parameters": [], + "description": "Get a list of filtered mod channels in the guild:return:" + }, + { + "command": "unignore", + "parameters": [ + "ignore", + "too_many_arguments" + ], + "description": "Remove an ignore from the guild:return:" + }, + { + "command": "modChannelRemove", + "parameters": [ + "channel_id", + "too_many_arguments" + ], + "description": "Remove a mod channel from the guild:return:" + }, + { + "command": "modChannelAdd", + "parameters": [ + "channel_id", + "too_many_arguments" + ], + "description": "Add a mod channel to the current guild:return:" + }, + { + "command": "unfilter", + "parameters": [ + "word", + "too_many_arguments" + ], + "description": "Remove an existing word/test from the filter list:return:" + }, + { + "command": "unignore", + "parameters": [ + "ignore", + "too_many_arguments" + ], + "description": "Remove an ignore from the guild:return:" + }, + { + "command": "modChannelRemove", + "parameters": [ + "channel_id", + "too_many_arguments" + ], + "description": "Remove a mod channel from the guild:return:" + } + ] + }, + { + "name": "ReactForRole (RFR)", + "commands": [ + { + "command": "rfr", + "parameters": [], + "description": "Group of commands for React for Role (rfr) functionality.:return:" + }, + { + "command": "rfr addRequiredRole", + "parameters": [ + "role_str" + ], + "description": "Adds a role to perms to use rfr functionality in a server, so you can specify that you need, e.g. \"@Student\" tobe able to use rfr functionality in the server. It's server-wide permissions handling however. By default anyonecan use rfr functionality in the server. User needs to have admin perms to use.:return:" + }, + { + "command": "rfr edit addRoles", + "parameters": [], + "description": " Adds roles to an existing rfr message. User is prompted for rfr message channel ID/name/mention, rfr message ID/ URL, emoji-role combos. Emoji-role combinations are to be given in \\\"<emoji>, <role>\" \\\"<emoji>, <role>\" format. <role> can be the role ID, name or mention. `emoji` can be a custom emoji from the server, or a standard unicode emoji. \\User needs admin perms to use. :param ctx: Context of the command. :return: " + }, + { + "command": "rfr create", + "parameters": [], + "description": "Creates a new rfr message in a channel of user's choice. User is prompted for (in this order)channel ID/name/mention, message title, message description. Default title and description exist, which are\"React for Role\" and \"Roles below!\" respectively. User requires admin perms to use.:return:" + }, + { + "command": "rfr delete", + "parameters": [], + "description": "Deletes an existing rfr message. User is prompted for (in this order) channel ID/name/mention, message ID/URL,Y/N confirmation. User needs admin perms to use.:return:" + }, + { + "command": "rfr edit description", + "parameters": [], + "description": "Edit the description of an existing rfr message. User is prompted for rfr message channel ID/name/mention,rfr message ID/URL, new description, Y/N confirmation. User needs admin perms to use.:return:" + }, + { + "command": "rfr edit inline", + "parameters": [], + "description": "Edit the inline property of embed fields in rfr embeds. Can edit all rfr messages in a server or a specific one.User is prompted for whether they'd like inline fields or not, as well as details of the specific message ifthat option is selected. User requires admin perms:return:" + }, + { + "command": "rfr edit thumbnail", + "parameters": [], + "description": "Edit the thumbnail of an existing rfr message. User is prompted for rfr message channel ID/name/mention, rfrmessage ID/URL, new thumbnail, Y/N confirmation. User needs admin perms:return:" + }, + { + "command": "rfr edit title", + "parameters": [], + "description": "Edit the title of an existing rfr message. User is prompted for rfr message channel ID/name/mention,rfr message ID/URL, new title, Y/N confirmation. User needs admin perms to use.:return:" + }, + { + "command": "rfr edit fixEmbed", + "parameters": [], + "description": "Cosmetic fix method if the bot ever has a moment and doesn't react with the correct emojis/has duplicates." + }, + { + "command": "rfr listRequiredRoles", + "parameters": [], + "description": "Lists the server-specific role permissions for using rfr functionality. If list is empty, any role can use rfrfunctionality.:return:" + }, + { + "command": "rfr removeRequiredRole", + "parameters": [ + "role_str" + ], + "description": "Removes a role from perms for use of rfr functionality in a server, so you can specify that you need, e.g.\"@Student\" to be able to use rfr functionality in the server. It's server-wide permissions handling however. Bydefault anyone can use rfr functionality in the server. User needs to have admin perms to use.:return:" + }, + { + "command": "rfr edit removeRoles", + "parameters": [], + "description": " Removes roles from an existing rfr message. User is prompted for rfr message channel ID/name/mention, rfr message ID/URL, emojis/roles to remove. User can specify either the emoji or the role for any emoji-role combination to remove it, but it needs to be specified in the format below. \\\"<emoji>/<role>\" \\\"<emoji>/<role>\" <role> can be the role ID, name or mention. emoji can be a custom emoji from the server, or a standard unicode emoji. \\User needs admin perms to use. :param ctx: Context of the command. :return: " + } + ] + }, + { + "name": "ColourRole", + "commands": [ + { + "command": "addCustomColourAllowedRole", + "parameters": [ + "role_str" + ], + "description": "Adds a role, via ID, mention or name, to the list of roles allowed to have a custom colour. Needsadmin permissions to use." + }, + { + "command": "addProtectedRoleColour", + "parameters": [ + "role_str" + ], + "description": "Adds a role, via ID, mention or name, to the list of protected roles. Needs admin permissions touse." + }, + { + "command": "customColour", + "parameters": [ + "colour_str" + ], + "description": "For a user with the correct role to be able to change their display colour in a guild.Syntax is k!custom_colour (\"no\" / colour hex). Usage with no removes any custom colour held before.Won't accept it if the colour chosen too closely resembles a role that was protected's colour or a discordblocked colour. A role must be made and that role be added to the permissions by usage ofk!add_custom_colour_allowed_role <role>, and the command invoker must have that role before they can use thiscommand. Has a 15 second cooldown." + }, + { + "command": "listCustomColourAllowedRoles", + "parameters": [], + "description": "Lists the roles in a guild which are permitted to have their own custom colours. Requires adminpermissions to use.:return: Sends a message with the mentions of the roles that are protected in a guild." + }, + { + "command": "listProtectedRoleColours", + "parameters": [], + "description": "Lists the protected roles, whose colours are protected from being imitated by a custom colour, in aguild. Requires admin permissions to use.:return: Sends a message with the mentions of the roles that are protected in a guild" + }, + { + "command": "removeCustomColourAllowedRole", + "parameters": [ + "role_str" + ], + "description": "Removes a role, via ID, mention or name, from the list of roles allowed to have a custom colour.Needs admin permissions to use." + }, + { + "command": "removeProtectedRoleColour", + "parameters": [ + "role_str" + ], + "description": "Removes a role, via ID, mention or name, from the list of protected roles. Needs admin permissionsto use." + } + ] + } +] \ No newline at end of file From adcac253da0f343cec76e8d354cbeeda5de38358 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 14:59:11 +0100 Subject: [PATCH 32/37] Removed working code GenerateDocOther.py --- GenerateDocOther.py | 112 -------------------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 GenerateDocOther.py diff --git a/GenerateDocOther.py b/GenerateDocOther.py deleted file mode 100644 index 92e706f6..00000000 --- a/GenerateDocOther.py +++ /dev/null @@ -1,112 +0,0 @@ -import os -import re - -class DocumentationEntry: - """Class for storing documentation entries - """ - name = None - params = [] - desc = None - - def __init__(self,name: str,params,desc: str): - self.name = name - self.params = params - self.desc = desc - - def getName(self): - return self.name - -class CogDocumentation: - """Stores a list of documentation entries for a cog - """ - name = None - docs = [] - - def __init__(self,name: str, docs): - self.name = name - self.docs = docs - - def addDoc(self,doc): - self.docs.append(doc) - - def getDocs(self): - return self.docs - -files = os.listdir(os.getcwd()+"\cogs") - -workingDir = os.path.join(os.getcwd(),"cogs") - -def get_docstrings(): - cogs=[] - for filename in files: - if (filename[-3:] != '.py'): - print(filename + " is not a python file") - break - f = open(os.path.join(workingDir, filename), "r") - find_command(f, cogs) - - f.close() - -def find_command(filename, cogs): - try: - filecontents = filename.readlines() #Gives a list of the lines in the cog file - except ValueError: #this shouldn't happen - print("End of file.") - return - - #commands=[] #list of all the commands - checkgroup = False #notes whether it found a decorator labeled @commands.group yet - for line in filecontents: - #print(line) - - if checkgroup: #if its found the decorator - for name in groupnames: - if "@" + name in line: - newline = filecontents[filecontents.index(line)+1] - foundDef = False - breakCatch = 0 - while foundDef == False: - if "def " in newline: - temp = newline[newline.index("def ")+4:] #fix this - temp = temp[:temp.index("(")] - foundDef = True - cogs[len(cogs)-1].addDoc(DocumentationEntry(temp, "", "")) - #print(temp) - #commands += temp - - else: - breakCatch+=1 - if breakCatch > 4: - break - else: - newline = filecontents[filecontents.index(newline)+1] - #commands += line[:line[line.index('"')+1:].index('"')] - else: - if "@commands.group" in line: - print("This bit runs") - #temp = line - #temp = temp[temp.index('"')+1:] - #groupnames = [temp[:temp.index('')]] - #groupnames = [line[:line[line.index('"')+1:].index('"')]] - groupnames = (re.findall(r'"(.*?)"', line)) - #print(line) - #print(groupnames) - cogs.append(CogDocumentation(groupnames[0], [])) - checkgroup = True - if "aliases" in line: - temp = line - temp = temp[temp.index('"')+1:] - temp = temp[temp.index('"')+1:] - for i in range(1, temp.count(",")): - temp = temp[temp.index('"')+1:] - groupnames += temp[:temp.index('"')] - temp = temp[temp.index('"')+1:] - #print(groupnames) - #print(commands) - for doc in cogs[len(cogs)-1].getDocs(): - print(doc.getName()) - -#help(cogs.Announce.Announce) - - -get_docstrings() \ No newline at end of file From 7c31d0f8abb5545c31e5dc567de1596f9d94438e Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 15:04:10 +0100 Subject: [PATCH 33/37] Adjusting git push --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 680ca385..730f74e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,11 +118,9 @@ jobs: TWITCH_SECRET: ${{ secrets.TWITCH_SECRET }} TWITCH_TOKEN: ${{ secrets.TWITCH_TOKEN }} run: | - pwd - ls python ./GenerateDoc.py - name: commit changes uses: EndBug/add-and-commit@v7 # You can change this to use a specific version - name: git push run: | - git push \ No newline at end of file + git push origin ${branch input} \ No newline at end of file From c6bfbf035c85e3a7b1953b2cb56bebdf1a7347ad Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 15:06:18 +0100 Subject: [PATCH 34/37] Adjusting git push --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 730f74e7..bbe9fc42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,7 +120,4 @@ jobs: run: | python ./GenerateDoc.py - name: commit changes - uses: EndBug/add-and-commit@v7 # You can change this to use a specific version - - name: git push - run: | - git push origin ${branch input} \ No newline at end of file + uses: EndBug/add-and-commit@v7 # You can change this to use a specific version \ No newline at end of file From 752417faf7535e46f986c64c728b66e258ab549b Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 15:11:59 +0100 Subject: [PATCH 35/37] Added pushing of doc changes to remote --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbe9fc42..e8d40410 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,4 +120,6 @@ jobs: run: | python ./GenerateDoc.py - name: commit changes - uses: EndBug/add-and-commit@v7 # You can change this to use a specific version \ No newline at end of file + uses: EndBug/add-and-commit@v7 + run: | + git push \ No newline at end of file From 514a21a675113f81a06c2947bcafcca9cf51c4d8 Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 15:13:12 +0100 Subject: [PATCH 36/37] Added pushing of doc changes to remote --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8d40410..8a4517d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,6 +120,7 @@ jobs: run: | python ./GenerateDoc.py - name: commit changes - uses: EndBug/add-and-commit@v7 + uses: EndBug/add-and-commit@v7 # You can change this to use a specific version + - name: git push run: | git push \ No newline at end of file From ac6ea00180c199c501556a75c7f18239251a211b Mon Sep 17 00:00:00 2001 From: MoistBiscuits <aqeel.little@hotmail.co.uk> Date: Wed, 4 Aug 2021 15:17:21 +0100 Subject: [PATCH 37/37] Added pushing of doc changes to remote --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a4517d7..7dac3446 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,6 +121,5 @@ jobs: python ./GenerateDoc.py - name: commit changes uses: EndBug/add-and-commit@v7 # You can change this to use a specific version - - name: git push - run: | - git push \ No newline at end of file + with: + push: true \ No newline at end of file