mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
fix mute and open_case
This commit is contained in:
parent
81e4bca9ef
commit
fe2c82b03c
@ -249,7 +249,9 @@ __Docker 最新版本由 [Sakuracio](https://github.com/Sakuracio) 提供__
|
|||||||
* 修复原神玩家查询没开地图时报错
|
* 修复原神玩家查询没开地图时报错
|
||||||
* 最低priority修改为 999
|
* 最低priority修改为 999
|
||||||
* 修复刷屏检测失效
|
* 修复刷屏检测失效
|
||||||
|
* 修复刷屏检测设置命令无法生效
|
||||||
* 优化刷屏显示设置禁言时长显示,并改为分钟
|
* 优化刷屏显示设置禁言时长显示,并改为分钟
|
||||||
|
* 修复了多连开箱无法指定武器箱
|
||||||
|
|
||||||
### 2022/5/19
|
### 2022/5/19
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ mute_setting = on_command(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_data() -> Dict[Any]:
|
def get_data() -> Dict[Any, Any]:
|
||||||
try:
|
try:
|
||||||
with open(DATA_PATH / "group_mute_data.json", "r", encoding="utf8") as f:
|
with open(DATA_PATH / "group_mute_data.json", "r", encoding="utf8") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
@ -134,9 +134,10 @@ async def _(bot: Bot, event: GroupMessageEvent):
|
|||||||
|
|
||||||
@mute_setting.handle()
|
@mute_setting.handle()
|
||||||
async def _(event: GroupMessageEvent, cmd: Tuple[str, ...] = Command(), arg: Message = CommandArg()):
|
async def _(event: GroupMessageEvent, cmd: Tuple[str, ...] = Command(), arg: Message = CommandArg()):
|
||||||
|
global mute_data
|
||||||
group_id = str(event.group_id)
|
group_id = str(event.group_id)
|
||||||
if not mute_data.get(group_id):
|
if not mute_data.get(group_id):
|
||||||
mute_data[group_id] = {"count": 10, "time": 7, "duration": 0}
|
mute_data[group_id] = {"count": Config.get_config("mute", "MUTE_DEFAULT_COUNT"), "time": Config.get_config("mute", "MUTE_DEFAULT_TIME"), "duration": Config.get_config("mute", "MUTE_DEFAULT_DURATION")}
|
||||||
msg = arg.extract_plain_text().strip()
|
msg = arg.extract_plain_text().strip()
|
||||||
if cmd[0] == "刷屏检测设置":
|
if cmd[0] == "刷屏检测设置":
|
||||||
await mute_setting.finish(
|
await mute_setting.finish(
|
||||||
@ -147,17 +148,18 @@ async def _(event: GroupMessageEvent, cmd: Tuple[str, ...] = Command(), arg: Mes
|
|||||||
)
|
)
|
||||||
if not is_number(msg):
|
if not is_number(msg):
|
||||||
await mute.finish("设置的参数必须是数字啊!", at_sender=True)
|
await mute.finish("设置的参数必须是数字啊!", at_sender=True)
|
||||||
if cmd[0] == "设置检测时间":
|
if cmd[0] == "设置刷屏检测时间":
|
||||||
mute_data[group_id]["time"] = int(msg)
|
mute_data[group_id]["time"] = int(msg)
|
||||||
msg += "秒"
|
msg += "秒"
|
||||||
if cmd[0] == "设置检测次数":
|
if cmd[0] == "设置刷屏检测次数":
|
||||||
mute_data[group_id]["count"] = int(msg)
|
mute_data[group_id]["count"] = int(msg)
|
||||||
msg += " 次"
|
msg += " 次"
|
||||||
if cmd[0] == "设置禁言时长":
|
if cmd[0] == "设置刷屏禁言时长":
|
||||||
mute_data[group_id]["duration"] = int(msg)
|
mute_data[group_id]["duration"] = int(msg)
|
||||||
msg += " 分钟"
|
msg += " 分钟"
|
||||||
await mute_setting.send(f'刷屏检测:{cmd[0]}为 {msg}')
|
await mute_setting.send(f'刷屏检测:{cmd[0]}为 {msg}')
|
||||||
logger.info(
|
logger.info(
|
||||||
f'USER {event.user_id} GROUP {group_id} {cmd[0]}:{msg}'
|
f'USER {event.user_id} GROUP {group_id} {cmd[0]}:{msg}'
|
||||||
)
|
)
|
||||||
|
print(mute_data)
|
||||||
save_data()
|
save_data()
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
from typing import Type
|
from typing import Type, Tuple, Any
|
||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from utils.utils import scheduler, is_number
|
from utils.utils import scheduler, is_number
|
||||||
@ -9,7 +9,7 @@ from nonebot.permission import SUPERUSER
|
|||||||
import random
|
import random
|
||||||
from nonebot.plugin import MatcherGroup
|
from nonebot.plugin import MatcherGroup
|
||||||
from configs.path_config import IMAGE_PATH
|
from configs.path_config import IMAGE_PATH
|
||||||
from nonebot.params import CommandArg
|
from nonebot.params import CommandArg, RegexGroup
|
||||||
from .open_cases_c import (
|
from .open_cases_c import (
|
||||||
open_case,
|
open_case,
|
||||||
total_open_statistics,
|
total_open_statistics,
|
||||||
@ -145,12 +145,12 @@ async def _(event: GroupMessageEvent):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
open_shilian: Type[Matcher] = cases_matcher_group.on_regex("(.*)连开箱(.*?)")
|
open_shilian: Type[Matcher] = cases_matcher_group.on_regex("(.*)连开箱(.*)?")
|
||||||
|
|
||||||
|
|
||||||
@open_shilian.handle()
|
@open_shilian.handle()
|
||||||
async def _(event: GroupMessageEvent, state: T_State):
|
async def _(event: GroupMessageEvent, state: T_State, reg_group: Tuple[Any, ...] = RegexGroup()):
|
||||||
num = state["_matched_groups"][0].strip()
|
num, case_name = reg_group
|
||||||
if is_number(num) or num_dict.get(num):
|
if is_number(num) or num_dict.get(num):
|
||||||
try:
|
try:
|
||||||
num = num_dict[num]
|
num = num_dict[num]
|
||||||
@ -162,7 +162,6 @@ async def _(event: GroupMessageEvent, state: T_State):
|
|||||||
await open_shilian.finish("再负开箱就扣你明天开箱数了!", at_sender=True)
|
await open_shilian.finish("再负开箱就扣你明天开箱数了!", at_sender=True)
|
||||||
else:
|
else:
|
||||||
await open_shilian.finish("必须要是数字切不要超过30啊笨蛋!中文也可!", at_sender=True)
|
await open_shilian.finish("必须要是数字切不要超过30啊笨蛋!中文也可!", at_sender=True)
|
||||||
case_name = state["_matched_groups"][1].strip()
|
|
||||||
case_name = case_name.replace("武器箱", "").strip()
|
case_name = case_name.replace("武器箱", "").strip()
|
||||||
if not case_name:
|
if not case_name:
|
||||||
case_name = random.choice(cases_name)
|
case_name = random.choice(cases_name)
|
||||||
|
|||||||
@ -25,7 +25,7 @@ async def get_saucenao_image(url: str) -> Union[str, List[str]]:
|
|||||||
}
|
}
|
||||||
data = (await AsyncHttpx.post(API_URL_SAUCENAO, params=params)).json()
|
data = (await AsyncHttpx.post(API_URL_SAUCENAO, params=params)).json()
|
||||||
if data["header"]["status"] != 0:
|
if data["header"]["status"] != 0:
|
||||||
return "Saucenao识图失败.."
|
return f"Saucenao识图失败..status:{data['header']['status']}"
|
||||||
data = data["results"]
|
data = data["results"]
|
||||||
data = (
|
data = (
|
||||||
data
|
data
|
||||||
|
|||||||
@ -14,7 +14,6 @@ async def check(bot: Bot, event: Event, state: T_State) -> bool:
|
|||||||
for img_file in list_img:
|
for img_file in list_img:
|
||||||
strinfo = re.compile(f"{img_file},subType=\d*]")
|
strinfo = re.compile(f"{img_file},subType=\d*]")
|
||||||
msg = strinfo.sub(f'{img_file}]', msg)
|
msg = strinfo.sub(f'{img_file}]', msg)
|
||||||
print(msg)
|
|
||||||
return bool(
|
return bool(
|
||||||
await WordBank.check(event.group_id, msg, event.is_tome())
|
await WordBank.check(event.group_id, msg, event.is_tome())
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user