From 0c2dcacaaccd476597d3d489b3a9743a079b3cd4 Mon Sep 17 00:00:00 2001
From: CMHopeSunshine <277073121@qq.com>
Date: Fri, 7 Oct 2022 11:23:13 +0800
Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E`myb=E5=85=A8?=
=?UTF-8?q?=E9=83=A8=E9=87=8D=E5=81=9A`=E8=B6=85=E7=AE=A1=E5=91=BD?=
=?UTF-8?q?=E4=BB=A4=EF=BC=8C=E5=8A=A0=E5=A4=A7`=E7=B1=B3=E6=B8=B8?=
=?UTF-8?q?=E5=B8=81=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96`=E6=97=B6?=
=?UTF-8?q?=E9=97=B4=E5=BB=B6=E8=BF=9F(=E8=AF=B7=E5=B0=9D=E8=AF=95?=
=?UTF-8?q?=E6=9B=B4=E6=8D=A2=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96=E6=97=B6?=
=?UTF-8?q?=E9=97=B4=E6=9D=A5=E5=A2=9E=E5=8A=A0=E6=88=90=E5=8A=9F=E7=8E=87?=
=?UTF-8?q?)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../plugins/Paimon_Autobbs/__init__.py | 18 +++++++++++++++--
.../plugins/Paimon_Autobbs/coin_handle.py | 20 +++++++++++--------
.../plugins/Paimon_Autobbs/sign_handle.py | 2 +-
3 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/LittlePaimon/plugins/Paimon_Autobbs/__init__.py b/LittlePaimon/plugins/Paimon_Autobbs/__init__.py
index 2fc32fc..4211ab2 100644
--- a/LittlePaimon/plugins/Paimon_Autobbs/__init__.py
+++ b/LittlePaimon/plugins/Paimon_Autobbs/__init__.py
@@ -1,6 +1,7 @@
from typing import Union
from nonebot import on_command
+from nonebot.rule import to_me
from nonebot.permission import SUPERUSER
from nonebot.adapters.onebot.v11 import GroupMessageEvent, PrivateMessageEvent
from nonebot.plugin import PluginMetadata
@@ -8,7 +9,7 @@ from nonebot.plugin import PluginMetadata
from LittlePaimon.database.models import MihoyoBBSSub, PrivateCookie
from LittlePaimon.utils import logger
from LittlePaimon.utils.message import CommandUID, CommandSwitch
-from .coin_handle import mhy_bbs_coin
+from .coin_handle import mhy_bbs_coin, bbs_auto_coin
from .sign_handle import mhy_bbs_sign, bbs_auto_sign
from .draw import draw_result
@@ -35,7 +36,7 @@ sign = on_command('mys签到', aliases={'米游社签到', 'mys自动签到', '
'pm_usage': '米游社签到(uid)[on|off]',
'pm_priority': 1
})
-all_sign = on_command('全部重签', priority=8, block=True, permission=SUPERUSER, state={
+all_sign = on_command('全部重签', priority=8, block=True, permission=SUPERUSER, rule=to_me(), state={
'pm_name': '米游社全部重签',
'pm_description': '重签全部米游社签到任务,需超级用户权限',
'pm_usage': '@Bot 全部重签',
@@ -49,6 +50,13 @@ get_coin = on_command('myb获取', aliases={'米游币获取', 'myb自动获取'
'pm_priority': 2
})
+all_coin = on_command('myb全部重做', priority=8, block=True, permission=SUPERUSER, rule=to_me(), state={
+ 'pm_name': '米游币获取全部重做',
+ 'pm_description': '重做全部米游币获取任务,需超级用户权限',
+ 'pm_usage': '@Bot myb全部重做',
+ 'pm_priority': 4
+ })
+
signing_list = []
coin_getting_list = []
@@ -134,3 +142,9 @@ async def _(event: Union[GroupMessageEvent, PrivateMessageEvent], uid=CommandUID
await sign.finish(f'UID{uid}关闭米游币自动获取成功', at_sender=True)
else:
await sign.finish(f'UID{uid}尚未开启米游币自动获取,无需关闭!', at_sender=True)
+
+
+@all_coin.handle()
+async def _(event: Union[GroupMessageEvent, PrivateMessageEvent]):
+ await all_coin.send('开始执行myb全部重做,需要一定时间...')
+ await bbs_auto_coin()
diff --git a/LittlePaimon/plugins/Paimon_Autobbs/coin_handle.py b/LittlePaimon/plugins/Paimon_Autobbs/coin_handle.py
index fa862df..fb16f0b 100644
--- a/LittlePaimon/plugins/Paimon_Autobbs/coin_handle.py
+++ b/LittlePaimon/plugins/Paimon_Autobbs/coin_handle.py
@@ -207,7 +207,7 @@ class MihoyoBBSCoin:
10001] else f"出错了:{data['retcode']} {data['message']}"
logger.info('米游币自动获取', f'➤➤{self.state}')
return self.state
- await asyncio.sleep(random.randint(3, 6))
+ await asyncio.sleep(random.randint(5, 10))
logger.info('米游币自动获取', '➤➤讨论区签到完成')
return '讨论区签到:完成!'
@@ -223,7 +223,7 @@ class MihoyoBBSCoin:
data = req.json()
if data['message'] == 'OK':
num_ok += 1
- await asyncio.sleep(random.randint(3, 6))
+ await asyncio.sleep(random.randint(5, 10))
logger.info('米游币自动获取', '➤➤看帖任务完成')
return f'浏览帖子:完成{str(num_ok)}个!'
@@ -246,7 +246,7 @@ class MihoyoBBSCoin:
if data['message'] == 'OK':
num_ok += 1
# 取消点赞
- await asyncio.sleep(random.randint(2, 4))
+ await asyncio.sleep(random.randint(3, 6))
req = await aiorequests.post(url=bbs_Likeurl,
headers=self.headers,
json={
@@ -257,7 +257,7 @@ class MihoyoBBSCoin:
if data['message'] == 'OK':
num_cancel += 1
logger.info('米游币自动获取', '➤➤点赞任务完成')
- await asyncio.sleep(random.randint(3, 6))
+ await asyncio.sleep(random.randint(5, 10))
return f'点赞帖子:完成{str(num_ok)}个!'
async def share_post(self):
@@ -274,9 +274,9 @@ class MihoyoBBSCoin:
if data['message'] == 'OK':
return '分享帖子:完成!'
else:
- await asyncio.sleep(random.randint(4, 7))
+ await asyncio.sleep(random.randint(5, 10))
logger.info('米游币自动获取', '➤➤分享任务完成')
- await asyncio.sleep(random.randint(3, 6))
+ await asyncio.sleep(random.randint(5, 10))
return '分享帖子:完成!'
@@ -301,6 +301,10 @@ async def mhy_bbs_coin(user_id: str, uid: str) -> str:
@scheduler.scheduled_job('cron', hour=pm.config.auto_myb_hour, minute=pm.config.auto_myb_minute, misfire_grace_time=10)
+async def _():
+ await bbs_auto_coin()
+
+
async def bbs_auto_coin():
"""
指定时间,执行所有米游币获取订阅任务, 并将结果分群绘图发送
@@ -311,7 +315,7 @@ async def bbs_auto_coin():
subs = await MihoyoBBSSub.filter(sub_event='米游币自动获取').all()
if not subs:
return
- logger.info('米游币自动获取', f'开始执行米游币自动获取,共{len(subs)}个任务,预计花费{round(75 * len(subs) / 60, 2)}分钟')
+ logger.info('米游币自动获取', f'开始执行米游币自动获取,共{len(subs)}个任务,预计花费{round(100 * len(subs) / 60, 2)}分钟')
coin_result_group = defaultdict(list)
coin_result_private = defaultdict(list)
for sub in subs:
@@ -328,7 +332,7 @@ async def bbs_auto_coin():
'result': '出错' not in result and 'Cookie' not in result,
'msg': result
})
- await asyncio.sleep(random.randint(3, 6))
+ await asyncio.sleep(random.randint(15, 25))
for group_id, result_list in coin_result_group.items():
result_num = len(result_list)
diff --git a/LittlePaimon/plugins/Paimon_Autobbs/sign_handle.py b/LittlePaimon/plugins/Paimon_Autobbs/sign_handle.py
index 06ffff7..ce410f5 100644
--- a/LittlePaimon/plugins/Paimon_Autobbs/sign_handle.py
+++ b/LittlePaimon/plugins/Paimon_Autobbs/sign_handle.py
@@ -124,7 +124,7 @@ async def bbs_auto_sign():
if not subs:
# 如果没有米游社原神签到订阅,则不执行签到任务
return
- logger.info('米游社原神签到', f'开始执行米游社自动签到,共{len(subs)}个任务,预计花费{round(100 * len(subs) / 60, 2)}分钟')
+ logger.info('米游社原神签到', f'开始执行米游社自动签到,共{len(subs)}个任务,预计花费{len(subs) * 2}分钟')
sign_result_group = defaultdict(list)
sign_result_private = defaultdict(list)
for sub in subs: