From ccbcfedfa747e8ddac7639291a8033167ec71b8e Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 6 Aug 2022 15:37:43 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=20`sign`=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=AD=BE=E5=88=B0=E6=B7=BB=E5=8A=A0=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jobs/sign.py | 5 ++++- plugins/sign.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/jobs/sign.py b/jobs/sign.py index e381e76..fe2fd4e 100644 --- a/jobs/sign.py +++ b/jobs/sign.py @@ -3,6 +3,7 @@ import time from aiohttp import ClientConnectorError from genshin import Game, GenshinException, AlreadyClaimed, InvalidCookies +from telegram.constants import ParseMode from telegram.error import BadRequest, Forbidden from telegram.ext import CallbackContext, JobQueue @@ -80,8 +81,10 @@ class SignJob: except BaseException as exc: Log.error(f"执行自动签到时发生错误", exc) continue + if sign_db.chat_id < 0: + text = f"NOTICE {sign_db.user_id}\n\n{text}" try: - await context.bot.send_message(sign_db.chat_id, text) + await context.bot.send_message(sign_db.chat_id, text, parse_mode=ParseMode.HTML) except BadRequest as exc: Log.error(f"执行自动签到时发生错误", exc) sign_db.status = SignStatusEnum.BAD_REQUEST diff --git a/plugins/sign.py b/plugins/sign.py index 168382d..5bffbbe 100644 --- a/plugins/sign.py +++ b/plugins/sign.py @@ -7,7 +7,7 @@ from telegram.ext import CommandHandler, MessageHandler, ConversationHandler, fi from apps.cookies.services import CookiesService from apps.sign.services import SignServices -from apps.sign.models import Sign as SignUser +from apps.sign.models import Sign as SignUser, SignStatusEnum from apps.user.repositories import UserNotFoundError from apps.user.services import UserService from logger import Log @@ -99,7 +99,7 @@ class Sign(BasePlugins): elif method == "关闭": return "您还没有开启自动签到" elif method == "开启": - user = SignUser(user_id=user_id, chat_id=chat_id) + user = SignUser(user_id=user_id, chat_id=chat_id, status=SignStatusEnum.STATUS_SUCCESS) await self.sign_service.add(user) return "开启自动签到成功"