Merge branch 'main' of github.com:LiteyukiStudio/nonebot-plugin-marshoai

This commit is contained in:
远野千束(神羽) 2024-12-17 01:36:38 +08:00
commit d8ac06419b
7 changed files with 63 additions and 23 deletions

View File

@ -10,8 +10,9 @@
_✨ 使用 OpenAI 标准格式 API 的聊天机器人插件 ✨_ _✨ 使用 OpenAI 标准格式 API 的聊天机器人插件 ✨_
<a href="./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)
<img src="https://img.shields.io/github/license/LiteyukiStudio/nonebot-plugin-marshoai.svg" alt="license"> <a href="https://registry.nonebot.dev/plugin/nonebot-plugin-marshoai:nonebot_plugin_marshoai">
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-marshoai" alt="Supported Adapters">
</a> </a>
<a href="https://pypi.python.org/pypi/nonebot-plugin-marshoai"> <a href="https://pypi.python.org/pypi/nonebot-plugin-marshoai">
<img src="https://img.shields.io/pypi/v/nonebot-plugin-marshoai.svg" alt="pypi"> <img src="https://img.shields.io/pypi/v/nonebot-plugin-marshoai.svg" alt="pypi">

View File

@ -10,8 +10,9 @@
_✨ A chat bot plugin which use OpenAI standard API ✨_ _✨ A chat bot plugin which use OpenAI standard API ✨_
<a href="./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)
<img src="https://img.shields.io/github/license/LiteyukiStudio/nonebot-plugin-marshoai.svg" alt="license"> <a href="https://registry.nonebot.dev/plugin/nonebot-plugin-marshoai:nonebot_plugin_marshoai">
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-marshoai" alt="Supported Adapters">
</a> </a>
<a href="https://pypi.python.org/pypi/nonebot-plugin-marshoai"> <a href="https://pypi.python.org/pypi/nonebot-plugin-marshoai">
<img src="https://img.shields.io/pypi/v/nonebot-plugin-marshoai.svg" alt="pypi"> <img src="https://img.shields.io/pypi/v/nonebot-plugin-marshoai.svg" alt="pypi">

View File

@ -64,6 +64,13 @@ marsho_cmd = on_alconna(
priority=10, priority=10,
block=True, 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) marsho_at = on_message(rule=to_me() & at_enable, priority=11)
nickname_cmd = on_alconna( nickname_cmd = on_alconna(
Alconna( Alconna(
@ -208,6 +215,11 @@ async def refresh_data():
await refresh_data_cmd.finish("已刷新数据") await refresh_data_cmd.finish("已刷新数据")
@marsho_help_cmd.handle()
async def marsho_help():
await marsho_help_cmd.finish(metadata.usage)
@marsho_at.handle() @marsho_at.handle()
@marsho_cmd.handle() @marsho_cmd.handle()
async def marsho( async def marsho(
@ -225,8 +237,8 @@ async def marsho(
text = event.get_message() # type: ignore text = event.get_message() # type: ignore
if not text: if not text:
# 发送说明 # 发送说明
await UniMessage(metadata.usage + "\n当前使用的模型:" + model_name).send() # await UniMessage(metadata.usage + "\n当前使用的模型" + model_name).send()
await marsho_cmd.finish(INTRODUCTION) await marsho_cmd.finish(INTRODUCTION + "\n当前使用的模型:" + model_name)
try: try:
user_id = event.get_user_id() user_id = event.get_user_id()
nicknames = await get_nicknames() nicknames = await get_nicknames()

View File

@ -2,8 +2,7 @@ import re
from .config import config from .config import config
USAGE: str = f"""MarshoAI-NoneBot Beta by Asankilp USAGE: str = f"""用法:
用法
{config.marshoai_default_name} <聊天内容> : Marsho 进行对话当模型为 GPT-4o(-mini) 等时可以带上图片进行对话 {config.marshoai_default_name} <聊天内容> : Marsho 进行对话当模型为 GPT-4o(-mini) 等时可以带上图片进行对话
nickname [昵称] : 为自己设定昵称设置昵称后Marsho 会根据你的昵称进行回答使用'nickname reset'命令可清除自己设定的昵称 nickname [昵称] : 为自己设定昵称设置昵称后Marsho 会根据你的昵称进行回答使用'nickname reset'命令可清除自己设定的昵称
reset : 重置当前会话的上下文 需要加上命令前缀使用(默认为'/') reset : 重置当前会话的上下文 需要加上命令前缀使用(默认为'/')
@ -26,14 +25,12 @@ SUPPORT_IMAGE_MODELS: list = [
"llama-3.2-11b-vision-instruct", "llama-3.2-11b-vision-instruct",
] ]
REASONING_MODELS: list = ["o1-preview", "o1-mini"] REASONING_MODELS: list = ["o1-preview", "o1-mini"]
INTRODUCTION: str = """你好喵~我是一只可爱的猫娘AI名叫小棉~🐾! INTRODUCTION: str = f"""MarshoAI-NoneBot by LiteyukiStudio
我的代码在这里哦~ 你好喵~我是一只可爱的猫娘AI名叫小棉~🐾
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai 我的主页在这里哦~
https://marsho.liteyuki.icu
也可以关注一下还在成长中的 Melobot 酱喵~ 使用{config.marshoai_default_name}.help命令获取使用说明"""
https://github.com/Meloland/melobot
我与 Melobot 酱贴贴的代码在这里喵~
https://github.com/LiteyukiStudio/marshoai-melo"""
# 正则匹配代码块 # 正则匹配代码块

View File

@ -11,5 +11,5 @@ metadata = PluginMetadata(
config=ConfigModel, config=ConfigModel,
homepage="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai", homepage="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai",
supported_adapters=inherit_supported_adapters("nonebot_plugin_alconna"), 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"},
) )

View File

@ -2,12 +2,41 @@ import traceback
import httpx import httpx
from nonebot_plugin_marshoai.plugin import PluginMetadata from nonebot_plugin_marshoai.plugin import PluginMetadata, on_function_call
# 定义插件元数据
__marsho_meta__ = PluginMetadata( __marsho_meta__ = PluginMetadata(
name="Bangumi 番剧信息", name="Bangumi日历",
description="Bangumi 番剧信息", author="MarshoAI",
usage="Bangumi 番剧信息", description="这个插件可以帮助你获取Bangumi的日历信息~",
author="Liteyuki",
homepage="",
) )
@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 ""

View File

@ -27,7 +27,7 @@ dependencies = [
license = { text = "MIT, Mulan PSL v2" } license = { text = "MIT, Mulan PSL v2" }
[project.urls] [project.urls]
Homepage = "https://github.com/LiteyukiStudio/nonebot-plugin-marshoai" Homepage = "https://marsho.liteyuki.icu/"
[tool.nonebot] [tool.nonebot]