From 2afe3c48ce7ff6b4e3c447b1757da1a7671e1708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E7=BE=BFELS?= <71250018+EillesWan@users.noreply.github.com> Date: Fri, 31 Jan 2025 16:11:07 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=E5=A2=9E=E8=AE=BE=E7=89=88=E6=9D=83?= =?UTF-8?q?=E5=A3=B0=E6=98=8E=EF=BC=8C=E6=9B=B4=E6=96=B0=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E5=B9=B4=E4=BB=BD=EF=BC=8C=E4=B8=BB=E9=A2=98=E8=89=B2=EF=BC=81?= =?UTF-8?q?=20(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 优化更新 * 代码不够黑,新增一个空行 * ? * 空格? * 新年新气象,莫生气 * 又是空格 * 附和:zhDateTime1.1.1 修复过于愚蠢导致的问题 * ⭐增设版权声明,更新授权年份,主题色! * ?怎么没删 * 更新 zhDateTime 库版本,主题色往文档里塞 * 我愚蠢了 --- LICENSE-LSO | 2 +- LICENSE-MIT | 2 +- LICENSE-MULAN | 2 +- README.md | 2 ++ docs/en/dev/api/config.md | 2 +- docs/en/start/install.md | 2 +- docs/zh/dev/api/config.md | 2 +- docs/zh/start/install-old.md | 2 +- docs/zh/start/install.md | 2 +- nonebot_plugin_marshoai/__init__.py | 24 +++++++++++++++++++ nonebot_plugin_marshoai/config.py | 2 +- nonebot_plugin_marshoai/config_example.yaml | 2 +- .../plugins_test/marshoai_basic/__init__.py | 16 +++++++------ nonebot_plugin_marshoai/util.py | 9 ++++--- pyproject.toml | 2 +- resources/README.md | 2 ++ 16 files changed, 52 insertions(+), 23 deletions(-) diff --git a/LICENSE-LSO b/LICENSE-LSO index e492d6a8..b865d48a 100644 --- a/LICENSE-LSO +++ b/LICENSE-LSO @@ -3,7 +3,7 @@ LiteyukiStudio Opensource license --- -Copyright © 2024 +Copyright © 2025 Asankilp & LiteyukiStudio --- diff --git a/LICENSE-MIT b/LICENSE-MIT index 060342d3..85d2e25f 100755 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 LiteyukiStudio +Copyright (c) 2025 Asankilp & LiteyukiStudio Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/LICENSE-MULAN b/LICENSE-MULAN index d4271fce..3a105a77 100755 --- a/LICENSE-MULAN +++ b/LICENSE-MULAN @@ -1,4 +1,4 @@ -Copyright (c) 2024 EillesWan +Copyright (c) 2025 EillesWan nonebot-plugin-latex & other specified codes is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: diff --git a/README.md b/README.md index cfaf9508..88040c19 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ _谁不喜欢回复消息快又可爱的猫娘呢?_ ## ❤ 鸣谢&版权说明 +> Copyright (c) 2025 Asankilp & LiteyukiStudio + 本项目使用了以下项目的代码: - [nonebot-plugin-latex](https://github.com/EillesWan/nonebot-plugin-latex) diff --git a/docs/en/dev/api/config.md b/docs/en/dev/api/config.md index d35eed8c..99428936 100755 --- a/docs/en/dev/api/config.md +++ b/docs/en/dev/api/config.md @@ -14,7 +14,7 @@ title: config #### ***attr*** `marshoai_aliases: set[str] = {'小棉'}` -#### ***attr*** `marshoai_main_colour: str = 'FFAAAA'` +#### ***attr*** `marshoai_main_colour: str = 'FEABA9'` #### ***attr*** `marshoai_default_model: str = 'gpt-4o-mini'` diff --git a/docs/en/start/install.md b/docs/en/start/install.md index e6c5d285..8bc4a0b4 100644 --- a/docs/en/start/install.md +++ b/docs/en/start/install.md @@ -109,7 +109,7 @@ Add options in the `.env` file from the diagram below in nonebot2 project. | MARSHOAI_DEFAULT_NAME | `str` | `marsho` | Command to call Marsho | | MARSHOAI_ALIASES | `set[str]` | `list["小棉"]` | Other name(Alias) to call Marsho | | MARSHOAI_AT | `bool` | `false` | Call by @ or not | -| MARSHOAI_MAIN_COLOUR | `str` | `FFAAAA` | Theme color, used by some tools and features | +| MARSHOAI_MAIN_COLOUR | `str` | `FEABA9` | Theme color, used by some tools and features | #### AI call diff --git a/docs/zh/dev/api/config.md b/docs/zh/dev/api/config.md index 8a92286a..e27a66d8 100755 --- a/docs/zh/dev/api/config.md +++ b/docs/zh/dev/api/config.md @@ -14,7 +14,7 @@ title: config #### ***attr*** `marshoai_aliases: set[str] = {'小棉'}` -#### ***attr*** `marshoai_main_colour: str = 'FFAAAA'` +#### ***attr*** `marshoai_main_colour: str = 'FEABA9'` #### ***attr*** `marshoai_default_model: str = 'gpt-4o-mini'` diff --git a/docs/zh/start/install-old.md b/docs/zh/start/install-old.md index 18ad38b5..77f8d28e 100644 --- a/docs/zh/start/install-old.md +++ b/docs/zh/start/install-old.md @@ -103,7 +103,7 @@ title: 安装 | MARSHOAI_DEFAULT_NAME | `str` | `marsho` | 调用 Marsho 默认的命令前缀 | | MARSHOAI_ALIASES | `set[str]` | `set{"小棉"}` | 调用 Marsho 的命令别名 | | MARSHOAI_AT | `bool` | `false` | 决定是否使用at触发 | -| MARSHOAI_MAIN_COLOUR | `str` | `FFAAAA` | 主题色,部分工具和功能可用 | +| MARSHOAI_MAIN_COLOUR | `str` | `FEABA9` | 主题色,部分工具和功能可用 | #### AI 调用 diff --git a/docs/zh/start/install.md b/docs/zh/start/install.md index 8e3fcfcc..885af28c 100644 --- a/docs/zh/start/install.md +++ b/docs/zh/start/install.md @@ -111,7 +111,7 @@ GitHub Models API 的限制较多,不建议使用,建议通过修改`MARSHOA | MARSHOAI_DEFAULT_NAME | `str` | `marsho` | 调用 Marsho 默认的命令前缀 | | MARSHOAI_ALIASES | `set[str]` | `list["小棉"]` | 调用 Marsho 的命令别名 | | MARSHOAI_AT | `bool` | `false` | 决定是否使用at触发 | -| MARSHOAI_MAIN_COLOUR | `str` | `FFAAAA` | 主题色,部分工具和功能可用 | +| MARSHOAI_MAIN_COLOUR | `str` | `FEABA9` | 主题色,部分工具和功能可用 | #### AI 调用 diff --git a/nonebot_plugin_marshoai/__init__.py b/nonebot_plugin_marshoai/__init__.py index 568fe062..d5dc923a 100755 --- a/nonebot_plugin_marshoai/__init__.py +++ b/nonebot_plugin_marshoai/__init__.py @@ -1,3 +1,27 @@ +""" +MIT License + +Copyright (c) 2025 Asankilp & LiteyukiStudio + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + from nonebot.plugin import require require("nonebot_plugin_alconna") diff --git a/nonebot_plugin_marshoai/config.py b/nonebot_plugin_marshoai/config.py index 156c27b1..a5b40742 100644 --- a/nonebot_plugin_marshoai/config.py +++ b/nonebot_plugin_marshoai/config.py @@ -16,7 +16,7 @@ class ConfigModel(BaseModel): marshoai_aliases: list[str] = [ "小棉", ] - marshoai_main_colour: str = "FFAAAA" + marshoai_main_colour: str = "FEABA9" marshoai_default_model: str = "gpt-4o-mini" marshoai_prompt: str = ( "你是一只可爱的猫娘,你的生日是9月6日,你喜欢晒太阳,撒娇,吃零食,玩耍等等可爱的事情,偶尔会调皮一下," diff --git a/nonebot_plugin_marshoai/config_example.yaml b/nonebot_plugin_marshoai/config_example.yaml index ddd0d38d..eaa97b8d 100644 --- a/nonebot_plugin_marshoai/config_example.yaml +++ b/nonebot_plugin_marshoai/config_example.yaml @@ -8,7 +8,7 @@ marshoai_aliases: marshoai_at: false # 决定是否开启at响应 -marshoai_main_colour: "FFAAAA" # 默认主色,部分插件和功能使用 +marshoai_main_colour: "FEABA9" # 默认主色,部分插件和功能使用 marshoai_default_model: "gpt-4o-mini" # 默认模型,设定为gpt-4o-mini。 # 主提示词,定义了Marsho的性格和行为,包含多语言名字翻译规则和对特定问题的回答约束。 diff --git a/nonebot_plugin_marshoai/plugins_test/marshoai_basic/__init__.py b/nonebot_plugin_marshoai/plugins_test/marshoai_basic/__init__.py index ef51a019..93d3415e 100755 --- a/nonebot_plugin_marshoai/plugins_test/marshoai_basic/__init__.py +++ b/nonebot_plugin_marshoai/plugins_test/marshoai_basic/__init__.py @@ -13,15 +13,17 @@ __marsho_meta__ = PluginMetadata( ) +weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"] + + @on_function_call(description="获取当前时间,日期和星期") async def get_current_time() -> str: """获取当前的时间和日期""" - current_time = DateTime.now().strftime("%Y.%m.%d %H:%M:%S") - current_weekday = DateTime.now().weekday() + current_time = DateTime.now() - weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"] - current_weekday_name = weekdays[current_weekday] - - current_lunar_date = DateTime.now().to_lunar().date_hanzify()[5:] - time_prompt = f"现在的时间是 {current_time},{current_weekday_name},农历 {current_lunar_date}。" + time_prompt = "现在的时间是 {},{},{}。".format( + current_time.strftime("%Y.%m.%d %H:%M:%S"), + weekdays[current_time.weekday()], + current_time.chinesize.date_hanzify("农历{干支年}{生肖}年 {月份}月{数序日}"), + ) return time_prompt diff --git a/nonebot_plugin_marshoai/util.py b/nonebot_plugin_marshoai/util.py index 904c9eeb..35789d2b 100755 --- a/nonebot_plugin_marshoai/util.py +++ b/nonebot_plugin_marshoai/util.py @@ -30,7 +30,7 @@ NOT_GIVEN = NotGiven() # 时间参数相关 if config.marshoai_enable_time_prompt: _weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"] - _time_prompt = "现在的时间是{date_time},{weekday_name},农历{lunar_date}。" + _time_prompt = "现在的时间是{date_time}{weekday_name},{lunar_date}。" # noinspection LongLine @@ -254,8 +254,7 @@ async def refresh_nickname_json(): def get_prompt(): """获取系统提示词""" - prompts = "" - prompts += config.marshoai_additional_prompt + prompts = config.marshoai_additional_prompt if config.marshoai_enable_praises: praises_prompt = build_praises() prompts += praises_prompt @@ -266,8 +265,8 @@ def get_prompt(): "%Y年%m月%d日 %H:%M:%S" ), weekday_name=_weekdays[current_time.weekday()], - lunar_date=current_time.to_lunar().date_hanzify( - "{干支年}{生肖}年{月份}月{日期}日" + lunar_date=current_time.chinesize.date_hanzify( + "农历{干支年}{生肖}年{月份}月{日期}" ), ) diff --git a/pyproject.toml b/pyproject.toml index 9b111367..16c9436d 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ dependencies = [ "nonebot2>=2.4.0", "nonebot-plugin-alconna>=0.48.0", "nonebot-plugin-localstore>=0.7.1", - "zhDatetime>=1.1.1", + "zhDatetime>=2.0.0", "aiohttp>=3.9", "httpx>=0.27.0", "ruamel.yaml>=0.18.6", diff --git a/resources/README.md b/resources/README.md index d181a050..8b834bc4 100755 --- a/resources/README.md +++ b/resources/README.md @@ -1,4 +1,6 @@ # Marsho Resources +> Copyright (c) 2025 [@Asankilp](https://github.com/Asankilp) + 本目录存放 Marsho 的图像资源(logo, icon),均由[Asankilp](https://github.com/Asankilp)绘制。\ 上述所有资源均在[CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/)许可下提供。