Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新戳一戳语录 #33

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@
"description": "戳一戳发送语音美图萝莉图不美哉?",
"usage": "戳一戳随机掉落语音或美图萝莉图",
"author": "HibiKier",
"version": "0.1-eb2b7db",
"version": "0.1-5fbfdd5",
"plugin_type": "DEPENDANT",
"is_dir": true
},
Expand Down Expand Up @@ -405,7 +405,7 @@
"description": "嗨嗨,这里是小记者真寻哦",
"usage": "真寻日报",
"author": "HibiKier",
"version": "0.1",
"version": "0.1-606459a",
"plugin_type": "NORMAL",
"is_dir": true
}
Expand Down
21 changes: 18 additions & 3 deletions plugins/mahiro_report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from zhenxun.utils.platform import broadcast_group
from zhenxun.services.plugin_init import PluginInit
from zhenxun.configs.path_config import TEMPLATE_PATH
from zhenxun.configs.utils import Task, PluginExtraData
from zhenxun.configs.utils import Task, PluginExtraData, RegisterConfig
from zhenxun.configs.config import Config # 引入 Config 用于获取 ALAPI_TOKEN

from .config import REPORT_PATH
from .data_source import Report
Expand All @@ -30,9 +31,17 @@
""".strip(),
extra=PluginExtraData(
author="HibiKier",
version="0.1",
version="0.1-606459a",
superuser_help="""重置真寻日报""",
tasks=[Task(module="mahiro_report", name="真寻日报")],
configs=[ # 添加配置项提示用户如何获取和填写ALAPI_TOKEN
RegisterConfig(
module="alapi",
key="ALAPI_TOKEN",
value=None,
help="在https://admin.alapi.cn/user/login登录后获取token",
)
]
).dict(),
)

Expand All @@ -57,6 +66,12 @@ async def _(session: EventSession, arparma: Arparma):

@_matcher.handle()
async def _(session: EventSession, arparma: Arparma):
# 检查 ALAPI_TOKEN 是否存在
alapi_token = Config.get_config("alapi", "ALAPI_TOKEN")
if not alapi_token:
await MessageUtils.build_message("缺失ALAPI TOKEN,请在config.yaml中填写!").send(at_sender=True)
return # 停止执行

try:
await MessageUtils.build_message(await Report.get_report_image()).send()
logger.info("查看真寻日报", arparma.header_result, session=session)
Expand Down Expand Up @@ -99,7 +114,7 @@ async def _():
logger.info("自动生成日报成功...")
break
except TimeoutError:
logger.warning("自动是生成日报失败...")
logger.warning("自动生成日报失败...")


@scheduler.scheduled_job(
Expand Down
23 changes: 16 additions & 7 deletions plugins/mahiro_report/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@

from zhenxun.utils.http_utils import AsyncHttpx
from zhenxun.utils._build_image import BuildImage
from zhenxun.configs.config import Config
from zhenxun.configs.path_config import TEMPLATE_PATH

from .config import REPORT_PATH, Anime, SixData, Hitokoto, favs_arr, favs_list
from .config import REPORT_PATH, Anime, Hitokoto, favs_arr, favs_list


class Report:
hitokoto_url = "https://v1.hitokoto.cn/?c=a"
six_url = "https://60s.viki.moe/?v2=1"
game_url = "https://www.4gamers.com.tw/rss/latest-news"
six_url = "https://v2.alapi.cn/api/zaobao"
bili_url = "https://s.search.bilibili.com/main/hotword"
it_url = "https://www.ithome.com/rss/"
anime_url = "https://api.bgm.tv/calendar"

week = { # noqa: RUF012
week = {
0: "一",
1: "二",
2: "三",
Expand Down Expand Up @@ -97,9 +97,16 @@ async def get_bili(cls) -> list[str]:
@classmethod
async def get_six(cls) -> list[str]:
"""获取60s看时间数据"""
res = await AsyncHttpx.get(cls.six_url)
data = SixData(**res.json())
return data.data.news[:11] if len(data.data.news) > 11 else data.data.news
token = Config.get_config("alapi", "ALAPI_TOKEN")#从配置中获取alapi
payload = {"token": token, "format": "json"}
headers = {'Content-Type': "application/x-www-form-urlencoded"}
res = await AsyncHttpx.post(cls.six_url, data=payload, headers=headers)
if res.status_code == 200:
data = res.json()
news_items = data.get("data", {}).get("news", [])
return news_items[:11] if len(news_items) > 11 else news_items
else:
return ["Error: Unable to fetch data"]

@classmethod
async def get_it(cls) -> list[str]:
Expand All @@ -113,6 +120,7 @@ async def get_it(cls) -> list[str]:
titles.append(title_element.text)
return titles[:11] if len(titles) > 11 else titles


@classmethod
async def get_anime(cls) -> list[tuple[str, str]]:
"""获取动漫数据"""
Expand All @@ -125,3 +133,4 @@ async def get_anime(cls) -> list[tuple[str, str]]:
anime = Anime(**res.json()[-1])
data_list.extend((data.name_cn or data.name, data.image) for data in anime.items)
return data_list[:8] if len(data_list) > 8 else data_list

18 changes: 17 additions & 1 deletion plugins/poke/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
""".strip(),
extra=PluginExtraData(
author="HibiKier",
version="0.1-eb2b7db",
version="0.1-5fbfdd5",
menu_type="其他",
plugin_type=PluginType.NORMAL,
).dict(),
Expand All @@ -49,6 +49,22 @@
"正在关闭对您的所有服务...关闭成功",
"啊呜,太舒服刚刚竟然睡着了。什么事?",
"正在定位您的真实地址...定位成功。轰炸机已起飞",
"别戳了,别戳了,真寻的呆毛要掉拉!",
"我在呢!",
"你是来找小真寻玩的嘛?",
"别急呀,小真寻要宕机了!QAQ",
"你好!Ov<",
"你再戳我要喊美波里给你下药了!",
"别戳了,怕疼QwQ",
"再戳,小真寻就要咬你了嗷~",
"恶龙咆哮,嗷呜~",
"生气(╯▔皿▔)╯",
"不要这样子啦(*/ w \*)",
"戳坏了",
"戳坏了,赔钱!",
"喂,110吗,有人老戳我",
"别戳小真寻啦,您歇会吧~",
"喂(#`O′) 戳小真寻干嘛!",
]


Expand Down