1
0
forked from bot/app
This commit is contained in:
2023-10-04 21:25:49 +08:00
parent e495028198
commit 656a4687f2
25 changed files with 431 additions and 21 deletions

38
src/api/command.py Normal file
View File

@ -0,0 +1,38 @@
from typing import List, Any, Tuple, Dict
from src.api.adapter import Bot
async def run_function(bot: Bot, function_name: str) -> List[Any]:
await bot.call_api()
async def run_command(bot: Bot, cmd: str) -> Any:
await bot.call_api()
def message_unescape(message: str):
"""把那堆乱七八糟的文本转回原始文本
:param message:
:return:
"""
data = {
'&': '&',
'[': '[',
']': ']',
',': ',',
'%20': ' '
}
for old, new in data.items():
message = message.replace(old, new)
return message
def format_command(command_str: str) -> Tuple[str, Tuple[str], Dict[str, str]]:
args, kwargs = [], {}
for element in command_str.split(' '):
if '=' in element:
kwargs[element.split('=')[0]] = kwargs[element.split('=')[1]]
else:
args.append(element)