From 7f0e16c7f2f968b467ba0cabc99eff16bb789d0f Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 19 Jun 2024 20:47:36 +0800 Subject: [PATCH] fix: miyoushe splash --- config.gen.ini | 1 + defs/splash.py | 8 ++++++-- modules/repeater.py | 14 ++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/config.gen.ini b/config.gen.ini index e375433..9a649cc 100644 --- a/config.gen.ini +++ b/config.gen.ini @@ -25,3 +25,4 @@ amap_key = ABCD bili_cookie = ABCD bili_auth_user = 777000,111000 bili_auth_chat = 777000,111000 +mys_cookie = ABCD diff --git a/defs/splash.py b/defs/splash.py index b3b7338..257ed93 100644 --- a/defs/splash.py +++ b/defs/splash.py @@ -7,7 +7,7 @@ from pyrogram.enums import ParseMode from pyrogram.errors import FloodWait from pyrogram.types import InlineQueryResultCachedPhoto -from defs.glover import splash_channel, splash_channel_username +from defs.glover import splash_channel, splash_channel_username, config from defs.request import cache_file from init import bot, request, logger from models.models.splash import Splash as SplashModel @@ -16,7 +16,11 @@ from models.services.splash import SplashService async def get_splash() -> List[SplashApi]: - data = await request.get("https://bbs-api.miyoushe.com/apihub/api/getAppSplash") + mys_cookie = config.get("api", "mys_cookie", fallback="") + headers = { + "cookie": mys_cookie, + } + data = await request.get("https://bbs-api.miyoushe.com/apihub/api/getAppSplash", headers=headers) splash_list = [] if data.is_success: data = data.json() diff --git a/modules/repeater.py b/modules/repeater.py index a1f4581..8b4f492 100644 --- a/modules/repeater.py +++ b/modules/repeater.py @@ -17,7 +17,7 @@ async def repeater_handler(client: Client, message: Message): try: last_msg[group_id] except KeyError: - last_msg[group_id] = "" + last_msg[group_id] = {} try: last_repeat_msg[group_id] except KeyError: @@ -34,8 +34,14 @@ async def repeater_handler(client: Client, message: Message): ): raise ContinuePropagation - if msg != last_msg[group_id] or msg == last_repeat_msg[group_id]: - last_msg[group_id] = msg + last_msg_text = last_msg[group_id].get("text", "") + last_msg_id = last_msg[group_id].get("id", 0) + + if message.id == last_msg_id: + raise ContinuePropagation + + if msg != last_msg_text or msg == last_repeat_msg[group_id]: + last_msg[group_id] = {"text": msg, "id": message.id} repeat_count[group_id] = 0 else: repeat_count[group_id] += 1 @@ -43,6 +49,6 @@ async def repeater_handler(client: Client, message: Message): if repeat_count[group_id] >= 2: await client.send_message(group_id, t_msg) repeat_count[group_id] = 0 - last_msg[group_id] = "" + last_msg[group_id] = {} last_repeat_msg[group_id] = msg raise ContinuePropagation