mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-16 12:51:45 +00:00
🔧 批量修复插件异常
This commit is contained in:
parent
a4b019a7d7
commit
a714fa3ebd
@ -17,12 +17,12 @@ class CookiesRepository:
|
||||
async with self.mysql.Session() as session:
|
||||
session = cast(AsyncSession, session)
|
||||
if region == RegionEnum.HYPERION:
|
||||
db_data = HyperionCookie(user_id=user_id, cookie=cookies)
|
||||
db_data = HyperionCookie(user_id=user_id, cookies=cookies)
|
||||
elif region == RegionEnum.HOYOLAB:
|
||||
db_data = HoyolabCookie(user_id=user_id, cookie=cookies)
|
||||
db_data = HoyolabCookie(user_id=user_id, cookies=cookies)
|
||||
else:
|
||||
raise RegionNotFoundError(region.name)
|
||||
await session.add(db_data)
|
||||
session.add(db_data)
|
||||
await session.commit()
|
||||
|
||||
async def update_cookies(self, user_id: int, cookies: dict, region: RegionEnum):
|
||||
@ -30,26 +30,19 @@ class CookiesRepository:
|
||||
session = cast(AsyncSession, session)
|
||||
if region == RegionEnum.HYPERION:
|
||||
statement = select(HyperionCookie).where(HyperionCookie.user_id == user_id)
|
||||
elif region == RegionEnum.HOYOLAB:
|
||||
statement = select(HoyolabCookie).where(HoyolabCookie.user_id == user_id)
|
||||
else:
|
||||
raise RegionNotFoundError(region.name)
|
||||
results = await session.exec(statement)
|
||||
db_cookies = results.one()[0]
|
||||
db_cookies = results.one()
|
||||
if db_cookies is None:
|
||||
raise CookiesNotFoundError(user_id)
|
||||
db_cookies = db_cookies[0]
|
||||
db_cookies.cookies = cookies
|
||||
session.add(db_cookies)
|
||||
await session.commit()
|
||||
await session.refresh(db_cookies)
|
||||
elif region == RegionEnum.HOYOLAB:
|
||||
statement = select(HyperionCookie).where(HyperionCookie.user_id == user_id)
|
||||
results = await session.add(statement)
|
||||
db_cookies = results.one()[0]
|
||||
if db_cookies is None:
|
||||
raise CookiesNotFoundError(user_id)
|
||||
db_cookies.cookie = cookies
|
||||
session.add(db_cookies)
|
||||
await session.commit()
|
||||
await session.refresh(db_cookies)
|
||||
else:
|
||||
raise RegionNotFoundError(region.name)
|
||||
|
||||
async def update_cookies_ex(self, cookies: Cookies, region: RegionEnum):
|
||||
async with self.mysql.Session() as session:
|
||||
|
@ -17,8 +17,10 @@ class UserRepository:
|
||||
session = cast(AsyncSession, session)
|
||||
statement = select(User).where(User.user_id == user_id)
|
||||
results = await session.exec(statement)
|
||||
user = results.first()
|
||||
if user := results.first():
|
||||
return user[0]
|
||||
else:
|
||||
raise UserNotFoundError(user_id)
|
||||
|
||||
async def update_user(self, user: User):
|
||||
async with self.mysql.Session() as session:
|
||||
|
@ -90,7 +90,7 @@ class Abyss(BasePlugins):
|
||||
abyss_data["most_played_list"].append(temp)
|
||||
return abyss_data
|
||||
|
||||
@restricts
|
||||
@restricts()
|
||||
@error_callable
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> None:
|
||||
user = update.effective_user
|
||||
|
@ -9,6 +9,7 @@ from telegram.helpers import escape_markdown
|
||||
|
||||
from apps.cookies.services import CookiesService
|
||||
from apps.user.models import User
|
||||
from apps.user.repositories import UserNotFoundError
|
||||
from apps.user.services import UserService
|
||||
from logger import Log
|
||||
from models.base import RegionEnum
|
||||
@ -77,7 +78,10 @@ class AddUser(BasePlugins):
|
||||
async def check_server(self, update: Update, context: CallbackContext) -> int:
|
||||
user = update.effective_user
|
||||
add_user_command_data: AddUserCommandData = context.chat_data.get("add_user_command_data")
|
||||
try:
|
||||
user_info = await self.user_service.get_user_by_id(user.id)
|
||||
except UserNotFoundError:
|
||||
user_info = None
|
||||
add_user_command_data.user = user_info
|
||||
if update.message.text == "退出":
|
||||
await update.message.reply_text("退出任务", reply_markup=ReplyKeyboardRemove())
|
||||
@ -188,11 +192,11 @@ class AddUser(BasePlugins):
|
||||
elif update.message.text == "确认":
|
||||
if add_user_command_data.user is None:
|
||||
if add_user_command_data.region == RegionEnum.HYPERION:
|
||||
user_db = User(user_id=user.id, yuanshen_id=add_user_command_data.game_uid,
|
||||
region=add_user_command_data)
|
||||
user_db = User(user_id=user.id, yuanshen_uid=add_user_command_data.game_uid,
|
||||
region=add_user_command_data.region)
|
||||
elif add_user_command_data.region == RegionEnum.HOYOLAB:
|
||||
user_db = User(user_id=user.id, genshin_id=add_user_command_data.game_uid,
|
||||
region=add_user_command_data)
|
||||
user_db = User(user_id=user.id, genshin_uid=add_user_command_data.game_uid,
|
||||
region=add_user_command_data.region)
|
||||
else:
|
||||
await update.message.reply_text("数据错误")
|
||||
return ConversationHandler.END
|
||||
|
@ -1,5 +1,6 @@
|
||||
import datetime
|
||||
import os
|
||||
from typing import Optional
|
||||
|
||||
from genshin import DataNotPublic
|
||||
from telegram import Update
|
||||
@ -88,9 +89,9 @@ class DailyNote(BasePlugins):
|
||||
{"width": 600, "height": 548}, full_page=False)
|
||||
return png_data
|
||||
|
||||
@restricts
|
||||
@restricts()
|
||||
@error_callable
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> None:
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> Optional[int]:
|
||||
user = update.effective_user
|
||||
message = update.message
|
||||
Log.info(f"用户 {user.full_name}[{user.id}] 查询游戏状态命令请求")
|
||||
|
@ -27,6 +27,7 @@ def check_ledger_month(context: CallbackContext) -> int:
|
||||
args = get_all_args(context)
|
||||
if len(args) >= 1:
|
||||
month = args[0]
|
||||
elif isinstance(month, int):
|
||||
pass
|
||||
elif re_data := re.findall(r"\d+", month):
|
||||
month = int(re_data[0])
|
||||
|
@ -74,7 +74,7 @@ async def get_genshin_client(user_id: int, user_service: UserService, cookies_se
|
||||
client = genshin.Client(cookies=cookies.cookies,
|
||||
game=types.Game.GENSHIN, region=types.Region.OVERSEAS, lang="zh-cn", uid=uid)
|
||||
else:
|
||||
raise TypeError(f"region is not RegionEnum.NULL")
|
||||
raise TypeError("region is not RegionEnum.NULL")
|
||||
return client
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user