mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-07 04:03:45 +08:00
🎨 优化米游社相关操作
This commit is contained in:
parent
e305293e0c
commit
4f21d66dec
@ -1,9 +1,10 @@
|
||||
import time
|
||||
import random
|
||||
import asyncio
|
||||
from copy import deepcopy
|
||||
from typing import Dict, Literal
|
||||
|
||||
from httpx import AsyncClient
|
||||
|
||||
from gsuid_core.logger import logger
|
||||
|
||||
from ..utils.mys_api import mys_api
|
||||
@ -102,10 +103,10 @@ class MihoyoBBSCoin:
|
||||
await self.load_mihoyo_bbs_list_use()
|
||||
start = await self.get_tasks_list()
|
||||
self.postsList = await self.get_list()
|
||||
sign = await self.signing()
|
||||
read = await self.read_posts()
|
||||
like = await self.like_posts()
|
||||
share = await self.share_post()
|
||||
sign = await self.signing()
|
||||
if start and sign and read and like and share:
|
||||
im = '\n'.join([start, sign, read, like, share])
|
||||
return im
|
||||
@ -199,6 +200,7 @@ class MihoyoBBSCoin:
|
||||
if self.Task_do['bbs_Sign']:
|
||||
return 'SignM已经完成过了~'
|
||||
else:
|
||||
logger.info('开始执行米游社签到......')
|
||||
header = deepcopy(self.headers)
|
||||
for i in self.mihoyobbs_List_Use:
|
||||
header['DS'] = get_ds_token('', {'gids': i['id']}, '22')
|
||||
@ -209,9 +211,11 @@ class MihoyoBBSCoin:
|
||||
{'gids': i['id']},
|
||||
)
|
||||
if 'err' not in data['message']:
|
||||
time.sleep(random.randint(2, 8))
|
||||
await asyncio.sleep(random.randint(2, 8))
|
||||
else:
|
||||
return '你的Cookies已失效。'
|
||||
logger.warning(f'米游社签到 [game_id: {i["id"]}] 失败...')
|
||||
await asyncio.sleep(random.randint(9, 30))
|
||||
continue
|
||||
return 'SignM:完成!'
|
||||
|
||||
# 看帖子
|
||||
@ -219,6 +223,7 @@ class MihoyoBBSCoin:
|
||||
if self.Task_do['bbs_Read_posts']:
|
||||
return 'ReadM已经完成过了~'
|
||||
else:
|
||||
logger.info('开始执行米游社看帖......')
|
||||
num_ok = 0
|
||||
for i in range(self.Task_do['bbs_Read_posts_num']):
|
||||
data = await self._request(
|
||||
@ -228,7 +233,7 @@ class MihoyoBBSCoin:
|
||||
)
|
||||
if data['message'] == 'OK':
|
||||
num_ok += 1
|
||||
time.sleep(random.randint(2, 8))
|
||||
await asyncio.sleep(random.randint(2, 8))
|
||||
return 'ReadM:成功!Read:{}!'.format(str(num_ok))
|
||||
|
||||
# 点赞
|
||||
@ -236,6 +241,7 @@ class MihoyoBBSCoin:
|
||||
if self.Task_do['bbs_Like_posts']:
|
||||
return 'LikeM任务已经完成过了~'
|
||||
else:
|
||||
logger.info('开始执行米游社点赞......')
|
||||
num_ok = 0
|
||||
num_cancel = 0
|
||||
for i in range(self.Task_do['bbs_Like_posts_num']):
|
||||
@ -252,7 +258,7 @@ class MihoyoBBSCoin:
|
||||
num_ok += 1
|
||||
# 判断取消点赞是否打开
|
||||
if True:
|
||||
time.sleep(random.randint(2, 8))
|
||||
await asyncio.sleep(random.randint(2, 8))
|
||||
data = await self._request(
|
||||
'POST',
|
||||
BBS_LIKE_URL,
|
||||
@ -264,16 +270,15 @@ class MihoyoBBSCoin:
|
||||
)
|
||||
if data['message'] == 'OK':
|
||||
num_cancel += 1
|
||||
time.sleep(random.randint(2, 8))
|
||||
return 'LikeM:完成!like:{}, dislike:{}!'.format(
|
||||
str(num_ok), str(num_cancel)
|
||||
)
|
||||
await asyncio.sleep(random.randint(2, 8))
|
||||
return f'LikeM:完成!like:{num_ok}, dislike:{num_cancel}!'
|
||||
|
||||
# 分享操作
|
||||
async def share_post(self):
|
||||
if self.Task_do['bbs_Share']:
|
||||
return 'ShareM已经完成过了~'
|
||||
else:
|
||||
logger.info('开始执行米游社分享......')
|
||||
for _ in range(3):
|
||||
data = await self._request(
|
||||
'GET',
|
||||
@ -283,8 +288,8 @@ class MihoyoBBSCoin:
|
||||
if data['message'] == 'OK':
|
||||
return 'ShareM:完成!'
|
||||
else:
|
||||
time.sleep(random.randint(2, 8))
|
||||
time.sleep(random.randint(2, 8))
|
||||
await asyncio.sleep(random.randint(2, 8))
|
||||
await asyncio.sleep(random.randint(2, 8))
|
||||
|
||||
async def _request(
|
||||
self,
|
||||
|
@ -107,7 +107,10 @@ async def send_char_cost(bot: Bot, ev: Event):
|
||||
|
||||
@sv_wiki_text.on_prefix(('武器材料'))
|
||||
async def send_weapon_cost(bot: Bot, ev: Event):
|
||||
im = await weapon_costs_wiki(ev.text)
|
||||
if gsconfig.get_config('PicWiki').data:
|
||||
im = await get_weapons_wiki_img(ev.text)
|
||||
else:
|
||||
im = await weapon_costs_wiki(ev.text)
|
||||
await bot.send(im)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user