Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/ask/__init__.py

26 lines
874 B
Python
Raw Normal View History

2023-04-07 12:41:06 +00:00
from aiohttp import ClientSession
from core.dirty_check import check_bool
from core.builtins import Bot
from core.component import module
from .AkariAgent import agent_executor
from core.exceptions import NoReportException
2023-04-05 10:15:09 +00:00
a = module('ask', developers=['Dianliang233'], desc='{ask.help.desc}', required_superuser=True)
2023-04-05 11:08:13 +00:00
@a.command('<question> {{ask.help}}')
@a.regex(r'^(?:ask|问)[\:]? ?(.+?)[?]$')
async def _(msg: Bot.MessageSession):
2023-03-31 14:57:33 +00:00
if hasattr(msg, 'parsed_msg'):
question = msg.parsed_msg['<question>']
else:
question = msg.matched_msg[0]
if await check_bool(question):
raise NoReportException('https://wdf.ink/6OUp')
2023-04-07 12:41:06 +00:00
async with ClientSession() as session:
res = await agent_executor.arun(question)
if await check_bool(res):
raise NoReportException('https://wdf.ink/6OUp')
await msg.finish(res)