amiyabot / amiya-bot-plugins Goto Github PK
View Code? Open in Web Editor NEWAmiya-Bot 插件开发
Amiya-Bot 插件开发
很多用户,包括我,均遇到过这样一件邪门事儿:一切看起来都正常,也没有报错,但自动维护莫名其妙就挂了,导致各种数据没有及时刷新。
受限于个人水平,我认为这种错误是较难排查并解决的。那么,直接换个逻辑好了。
提供一个 HTTP API 用于进行维护,这个 API 被访问则立刻执行一次维护。这样便可以用系统的定时任务甚至是第三方的定时任务来确保维护按预期工作。
当然,这个 API 最好提供鉴权,否则意外的被滥用就惨了。建议提供 GET 或 POST 可选的鉴权方式,甚至是 IP 黑白名单,方便灵活应用。
安装微博推送插件,或者已经安装微博推送插件的情况下每次重新启动兔兔。都会蹦出这一段错误,但似乎无影响(?)
v6.2.7
无其它插件
2023-09-20 17:36:38,287 Main] INFO] checking assets update...
2023-09-20 17:36:38,493 [ Main][ ERROR] assets version file requestfailed.
Unable to find local data/json file or could not parse the contents using importlib-resources. Try pkg-resource next. Traceback(most recent calllast)
File"fake_useragent\utils.py”,line 27, in load
File importlib resources\common.py line 46, in wrapper
File importlib resources common. py, line 56, in files
File functools.py,line 875. in wrapper
File importlibresourcescommon.DV. line 82, in
File "importlib\init_.py”, line 127, in import_module
File Kfrozen importlib.bootstrap line1014, in gcd_import
File"<frozenimportlib.bootstrap)m line 991, infind and load
File"<frozen importlib.bootstrap line 973.in _find_and_load_unlocked
ModuleNotFoundError:No module named fake useragent.data
Could not find localdata/json file or could not parse the contents using pkg-resource.
Traceback(most recent calllast):
File fake useragent\utils.py , line 27, in load
File importlib resources common.py line 46, in wrapper
File importlib resourcescommon.DV.line 56, in files
File functools.py,line 875,in wrapper
File importlib_resourcescommon.py line 82, in
File importlib\ init .py",line 127, in import module
File<frozen importlib.bootstrap. line1014, in gcd import
File <frozen importlib. bootstrap line 991. in find and load
File<frozen importlib.bootstrap line973, in _find_and_load_unlocked
ModuleNotFoundError:No module named fake_useragent.data
During handling of the above exception, another exception occurred:
fTraceback(most recent calllast):
Filefake useragent\utils.pv line 40, in load
FileNotFoundError: [Errno 2]No such file or directory:'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\2\\_MEI20242\\fake_useragent\\data\\browsers.json MainlI
2023-09-20 17:36:38.892 INFO]plugin loaded:amiyabot-weibo-2.5.zip
2023-09-20 17:36:38.897 Main INFO plugin installed:amiyabot-weibo
2023-09-2017:36:38.898 Mainl INFO successfully installed l plugin(s).
2023-09-2017:36:38.962 Server] INFO] Started server process[3728]
2023-09-20 17:36:38,964 ServerJL INFO] Waitingfor applicationstartup.
No response
默认安装时会出错
File "C:\app\Git\Amiya-Bot\amiya\lib\site-packages\starlette_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "C:\app\Git\Amiya-Bot\amiya\lib\site-packages\starlette\routing.py", line 72, in app response = await func(request) File "C:\app\Git\Amiya-Bot\amiya\lib\site-packages\fastapi\routing.py", line 299, in app raise e File "C:\app\Git\Amiya-Bot\amiya\lib\site-packages\fastapi\routing.py", line 294, in app raw_response = await run_endpoint_function( File "C:\app\Git\Amiya-Bot\amiya\lib\site-packages\fastapi\routing.py", line 191, in run_endpoint_function return await dependant.call(**values) File "C:\app\Git\Amiya-Bot\core\server\plugin.py", line 95, in get_plugin_default_config return app.response(plugin.get_config_defaults()) File "C:\app\Git\Amiya-Bot\core\plugins\customPluginInstance\amiyaBotPluginInstance.py", line 247, in get_config_defaults 'global_config_schema': json.dumps(self.__get_dynamic_global_config_schema()), File "C:\app\Git\Amiya-Bot\core\plugins\customPluginInstance\amiyaBotPluginInstance.py", line 240, in __get_dynamic_global_config_schema return self.__parse_to_json(self.__global_config_schema) File "C:\app\Git\Amiya-Bot\core\plugins\customPluginInstance\amiyaBotPluginInstance.py", line 256, in _parse_to_json value = value() File "C:\app\Git\Amiya-Bot\plugins\amiyabot-blm-library-1_2_1\main.py", line 18, in dynamic_get_global_config_schema_data data = json.load(file) File "C:\ProgramData\Anaconda3\lib\json_init.py", line 293, in load return loads(fp.read(), UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 131: illegal multibyte sequence
在手动修改main中代码为这个后不再报错
with open(file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
同标题,十分简单,我认为不需要更多的描述。
这可以避免在某些时候需要重装插件时丢失配置。
1.简易、兼容性好的方案
检查插件目录下所有 yaml 文件,如果选择保留配置则保留这些文件。这要求开发者将 yaml 配置作为规范并遵守。
2.更安全、更准确但可能具有破坏性的方案
要求插件提供配置文件(目录),保留插件声明的这个文件(目录)。
3.较为平衡的方案
可以综合以上两点,当声明存在时给出保留选项,而不存在时不给出这个选项。当然,可以给出一个”开发者模式“或者类似的东西,在"开发者模式"下卸载插件使用方案 1 处理配置。
敌人缺少天赋和技能数据,希望添加
了解敌人的技能比较重要
No response
虽然用的是CQHTTP也不行,识别不了公招
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.