🐛 签到和米游币记录uid

This commit is contained in:
CMHopeSunshine 2022-08-29 19:41:45 +08:00
parent 185484cad6
commit 3cbfe8e9d2
2 changed files with 8 additions and 2 deletions

View File

@ -1,9 +1,10 @@
import asyncio import asyncio
import datetime
import random import random
import time import time
from collections import defaultdict from collections import defaultdict
from LittlePaimon.database.models import PrivateCookie, MihoyoBBSSub from LittlePaimon.database.models import PrivateCookie, MihoyoBBSSub, LastQuery
from LittlePaimon.utils import logger, aiorequests from LittlePaimon.utils import logger, aiorequests
from LittlePaimon.utils import scheduler from LittlePaimon.utils import scheduler
from LittlePaimon.utils.api import random_text, random_hex, get_old_version_ds, get_ds from LittlePaimon.utils.api import random_text, random_hex, get_old_version_ds, get_ds
@ -283,6 +284,8 @@ async def mhy_bbs_coin(user_id: str, uid: str) -> str:
return '你尚未绑定Cookie和Stoken请先用ysb指令绑定' return '你尚未绑定Cookie和Stoken请先用ysb指令绑定'
elif cookie.stoken is None: elif cookie.stoken is None:
return '你绑定Cookie中没有login_ticket请重新用ysb指令绑定' return '你绑定Cookie中没有login_ticket请重新用ysb指令绑定'
await LastQuery.update_or_create(user_id=user_id,
defaults={'uid': uid, 'last_time': datetime.datetime.now()})
logger.info('米游币自动获取', '➤执行', {'用户': user_id, 'UID': uid, '的米游币获取': '......'}) logger.info('米游币自动获取', '➤执行', {'用户': user_id, 'UID': uid, '的米游币获取': '......'})
get_coin_task = MihoyoBBSCoin(cookie.stoken) get_coin_task = MihoyoBBSCoin(cookie.stoken)
result, msg = await get_coin_task.run() result, msg = await get_coin_task.run()

View File

@ -1,11 +1,12 @@
import asyncio import asyncio
import datetime
import random import random
import time import time
from nonebot import get_bot from nonebot import get_bot
from collections import defaultdict from collections import defaultdict
from typing import Tuple from typing import Tuple
from LittlePaimon import DRIVER from LittlePaimon import DRIVER
from LittlePaimon.database.models import MihoyoBBSSub from LittlePaimon.database.models import MihoyoBBSSub, LastQuery
from LittlePaimon.utils import logger, scheduler from LittlePaimon.utils import logger, scheduler
from LittlePaimon.utils.api import get_mihoyo_private_data, get_sign_reward_list from LittlePaimon.utils.api import get_mihoyo_private_data, get_sign_reward_list
from LittlePaimon.manager.plugin_manager import plugin_manager as pm from LittlePaimon.manager.plugin_manager import plugin_manager as pm
@ -21,6 +22,8 @@ async def mhy_bbs_sign(user_id: str, uid: str) -> Tuple[SignResult, str]:
:param uid: 原神uid :param uid: 原神uid
:return: 签到成功天数或失败原因 :return: 签到成功天数或失败原因
""" """
await LastQuery.update_or_create(user_id=user_id,
defaults={'uid': uid, 'last_time': datetime.datetime.now()})
sign_info = await get_mihoyo_private_data(uid, user_id, 'sign_info') sign_info = await get_mihoyo_private_data(uid, user_id, 'sign_info')
if isinstance(sign_info, str): if isinstance(sign_info, str):
logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, '未绑定私人cookie', False) logger.info('米游社原神签到', '', {'用户': user_id, 'UID': uid}, '未绑定私人cookie', False)