mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-28 08:41:29 +00:00
New generation init
This commit is contained in:
31
none/plugin.py
Normal file
31
none/plugin.py
Normal file
@ -0,0 +1,31 @@
|
||||
from typing import Dict, Any
|
||||
|
||||
from aiocqhttp import CQHttp
|
||||
from aiocqhttp.message import MessageSegment
|
||||
|
||||
from . import command, logger
|
||||
|
||||
|
||||
async def handle_message(bot: CQHttp, ctx: Dict[str, Any]):
|
||||
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(''))
|
||||
|
||||
handled = await command.handle_command(bot, ctx)
|
||||
if handled:
|
||||
logger.debug('Message is handled as a command')
|
||||
else:
|
||||
await bot.send(ctx, '你在说什么我看不懂诶')
|
||||
|
||||
|
||||
async def handle_notice(bot: CQHttp, ctx: Dict[str, Any]):
|
||||
pass
|
||||
|
||||
|
||||
async def handle_request(bot: CQHttp, ctx: Dict[str, Any]):
|
||||
pass
|
Reference in New Issue
Block a user