Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 查询用户时出现KeyError #2

Closed
OnlyblackTea opened this issue Dec 30, 2022 · 6 comments
Closed

[Bug]: 查询用户时出现KeyError #2

OnlyblackTea opened this issue Dec 30, 2022 · 6 comments

Comments

@OnlyblackTea
Copy link

使用的系統? || What operating system are you using?

Linux

问题描述 | Describe the bug

具体报错内容详情请见:

命令:/BFV GasolineAndTorch

error

出现问题的QQ | QQ

No response

@GC-ZF
Copy link
Owner

GC-ZF commented Dec 31, 2022

image

我没法复现你的问题,看样子是网络问题,没有拿到实际数据,尝试用命令去请求测试一下,如果返回和我一致再尝试用机器人。curl https://api.gametools.network/bfv/all/?name=GasolineAndTorch&lang=en-us

image

@GC-ZF GC-ZF closed this as completed Jan 1, 2023
@OnlyblackTea
Copy link
Author

我用curl可以复现您的结果,然后在python的交互式界面上用requests.get也能获取到正确的结果

然而通过机器人反复测试,依旧出现网络问题

我会再尝试一下在代码中寻找结果

@OnlyblackTea
Copy link
Author

打logger查到原因了,我改了指令前缀为["!", "!"],输入到get_data函数的参数msg是"! GasolineAndTorch",然后它就直接把这个当作ID传给url了,然后网页就返回404了。

@GC-ZF
Copy link
Owner

GC-ZF commented Jan 4, 2023

打logger查到原因了,我改了指令前缀为["!", "!"],输入到get_data函数的参数msg是"! GasolineAndTorch",然后它就直接把这个当作ID传给url了,然后网页就返回404了。

原来如此!赞哦,找到问题所在。命令前缀不知道你是在配置文件.evn改的还是我的源码,解决办法就是在这两行把你的感叹号也做进去,例如

msg = event.message.extract_plain_text ().replace ( "BFV", "!" ).replace ( "BFV", "!" )

https://github.com/GC-ZF/nonebot_plugin_bfinfo/blob/main/nonebot_plugin_bfinfo/__init__.py#L391

https://github.com/GC-ZF/nonebot_plugin_bfinfo/blob/main/nonebot_plugin_bfinfo/__init__.py#L404

顺便问一下打logger是个啥?哪里的日志可以查到这么详细的错误?

@OnlyblackTea
Copy link
Author

打logger查到原因了,我改了指令前缀为["!", "!"],输入到get_data函数的参数msg是"! GasolineAndTorch",然后它就直接把这个当作ID传给url了,然后网页就返回404了。

原来如此!赞哦,找到问题所在。命令前缀不知道你是在配置文件.evn改的还是我的源码,解决办法就是在这两行把你的感叹号也做进去,例如

msg = event.message.extract_plain_text ().replace ( "BFV", "!" ).replace ( "BFV", "!" )

https://github.com/GC-ZF/nonebot_plugin_bfinfo/blob/main/nonebot_plugin_bfinfo/__init__.py#L391

https://github.com/GC-ZF/nonebot_plugin_bfinfo/blob/main/nonebot_plugin_bfinfo/__init__.py#L404

顺便问一下打logger是个啥?哪里的日志可以查到这么详细的错误?

稍微改了一下源代码,在get_data函数用nonebot自带的from nonebot.log import logger输出一下参数msg的内容而已。具体你可以看nonebot的API文档。

顺便,你可以通过nonebot.config获取env里的配置参数。

@GC-ZF
Copy link
Owner

GC-ZF commented Jan 5, 2023

稍微改了一下源代码,在get_data函数用nonebot自带的from nonebot.log import logger输出一下参数msg的内容而已。具体你可以看nonebot的API文档。

顺便,你可以通过nonebot.config获取env里的配置参数。

嗯嗯,谢谢指正!已发布新版本解决命令起始符导致的ID获取错误。我好久没玩这个游戏了,当时自己想开私服加机器人,环境不太好,问了几个服主怎么挂机器人、检测外挂什么的然后就会被秒踢群,气得我简单肝了一个简化版只能查战绩,加上挂太多所以哈哈超久没玩了。我刚见商店有新人写这个插件,你可以去试试,看着还挺不错的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants