From dec072986120841e038c8e756e1a13a8271a4d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Wed, 25 Oct 2023 22:52:19 +0800 Subject: [PATCH] update tos --- config/config.toml.example | 1 + core/tos.py | 43 ++++++++++++++------------ locales/zh_cn.json | 4 ++- modules/coin/__init__.py | 2 -- modules/coin/locales/zh_cn.json | 3 +- modules/fish/__init__.py | 2 +- modules/fish/locales/zh_cn.json | 5 +-- modules/tic_tac_toe/locales/zh_cn.json | 10 +++--- 8 files changed, 37 insertions(+), 33 deletions(-) diff --git a/config/config.toml.example b/config/config.toml.example index 2de64c71..7df5caac 100644 --- a/config/config.toml.example +++ b/config/config.toml.example @@ -53,6 +53,7 @@ slower_schedule = false enable_dirty_check = true enable_urlmanager = true enable_tos = false +tos_waring_counts = 5 enable_analytics = true enable_eval = true enable_rickroll = true diff --git a/core/tos.py b/core/tos.py index c870e139..5dc68704 100644 --- a/core/tos.py +++ b/core/tos.py @@ -2,23 +2,25 @@ from config import Config from core.builtins import Bot from database import BotDBUtil +WARNING_COUNTS = int(Config('tos_waring_counts', 5)) async def warn_target(msg: Bot.MessageSession, reason=None): - current_warns = int(msg.target.sender_info.query.warns) + 1 - msg.target.sender_info.edit('warns', current_warns) - warn_template = [msg.locale.t("tos.warning")] - if reason is not None: - warn_template.append(msg.locale.t("tos.reason") + reason) - if current_warns < 5: - warn_template.append(msg.locale.t('tos.warning.count', current_warns=current_warns)) - if current_warns <= 2: - warn_template.append(msg.locale.t('tos.warning.appeal', issue_url=Config('issue_url'))) - if current_warns == 5: - warn_template.append(msg.locale.t('tos.warning.last')) - if current_warns > 5: - msg.target.sender_info.edit('isInBlockList', True) - return - await msg.send_message('\n'.join(warn_template)) + if WARNING_COUNTS >= 1: + current_warns = int(msg.target.sender_info.query.warns) + 1 + msg.target.sender_info.edit('warns', current_warns) + warn_template = [msg.locale.t("tos.warning")] + if reason is not None: + warn_template.append(msg.locale.t("tos.reason") + reason) + if current_warns < WARNING_COUNTS: + warn_template.append(msg.locale.t('tos.warning.count', current_warns=current_warns)) + if current_warns <= 2: + warn_template.append(msg.locale.t('tos.warning.appeal', issue_url=Config('issue_url'))) + if current_warns == WARNING_COUNTS: + warn_template.append(msg.locale.t('tos.warning.last')) + if current_warns > WARNING_COUNTS: + msg.target.sender_info.edit('isInBlockList', True) + return + await msg.send_message('\n'.join(warn_template)) async def pardon_user(user: str): @@ -26,8 +28,9 @@ async def pardon_user(user: str): async def warn_user(user: str, count=1): - current_warns = int(BotDBUtil.SenderInfo(user).query.warns) + count - BotDBUtil.SenderInfo(user).edit('warns', current_warns) - if current_warns > 5: - BotDBUtil.SenderInfo(user).edit('isInBlockList', True) - return current_warns + if WARNING_COUNTS >= 1: + current_warns = int(BotDBUtil.SenderInfo(user).query.warns) + count + BotDBUtil.SenderInfo(user).edit('warns', current_warns) + if current_warns > WARNING_COUNTS: + BotDBUtil.SenderInfo(user).edit('isInBlockList', True) + return current_warns diff --git a/locales/zh_cn.json b/locales/zh_cn.json index 823dd8a7..48570c38 100644 --- a/locales/zh_cn.json +++ b/locales/zh_cn.json @@ -49,7 +49,9 @@ "petal.message.gained.success": "获得了 ${amount} 片花瓣。", "petal.message.gained.limit": "但是,本日获得花瓣已达到每日上限,请明日再试。", "petal.message.lost.success": "失去了 ${amount} 片花瓣。", - "petal.message.lost.limit": "(本日失去花瓣已达到每日上限)", + "petal.message.lost.limit": "(本日失去花瓣已达到每日上限。)", + "game.message.stop": "已停止。", + "game.message.none": "当前游戏未在进行。", "success": "成功。", "tos.reason": "具体原因:", "tos.reason.abuse": "一段时间内使用命令的次数过多。", diff --git a/modules/coin/__init__.py b/modules/coin/__init__.py index 012738d1..5185c05f 100644 --- a/modules/coin/__init__.py +++ b/modules/coin/__init__.py @@ -99,8 +99,6 @@ async def skip_stone(msg: Bot.MessageSession): if count == 10: if g := gained_petal(msg, 2): send += '\n' + g - if count in [3, 5, 9]: - send += '\n' + msg.locale.t('eastereggs.message.1') await msg.finish(send) diff --git a/modules/coin/locales/zh_cn.json b/modules/coin/locales/zh_cn.json index 209c200d..cb61641a 100644 --- a/modules/coin/locales/zh_cn.json +++ b/modules/coin/locales/zh_cn.json @@ -19,6 +19,5 @@ "coin.message.tail": "…\n…是反面!", "stone.help.desc": "打水漂。", "stone.message.skip": "你扔了一块石头,漂了 ${count} 下。", - "stone.message.skip.nothing": "你扔了一块石头,什么也没发生。", - "eastereggs.message.1": "※ 这使你充满了决心。" + "stone.message.skip.nothing": "你扔了一块石头,什么也没发生。" } diff --git a/modules/fish/__init__.py b/modules/fish/__init__.py index c89adab0..bcfb7bd5 100644 --- a/modules/fish/__init__.py +++ b/modules/fish/__init__.py @@ -147,7 +147,7 @@ async def _(msg: Bot.MessageSession): await asyncio.create_task(timer(datetime.now().timestamp(), wait_time, hooked_time)) -@fish.handle('retract') +@fish.handle('retract {{fish.retract.help}}') @fish.regex(r'^(?:收杆|收)$') async def _(msg: Bot.MessageSession): if msg.target.target_id in play_state and play_state[msg.target.target_id]['active']: diff --git a/modules/fish/locales/zh_cn.json b/modules/fish/locales/zh_cn.json index a12abe9f..5666dcc9 100644 --- a/modules/fish/locales/zh_cn.json +++ b/modules/fish/locales/zh_cn.json @@ -1,6 +1,7 @@ { - "fish.help.desc": "钓鱼", - "fish.help": "抛竿/收竿", + "fish.help.desc": "钓鱼。", + "fish.help": "抛竿。", + "fish.retract.help": "收竿。", "fish.message.size.tiny": "特小", "fish.message.size.small": "稍小", "fish.message.size.medium": "中", diff --git a/modules/tic_tac_toe/locales/zh_cn.json b/modules/tic_tac_toe/locales/zh_cn.json index 9e646f92..960a618d 100644 --- a/modules/tic_tac_toe/locales/zh_cn.json +++ b/modules/tic_tac_toe/locales/zh_cn.json @@ -1,11 +1,11 @@ { "tic_tac_toe.help.desc": "下井字棋。", - "tic_tac_toe.help": "和(菜鸡)机器人下井字棋。不会获得花瓣。", + "tic_tac_toe.help": "和机器人下井字棋。", "tic_tac_toe.expert.help": "和专家级机器人下井字棋。", - "tic_tac_toe.master.help": "和大师级机器人下井字棋。可能获得花瓣,但是你不会赢。", - "tic_tac_toe.noob.help": "和一心只想让你赢的机器人下井字棋。不会获得花瓣。", - "tic_tac_toe.duo.help": "双人(也可以是多人)对战井字棋。不会获得花瓣。", - "tic_tac_toe.message.turn": "请 ${player} 落子。", + "tic_tac_toe.master.help": "和大师级机器人下井字棋。", + "tic_tac_toe.noob.help": "和菜鸟级机器人下井字棋。", + "tic_tac_toe.duo.help": "双人对战井字棋。", + "tic_tac_toe.message.turn": "请 ${player} 落子。\n(发送数字以确定要落子的位置)", "tic_tac_toe.stop.message": "已停止。", "tic_tac_toe.stop.message.none": "当前没有游戏正在进行。", "tic_tac_toe.message.draw": "游戏已结束,平局。",