Giter VIP home page Giter VIP logo

nonebot_plugin_what2eat's People

Contributors

akiraxie avatar elainafanboy avatar kafcoppelia avatar lonelyion avatar pre-commit-ci[bot] avatar timerainstarsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nonebot_plugin_what2eat's Issues

🔥 dev: 今天喝什么/What to Drink?

dev-v0.4.0 新的功能:今天喝什么?实现你问今天喝什么,Bot随机选取并回答:

不如来一杯 大杯 去冰 半糖 四季玛奇朵,加波霸和椰果!

当然,上述回答形式没有固定,但是我想实现的随机选取的变量有:

  1. 杯型,例如:中杯、大杯;
  2. 冰度,例如:少冰、去冰、常温、热;
  3. 甜度(糖度),例如:全糖、半糖、无糖;
  4. 饮品,这个随不同品牌菜单而选择,数据来源各品牌小程序的菜单;
  5. 配料,例如波霸、珍珠等,随机选取0~3项为宜;

可以去dev分支查看drinking.jsondrinking2.json以及data_source.py的部分代码:

class DrinkingManager:
    ...

json文件存有诸如一点点茶颜悦色蜜雪冰城CoCo的菜单信息,代码部分仅列出了选取的逻辑。目前,我仅考虑一点点的点单逻辑就稍显复杂了,后续喜茶等品牌则更复杂。问题有:

  1. 部分饮品仅支持热/冷(例如冰沙🍧,但仍可选择全冰、少冰),由此带来的冰度选取逻辑的改动;
  2. 部分饮品仅一种杯型(在喜茶中更为常见);
  3. 多数品牌配料有免费与付费两种,当然大多数情况下只会加免费配料,且不止一种(尤其是一点点)。期望实现大概率添加1~3项不同的配料,小概率添加1项付费配料,总配料不宜过多;
  4. 更复杂的情况:不同饮品有不同的配料选择(例如茶颜悦色泡沫茶仅有茶小冻选项,而奶盖茶无茶小冻而有加坚果碎等选项)、或者配料均付费(例如CoCo)一般人不会加太多种、或者更复杂如喜茶部分饮品的配料升级/替换的逻辑(冷热饮可选或可更换的配料不同);
  5. 上述几点问题导致菜单数据存储格式未定,目前我所拟定的菜单项目有(简化了部分内容,参见json),虽然比较清晰,如此选择逻辑的实现也导致代码会比较复杂,例如Q1、Q3:
{
    "一点点": {
        "cup": [
            "中杯",
            "大杯"
        ],
        "sugar_level": [
            "无糖",
            "三分糖",
            "五分糖",
            "七分糖",
            "全糖"
        ],
        "ice_level": [
            "热",
            "标准冰",
            "少冰",
            "去冰",
            "常温"
        ],
        "ingredients": {
            "free": [
                ...
            ],
            "paid": [
                ...
            ]
        },
        "drinks": {
            "general": [
                ...
            ],
            "hot_only": [
                ...
            ],
            "ice_only": [
                ...
            ]
        }
    }
}
  1. 后续会加入更多的品牌:瑞幸、茶百道等……

如果您有更好的想法或建议,欢迎提出!🥳 此issue长期开启

`on_regex` 的命令handler没有被执行

发送:晚上喝啥/今晚吃啥 等都回出现类似的log

06-15 16:54:00 [SUCCESS] nonebot | OneBot V11 ********* | [message.group.normal]: Message *********from ***********@[群:**********] '晚上喝啥'
06-15 16:54:00 [DEBUG] nonebot | Checking for matchers in priority 1...
06-15 16:54:00 [DEBUG] nonebot | Checking for matchers in priority 5...
06-15 16:54:00 [DEBUG] nonebot | Checking for matchers in priority 10...
06-15 16:54:00 [DEBUG] nonebot | Checking for matchers in priority 12...
06-15 16:54:00 [DEBUG] nonebot | Checking for matchers in priority 15...
06-15 16:54:00 [INFO] nonebot | Event will be handled by Matcher(type='message', module=src.plugins.nonebot_plugin_what2eat)
06-15 16:54:00 [DEBUG] nonebot | Running Matcher(type='message', module=src.plugins.nonebot_plugin_what2eat)
06-15 16:54:00 [DEBUG] nonebot | Running handler Dependent(call=_)
06-15 16:54:00 [DEBUG] nonebot | Handler Dependent(call=_) skipped
06-15 16:54:00 [INFO] nonebot | Matcher(type='message', module=src.plugins.nonebot_plugin_what2eat) running complete
06-15 16:54:00 [DEBUG] nonebot | Stop event propagation
06-15 16:54:00 [DEBUG] nonebot | Checking for matchers completed
06-15 16:54:00 [DEBUG] nonebot | Running PostProcessors...
06-15 16:54:01 [DEBUG] nonebot | Running PostProcessors...

其中的Handler Dependent(call=_) skipped可能是问题的关键,但是我不清楚为什么会被skip

插件中使用on_command的命令是可以执行的,log如下,bot回复的是test已加入群特色菜单~

Details

06-15 16:54:43 [SUCCESS] nonebot | OneBot V11 *****| [message.group.normal]: Message -*****from *****@[群:*****] '添加 test'
06-15 16:54:43 [DEBUG] nonebot | Checking for matchers in priority 1...
06-15 16:54:43 [DEBUG] nonebot | Checking for matchers in priority 5...
06-15 16:54:43 [DEBUG] nonebot | Checking for matchers in priority 10...
06-15 16:54:43 [DEBUG] nonebot | Checking for matchers in priority 12...
06-15 16:54:43 [DEBUG] nonebot | Checking for matchers in priority 15...
06-15 16:54:43 [INFO] nonebot | Event will be handled by Matcher(type='message', module=src.plugins.nonebot_plugin_what2eat)
06-15 16:54:43 [DEBUG] nonebot | Running Matcher(type='message', module=src.plugins.nonebot_plugin_what2eat)
06-15 16:54:43 [DEBUG] nonebot | Running handler Dependent(call=_)
06-15 16:54:43 [DEBUG] nonebot | OneBot V11 | Calling API send_msg
06-15 16:54:43 [DEBUG] nonebot | Running CalledAPI hooks...
06-15 16:54:43 [INFO] nonebot | Matcher(type='message', module=src.plugins.nonebot_plugin_what2eat) running complete
06-15 16:54:43 [DEBUG] nonebot | Stop event propagation
06-15 16:54:43 [DEBUG] nonebot | Checking for matchers completed
06-15 16:54:43 [DEBUG] nonebot | Running PostProcessors...

数据储存问题

  • 而不是 resource 因为里面我存着有色图

另外,插件第一次的时候并没有正常的创建 data.jsongreating.json
此时我的配置是(用的yaml)

what2eat_path: data/what2eat
use_preset_menu: true
use_preset_greating: true

插件会报错,FileNotFoundError: [Errno 2] No such file or directory: 'data/what2eat/data.json'

不知道为啥on_command下的所有指令都不识别

nonebot2 2.0.0 rc1,像查看菜单,添加,啥的都不识别,bot没反应,
image

image
直接跳过到下一个插件条件了,最后那个优先级99的是商店那个智能回复。而且安装插件后nonebot_plugin_apscheduler报错,重新安装这个插件就好了

基础菜单命令出错

其他命令都能正常使用,添加菜品也能添加到文件里,和基础菜品重名也会提示“已在基础菜单中”,所以文件路径应该是没问题的
1
2

正则指令无回复

今天吃什么指令无回复,同#41.已尝试切换到v-0.4.x和切换到较早commit,无效果。
顺便问下图片资源在哪里下载

添加图片报错

QQ截图20220825234148

如图,在img文件夹添加图片之后,删除菜单中其他菜测试
image

BOT无反应

日志如下

08-25 23:42:15 [SUCCESS] nonebot | ONEBOT V11 2821521344 | [message.group.normal]: Message -1918647081 from 609638635@[ 群:1006443456] "晚上吃什么"
08-25 23:42:15 [INFO] nonebot | Event will be handled by <Matcher from nonebot_plugin_what2eat, type=message, priority=15, temp=False>
08-25 23:42:15 [INFO] nonebot | Matcher <Matcher from nonebot_plugin_what2eat, type=message, priority=15, temp=False> running complete
08-25 23:42:15 [ERROR] nonebot | Running matcher <Matcher from nonebot_plugin_what2eat, type=message, priority=15, temp=False> failed.
Traceback (most recent call last):
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts\nb.exe\__main__.py", line 7, in <module>
    sys.exit(main())
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nb_cli\commands\main.py", line 30, in run
    run_bot(file, app)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nb_cli\handlers\deploy.py", line 25, in run_bot
    nonebot.run(app=f"{module_name}:{app}")
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nonebot\__init__.py", line 261, in run
    get_driver().run(*args, **kwargs)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nonebot\drivers\fastapi.py", line 170, in run
    uvicorn.run(
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\uvicorn\main.py", line 576, in run
    server.run()
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\uvicorn\server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\asyncio\base_events.py", line 603, in run_until_complete
    self.run_forever()
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\asyncio\windows_events.py", line 316, in run_forever
    super().run_forever()
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\asyncio\base_events.py", line 570, in run_forever
    self._run_once()
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\asyncio\base_events.py", line 1859, in _run_once
    handle._run()
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nonebot\message.py", line 146, in _check_matcher
    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
> File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nonebot\message.py", line 196, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nonebot\internal\matcher.py", line 672, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nonebot\internal\matcher.py", line 639, in simple_run
    await handler(
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nonebot\dependencies\__init__.py", line 92, in __call__
    return await self.call(**values)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nonebot_plugin_what2eat\__init__.py", line 45, in _
    msg = eating_manager.get2eat(event)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nonebot_plugin_what2eat\data_source.py", line 48, in get2eat
    self._eating = load_json(self._eating_json)
  File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\nonebot_plugin_what2eat\utils.py", line 53, in load_json
    return json.load(f)
ValueError: Unexpected character found when decoding array value (1)

能在建议后边添加配图吗?

如图,有些东西可能因为地方原因吧没有听过(流泪猫猫头.jpg),想加个配图辅助一下(ps:绝对不是想半夜放毒)
就像是说像这样的
图片

主要是想问能不能自己设置图片啊,从本地选择什么的

突然就不能用了

image
发了指令后台看起来是收到了,但是聊天里没有信息发送,每天的吃饭提醒还是有的,重新clone过插件也没反应。

加载时报错

05-02 21:16:25 [WARNING] nonebot_plugin_what2eat | What2eat text resource missing! Please check!
05-02 21:16:25 [ERROR] uvicorn | Traceback (most recent call last):
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\routing.py", line 677, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\drivers\fastapi.py", line 165, in _lifespan_manager
    await self._lifespan.startup()
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\drivers\_lifespan.py", line 35, in startup
    await self._run_lifespan_func(self._startup_funcs)
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\drivers\_lifespan.py", line 29, in _run_lifespan_func
    await cast(ASYNC_LIFESPAN_FUNC, func)()
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot_plugin_what2eat\config.py", line 240, in what2eat_check
    await eating_check()
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot_plugin_what2eat\config.py", line 77, in eating_check
    raise ResourceError("Missing necessary resource: eating.json!")
nonebot_plugin_what2eat.config.ResourceError: Missing necessary resource: eating.json!

05-02 21:16:25 [ERROR] uvicorn | Application startup failed. Exiting.
05-02 21:16:25 [ERROR] apscheduler | Job "dy_sched (trigger: date[2023-05-02 21:16:25 CST], next run at: 2023-05-02 21:16:25 CST)" raised an exception
Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\__init__.py", line 309, in run
    get_driver().run(*args, **kwargs)
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\drivers\fastapi.py", line 198, in run
    uvicorn.run(
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\main.py", line 568, in run
    server.run()
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\server.py", line 59, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 47, in run
    _cancel_all_tasks(loop)
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 63, in _cancel_all_tasks
    loop.run_until_complete(tasks.gather(*to_cancel, return_exceptions=True))
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 633, in run_until_complete
    self.run_forever()
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 600, in run_forever
    self._run_once()
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 1896, in _run_once
    handle._run()
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
> File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\apscheduler\executors\base_py3.py", line 30, in run_coroutine_job
    retval = await job.func(*job.args, **job.kwargs)
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\site-packages\haruka_bot\plugins\pusher\dynamic_pusher.py", line 28, in dy_sched
    await asyncio.sleep(1)
  File "C:\Users\hakurei\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 605, in sleep
    return await future
asyncio.exceptions.CancelledError

使用加菜报错

使用"加菜 西北风",机器人无回复后台报错。
07-30 18:59:59 [ERROR] nonebot | Running matcher <Matcher from nonebot_plugin_what2eat, type=message, priority=15, temp=False> failed.
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.9/multiprocessing/spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "/usr/lib/python3.9/multiprocessing/spawn.py", line 129, in _main
return self._bootstrap(parent_sentinel)
File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.9/dist-packages/uvicorn/subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
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 146, 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 196, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/matcher.py", line 668, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/matcher.py", line 635, in simple_run
await handler(
File "/usr/local/lib/python3.9/dist-packages/nonebot/dependencies/init.py", line 92, in call
return await self.call(**values)
File "/usr/local/lib/python3.9/dist-packages/nonebot_plugin_what2eat/init.py", line 69, in _
msg = eating_manager.add_basic_food(new_food)
File "/usr/local/lib/python3.9/dist-packages/nonebot_plugin_what2eat/data_source.py", line 150, in add_basic_food
status: FoodLoc = self._is_food_exists(new_food)
TypeError: _is_food_exists() missing 1 required positional argument: 'gid'

AttributeError: 'Config' object has no attribute 'groups_id'

当我在一个全新的环境中启动(python3.11),插件加载错误(其余几个插件均正常),具体报错日志如下

05-08 04:34:15 [ERROR] nonebot | Failed to import "nonebot_plugin_what2eat"
Traceback (most recent call last):
  File "/root/Ansel-Bot/bot.py", line 25, in <module>
    nonebot.load_plugin('nonebot_plugin_what2eat')
  File "/root/mambaforge/envs/nonebot/lib/python3.11/site-packages/nonebot/plugin/load.py", line 37, in load_plugin
    return manager.load_plugin(module_path)
> File "/root/mambaforge/envs/nonebot/lib/python3.11/site-packages/nonebot/plugin/manager.py", line 141, in load_plugin
    module = importlib.import_module(name)
  File "/root/mambaforge/envs/nonebot/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "/root/mambaforge/envs/nonebot/lib/python3.11/site-packages/nonebot/plugin/manager.py", line 240, in exec_module
    super().exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/root/mambaforge/envs/nonebot/lib/python3.11/site-packages/nonebot_plugin_what2eat/__init__.py", line 6, in <module>
    from .utils import eating_manager, Meals, GROUPS_ID
  File "/root/mambaforge/envs/nonebot/lib/python3.11/site-packages/nonebot_plugin_what2eat/utils.py", line 24, in <module>
    _GROUPS_ID = nonebot.get_driver().config.groups_id
AttributeError: 'Config' object has no attribute 'groups_id'

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.