minatoaquacrews / nonebot_plugin_tarot Goto Github PK
View Code? Open in Web Editor NEWTarot divination plugin for nonebot2.
License: MIT License
Tarot divination plugin for nonebot2.
License: MIT License
文件里是愚者1、愚者2,但是卡片是愚者,所以图片显示不全
顺便建议加上发消息记录失败时发送占卜失败的提示
超管指令是开启/关闭群聊转发模式
随机牌阵有时候比较复杂,希望加入单张塔罗牌切牌的指令(作为一种简单的占卜),或者能够指定阵型的指令。
如题,非常喜欢这个功能,希望大佬更新~
在bot更新遇到问题后,为了测试0.4.0 post1的bug是否普遍,我重新在新project里安装了本插件。从初步安装到启动日志如下:
C:\Users\Administrator\Desktop\NoneBot\test\w\test>nb plugin install nonebot_plugin_tarot
Requirement already satisfied: nonebot-plugin-tarot in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (0.4.0.post1)
Requirement already satisfied: aiocache<0.12.0,>=0.11.1 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot-plugin-tarot) (0.11.1)
Requirement already satisfied: httpx<0.24.0,>=0.23.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot-plugin-tarot) (0.23.3)
Requirement already satisfied: nonebot-adapter-onebot<3.0.0,>=2.1.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot-plugin-tarot) (2.2.2)
Requirement already satisfied: pillow<10.0.0,>=9.0.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot-plugin-tarot) (9.4.0)
Requirement already satisfied: nonebot2<3.0.0,>=2.0.0b3 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot-plugin-tarot) (2.0.0rc3)
Requirement already satisfied: sniffio in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from httpx<0.24.0,>=0.23.0->nonebot-plugin-tarot) (1.3.0)
Requirement already satisfied: rfc3986[idna2008]<2,>=1.3 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from httpx<0.24.0,>=0.23.0->nonebot-plugin-tarot) (1.5.0)
Requirement already satisfied: httpcore<0.17.0,>=0.15.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from httpx<0.24.0,>=0.23.0->nonebot-plugin-tarot) (0.16.3)
Requirement already satisfied: certifi in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from httpx<0.24.0,>=0.23.0->nonebot-plugin-tarot) (2022.12.7)
Requirement already satisfied: msgpack<2.0.0,>=1.0.3 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot-adapter-onebot<3.0.0,>=2.1.0->nonebot-plugin-tarot) (1.0.4)
Requirement already satisfied: typing-extensions<5.0.0,>=3.10.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot2<3.0.0,>=2.0.0b3->nonebot-plugin-tarot) (4.5.0)
Requirement already satisfied: loguru<0.7.0,>=0.6.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot2<3.0.0,>=2.0.0b3->nonebot-plugin-tarot) (0.6.0)
Requirement already satisfied: pygtrie<3.0.0,>=2.4.1 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot2<3.0.0,>=2.0.0b3->nonebot-plugin-tarot) (2.5.0)
Requirement already satisfied: pydantic[dotenv]<2.0.0,>=1.10.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot2<3.0.0,>=2.0.0b3->nonebot-plugin-tarot) (1.10.7)
Requirement already satisfied: tomlkit<1.0.0,>=0.10.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot2<3.0.0,>=2.0.0b3->nonebot-plugin-tarot) (0.11.6)
Requirement already satisfied: yarl<2.0.0,>=1.7.2 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from nonebot2<3.0.0,>=2.0.0b3->nonebot-plugin-tarot) (1.8.2)
Requirement already satisfied: anyio<5.0,>=3.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from httpcore<0.17.0,>=0.15.0->httpx<0.24.0,>=0.23.0->nonebot-plugin-tarot) (3.6.2)
Requirement already satisfied: h11<0.15,>=0.13 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from httpcore<0.17.0,>=0.15.0->httpx<0.24.0,>=0.23.0->nonebot-plugin-tarot) (0.14.0)
Requirement already satisfied: colorama>=0.3.4 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from loguru<0.7.0,>=0.6.0->nonebot2<3.0.0,>=2.0.0b3->nonebot-plugin-tarot) (0.4.6)
Requirement already satisfied: win32-setctime>=1.0.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from loguru<0.7.0,>=0.6.0->nonebot2<3.0.0,>=2.0.0b3->nonebot-plugin-tarot) (1.1.0)
Requirement already satisfied: python-dotenv>=0.10.4 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from pydantic[dotenv]<2.0.0,>=1.10.0->nonebot2<3.0.0,>=2.0.0b3->nonebot-plugin-tarot) (0.21.0)
Requirement already satisfied: idna in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from rfc3986[idna2008]<2,>=1.3->httpx<0.24.0,>=0.23.0->nonebot-plugin-tarot) (3.4)
Requirement already satisfied: multidict>=4.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from yarl<2.0.0,>=1.7.2->nonebot2<3.0.0,>=2.0.0b3->nonebot-plugin-tarot) (6.0.4)
[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: python.exe -m pip install --upgrade pip
C:\Users\Administrator\Desktop\NoneBot\test\w\test>nb run
03-26 18:29:36 [SUCCESS] nonebot | NoneBot is initializing...
03-26 18:29:36 [INFO] nonebot | Current Env: prod
ujson module not found, using json
03-26 18:29:37 [SUCCESS] nonebot | Succeeded to import "nonebot_plugin_tarot"
03-26 18:29:37 [SUCCESS] nonebot | Running NoneBot...
03-26 18:29:37 [INFO] uvicorn | Started server process [2748]
03-26 18:29:37 [INFO] uvicorn | Waiting for application startup.
03-26 18:29:38 [ERROR] uvicorn | Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\routing.py", line 671, in lifespan
async with self.lifespan_context(app):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\routing.py", line 566, in __aenter__
await self._router.startup()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\routing.py", line 648, in startup
await handler()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot_plugin_tarot\config.py", line 94, in tarot_version_check
docs = response.json()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx\_models.py", line 756, in json
return jsonlib.loads(self.text, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
03-26 18:29:38 [ERROR] uvicorn | Application startup failed. Exiting.
C:\Users\Administrator\Desktop\NoneBot\test\w\test>
config.py 第56行中的镜像好像已经寄了,换成https://raw.githubusercontent.com/MinatoAquaCrews/nonebot_plugin_tarot/master/nonebot_plugin_tarot/
也不行,
我的解决办法是换成https://ghproxy.com/https://raw.githubusercontent.com/MinatoAquaCrews/nonebot_plugin_tarot/master/nonebot_plugin_tarot/
,然后把126行后面加上.png
, resource: str = "resource/" + f"{_theme}/{_type}/{_name}.png"
,
但是东方主题的塔罗牌图片是jpg的,这样就不能访问了
根据readme中的内容将图片文件夹部署到nonebot_plugin_tarot/resource/picture
,并修改config.py
中tarot_path: Path = Path(__file__).parent / "resource/picture
(已经尝试过resource,picture和picture的绝对路径),bot的反馈一直是“图片下载失败请重试
[INFO] nonebot_plugin_tarot | Downloading tarot image Wands/权杖骑士.png
12-12 02:53:09 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/Wands/权杖骑士.png, 1/3: peer closed connection without sending complete message body (received 130298 bytes, expected 2951297)
12-12 02:53:11 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/Wands/权杖骑士.png, 2/3: peer closed connection without sending complete message body (received 130301 bytes, expected 2951297)
12-12 02:53:12 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/Wands/权杖骑士.png, 3/3: peer closed connection without sending complete message body (received 130300 bytes, expected 2951297)
12-12 02:53:12 [WARNING] nonebot_plugin_tarot | Abort downloading
12-12 02:53:12 [WARNING] nonebot_plugin_tarot | Downloading tarot image Wands/权杖骑士.png failed!
12-12 02:53:12 [INFO] nonebot | Matcher <Matcher from nonebot_plugin_tarot, type=message, priority=7, temp=False> running complete
似乎没有看到bot加载本地图片的反馈
塔罗牌有的牌之间有互相加强和削弱的效果,能否给这个效果加上
01-07 17:10:28 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/tarot.json, 1/3: [Errno -3] Temporary failure in name resolution
01-07 17:10:33 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/tarot.json, 2/3:
01-07 17:10:38 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/tarot.json, 3/3:
01-07 17:10:38 [WARNING] nonebot_plugin_tarot | Abort downloading
nonebot2: 2.0.0b2
nb-cli: 0.6.6
nonebot-plugin-tarot: 0.2.4
nb run
启动后报错
module = importlib.import_module(module_str)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/newqqbot/nonebot/Alice/./bot.py", line 26, in <module>
nonebot.load_from_toml("pyproject.toml")
File "/home/newqqbot/.local/lib/python3.8/site-packages/nonebot/plugin/load.py", line 119, in load_from_toml
return load_all_plugins(plugins, plugin_dirs)
File "/home/newqqbot/.local/lib/python3.8/site-packages/nonebot/plugin/load.py", line 53, in load_all_plugins
return manager.load_all_plugins()
File "/home/newqqbot/.local/lib/python3.8/site-packages/nonebot/plugin/manager.py", line 128, in load_all_plugins
return set(
File "/home/newqqbot/.local/lib/python3.8/site-packages/nonebot/plugin/manager.py", line 129, in <genexpr>
filter(None, (self.load_plugin(name) for name in self.list_plugins()))
> File "/home/newqqbot/.local/lib/python3.8/site-packages/nonebot/plugin/manager.py", line 104, in load_plugin
module = importlib.import_module(name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "/home/newqqbot/.local/lib/python3.8/site-packages/nonebot/plugin/manager.py", line 194, in exec_module
super().exec_module(module)
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/newqqbot/.local/lib/python3.8/site-packages/nonebot_plugin_tarot/__init__.py", line 17, in <module>
NICKNAME = list(_NICKNAME)[0]
IndexError: list index out of range
看到同类bot插件有正逆位,塔罗果然还是需要有正逆位才对。希望能整一下。
2022-03-15T20:02:54: �[0m�[33m[2022-03-15 20:02:54] [WARNING]: 转换CQ码 ({"type": "image", "data": {"file": "file:////root/bot/src/plugins/nonebot_plugin_tarot/resource/\u4e16\u754c.jpg", "type": null, "cache": "true", "proxy": "true", "timeout": null}}) 到MiraiGo Element时出现错误: file not found 将忽略本段CQ码.
错误提示↑
压缩包中的是皇后,仓库里resource的是女皇。
请问安装的第二步可以再说的详细一点吗,万分感谢
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\nonebot\plugin\manager.py", line 181, in exec_module
super().exec_module(module)
File "", line 850, in exec_module
File "", line 228, in call_with_frames_removed
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\nonebot_plugin_fortune_init.py", line 6, in
from nonebot.adapters.cqhttp import Bot, GROUP, GROUP_ADMIN, GROUP_OWNER, GroupMessageEvent, MessageSegment
ModuleNotFoundError: No module named 'nonebot.adapters.cqhttp'
adapter cqhttp was replaced by onebot
请问可以限制占卜的次数吗?
最近我试着把我的bot从nonebot1换成nonebot2,发现nb2的商店里居然也有塔罗牌插件(不用重写了,好耶)。
结果打开来一用,熟悉の气息扑面而来,发现是改自自己之前写了没管的destiny_tarot插件。(世界真小)
原插件是我刚学编程的时候写的(贼烂对吧),这个插件似乎对原插件进行了简化。
但其实原插件的主要作用是发到酷Q论坛骗开发者激活码(划掉),所以并没有斟酌各张塔罗牌的具体含义,而是照抄了路边摊10块钱买来的一幅塔罗牌的说明书。所以其中很多牌的含义都不准。Emmmm...或许可以找点时间重新斟酌下塔罗牌的含义。
(现在上高中了,好像没那么多时间整bot惹,感谢大佬的优化。)
Traceback (most recent call last):
File "/home/unb/nb2/bot.py", line 45, in <module>
nonebot.run(app="__mp_main__:app")
File "/usr/local/lib/python3.9/dist-packages/nonebot/__init__.py", line 309, in run
get_driver().run(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/nonebot/drivers/fastapi.py", line 198, in run
uvicorn.run(
File "/usr/local/lib/python3.9/dist-packages/uvicorn/main.py", line 569, in run
server.run()
File "/usr/local/lib/python3.9/dist-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.9/dist-packages/nonebot/message.py", line 141, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
> File "/usr/local/lib/python3.9/dist-packages/nonebot/message.py", line 187, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/matcher/matcher.py", line 753, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/matcher/matcher.py", line 728, in simple_run
await handler(
File "/usr/local/lib/python3.9/dist-packages/nonebot/dependencies/__init__.py", line 108, in __call__
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "/usr/local/lib/python3.9/dist-packages/nonebot_plugin_tarot/__init__.py", line 50, in _
msg = await tarot_manager.onetime_divine()
File "/usr/local/lib/python3.9/dist-packages/nonebot_plugin_tarot/data_source.py", line 151, in onetime_divine
card_info_list = self._random_cards(all_cards, theme)
File "/usr/local/lib/python3.9/dist-packages/nonebot_plugin_tarot/data_source.py", line 175, in _random_cards
raise ResourceError(f"本地塔罗牌主题 {theme} 为空!请检查资源!")
nonebot_plugin_tarot.config.ResourceError: 本地塔罗牌主题 MajorArcana 为空! 请检查资源!
06-07 20:20:27 [INFO] nonebot_plugin_apscheduler | Scheduler Started
06-07 20:20:33 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/tarot.json, 1/3:
06-07 20:20:38 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/tarot.json, 2/3:
06-07 20:20:44 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/tarot.json, 3/3:
06-07 20:20:44 [ERROR] uvicorn | Traceback (most recent call last):
File "/root/miniconda3/lib/python3.9/site-packages/starlette/routing.py", line 635, in lifespan
async with self.lifespan_context(app):
File "/root/miniconda3/lib/python3.9/site-packages/starlette/routing.py", line 530, in aenter
await self._router.startup()
File "/root/miniconda3/lib/python3.9/site-packages/starlette/routing.py", line 612, in startup
await handler()
File "/root/miniconda3/lib/python3.9/site-packages/nonebot_plugin_tarot/config.py", line 49, in tarot_version_check
response = await download_url(url)
File "/root/miniconda3/lib/python3.9/site-packages/nonebot_plugin_tarot/config.py", line 38, in download_url
raise DownloadError
nonebot_plugin_tarot.config.DownloadError
06-07 20:20:44 [ERROR] uvicorn | Application startup failed. Exiting.
网络环境 腾讯云国内
"塔罗牌"
12-21 10:38:16 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_tarot)
12-21 10:38:16 [INFO] nonebot_plugin_tarot | Downloading tarot image Swords/宝剑-07.png
12-21 10:38:21 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/Swords/宝剑-07.png, 1/3:
12-21 10:38:27 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/Swords/宝剑-07.png, 2/3:
12-21 10:38:54 [WARNING] nonebot_plugin_tarot | Error occured when downloading https://raw.fastgit.org/MinatoAquaCrews/nonebot_plugin_tarot/beta/nonebot_plugin_tarot/resource/Swords/宝剑-07.png, 3/3:
12-21 10:38:54 [WARNING] nonebot_plugin_tarot | Abort downloading
12-21 10:38:54 [WARNING] nonebot_plugin_tarot | Downloading tarot image Swords/宝剑-07.png failed!
12-21 10:38:54 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_tarot) running complete
12-21 10:38:54 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_kawaii_robot)
12-21 10:38:54 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_kawaii_robot) running complete
为什么bilibili塔罗牌安装后触发bot会一直提示 “本地塔罗牌主题 Wands 为空!请检查资源!”或是 “图片下载出错,请重试或将资源部署本地……”
单张塔罗牌只有编号为1-9的卡罗牌。
看了下代码,self.devined被赋值成String了,devined[0]就只有1~9
single_divine()
self.devined = random.choice(list(self._cards))
修改
self.devined = [random.choice(list(self._cards))]
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.