Giter Club home page Giter Club logo

nonebot2's Issues

Plugin: 通用数据库连接

你的插件名称:

通用数据库连接

简短描述插件功能:

连接至各种数据库,为其他插件导出连接对象

插件 import 使用的名称

nonebot_plugin_navicat

插件 install 使用的名称

nonebot-plugin-navicat

插件项目仓库/主页链接

synodriver/nonebot_plugin_navicat

Plugin: sentry日志监控插件

你的插件名称:

Sentry日志监控

简短描述插件功能:

使用Sentry监控机器人日志并处理报错

插件 import 使用的名称

nonebot_plugin_sentry

插件 install 使用的名称

nonebot-plugin-sentry

插件项目仓库/主页链接

cscs181/QQ-GitHub-Bot/tree/master/src/plugins/nonebot_plugin_sentry

Plugin: NoneBot离线文档

你的插件名称:

NoneBot离线文档

简短描述插件功能:

在本地浏览NoneBot文档

插件 import 使用的名称

nonebot_plugin_docs

插件 install 使用的名称

nonebot-plugin-docs

插件项目仓库/主页链接

yanyongyu/nonebot2/tree/master/packages/nonebot-plugin-docs

在 nonebot-test 前端调试时无法让 Bot 说出 <test>

nonebot.load_builtin_plugins() 后,在 nonebot-test 前端向 Bot 发送 /say

Bot 未发送任何消息,且 nonebot2 控制台返回:

[ERROR] nonebot_test | Tag "<test>" does not corespond to any known ansi directive, make sure you did not misspelled it (or prepend '\' to escape it)

Bug: 鉴权处理位置错误

描述问题:

目前鉴权在driver中完成,而非adapter,导致不同adapter共用一种鉴权

期望的结果

在adapter内实现鉴权

环境信息:

  • OS: Any
  • Python Version: Any
  • Nonebot Version: 2.0.0a4

Refactor: 更新内置 register_adapter 逻辑

描述你所需要的特性:

我更倾向于让用户来 register_adapter,

类似这样的代码:

from nonebot.adapters import DingBot

bot = DingBot()
bot.init_driver(nonebot.get_driver())

有以下好处:

  1. 用户可以继承 bot 了,用于魔改原来的 bot
  2. 多个 adapter 注册时 driver 上不会挂着太多无用路径

Plugin: HarukaBot

你的插件名称:

HarukaBot

简短描述插件功能:

将B站UP主的动态和直播信息推送至QQ

插件 import 使用的名称

haruka_bot

插件 install 使用的名称

haruka-bot

通过 pypi 安装

请事先发布插件到pypi

插件项目仓库/主页链接

SK-415/HarukaBot

Bug: expired matcher 在删除前依然会运行

描述问题:

超出有效期的事件响应器在删除前仍然会运行一次

期望的结果

超出有效期的事件响应器不被运行

环境信息:

  • OS: Any
  • Python Version: Any
  • Nonebot Version: 2.0.0a6

Plugin: 前端测试机器人插件

你的插件名称:

前端测试机器人插件

简短描述插件功能:

在浏览器中测试你的 NoneBot 机器人

插件 import 使用的名称

nonebot_plugin_test

插件 install 使用的名称

nonebot-plugin-test

插件项目仓库/主页链接

nonebot/plugin-test

Bug: 在旧版onebot协议中,access_token使用Token而非Bearer

描述问题:

nonebot2 和 go-cqhttp v0.9.29 设置一致的 access_token 时, nonebot2 返回 401

如何复现?

  1. 在 nonebot2 的 .env.* 内设置 access_token = "xxxx" (总之是非空的 token )
  2. 在 go-cqhttp v0.9.29 的 config.json 设置和上面相同的 access_token
  3. 启动 nonebot2,等待来自 go-cqhttp 的连接
  4. 启动 go-cqhttp,尝试连接 nonebot2

期望的结果

连接成功

环境信息:

  • OS: Windows 10 May 2004
  • Python Version: 3.8.6
  • Nonebot Version: nonebot2-dev-4f6f991

[Bug] 为 on_command 设置 aliases 后,通过 aliases 触发的消息有关问题

当前提交 nonebot2-dev-1aac3d5

该版本可以在 on_command 设置 aliases ,如:

from nonebot import on_command
from nonebot.adapters.cqhttp import Bot, Event


test = on_command('test', aliases=('ts'))


@test.handle()
async def _(bot: Bot, event: Event, state: dict):
    print(f'{event.message}')


@test.got('input', prompt='xxxx')
async def _(bot: Bot, event: Event, state: dict):
    ....

加入以上代码,并通过 nonebot-test 向 Bot 发送:

test nonebot2

此时 nonebot2 控制台上 print() 的内容:

nonebot2

以上为符合预期的情况。
但通过 aliases 调用时,通过 nonebot-test 向 Bot 发送:

ts nonebot2

此时 nonebot2 控制台上 print() 的内容:

s nonebot2

除此以外,当发送的消息仅包含 aliases 时,通过 nonebot-test 向 Bot 发送:

ts

此时 nonebot2 控制台上 print() 的内容:

s

而上述情况的发送消息都成功被传入了 @test.got() 的函数中,即使发送的消息并不包含参数。
PS: 经测试,上述问题和首个字符是什么无关,和是否有命令分隔符无关。

Plugin: translator

你的插件名称:

translator

简短描述插件功能:

多语种翻译插件

插件 import 使用的名称

nonebot_plugin_translator

插件 install 使用的名称

nonebot-plugin-translator

安装

  • 通过 poetry 添加到 nonebot2 项目的 pyproject.toml
poetry add nonebot-plugin-translator
  • 也可以通过 pip 从 PyPI 安装
pip install nonebot-plugin-translator

插件项目仓库/主页链接

Lancercmd/nonebot_plugin_translator

Docs: 更新文档

  • 完成各模块 nb-autodoc 文档注释
  • 完成指南
    • introduction
    • installation
    • create project
    • configuration
    • plugin
    • matcher
    • handler
    • Bot 调用api
    • Event, Message使用方法
    • deployment
  • 完成进阶文档
    • permission
    • scheduler
    • runtime hook
    • overloaded handlers
    • nonebug单元测试
  • 完成开发文档
    • publish plugin
    • writing adapter
    • writing driver

Bug: event.plain_text 输出的 string 头多了个空格

from nonebot import on_message
from nonebot.adapters.cqhttp import Bot, Event
from nonebot.log import logger

test = on_message()


@test.handle()
async def _(bot: Bot, event: Event, state: dict):
    logger.debug('Solving...')
    logger.debug(type(event.plain_text))
    logger.debug(event.plain_text)
    logger.debug(event.raw_message)

Bug: 群信息右键回复似乎导致会报错 Failed to handle event

描述问题:

提示报错 Failed to handle event.
使用的go-cqhttp+nb
第一次部署nb2,按照文档"创建一个完整项目"->python bot.py
报错信息:

11-28 15:56:53 [ERROR] nonebot | Failed to handle event. Raw: {'anonymous': None, 'font': 0, 'group_id': 91*55, 'message': [MessageSegment(type='reply', data={'id': '-10*721'})
, MessageSegment(type='at', data={'qq': '69*5'}), MessageSegment(type='text', data={'text': ' 我只看过脸遮住的'})], 'message_id': 88*154, 'message_type': 'group', 'post_type':
'message', 'raw_message': '[CQ:reply,id=-10*21][CQ:at,qq=6*25] 我只看过脸遮住的', 'self_id': 14*49, 'sender': {'age': 0, 'area': '', 'card': '阿尔托莉雅·草履虫·潘德拉
贡', 'level': '', 'nickname': '草履虫', 'role': 'member', 'sex': 'unknown', 'title': '', 'user_id': 11*14}, 'sub_type': 'normal', 'time': 1606550213, 'user_id': 11*14}
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "E:\Python\Python37\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "E:\Python\Python37\lib\multiprocessing\spawn.py", line 118, in _main
    return self._bootstrap()
  File "E:\Python\Python37\lib\multiprocessing\process.py", line 297, in _bootstrap
    self.run()
  File "E:\Python\Python37\lib\multiprocessing\process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\uvicorn\subprocess.py", line 62, in subprocess_started
    target(sockets=sockets)
  File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\uvicorn\main.py", line 390, in run
    loop.run_until_complete(self.serve(sockets=sockets))
  File "E:\Python\Python37\lib\asyncio\base_events.py", line 574, in run_until_complete
    self.run_forever()
  File "E:\Python\Python37\lib\asyncio\base_events.py", line 541, in run_forever
    self._run_once()
  File "E:\Python\Python37\lib\asyncio\base_events.py", line 1786, in _run_once
    handle._run()
  File "E:\Python\Python37\lib\asyncio\events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
> File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\nonebot\adapters\cqhttp\__init__.py", line 354, in handle_message
    await _check_reply(self, event)
  File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\nonebot\adapters\cqhttp\__init__.py", line 114, in _check_reply
    event.reply = await bot.get_msg(message_id=msg_seg.data["id"])
  File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\nonebot\adapters\cqhttp\__init__.py", line 402, in call_api
    seq, self.config.api_timeout))
  File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\nonebot\adapters\cqhttp\__init__.py", line 230, in _handle_api_result
    raise ActionFailed(retcode=result.get("retcode"))
nonebot.exception.ActionFailed: <ActionFailed, retcode=100>

11-28 15:56:54 [INFO] nonebot | CQHTTP | 1486431349 [message.group.normal]: Message -1378210328 from 1147259114@[群:91*55]: "[CQ:image,file=0b06c834f89cc95bbc7d2c882c2f5382.image,u
rl=http://gchat.qpic.cn/gchatpic_new/1147259114/910883855-2764891748-0B06C834F89CC95BBC7D2C882C2F5382/0?term=2]"
11-28 15:56:56 [DEBUG] nonebot | CQHTTP | Calling API get_msg
11-28 15:56:56 [ERROR] nonebot | Failed to handle event. Raw: {'anonymous': None, 'font': 0, 'group_id': 91*55, 'message': [MessageSegment(type='reply', data={'id': '11*85'}),
 MessageSegment(type='at', data={'qq': '25*94'}), MessageSegment(type='text', data={'text': ' '}), MessageSegment(type='at', data={'qq': '2508512894'}), MessageSegment(type='text'
, data={'text': ' 闪图吗'})], 'message_id': -623043202, 'message_type': 'group', 'post_type': 'message', 'raw_message': '[CQ:reply,id=1153009885][CQ:at,qq=25*94] [CQ:at,qq=2*12
894] 闪图吗', 'self_id': 14*49, 'sender': {'age': 0, 'area': '', 'card': '喵喵定制 香草蛋仔_', 'level': '', 'nickname': '星野_', 'role': 'member', 'sex': 'unknown', 'title': '', '
user_id': 240714778}, 'sub_type': 'normal', 'time': 1606550216, 'user_id': 240714778}
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "E:\Python\Python37\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "E:\Python\Python37\lib\multiprocessing\spawn.py", line 118, in _main
    return self._bootstrap()
  File "E:\Python\Python37\lib\multiprocessing\process.py", line 297, in _bootstrap
    self.run()
  File "E:\Python\Python37\lib\multiprocessing\process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\uvicorn\subprocess.py", line 62, in subprocess_started
    target(sockets=sockets)
  File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\uvicorn\main.py", line 390, in run
    loop.run_until_complete(self.serve(sockets=sockets))
  File "E:\Python\Python37\lib\asyncio\base_events.py", line 574, in run_until_complete
    self.run_forever()
  File "E:\Python\Python37\lib\asyncio\base_events.py", line 541, in run_forever
    self._run_once()
  File "E:\Python\Python37\lib\asyncio\base_events.py", line 1786, in _run_once
    handle._run()
  File "E:\Python\Python37\lib\asyncio\events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
> File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\nonebot\adapters\cqhttp\__init__.py", line 354, in handle_message
    await _check_reply(self, event)
  File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\nonebot\adapters\cqhttp\__init__.py", line 114, in _check_reply
    event.reply = await bot.get_msg(message_id=msg_seg.data["id"])
  File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\nonebot\adapters\cqhttp\__init__.py", line 402, in call_api
    seq, self.config.api_timeout))
  File "D:\ProgramData\pyVenvs\nyamoo\lib\site-packages\nonebot\adapters\cqhttp\__init__.py", line 230, in _handle_api_result
    raise ActionFailed(retcode=result.get("retcode"))
nonebot.exception.ActionFailed: <ActionFailed, retcode=100>

如何复现?

  1. 群聊天对某人右键选择回复信息,似乎就会导致这个问题。
  2. 下面发出截图,跟报错信息一一对应。

期望的结果

虽然不会影响到整体运行,但是想知道如何处理这样的错误,不知道切入点.
总之先反馈一下。

环境信息:

  • OS: win10 2004 企业G
  • Python Version: 3.77
  • Nonebot Version: nonebot2 V2.0.0a6

截图

image

image

Plugin: 服务器状态查看插件

你的插件名称:

NoneBot 服务器状态查看插件

简短描述插件功能:

查看服务器 CPU, Memory, Disk Usage 百分比

插件 import 使用的名称

nonebot_plugin_status

插件 install 使用的名称

nonebot-plugin-status

插件项目仓库/主页链接

cscs181/QQ-GitHub-Bot/tree/master/src/plugins/nonebot_plugin_status

Plugin: 图片搜索

你的插件名称:

图片搜索

简短描述插件功能:

从基本上所有你想的出名字的搜图平台找图片

插件 import 使用的名称

nonebot_plugin_picsearcher

插件 install 使用的名称

nonebot-plugin-picsearcher

插件项目仓库/主页链接

synodriver/nonebot_plugin_picsearcher

Doc: 增加插件广场

是否在使用中遇到某些问题而需要新的特性?请描述:

用户无法简单的获取nonebot社区用户开发的插件

描述你所需要的特性:

为文档界面增加一个商店界面,提供插件:pypi链接、仓库链接、作者信息、nb-cli下载命令

为nb-cli增加插件json接口,提供插件API

Bug: 临时事件响应器删除逻辑错误

描述问题:

临时事件响应器在运行完成后删除,导致长时间运行时仍会响应用户消息。同时存在索引删除错误

期望的结果

在运行前即删除。

环境信息:

  • OS: Any
  • Python Version: Any
  • Nonebot Version: 2.0.0a4

使用nb-cli创建项目后运行出现错误

问题描述
根据Nonebotv2的指南,使用nb create创建项目后,运行出错。

先前使用最小实例无任何错误。

复现方法
按照Nonebotv2指南配置脚手架后运行

期望的行为
正常连接ws,载入内置插件

日志信息

10-05 14:23:48 [INFO] nonebot | NoneBot is initializing...
10-05 14:23:48 [INFO] nonebot | Current Env: dev
10-05 14:23:48 [DEBUG] nonebot | Loaded Config: {'driver': 'nonebot.drivers.fastapi', 'host': IPv4Address('127.0.0.1'), 'port': 8080, 'debug': True, 'api_root': {}, 'api_timeout': 30.0, 'access_token': None, 'secret': None, 'superusers': set(), 'nickname': '', 'command_start': {'/'}, 'command_sep': {'.'}, 'session_expire_timeout': datetime.timedelta(seconds=120), 'apscheduler_config': {'apscheduler.timezone': 'Asia/Shanghai'}}
10-05 14:23:48 [DEBUG] nonebot | Succeeded to load adapter "cqhttp"
10-05 14:23:48 [INFO] nonebot | Succeeded to import "nonebot.plugins.base"
10-05 14:23:48 [INFO] nonebot | Running NoneBot...
10-05 14:23:48 [INFO] uvicorn | Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)
10-05 14:23:48 [INFO] uvicorn | Started reloader process [10388] using statreload
10-05 14:23:49 [INFO] nonebot | NoneBot is initializing...
10-05 14:23:49 [INFO] nonebot | Current Env: dev
10-05 14:23:49 [DEBUG] nonebot | Loaded Config: {'driver': 'nonebot.drivers.fastapi', 'host': IPv4Address('127.0.0.1'), 'port': 8080, 'debug': True, 'api_root': {}, 'api_timeout': 30.0, 'access_token': None, 'secret': None, 'superusers': set(), 'nickname': '', 'command_start': {'/'}, 'command_sep': {'.'}, 'session_expire_timeout': datetime.timedelta(seconds=120), 'apscheduler_config': {'apscheduler.timezone': 'Asia/Shanghai'}}
10-05 14:23:49 [DEBUG] nonebot | Succeeded to load adapter "cqhttp"
10-05 14:23:49 [INFO] nonebot | Succeeded to import "nonebot.plugins.base"
10-05 14:23:49 [INFO] uvicorn | Started server process [11652]
10-05 14:23:49 [INFO] uvicorn | Waiting for application startup.
10-05 14:23:49 [INFO] nonebot | Scheduler Started
10-05 14:23:49 [INFO] uvicorn | Application startup complete.
Exception in callback H11Protocol.connection_made(<_SelectorSoc...e, bufsize=0>>)
handle: <Handle H11Protocol.connection_made(<_SelectorSoc...e, bufsize=0>>)>
Traceback (most recent call last):
  File "D:\SDK\Python\Python37\lib\asyncio\events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "D:\Projects\python\nonebot-sdchao-v2\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 125, in connection_made
    self.client = get_remote_addr(transport)
  File "D:\Projects\python\nonebot-sdchao-v2\venv\lib\site-packages\uvicorn\protocols\utils.py", line 9, in get_remote_addr
    return (str(info[0]), int(info[1])) if isinstance(info, tuple) else None
ValueError: invalid literal for int() with base 10: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

此ValueError异常将会反复出现

[2020-10-05 14:28:39] [INFO]: 开始尝试连接到反向Websocket Universal服务器: ws://127.0.0.1:8080/cqhttp/ws
[2020-10-05 14:28:39] [WARNING]: 连接到反向Websocket Universal服务器 ws://127.0.0.1:8080/cqhttp/ws 时出现错误: unexpected EOF
[2020-10-05 14:28:42] [INFO]: 开始尝试连接到反向Websocket Universal服务器: ws://127.0.0.1:8080/cqhttp/ws
[2020-10-05 14:28:42] [WARNING]: 连接到反向Websocket Universal服务器 ws://127.0.0.1:8080/cqhttp/ws 时出现错误: unexpected EOF

相关代码

if __name__ == "__main__":
    nonebot.run(app="bot:app")

运行环境

  • 操作系统:Win10 1909
  • OneBot(CQHTTP)实现及版本:go-cqhttp-v0.9.27
  • NoneBot 版本:nonebot2-2.0.0a2
  • aiocqhttp 版本:1.3.0
  • Python 版本:3.7(venv)

Feature: 希望能够和v1共存,方便旧版本的维护

是否在使用中遇到某些问题而需要新的特性?请描述:

想尝试v2的开发,但是需要维护v1的仓库,按照文档指示需要先卸载v1,想做到两个版本共存

描述你所需要的特性:

希望v1和v2采用不同的包名用以区分,方便同时维护不同版本的机器人

import nonebot 时 tzlocal/win32.py/get_localzone_name 报错

描述问题:

启动时报错

如何复现?

仅仅是import nonebot就会报错
神奇的是,在将sched.py里面修改后

if AsyncIOScheduler:
    scheduler = AsyncIOScheduler(timezone="Asia/Shanghai")

就解决了现在正在这样苟着用

期望的结果

可以正常运行

环境信息:

  • OS: [win10]
  • Python Version: [3.8.5]
  • Nonebot Version: [2.0.0a6]

截图

import nonebot
Traceback (most recent call last):
  File "E:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3418, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-473157fb80ba>", line 1, in <module>
    import nonebot
  File "E:\pycharm\PyCharm 2020.1.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "E:\Anaconda3\lib\site-packages\nonebot\__init__.py", line 135, in <module>
    from nonebot.sched import scheduler
  File "E:\pycharm\PyCharm 2020.1.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "E:\Anaconda3\lib\site-packages\nonebot\sched.py", line 19, in <module>
    scheduler = AsyncIOScheduler()
  File "E:\Anaconda3\lib\site-packages\apscheduler\schedulers\base.py", line 87, in __init__
    self.configure(gconfig, **options)
  File "E:\Anaconda3\lib\site-packages\apscheduler\schedulers\base.py", line 126, in configure
    self._configure(config)
  File "E:\Anaconda3\lib\site-packages\apscheduler\schedulers\asyncio.py", line 48, in _configure
    super(AsyncIOScheduler, self)._configure(config)
  File "E:\Anaconda3\lib\site-packages\apscheduler\schedulers\base.py", line 697, in _configure
    self.timezone = astimezone(config.pop('timezone', None)) or get_localzone()
  File "E:\Anaconda3\lib\site-packages\tzlocal\win32.py", line 93, in get_localzone
    _cache_tz = pytz.timezone(get_localzone_name())
  File "E:\Anaconda3\lib\site-packages\tzlocal\win32.py", line 84, in get_localzone_name
    raise pytz.UnknownTimeZoneError('Can not find timezone ' + tzkeyname)
pytz.exceptions.UnknownTimeZoneError: 'Can not find timezone '

Plugin: 定时任务插件

你的插件名称:

定时任务

简短描述插件功能:

APScheduler 定时任务插件

插件 import 使用的名称

nonebot_plugin_apscheduler

插件 install 使用的名称

nonebot-plugin-apscheduler

插件项目仓库/主页链接

nonebot/plugin-apscheduler

Doc: 优化页面加载体验

是否在使用中遇到某些问题而需要新的特性?请描述:

由于网站使用netlify部署,部分国内用户访问较慢,长时间的空白页面体验不良

描述你所需要的特性:

增加网页离线缓存

Feature: 将内置on_*系列函数作为MatcherGroup的方法

是否在使用中遇到某些问题而需要新的特性?请描述:

在实际使用中,我需要对nonebot进行一层包装,而MatcherGroup类可以起到对Matcher类似于“工厂函数”的作用
我希望能够将on_*系列函数作为MatcherGroup类的一个方法

描述你所需要的特性:

group = MatcherGroup(rule=Rule(some_rule))

matcher = group.on_command("xxx")

@matcher.handle
async def foo():
    ...

在库内的on系列函数可以作为一个已经预先实例化的MatcherGroup的方法

_InnerGroup = MatcherGroup()

on_command = _InnerGroup.on_command

希望我描述清楚了

Bug: load_plugins加载时无法使用相对导入

描述问题:

在插件中使用相对导入时,使用load_plugins加载插件会抛出ImportError错误。

如何复现?

  1. 在插件目录下创建两个py文件
  2. 在一个文件中通过相对路径导入另一个(from . import
  3. 在main中使用load_plugins加载插件目录
  4. 控制台报错:ImportError: attempted relative import with no known parent package

期望的结果

无错误地加载两个插件。

环境信息:

  • OS: macOS
  • Python Version: 3.8
  • Nonebot Version: 2.0.0a3

question:"WebSocket /cqhttp/ws" 403

运行环境:CentOS8
整个文件夹就一个bot.py文件
image
bot.py文件内容如下
image
http端报错403
image

http配置那边只改过账号密码和反向ws地址
image

问题描述:

是个很蠢的问题,但是我昨天折腾了一天,都快怀疑人生了,救救孩子。 本来用的好好的,重装个系统就变成这样了。 换过QQ号,换过端口,重装过系统(Ubuntu也是403),都不行。 按照我的记忆,把go cq配置的端口和bot端口改一致就好了。还是说我遗漏了什么东西?

ps:重装系统的原因是CentOS8的screen有问题,假设主窗口什么都没有(即光标停留在第一行), screen -r 切换到工作窗口,作业完成之后使用CTRL+A+D切回主窗口时,会保留工作窗口的打印内容,而光标却依然留在第一行,虽然可以正常输入,也可以用clear清屏,然而依旧很麻烦。 已经多次更换过镜像(包括CentOS 7.6),也更换过SSH工具,确定是CentOS8的问题。 (然后我才知道有tmux可以代替,不过此时问题已经换成了ws 403,跟什么系统没关系了)
image

Feature: 更改command逻辑

是否在使用中遇到某些问题而需要新的特性?请描述:

on_command 返回 MatcherGroup 在使用上存在困扰

描述你所需要的特性:

修改 command 逻辑以使得确保返回为 Matcher

Bug: 部分 QQ 经典表情无法被处理

描述问题:

部分 QQ 经典表情无法被处理

如何复现?

确认存在此问题的 QQ 经典表情有:

2C2W)(9~7TTU8$3WK$(K8QA 搬砖中
)J NUOY09N_2DS {@VXMINS 忙得飞起
M%4DV 8)(CKG6)SM)7 755](https://user-images.githubusercontent.com/59906398/99346792-6fdd1300-28d0-11eb-868e-f4566cc0bbe2.png) 脑阔疼 ![9U4@Q%8W$5}G_E1UHS8_BK 沧桑
3U( BK(%L67XQ8KK$JR}~KH 捂脸
)~A)O3QR}35OAWPDC2W1FJD 辣眼睛
V7242_%3{V4E~TZTOKPLFS](https://user-images.githubusercontent.com/59906398/99346903-afa3fa80-28d0-11eb-94f0-ac42cc03eeed.png) 哦哟 ![PI 6@7WKAG1%W}8VN~_ASRB](https://user-images.githubusercontent.com/59906398/99346920-b6cb0880-28d0-11eb-8841-f8ebc431d1e2.png) 头秃 ![WWBD~M6BZP)YE6 YCK5O84 问号脸
@BW_GEX6M@_9222E3L)T67E 暗中观察
TI(}%JMOSFRF2GZ0VQH}EIH emm
$}(UJR)1WXN{9 _1M(~9DJH 吃瓜
)JS73GO$9_{S4@$24B_H](https://user-images.githubusercontent.com/59906398/99347002-ed088800-28d0-11eb-83f5-4eab90984d5b.png) 呵呵哒 ![%)RK8(~{5PA(@43ARLWE_I 汪汪
83UTS {DA9(4K6B2{JDSDK7 我酸了
}C}F$6~~B4)VBVR4Q@UY{2G 太南了

期望的结果

既可以被正确处理,也能正确输出至日志

环境信息:

  • OS: Windows 10 20H2
  • Python Version: 3.8.6
  • Nonebot Version: 2.0.0a4 bc8833c

Bug: Little Bug in the Guide Doc 文档中的小bug

描述问题:

在指南->编写插件->事件处理->常用事件处理结构里附加的一小段示例代码似乎有问题

在27行(附上下文)

    # 发送一些信息
    await bot.send("message")
    await matcher.send("message")
    await matcher.finish("message")

bot.send似乎是需要两个参数的,即,正确写法为

await bot.send(event,"message")

不知是不是作者疏忽忘记了,特此汇报

如何复现?

点★击★这★里

期望的结果

见描述问题一栏,略

环境信息:

浏览器: Cent Broswer

截图

Bug: 添加aliases后MatcherGroup没有_default_parser

例如如下命令:

five_query = on_command("5e", aliases={"5E"}, priority=50)

@five_query.handle()
async def five_query_first(bot: Bot, event: Event, status: dict):
    arg = str(event.message).strip()
    if arg:
        status["username"] = arg


@five_query.got("username", prompt="请输入查询用户名")
async def five_query_got_username(bot: Bot, event: Event, status: dict):

若用户发送 !5e,prompt发出后回复用户名,则会出现以下异常:

10-11 11:45:08 [ERROR] nonebot | Running matcher <Matcher from five_e_search, type=message, priority=0, temp=True> failed.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.7/multiprocessing/spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "/usr/lib/python3.7/multiprocessing/spawn.py", line 118, in _main
    return self._bootstrap()
  File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/.cache/pypoetry/virtualenvs/nonebot-sdchao-v2-aazKdxEz-py3.7/lib/python3.7/site-packages/uvicorn/subprocess.py", line 62, in subprocess_started
    target(sockets=sockets)
  File "/home/pi/.cache/pypoetry/virtualenvs/nonebot-sdchao-v2-aazKdxEz-py3.7/lib/python3.7/site-packages/uvicorn/main.py", line 390, in run
    loop.run_until_complete(self.serve(sockets=sockets))
> File "/home/pi/.cache/pypoetry/virtualenvs/nonebot-sdchao-v2-aazKdxEz-py3.7/lib/python3.7/site-packages/nonebot/message.py", line 44, in _run_matcher
    await matcher.run(bot, event, state)
  File "/home/pi/.cache/pypoetry/virtualenvs/nonebot-sdchao-v2-aazKdxEz-py3.7/lib/python3.7/site-packages/nonebot/matcher.py", line 248, in run
    await handler(bot, event, self.state)
  File "/home/pi/.cache/pypoetry/virtualenvs/nonebot-sdchao-v2-aazKdxEz-py3.7/lib/python3.7/site-packages/nonebot/matcher.py", line 410, in wrapper
    await parser(bot, event, state)
  File "/home/pi/.cache/pypoetry/virtualenvs/nonebot-sdchao-v2-aazKdxEz-py3.7/lib/python3.7/site-packages/nonebot/matcher.py", line 395, in _key_parser
    parser = args_parser or self._default_parser
AttributeError: 'MatcherGroup' object has no attribute '_default_parser'

将on_command中aliases参数去除后,工作正常。

five_query = on_command("5e", priority=50)

Plugin: rauthman

你的插件名称:

rauthman

简短描述插件功能:

基于规则的授权管理

插件 import 使用的名称

nonebot_plugin_rauthman

插件 install 使用的名称

nonebot-plugin-rauthman

安装

  • 通过 poetry 添加到 nonebot2 项目的 pyproject.toml
poetry add nonebot-plugin-rauthman
  • 通过 pip 从 PyPI 安装
pip install nonebot-plugin-rauthman

插件项目仓库/主页链接

https://github.com/Lancercmd/nonebot_plugin_rauthman

关于控制台日志

在调试过程中,控制台会不断出现ws心跳包的信息

10-06 20:08:56 [INFO] nonebot | CQHTTP | 1038029389 [meta_event.heartbeat.meta_event]: MetaEvent {'interval': 5000, 'meta_event_type': 'heartbeat', 'post_type': 'meta_event', 'self_id': 1038****89, 'status': None, 'time': 1601986136}
10-06 20:08:56 [DEBUG] nonebot | Checking for matchers in priority 0...
10-06 20:08:56 [DEBUG] nonebot | Checking for matchers in priority 1...

想请问有没有办法隐藏这个事件……不断跳出来,有时候会把正常调试信息顶到上面去……

使用bot.call_api()无法成功发送消息

bot.call_api()无法成功发送消息。2种情况。1.没有错误,但并没有成功发送消息。2.出现错误ActionFailed,retcode=100。
使用go-cqhttp。
刚开始用,可能是因为我不懂怎么用。非常感谢。
代码

import nonebot
from nonebot.rule import to_me
from nonebot.adapters.cqhttp import Bot, Event

keyword = {"test1", "test2"}

block = nonebot.plugin.on_keyword(keyword, rule=to_me(), priority=5)


@block.handle()
async def handle_first_receive(bot: Bot, event: Event, state: dict):
    user_id = event.user_id
    event_id = event.id
    print(event.user_id, "  ", event_id)
    await bot.call_api("send_msg", data={"user_id": user_id, "message": "123"})

日志
11-12 09:58:18 [INFO] nonebot | CQHTTP | 1XXXXXXXX2 [message.private.friend]: Message 7313 from 3XXXXXXXX6 "test1"
11-12 09:58:18 [DEBUG] nonebot | Checking for matchers in priority 5...
11-12 09:58:18 [INFO] nonebot | Event will be handled by <Matcher from block, type=message, priority=5, temp=False>
11-12 09:58:18 [DEBUG] nonebot | Running matcher <Matcher from block, type=message, priority=5, temp=False>
3XXXXXXXX6 7313
11-12 09:58:18 [DEBUG] nonebot | CQHTTP | Calling API send_msg
11-12 09:58:18 [INFO] nonebot | Matcher <Matcher from block, type=message, priority=5, temp=False> running complete
11-12 09:58:18 [DEBUG] nonebot | Stop event propagation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.