mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
✨myb自动获取
添加提示,修复抽卡记录百分比显示问题
This commit is contained in:
parent
cae77e6b75
commit
a43f589527
@ -3,7 +3,9 @@ import datetime
|
|||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
|
from nonebot import get_bot
|
||||||
from LittlePaimon.database.models import PrivateCookie, MihoyoBBSSub, LastQuery
|
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
|
||||||
@ -57,6 +59,12 @@ mihoyo_bbs_List = [
|
|||||||
'name': '崩坏:星穹铁道',
|
'name': '崩坏:星穹铁道',
|
||||||
'url': 'https://bbs.mihoyo.com/sr/',
|
'url': 'https://bbs.mihoyo.com/sr/',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'id': '8',
|
||||||
|
'forumId': '57',
|
||||||
|
'name': '绝区零',
|
||||||
|
'url': 'https://bbs.mihoyo.com/zzz/'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -96,7 +104,7 @@ class MihoyoBBSCoin:
|
|||||||
self.is_valid: bool = True
|
self.is_valid: bool = True
|
||||||
self.state: str = ''
|
self.state: str = ''
|
||||||
|
|
||||||
async def run(self) -> (bool, str):
|
async def run(self) -> Tuple[bool, str]:
|
||||||
"""
|
"""
|
||||||
执行米游币获取任务
|
执行米游币获取任务
|
||||||
:return: 获取消息
|
:return: 获取消息
|
||||||
@ -304,14 +312,40 @@ async def bbs_auto_coin():
|
|||||||
if not subs:
|
if not subs:
|
||||||
return
|
return
|
||||||
logger.info('米游币自动获取', f'开始执行米游币自动获取,共<m>{len(subs)}</m>个任务,预计花费<m>{round(75 * len(subs) / 60, 2)}</m>分钟')
|
logger.info('米游币自动获取', f'开始执行米游币自动获取,共<m>{len(subs)}</m>个任务,预计花费<m>{round(75 * len(subs) / 60, 2)}</m>分钟')
|
||||||
coin_result = defaultdict(list)
|
coin_result_group = defaultdict(list)
|
||||||
|
coin_result_private = defaultdict(list)
|
||||||
for sub in subs:
|
for sub in subs:
|
||||||
result = await mhy_bbs_coin(str(sub.user_id), sub.uid)
|
result = await mhy_bbs_coin(str(sub.user_id), sub.uid)
|
||||||
coin_result[sub.group_id].append({
|
if sub.user_id != sub.group_id:
|
||||||
|
coin_result_group[sub.group_id].append({
|
||||||
'user_id': sub.user_id,
|
'user_id': sub.user_id,
|
||||||
'uid': sub.uid,
|
'uid': sub.uid,
|
||||||
'result': '出错' not in result and 'Cookie' not in result
|
'result': '出错' not in result and 'Cookie' not in result
|
||||||
})
|
})
|
||||||
|
else:
|
||||||
|
coin_result_private[sub.user_id].append({
|
||||||
|
'uid': sub.uid,
|
||||||
|
'result': '出错' not in result and 'Cookie' not in result,
|
||||||
|
'msg': result
|
||||||
|
})
|
||||||
await asyncio.sleep(random.randint(3, 6))
|
await asyncio.sleep(random.randint(3, 6))
|
||||||
|
|
||||||
logger.info('米游币自动获取', f'签到完成,共花费<m>{round((time.time() - t) / 60, 2)}</m>分钟')
|
for group_id, result_list in coin_result_group.items():
|
||||||
|
result_num = len(result_list)
|
||||||
|
result_fail = len([result for result in result_list if not result['result']])
|
||||||
|
msg = f'本群米游币自动获取共{result_num}个任务,其中成功{result_num-result_fail}个,失败{result_fail}个,失败的UID列表:\n{"\n".join(result["uid"] for result in result_list if not result["result"])}'
|
||||||
|
try:
|
||||||
|
await get_bot().send_group_msg(group_id=int(group_id), message=msg)
|
||||||
|
except Exception as e:
|
||||||
|
logger.info('米游币自动获取', '➤➤', {'群': group_id}, f'发送米游币自动结果失败: {e}', False)
|
||||||
|
await asyncio.sleep(random.randint(3, 6))
|
||||||
|
|
||||||
|
for user_id, result_list in coin_result_private.items():
|
||||||
|
for result in result_list:
|
||||||
|
try:
|
||||||
|
await get_bot().send_private_msg(user_id=int(user_id), message=result['msg'])
|
||||||
|
except Exception as e:
|
||||||
|
logger.info('米游币自动获取', '➤➤', {'用户': user_id}, f'发送米游币自动结果失败: {e}', False)
|
||||||
|
await asyncio.sleep(random.randint(3, 6))
|
||||||
|
|
||||||
|
logger.info('米游币自动获取', f'获取完成,共花费<m>{round((time.time() - t) / 60, 2)}</m>分钟')
|
||||||
|
@ -105,6 +105,7 @@ async def bbs_auto_sign():
|
|||||||
await get_bot().send_group_msg(group_id=int(group_id), message=img)
|
await get_bot().send_group_msg(group_id=int(group_id), message=img)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info('米游社原神签到', '➤➤', {'群': group_id}, f'发送签到结果失败: {e}', False)
|
logger.info('米游社原神签到', '➤➤', {'群': group_id}, f'发送签到结果失败: {e}', False)
|
||||||
|
await asyncio.sleep(random.randint(3, 6))
|
||||||
|
|
||||||
for user_id, sign_result in sign_result_private.items():
|
for user_id, sign_result in sign_result_private.items():
|
||||||
for result in sign_result:
|
for result in sign_result:
|
||||||
@ -115,6 +116,7 @@ async def bbs_auto_sign():
|
|||||||
f'{"" if result["result"] == SignResult.FAIL else ",获得奖励:" + result["reward"]}')
|
f'{"" if result["result"] == SignResult.FAIL else ",获得奖励:" + result["reward"]}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info('米游社原神签到', '➤➤', {'用户': user_id}, f'发送签到结果失败: {e}', False)
|
logger.info('米游社原神签到', '➤➤', {'用户': user_id}, f'发送签到结果失败: {e}', False)
|
||||||
|
await asyncio.sleep(random.randint(3, 6))
|
||||||
|
|
||||||
logger.info('米游社原神签到', f'签到完成,共花费<m>{round((time.time() - t) / 60, 2)}</m>分钟')
|
logger.info('米游社原神签到', f'签到完成,共花费<m>{round((time.time() - t) / 60, 2)}</m>分钟')
|
||||||
|
|
||||||
|
@ -115,6 +115,8 @@ async def check_note():
|
|||||||
result_log += '银币'
|
result_log += '银币'
|
||||||
if result_log:
|
if result_log:
|
||||||
logger.info('原神实时便签', '➤', {'用户': sub.user_id, 'UID': sub.uid}, f'{result_log}达到了阈值,发送提醒', True)
|
logger.info('原神实时便签', '➤', {'用户': sub.user_id, 'UID': sub.uid}, f'{result_log}达到了阈值,发送提醒', True)
|
||||||
|
else:
|
||||||
|
logger.info('原神实时便签', '➤➤', {'用户': sub.user_id, 'UID': sub.uid}, '检查完成,未达到阈值', True)
|
||||||
if result:
|
if result:
|
||||||
sub.last_remind_time = datetime.datetime.now()
|
sub.last_remind_time = datetime.datetime.now()
|
||||||
sub.today_remind_num += 1
|
sub.today_remind_num += 1
|
||||||
@ -128,8 +130,8 @@ async def check_note():
|
|||||||
message=f'⚠️你的UID{sub.uid}{result}记得清理哦⚠️')
|
message=f'⚠️你的UID{sub.uid}{result}记得清理哦⚠️')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info('原神实时便签', '➤➤', {'用户': sub.user_id, 'UID': sub.uid}, f'发送提醒失败,{e}', False)
|
logger.info('原神实时便签', '➤➤', {'用户': sub.user_id, 'UID': sub.uid}, f'发送提醒失败,{e}', False)
|
||||||
# 等待2至4秒再检查下一个,防止检查过快
|
# 等待一会再检查下一个,防止检查过快
|
||||||
await asyncio.sleep(random.randint(2, 4))
|
await asyncio.sleep(random.randint(4, 8))
|
||||||
logger.info('原神实时便签', f'树脂检查完成,共花费<m>{round((time.time() - t) / 60, 2)}</m>分钟')
|
logger.info('原神实时便签', f'树脂检查完成,共花费<m>{round((time.time() - t) / 60, 2)}</m>分钟')
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,20 +172,20 @@ async def draw_gacha_log(user_id: str, uid: str, nickname: Optional[str], signat
|
|||||||
await img.text(str(total_five_star_count), (789, 884), 286, fm.get('bahnschrift_regular', 48), '#040404', 'center')
|
await img.text(str(total_five_star_count), (789, 884), 286, fm.get('bahnschrift_regular', 48), '#040404', 'center')
|
||||||
four_star_detail = await draw_four_star_detail(list(data4.values()))
|
four_star_detail = await draw_four_star_detail(list(data4.values()))
|
||||||
if total_five_star_count:
|
if total_five_star_count:
|
||||||
chara_pool_per = round(len(data5['角色祈愿']) / total_five_star_count, 3)
|
chara_pool_per = round(len(data5['角色祈愿']) / total_five_star_count * 100, 3)
|
||||||
weapon_pool_per = round(len(data5['武器祈愿']) / total_five_star_count, 3)
|
weapon_pool_per = round(len(data5['武器祈愿']) / total_five_star_count * 100, 3)
|
||||||
new_pool_per = round((len(data5['常驻祈愿']) + len(data5['新手祈愿'])) / total_five_star_count, 3)
|
new_pool_per = round((len(data5['常驻祈愿']) + len(data5['新手祈愿'])) / total_five_star_count * 100, 3)
|
||||||
now_used_width = 56
|
now_used_width = 56
|
||||||
pers = [chara_pool_per, weapon_pool_per, new_pool_per]
|
pers = [chara_pool_per, weapon_pool_per, new_pool_per]
|
||||||
i = 0
|
i = 0
|
||||||
for per in pers:
|
for per in pers:
|
||||||
if per >= 0.03:
|
if per >= 3:
|
||||||
await img.draw_rectangle((now_used_width, 399, now_used_width + int(per * 967), 446),
|
await img.draw_rectangle((now_used_width, 399, now_used_width + int(per / 100 * 967), 446),
|
||||||
bar_color[i][0])
|
bar_color[i][0])
|
||||||
if per >= 0.1:
|
if per >= 10:
|
||||||
await img.text(f'{per * 100}%', now_used_width + 18, 410, fm.get('bahnschrift_regular', 30, 'Bold'),
|
await img.text(f'{per}%', now_used_width + 18, 410, fm.get('bahnschrift_regular', 30, 'Bold'),
|
||||||
bar_color[i][1])
|
bar_color[i][1])
|
||||||
now_used_width += int(per * 967)
|
now_used_width += int(per / 100 * 967)
|
||||||
i += 1
|
i += 1
|
||||||
await img.paste(await load_image(RESOURCE_BASE_PATH / 'gacha_log' / 'text.png'), (484, 464))
|
await img.paste(await load_image(RESOURCE_BASE_PATH / 'gacha_log' / 'text.png'), (484, 464))
|
||||||
now_height = 525
|
now_height = 525
|
||||||
|
Loading…
Reference in New Issue
Block a user