diff --git a/konabot/plugins/solar_terms/__init__.py b/konabot/plugins/solar_terms/__init__.py new file mode 100644 index 0000000..cb34105 --- /dev/null +++ b/konabot/plugins/solar_terms/__init__.py @@ -0,0 +1,31 @@ +from borax.calendars import LunarDate +from nonebot_plugin_alconna import UniMessage +from nonebot_plugin_apscheduler import scheduler + +from konabot.common.llm import get_llm +from konabot.plugins.poster.poster_info import PosterInfo, register_poster_info +from konabot.plugins.poster.service import broadcast + +register_poster_info("二十四节气", PosterInfo( + {"节气", "24节气"}, + "当有新的节气时,报告节气信息", +)) + + +@scheduler.scheduled_job("cron", hour="8") +async def _(): + today = LunarDate.today() + term: str | None = today.term + + if term is not None: + llm = get_llm("qwen3-max") + prompt = f"请写两个四字词语,讲讲节气:{term}。以感叹号结尾,格式是「某某某某,某某某某!」,不要带有其他内容。" + result = await llm.chat([{ + "role": "user", "content": prompt, + }]) + result = result.content + if result is None: + result = "" + + await broadcast("二十四节气", UniMessage.text(f"【今日节气】今天是 {term} 哦!{result}")) + diff --git a/poetry.lock b/poetry.lock index 7aad563..87aba8a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -750,6 +750,22 @@ type = "legacy" url = "https://pypi.tuna.tsinghua.edu.cn/simple" reference = "mirrors" +[[package]] +name = "borax" +version = "4.1.3" +description = "A tool collections.(Chinese-Lunar-Calendars/Python-Patterns)" +optional = false +python-versions = ">=3.9" +groups = ["main"] +files = [ + {file = "borax-4.1.3-py3-none-any.whl", hash = "sha256:bdba9abe1c3be4ba1b6a014b3b4a97a7ba254a08c7f40cd4428a13b84db02558"}, +] + +[package.source] +type = "legacy" +url = "https://pypi.tuna.tsinghua.edu.cn/simple" +reference = "mirrors" + [[package]] name = "brotli" version = "1.2.0" @@ -5126,4 +5142,4 @@ reference = "mirrors" [metadata] lock-version = "2.1" python-versions = ">=3.12,<4.0" -content-hash = "4caff431bad39bc7fb0dd2685ed64394f2bf960660b017897b8d00a8137d32f5" +content-hash = "15e51d7d14d091295e7d0ecabaa601fd65ae392fce28f90d5f3deb4718544e17" diff --git a/pyproject.toml b/pyproject.toml index efcb8ae..5071753 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ dependencies = [ "pypinyin (>=0.55.0,<0.56.0)", "shapely (>=2.1.2,<3.0.0)", "mcstatus (>=12.2.1,<13.0.0)", + "borax (>=4.1.3,<5.0.0)", ] [tool.poetry]