mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-12-18 09:25:46 +08:00
Nothing
This commit is contained in:
parent
681b7a382a
commit
6d95c16f5e
@ -16,8 +16,8 @@ default_handler.setFormatter(logging.Formatter(
|
|||||||
))
|
))
|
||||||
logger.addHandler(default_handler)
|
logger.addHandler(default_handler)
|
||||||
|
|
||||||
from .plugin import handle_message, handle_notice, handle_request
|
from . import plugin
|
||||||
from .command import on_command
|
from .plugin import *
|
||||||
|
|
||||||
|
|
||||||
def create_bot(config_object: Any = None):
|
def create_bot(config_object: Any = None):
|
||||||
@ -37,15 +37,15 @@ def create_bot(config_object: Any = None):
|
|||||||
|
|
||||||
@bot.on_message
|
@bot.on_message
|
||||||
async def _(ctx):
|
async def _(ctx):
|
||||||
asyncio.ensure_future(handle_message(bot, ctx))
|
asyncio.ensure_future(plugin.handle_message(bot, ctx))
|
||||||
|
|
||||||
@bot.on_notice
|
@bot.on_notice
|
||||||
async def _(ctx):
|
async def _(ctx):
|
||||||
asyncio.ensure_future(handle_notice(bot, ctx))
|
asyncio.ensure_future(plugin.handle_notice(bot, ctx))
|
||||||
|
|
||||||
@bot.on_request
|
@bot.on_request
|
||||||
async def _(ctx):
|
async def _(ctx):
|
||||||
asyncio.ensure_future(handle_request(bot, ctx))
|
asyncio.ensure_future(plugin.handle_request(bot, ctx))
|
||||||
|
|
||||||
return bot
|
return bot
|
||||||
|
|
||||||
|
@ -3,10 +3,15 @@ from typing import Dict, Any
|
|||||||
from aiocqhttp import CQHttp
|
from aiocqhttp import CQHttp
|
||||||
from aiocqhttp.message import MessageSegment
|
from aiocqhttp.message import MessageSegment
|
||||||
|
|
||||||
from . import command, logger
|
from . import logger
|
||||||
|
from .command import on_command, handle_command
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'on_command',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
async def handle_message(bot: CQHttp, ctx: Dict[str, Any]):
|
async def handle_message(bot: CQHttp, ctx: Dict[str, Any]) -> None:
|
||||||
if ctx['message_type'] != 'private':
|
if ctx['message_type'] != 'private':
|
||||||
# group or discuss
|
# group or discuss
|
||||||
first_message_seg = ctx['message'][0]
|
first_message_seg = ctx['message'][0]
|
||||||
@ -16,16 +21,17 @@ async def handle_message(bot: CQHttp, ctx: Dict[str, Any]):
|
|||||||
if not ctx['message']:
|
if not ctx['message']:
|
||||||
ctx['message'].append(MessageSegment.text(''))
|
ctx['message'].append(MessageSegment.text(''))
|
||||||
|
|
||||||
handled = await command.handle_command(bot, ctx)
|
handled = await handle_command(bot, ctx)
|
||||||
if handled:
|
if handled:
|
||||||
logger.debug('Message is handled as a command')
|
logger.debug('Message is handled as a command')
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
await bot.send(ctx, '你在说什么我看不懂诶')
|
await bot.send(ctx, '你在说什么我看不懂诶')
|
||||||
|
|
||||||
|
|
||||||
async def handle_notice(bot: CQHttp, ctx: Dict[str, Any]):
|
async def handle_notice(bot: CQHttp, ctx: Dict[str, Any]) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
async def handle_request(bot: CQHttp, ctx: Dict[str, Any]):
|
async def handle_request(bot: CQHttp, ctx: Dict[str, Any]) -> None:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user