🐛 修复 sign 自动签到添加问题

This commit is contained in:
xtaodada 2022-08-06 15:37:43 +08:00
parent 44e13edced
commit ccbcfedfa7
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 6 additions and 3 deletions

View File

@ -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"<a href=\"tg://user?id={sign_db.user_id}\">NOTICE {sign_db.user_id}</a>\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

View File

@ -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 "开启自动签到成功"