Coder Social home page Coder Social logo

monsterxcn / nonebot_plugin_epicfree Goto Github PK

View Code? Open in Web Editor NEW
54.0 1.0 6.0 79 KB

🤖 NoneBot2 EpicGameStore 喜加一资讯插件,发送「喜加一」逝世看吧!

Home Page: https://pypi.org/project/nonebot-plugin-epicfree/

License: MIT License

Python 100.00%
epic-games python qqbot

nonebot_plugin_epicfree's Introduction

NoneBot Plugin EpicFree


🤖 用于获取 Epic 限免游戏资讯的 NoneBot2 插件


actions license pypi python


安装方法

使用以下命令之一快速安装(若配置了 PyPI 镜像,你可能无法及时检索到插件最新版本):

nb plugin install nonebot_plugin_epicfree

pip install --upgrade nonebot_plugin_epicfree

重启 Bot 即可体验此插件。

关于 NoneBot2 及相关依赖版本

在已淘汰的 NoneBot2 适配器 nonebot-adapter-cqhttp 下,切记不要使用 pipnb_cli 安装此插件。通过拷贝文件夹 nonebot_plugin_epicfree 至 NoneBot2 插件目录、手动安装 nonebot-plugin-apschedulerhttpx 依赖的方式仍可正常启用此插件。在未来某个版本会完全移除该适配器支持,请尽快升级至 nonebot-adapter-onebot

关于 go-cqhttp 版本

插件发送消息依赖 @Mrs4s/go-cqhttp 的合并转发接口,如需启用私聊响应请务必安装 v1.0.0-rc2 以上版本的 go-cqhttp。

使用方法

# nonebot_plugin_epicfree/__init__.py#L27
epic_matcher = on_regex(r"^(epic)?喜(加|\+|+)(一|1)$", priority=2, flags=IGNORECASE)

# nonebot_plugin_epicfree/__init__.py#L39
sub_matcher = on_regex(r"^喜(加|\+|+)(一|1)(私聊)?订阅(删除|取消)?$", priority=1)
  • 发送「喜加一」查找限免游戏
  • 发送「喜加一订阅」订阅游戏资讯
  • 发送「喜加一订阅删除」取消订阅游戏资讯

* 插件响应基于正则匹配,所以,甚至「EpIc喜+1」这样的指令都可用!

环境变量

RESOURCES_DIR="/data/bot/resources"
EPIC_SCHEDULER="8 8 8"

限免游戏资讯订阅功能默认在机器人根目录下 /data/epicfree 文件夹内生成配置文件。定义 RESOURCES_DIR 环境变量即可指定用于存放订阅配置的文件夹,填写包含 epicfree 文件夹的 父级文件夹 路径即可。如果是 Windows 系统应写成类似 D:/path/to/resources_dir 的格式。

限免游戏资讯订阅默认 08:08:08 发送(如果当天的游戏已经推送过则不产生推送),定义 EPIC_SCHEDULER 环境变量即可指定推送时间,该配置的三个数字依次代表 hour minute second

特别鸣谢

@nonebot/nonebot2 | @Mrs4s/go-cqhttp | @DIYgod/RSSHub | @SD4RK/epicstore_api

作者是 NoneBot2 新手,代码写的较为粗糙,欢迎提出修改意见或加入此插件开发!溜了溜了...

nonebot_plugin_epicfree's People

Contributors

monsterxcn avatar studylessshape 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

Watchers

 avatar

nonebot_plugin_epicfree's Issues

UnboundLocalError: local variable 'msg' referenced before assignment

07-30 19:37:31 [ERROR] nonebot | Running matcher <Matcher from nonebot_plugin_epicfree, type=message, priority=2, temp=False> failed.
Traceback (most recent call last):
  File "/home/ubuntu/.pyenv/versions/3.9.5/bin/nb", line 8, in <module>
    sys.exit(main())
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nb_cli/commands/main.py", line 30, in run
    run_bot(file, app)
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nb_cli/handlers/deploy.py", line 23, in run_bot
    nonebot.run()
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nonebot/__init__.py", line 261, in run
    get_driver().run(*args, **kwargs)
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nonebot/drivers/fastapi.py", line 170, in run
    uvicorn.run(
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/uvicorn/main.py", line 463, in run
    server.run()
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nonebot/message.py", line 146, in _check_matcher
    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
> File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nonebot/message.py", line 196, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 668, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 635, in simple_run
    await handler(
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nonebot/dependencies/__init__.py", line 92, in __call__
    return await self.call(**values)
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nonebot_plugin_epicfree/__init__.py", line 28, in onceHandle
    imfree = await getEpicFree()
  File "/home/ubuntu/.pyenv/versions/3.9.5/lib/python3.9/site-packages/nonebot_plugin_epicfree/data_source.py", line 121, in getEpicFree
    return msg

有空修吗,没有空我就自己试着改改提pr

关于依赖版本

当前 0.1.1 版本插件已在 Nonebot 2.0.0.alpha15 环境测试通过,如果遇到插件安装时依赖版本冲突,可参考以下版本解决。

如果无法解决依赖冲突,可手动将仓库下文件 nonebot_plugin_epicfree/__init__.pynonebot_plugin_epicfree/data_source.py 复制到机器人插件目录 nonebot_plugin_epicfree 文件夹下以安装此插件。

(Python 新手,后续有能力将改进依赖关系,欢迎 pr。

# requirements.txt
anyio==3.3.0
arrow==1.1.1
asgiref==3.4.1
binaryornot==0.4.4
certifi==2021.5.30
chardet==4.0.0
charset-normalizer==2.0.4
click==8.0.1
colorama==0.4.4
cookiecutter==1.7.3
fastapi==0.68.0
h11==0.12.0
h2==3.2.0
hpack==3.0.0
httpcore==0.13.6
httptools==0.2.0
httpx==0.18.2                       # httpx 版本与正在使用的 nb-cli nonenot2 需求一致
hyperframe==5.2.0
idna==3.2
Jinja2==3.0.1
jinja2-time==0.2.0
loguru==0.5.3
MarkupSafe==2.0.1
nb-cli==0.5.0                       # nonebot2 脚手架版本 0.5.0
nonebot-adapter-cqhttp==2.0.0a15    # nonebot2 cqhttp 适配器版本 2.0.0.alpha15
nonebot-plugin-epicfree==0.1.1      # 插件版本 0.1.1
nonebot2==2.0.0a15                  # nonebot2 纯净安装版本 2.0.0.alpha15
poyo==0.5.0
prompt-toolkit==3.0.19
pydantic==1.8.2
pyfiglet==0.8.post1
pygtrie==2.4.2
python-dateutil==2.8.2
python-dotenv==0.19.0
python-slugify==5.0.2
PyYAML==5.4.1
requests==2.26.0
rfc3986==1.5.0
six==1.16.0
sniffio==1.2.0
starlette==0.14.2
text-unidecode==1.3
tomlkit==0.7.2
typing-extensions==3.10.0.0
urllib3==1.26.6
uvicorn==0.14.0
uvloop==0.16.0
watchgod==0.7
wcwidth==0.2.5
websockets==9.1

使用限免游戏资讯查询时报错

如图,在群聊中查询游戏资讯时,发生了报错,但是机器人还是正常地把资讯给发了出来。请问这个问题该怎么解决呢?

私聊可以正常发送,但是群聊不行

03-31 12:01:25 [DEBUG] nonebot_plugin_epicfree | 获取到 6 个游戏数据:
Borderlands 3 Season Pass、Tunche、《消逝的光芒:增强版》、The Silent Age、《Blazing Sails》、Dishonored - Definitive Edition
03-31 12:01:25 [INFO] nonebot_plugin_epicfree | 跳过即将推出免费游玩的游戏:Borderlands 3 Season Pass(¥179.00)
03-31 12:01:25 [INFO] nonebot_plugin_epicfree | 跳过即将推出免费游玩的游戏:《消逝的光芒:增强版》(¥109.00)
03-31 12:01:25 [INFO] nonebot_plugin_epicfree | 跳过即将推出免费游玩的游戏:《Blazing Sails》(¥58.00)
03-31 12:01:25 [DEBUG] nonebot | OneBot V11 | Calling API send_group_forward_msg
03-31 12:01:33 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_epicfree) running complete
03-31 12:01:33 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_epicfree) failed.
Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/__init__.py", line 273, in run
    get_driver().run(*args, **kwargs)
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 187, in run
    uvicorn.run(
  File "/root/ac/.venv/lib/python3.10/site-packages/uvicorn/main.py", line 568, in run
    server.run()
  File "/root/ac/.venv/lib/python3.10/site-packages/uvicorn/server.py", line 59, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/message.py", line 141, in _check_matcher
    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
> File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/message.py", line 187, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 732, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 707, in simple_run
    await handler(
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/dependencies/__init__.py", line 108, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot_plugin_epicfree/__init__.py", line 34, in query_handle
    await bot.send_group_forward_msg(group_id=event.group_id, messages=free)  # type: ignore
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/internal/adapter/bot.py", line 120, in call_api
    raise exception
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/internal/adapter/bot.py", line 98, in call_api
    result = await self.adapter._call_api(self, api, **data)
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/adapters/onebot/v11/adapter.py", line 140, in _call_api
    return handle_api_result(await self._result_store.fetch(seq, timeout))
  File "/root/ac/.venv/lib/python3.10/site-packages/nonebot/adapters/onebot/v11/utils.py", line 58, in handle_api_result
    raise ActionFailed(**result)
nonebot.adapters.onebot.v11.exception.ActionFailed: ActionFailed(data=None, echo='2', message='请参考 go-cqhttp 端输出', msg='SEND_MSG_API_ERROR', retcode=100, status='failed', wording='请参考 go-cqhttp 端输出')
03-31 12:01:33 [DEBUG] nonebot | Stop event propagation

获取限免游戏时失败

获取限免游戏时失败
报错如下:

[INFO] nonebot_plugin_epicfree | 跳过即将推出免费游玩的游戏:《Fallout Tactics: Brotherhood of Steel》(¥41.00)
02-16 02:30:12 [INFO] nonebot_plugin_epicfree | 跳过即将推出免费游玩的游戏:《Fallout 2: A Post Nuclear Role Playing Game》(¥41.00)
02-16 02:30:12 [INFO] nonebot_plugin_epicfree | 跳过即将推出免费游玩的游戏:《Fallout: A Post Nuclear Role Playing Game》(¥41.00)
02-16 02:30:12 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_epicfree, lineno=27) running complete
02-16 02:30:12 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_epicfree, lineno=27) failed.
Traceback (most recent call last):
  File "/data/nb/bot.py", line 21, in <module>
    nonebot.run(app="__mp_main__:app")
  File "/usr/local/lib/python3.10/dist-packages/nonebot/__init__.py", line 333, in run
    get_driver().run(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/nonebot/drivers/fastapi.py", line 185, in run
    uvicorn.run(
  File "/usr/local/lib/python3.10/dist-packages/uvicorn/main.py", line 587, in run
    server.run()
  File "/usr/local/lib/python3.10/dist-packages/uvicorn/server.py", line 62, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.10/dist-packages/nonebot/message.py", line 476, in check_and_run_matcher
    await _run_matcher(
> File "/usr/local/lib/python3.10/dist-packages/nonebot/message.py", line 428, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "/usr/local/lib/python3.10/dist-packages/nonebot/internal/matcher/matcher.py", line 842, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "/usr/local/lib/python3.10/dist-packages/nonebot/internal/matcher/matcher.py", line 817, in simple_run
    await handler(
  File "/usr/local/lib/python3.10/dist-packages/nonebot/dependencies/__init__.py", line 106, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "/usr/local/lib/python3.10/dist-packages/nonebot_plugin_epicfree/__init__.py", line 34, in query_handle
    await bot.send_group_forward_msg(group_id=event.group_id, messages=free)  # type: ignore
  File "/usr/local/lib/python3.10/dist-packages/nonebot/internal/adapter/bot.py", line 122, in call_api
    raise exception
  File "/usr/local/lib/python3.10/dist-packages/nonebot/internal/adapter/bot.py", line 97, in call_api
    result = await self.adapter._call_api(self, api, **data)
  File "/usr/local/lib/python3.10/dist-packages/nonebot/adapters/onebot/v11/adapter.py", line 147, in _call_api
    return handle_api_result(await self._result_store.fetch(seq, timeout))
  File "/usr/local/lib/python3.10/dist-packages/nonebot/adapters/onebot/v11/utils.py", line 58, in handle_api_result
    raise ActionFailed(**result)
nonebot.adapters.onebot.v11.exception.ActionFailed: ActionFailed(status='failed', retcode=404, data=None, echo='9')

群聊中发送消息出现错误

群聊中发送喜加一出现错,消息没发出去,私聊使用正常
`06-10 10:36:38 [ERROR] nonebot | Running matcher <Matcher from nonebot_plugin_epicfree, type=message, priority=2, temp=False> failed.
Traceback (most recent call last):
File "", line 1, in
File "/root/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "/root/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 129, in _main
return self._bootstrap(parent_sentinel)
File "/root/miniconda3/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/root/miniconda3/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/root/miniconda3/lib/python3.9/site-packages/uvicorn/subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "/root/miniconda3/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/root/miniconda3/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/message.py", line 146, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "/root/miniconda3/lib/python3.9/site-packages/nonebot/message.py", line 196, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 668, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 635, in simple_run
await handler(
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/dependencies/init.py", line 92, in call
return await self.call(**values)
File "/root/miniconda3/lib/python3.9/site-packages/nonebot_plugin_epicfree/init.py", line 29, in onceHandle
await epicMatcher.finish(Message(imfree))
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 464, in finish
await cls.send(message, **kwargs)
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/internal/matcher.py", line 449, in send
return await bot.send(event=event, message=_message, **kwargs)
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/adapters/onebot/v11/bot.py", line 220, in send
return await self.class.send_handler(self, event, message, **kwargs)
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/adapters/onebot/v11/bot.py", line 175, in send
return await bot.send_msg(**params)
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/internal/adapter/bot.py", line 117, in call_api
raise exception
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/internal/adapter/bot.py", line 94, in call_api
result = await self.adapter._call_api(self, api, **data)
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/adapters/onebot/v11/adapter.py", line 131, in _call_api
return handle_api_result(
File "/root/miniconda3/lib/python3.9/site-packages/nonebot/adapters/onebot/utils.py", line 45, in handle_api_result
raise ActionFailed(**result)
nonebot.adapters.onebot.exception.ActionFailed: <ActionFailed data=None, echo=3, msg=SEND_MSG_API_ERROR, retcode=100, status=failed, wording=请参考 go-cqhttp 端输出>
`

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.