Skip to content
This repository has been archived by the owner on May 22, 2022. It is now read-only.

[Feature request] 防止冻结以及补偿刀计算 #74

Closed
HsuJv opened this issue May 13, 2020 · 2 comments
Closed

[Feature request] 防止冻结以及补偿刀计算 #74

HsuJv opened this issue May 13, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@HsuJv
Copy link

HsuJv commented May 13, 2020

  1. 登录操作的回应容易触发qq冻结机制 #28, [Feature request] 超级管理员可以手动为群友设置密码及其它 #57 的所有的需求, 其实最简单的规避冻结的方法就是减少如登录, 密码等敏感词汇, 尤其是和url一起发送时. 今早测试的时候发现单纯的web_hint也导致了一次冻结, 期望能将所有返回url的功能中的提示符去除
    image
    图上的消息导致了一次异常行为被检测, 然后冻结

  2. 希望新增补偿刀计算功能, 目前已实现一个简易版本, 有没有可能合到official里? (p.s. 懒得发PR了, 还要统一代码风格)

root@myserver:~/pcr/yobot# git show
commit 9d5a501212978ca379174d99148e2086e295eb1b (HEAD -> master)
Author: root <[email protected]>
Date:   Wed May 13 04:57:09 2020 +0000

    myhack

diff --git a/src/client/ybplugins/custom.py b/src/client/ybplugins/custom.py
index 1ad821b..d0ded95 100644
--- a/src/client/ybplugins/custom.py
+++ b/src/client/ybplugins/custom.py
@@ -20,6 +20,8 @@ from typing import Any, Dict, Union
 from aiocqhttp.api import Api
 from apscheduler.schedulers.asyncio import AsyncIOScheduler
 from quart import Quart
+import re
+from math import ceil
 
 
 class Custom:
@@ -43,7 +45,7 @@ class Custom:
         # 此时没有running_loop,不要直接使用await或asyncio.creat_task
 
         # 如果需要启用,请注释掉下面一行
-        return
+        #return
 
         # 这是来自yobot_config.json的设置,如果需要增加设置项,请修改default_config.json文件
         self.setting = glo_setting
@@ -60,6 +62,8 @@ class Custom:
         # @app.route('/is-bot-running', methods=['GET'])
         # async def check_bot():
         #     return 'yes, bot is running'
+        self.pre_re = re.compile("撞刀 ?(\d+) (\d+) (\d+)")
+        self.pre_help = re.compile("撞刀.*")
 
     async def execute_async(self, ctx: Dict[str, Any]) -> Union[None, bool, str]:
         '''
@@ -70,17 +74,36 @@ class Custom:
         # 注意:这是一个异步函数,禁止使用阻塞操作(比如requests)
 
         # 如果需要使用,请注释掉下面一行
-        return
+        #return
 
         cmd = ctx['raw_message']
-        if cmd == '你好':
+        match = re.match(self.pre_re, cmd)
+        if match:
 
             # 调用api发送消息,详见cqhttp文档
-            await self.api.send_private_msg(
-                user_id=123456, message='收到问好')
+            #await self.api.send_private_msg(
+            #    user_id=123456, message='收到问好')
 
             # 返回字符串:发送消息并阻止后续插件
-            return '世界'
+            # return '世界'
+            boss = int(match.group(1))
+            damage = int(match.group(2))
+            left = int(match.group(3))
+
+            if left > 90: left = 90
+
+            compensate = ceil(90 - (boss / (damage / (90 - left))) + 10)
+            ret1 =  "获得补偿: " + str(compensate) + "秒"
+            if (compensate < 90) :
+                dps = damage / 90
+                boss = int(dps * 10.999999)
+                ret2 = "控制血线低于" + str(boss) + "可获得90秒补偿"
+                if (compensate < 10) :
+                    return "无法击败boss\n" + ret2
+                return ret1 + "\n" + ret2
+            return ret1
+        elif re.match(self.pre_help, cmd):
+            return "发送 '撞刀 boss血量 伤害量 剩余时间'"
 
         # 返回布尔值:是否阻止后续插件(返回None视作False)
         return False
diff --git a/src/client/ybplugins/login.py b/src/client/ybplugins/login.py
index aca7018..afd5b36 100644
--- a/src/client/ybplugins/login.py
+++ b/src/client/ybplugins/login.py
@@ -72,10 +72,9 @@ class Login:
             }
         reply = ''
         if match_num == 1:
-            reply = f'{self._get_login_code_url(ctx)}' \
-                '\n如显示已被使用,可发送 重置密码,之后用密码登录\n※ 请及时设置一个登录密码以避免无法获取登录链接时无法登录'
+            reply = f'{self._get_login_code_url(ctx)}' 
         elif match_num == 3:
-            reply = f'您的密码已重置为临时密码:{self._reset_pwd(ctx)},登录后请立刻修改'
+            reply = f'临时:{self._reset_pwd(ctx)}'
         else:
             assert False, f"没有实现匹配码{match_num}对应的操作"

实际使用情况如下
image

Hint: 剩余时间可以设为默认0, 但是当撞刀的时候结算方那一刀能在90秒实际击败boss时, 就需要填写剩余血量作为辅助计算了, 例如
image

@yuudi
Copy link
Owner

yuudi commented May 13, 2020

  1. 感谢反馈,目前暂时可以用重置密码指令避免
  2. 项目不再增加功能了(不再增加新功能了 #8

@yuudi yuudi added the enhancement New feature or request label May 13, 2020
@HsuJv
Copy link
Author

HsuJv commented May 13, 2020

  1. 全局搜下来 (grep -rn "return.*url" --include="*.py") 还有这种地方, 感觉也是容易触发风控的.
    image, 可以在某次bugfix里顺便改掉

@yuudi yuudi closed this as completed May 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants