nonebot2/none/plugin.py

38 lines
959 B
Python
Raw Normal View History

2018-06-15 06:58:24 +08:00
from typing import Dict, Any
from aiocqhttp import CQHttp
from aiocqhttp.message import MessageSegment
2018-06-27 16:36:40 +08:00
from . import logger
from .command import on_command, handle_command
2018-06-15 06:58:24 +08:00
2018-06-27 16:36:40 +08:00
__all__ = [
'on_command',
]
2018-06-15 06:58:24 +08:00
2018-06-27 16:36:40 +08:00
async def handle_message(bot: CQHttp, ctx: Dict[str, Any]) -> None:
2018-06-15 06:58:24 +08:00
if ctx['message_type'] != 'private':
# group or discuss
first_message_seg = ctx['message'][0]
if first_message_seg != MessageSegment.at(ctx['self_id']):
return
del ctx['message'][0]
if not ctx['message']:
ctx['message'].append(MessageSegment.text(''))
2018-06-27 16:36:40 +08:00
handled = await handle_command(bot, ctx)
2018-06-15 06:58:24 +08:00
if handled:
logger.debug('Message is handled as a command')
2018-06-27 16:36:40 +08:00
return
2018-06-15 06:58:24 +08:00
else:
await bot.send(ctx, '你在说什么我看不懂诶')
2018-06-27 16:36:40 +08:00
async def handle_notice(bot: CQHttp, ctx: Dict[str, Any]) -> None:
2018-06-15 06:58:24 +08:00
pass
2018-06-27 16:36:40 +08:00
async def handle_request(bot: CQHttp, ctx: Dict[str, Any]) -> None:
2018-06-15 06:58:24 +08:00
pass