From e9a26e46f7ed1ad41011a68a5a572c9697e15615 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Mon, 16 Dec 2024 13:26:43 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=B1MarshoAI?= =?UTF-8?q?=E9=87=8D=E5=86=99=E7=9A=84bangumi=E6=8F=92=E4=BB=B6=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_marshoai/plugin/__init__.py | 2 +- .../plugins/marshoai_bangumi/bangumi.py | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 nonebot_plugin_marshoai/plugins/marshoai_bangumi/bangumi.py diff --git a/nonebot_plugin_marshoai/plugin/__init__.py b/nonebot_plugin_marshoai/plugin/__init__.py index 232f1a16..bffca6f8 100644 --- a/nonebot_plugin_marshoai/plugin/__init__.py +++ b/nonebot_plugin_marshoai/plugin/__init__.py @@ -8,4 +8,4 @@ from .load import * from .models import * from .utils import * -#logger.opt(colors=True).info("MarshoAI 插件功能开发中,用户请忽略相关日志") +# logger.opt(colors=True).info("MarshoAI 插件功能开发中,用户请忽略相关日志") diff --git a/nonebot_plugin_marshoai/plugins/marshoai_bangumi/bangumi.py b/nonebot_plugin_marshoai/plugins/marshoai_bangumi/bangumi.py new file mode 100644 index 00000000..9b6c37b2 --- /dev/null +++ b/nonebot_plugin_marshoai/plugins/marshoai_bangumi/bangumi.py @@ -0,0 +1,42 @@ +import traceback + +import httpx + +from nonebot_plugin_marshoai.plugin import PluginMetadata, on_function_call + +# 定义插件元数据 +__marsho_meta__ = PluginMetadata( + name="Bangumi日历", + author="MarshoAI", + description="这个插件可以帮助你获取Bangumi的日历信息~", +) + + +@on_function_call(description="获取Bangumi日历信息") +async def get_bangumi_news() -> str: + async def fetch_calendar(): + url = "https://api.bgm.tv/calendar" + headers = { + "User-Agent": "LiteyukiStudio/nonebot-plugin-marshoai (https://github.com/LiteyukiStudio/nonebot-plugin-marshoai)" + } + async with httpx.AsyncClient() as client: + response = await client.get(url, headers=headers) + # print(response.text) + return response.json() + + try: + result = await fetch_calendar() + info = "" + for i in result: + weekday = i["weekday"]["cn"] + # print(weekday) + info += f"{weekday}:" + items = i["items"] + for item in items: + name = item["name_cn"] + info += f"《{name}》" + info += "" + return info + except Exception as e: + traceback.print_exc() + return "" From 2472a8826b8a3fa1322af5e443a6eda3e8fdd981 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Mon, 16 Dec 2024 13:37:07 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8DMarshoAI?= =?UTF-8?q?=E7=BC=96=E5=86=99=E7=9A=84bangumi=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/marshoai_bangumi/__init__.py | 41 +++++++++++++++--- .../plugins/marshoai_bangumi/bangumi.py | 42 ------------------- 2 files changed, 35 insertions(+), 48 deletions(-) mode change 100755 => 100644 nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py delete mode 100644 nonebot_plugin_marshoai/plugins/marshoai_bangumi/bangumi.py diff --git a/nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py b/nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py old mode 100755 new mode 100644 index 6825364d..9b6c37b2 --- a/nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py +++ b/nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py @@ -2,12 +2,41 @@ import traceback import httpx -from nonebot_plugin_marshoai.plugin import PluginMetadata +from nonebot_plugin_marshoai.plugin import PluginMetadata, on_function_call +# 定义插件元数据 __marsho_meta__ = PluginMetadata( - name="Bangumi 番剧信息", - description="Bangumi 番剧信息", - usage="Bangumi 番剧信息", - author="Liteyuki", - homepage="", + name="Bangumi日历", + author="MarshoAI", + description="这个插件可以帮助你获取Bangumi的日历信息~", ) + + +@on_function_call(description="获取Bangumi日历信息") +async def get_bangumi_news() -> str: + async def fetch_calendar(): + url = "https://api.bgm.tv/calendar" + headers = { + "User-Agent": "LiteyukiStudio/nonebot-plugin-marshoai (https://github.com/LiteyukiStudio/nonebot-plugin-marshoai)" + } + async with httpx.AsyncClient() as client: + response = await client.get(url, headers=headers) + # print(response.text) + return response.json() + + try: + result = await fetch_calendar() + info = "" + for i in result: + weekday = i["weekday"]["cn"] + # print(weekday) + info += f"{weekday}:" + items = i["items"] + for item in items: + name = item["name_cn"] + info += f"《{name}》" + info += "" + return info + except Exception as e: + traceback.print_exc() + return "" diff --git a/nonebot_plugin_marshoai/plugins/marshoai_bangumi/bangumi.py b/nonebot_plugin_marshoai/plugins/marshoai_bangumi/bangumi.py deleted file mode 100644 index 9b6c37b2..00000000 --- a/nonebot_plugin_marshoai/plugins/marshoai_bangumi/bangumi.py +++ /dev/null @@ -1,42 +0,0 @@ -import traceback - -import httpx - -from nonebot_plugin_marshoai.plugin import PluginMetadata, on_function_call - -# 定义插件元数据 -__marsho_meta__ = PluginMetadata( - name="Bangumi日历", - author="MarshoAI", - description="这个插件可以帮助你获取Bangumi的日历信息~", -) - - -@on_function_call(description="获取Bangumi日历信息") -async def get_bangumi_news() -> str: - async def fetch_calendar(): - url = "https://api.bgm.tv/calendar" - headers = { - "User-Agent": "LiteyukiStudio/nonebot-plugin-marshoai (https://github.com/LiteyukiStudio/nonebot-plugin-marshoai)" - } - async with httpx.AsyncClient() as client: - response = await client.get(url, headers=headers) - # print(response.text) - return response.json() - - try: - result = await fetch_calendar() - info = "" - for i in result: - weekday = i["weekday"]["cn"] - # print(weekday) - info += f"{weekday}:" - items = i["items"] - for item in items: - name = item["name_cn"] - info += f"《{name}》" - info += "" - return info - except Exception as e: - traceback.print_exc() - return "" From 6b8b76edc40ef7a78528cbc615bd72449aa35669 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Mon, 16 Dec 2024 13:43:36 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BD=9C=E8=80=85?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=BB=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_marshoai/metadata.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nonebot_plugin_marshoai/metadata.py b/nonebot_plugin_marshoai/metadata.py index 5f1185fa..e7b18f00 100755 --- a/nonebot_plugin_marshoai/metadata.py +++ b/nonebot_plugin_marshoai/metadata.py @@ -11,5 +11,5 @@ metadata = PluginMetadata( config=ConfigModel, homepage="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai", supported_adapters=inherit_supported_adapters("nonebot_plugin_alconna"), - extra={"License": "MIT, Mulan PSL v2", "Author": "Asankilp"}, + extra={"License": "MIT, Mulan PSL v2", "Author": "Asankilp, LiteyukiStudio"}, ) diff --git a/pyproject.toml b/pyproject.toml index 52dde7a2..56a87a56 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ dependencies = [ license = { text = "MIT, Mulan PSL v2" } [project.urls] -Homepage = "https://github.com/LiteyukiStudio/nonebot-plugin-marshoai" +Homepage = "https://marsho.liteyuki.icu/" [tool.nonebot] From 1df988d439d32ed1bb881f8eced3802207371cc4 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Mon, 16 Dec 2024 23:22:54 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E7=AE=80=E5=8C=96marsho=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=BE=93=E5=87=BA=EF=BC=8C=E5=B0=86=E5=91=BD=E4=BB=A4=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=A7=BB=E5=85=A5marsho.help=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_marshoai/azure.py | 16 ++++++++++++++-- nonebot_plugin_marshoai/constants.py | 15 ++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/nonebot_plugin_marshoai/azure.py b/nonebot_plugin_marshoai/azure.py index 3f85d4d3..e628ebd3 100644 --- a/nonebot_plugin_marshoai/azure.py +++ b/nonebot_plugin_marshoai/azure.py @@ -64,6 +64,13 @@ marsho_cmd = on_alconna( priority=10, block=True, ) +marsho_help_cmd = on_alconna( + Alconna( + config.marshoai_default_name + ".help", + ), + priority=10, + block=True, +) marsho_at = on_message(rule=to_me() & at_enable, priority=11) nickname_cmd = on_alconna( Alconna( @@ -208,6 +215,11 @@ async def refresh_data(): await refresh_data_cmd.finish("已刷新数据") +@marsho_help_cmd.handle() +async def marsho_help(): + await marsho_help_cmd.finish(metadata.usage) + + @marsho_at.handle() @marsho_cmd.handle() async def marsho( @@ -225,8 +237,8 @@ async def marsho( text = event.get_message() # type: ignore if not text: # 发送说明 - await UniMessage(metadata.usage + "\n当前使用的模型:" + model_name).send() - await marsho_cmd.finish(INTRODUCTION) + # await UniMessage(metadata.usage + "\n当前使用的模型:" + model_name).send() + await marsho_cmd.finish(INTRODUCTION + "\n当前使用的模型:" + model_name) try: user_id = event.get_user_id() nicknames = await get_nicknames() diff --git a/nonebot_plugin_marshoai/constants.py b/nonebot_plugin_marshoai/constants.py index a8cd55b3..6294620a 100755 --- a/nonebot_plugin_marshoai/constants.py +++ b/nonebot_plugin_marshoai/constants.py @@ -2,8 +2,7 @@ import re from .config import config -USAGE: str = f"""MarshoAI-NoneBot Beta by Asankilp -用法: +USAGE: str = f"""用法: {config.marshoai_default_name} <聊天内容> : 与 Marsho 进行对话。当模型为 GPT-4o(-mini) 等时,可以带上图片进行对话。 nickname [昵称] : 为自己设定昵称,设置昵称后,Marsho 会根据你的昵称进行回答。使用'nickname reset'命令可清除自己设定的昵称。 reset : 重置当前会话的上下文。 ※需要加上命令前缀使用(默认为'/')。 @@ -26,14 +25,12 @@ SUPPORT_IMAGE_MODELS: list = [ "llama-3.2-11b-vision-instruct", ] REASONING_MODELS: list = ["o1-preview", "o1-mini"] -INTRODUCTION: str = """你好喵~我是一只可爱的猫娘AI,名叫小棉~🐾! -我的代码在这里哦~↓↓↓ -https://github.com/LiteyukiStudio/nonebot-plugin-marshoai +INTRODUCTION: str = f"""MarshoAI-NoneBot by LiteyukiStudio +你好喵~我是一只可爱的猫娘AI,名叫小棉~🐾! +我的主页在这里哦~↓↓↓ +https://marsho.liteyuki.icu -也可以关注一下还在成长中的 Melobot 酱喵~↓↓↓ -https://github.com/Meloland/melobot -我与 Melobot 酱贴贴的代码在这里喵~↓↓↓ -https://github.com/LiteyukiStudio/marshoai-melo""" +※ 使用「{config.marshoai_default_name}.help」命令获取使用说明。""" # 正则匹配代码块 From 2ffa38e0077b16d72442a2a0a7ceffe8129c0bc4 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Tue, 17 Dec 2024 00:29:34 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0lgc2333=E7=9A=84nonebot?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=BE=BD=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++-- README_EN.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d513eb5b..ee864746 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,9 @@ _✨ 使用 OpenAI 标准格式 API 的聊天机器人插件 ✨_ - - license +[![NoneBot Registry](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-marshoai)](https://registry.nonebot.dev/plugin/nonebot-plugin-marshoai:nonebot_plugin_marshoai) + + Supported Adapters pypi diff --git a/README_EN.md b/README_EN.md index 8159af99..dd5d018a 100644 --- a/README_EN.md +++ b/README_EN.md @@ -10,8 +10,9 @@ _✨ A chat bot plugin which use OpenAI standard API ✨_ - - license +[![NoneBot Registry](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-marshoai)](https://registry.nonebot.dev/plugin/nonebot-plugin-marshoai:nonebot_plugin_marshoai) + + Supported Adapters pypi