Spaces:
Runtime error
Runtime error
File size: 4,575 Bytes
78b07ad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
from Hellbot.core.config import Config, Symbols
class HelpMenu:
def __init__(self, file: str) -> None:
self.filename = file
self.command_dict = {}
self.command_info = ""
def add(
self,
command: str,
parameters: str = None,
description: str = None,
example: str = None,
note: str = None,
):
self.command_dict[command] = {
"command": command,
"parameters": parameters,
"description": description,
"example": example,
"note": note,
}
return self
def info(self, command_info: str):
self.command_info = command_info
return self
def get_menu(self) -> str:
result = f"**π―π
ππππ π₯ππ
πΎ:** `{self.filename}`"
if self.command_info:
result += f"\n**π―π
ππππ π¨ππΏπ:** __{self.command_info} π__"
result += "\n\n"
for command in self.command_dict:
command = self.command_dict[command]
result += f"**{Symbols.radio_select} π’ππππΊππ½:** `{Config.HANDLERS[0]}{command['command']}"
if command["parameters"]:
result += f" {command['parameters']}`\n"
else:
result += "`\n"
if command["description"]:
result += (
f"**{Symbols.arrow_right} π£πΎππΌπππππππ:** __{command['description']}__\n"
)
if command["example"]:
result += f"**{Symbols.arrow_right} π€ππΊπππ
πΎ:** `{Config.HANDLERS[0]}{command['example']}`\n"
if command["note"]:
result += f"**{Symbols.arrow_right} ππππΎ:** __{command['note']}__\n"
result += "\n"
Config.CMD_INFO[command["command"]] = {
"command": f"{command['command']} {command['parameters'] if command['parameters'] else ''}",
"description": command["description"],
"example": command["example"],
"note": command["note"],
"plugin": self.filename,
}
return result
def done(self) -> None:
Config.HELP_DICT[self.filename] = {
"commands": self.command_dict,
"info": self.command_info,
}
Config.CMD_MENU[self.filename] = self.get_menu()
class BotHelp:
def __init__(self, file: str) -> None:
self.category = file
self.command_dict = {}
self.command_info = ""
def add(self, command: str, description: str):
self.command_dict[command] = {"command": command, "description": description}
return self
def info(self, command_info: str):
self.command_info = command_info
return self
def get_menu(self) -> str:
result = f"**π―π
ππππ π’πΊππΎππππ:** `{self.category}`"
if self.command_info:
result += f"\n**π―π
ππππ π¨ππΏπ:** __{self.command_info}__"
result += "\n\n"
for command in self.command_dict:
command = self.command_dict[command]
result += f"**{Symbols.radio_select} π’ππππΊππ½:** `/{command['command']}`\n"
if command["description"]:
result += (
f"**{Symbols.arrow_right} π£πΎππΌπππππππ:** __{command['description']}__\n"
)
result += "\n"
Config.BOT_CMD_INFO[command["command"]] = {
"command": command["command"],
"description": command["description"],
"category": self.category,
}
return result
def done(self) -> None:
Config.BOT_HELP[self.category] = {
"commands": self.command_dict,
"info": self.command_info,
}
Config.BOT_CMD_MENU[self.category] = self.get_menu()
# example usage of HelpMenu class
"""
HelpMenu("example").add(
"example", "<text>", "description of command", "example of command", "note of command"
).info(
"information of plugin"
).done()
"""
# example usage of BotHelp class
"""
BotHelp("example").add(
"example", "description of command"
).info(
"information of category"
).done()
"""
|