support disable tos function
This commit is contained in:
parent
a238aa15eb
commit
3fb326f856
4 changed files with 18 additions and 7 deletions
|
@ -14,3 +14,4 @@ botarcapi_url =
|
|||
botarcapi_agent =
|
||||
tg_token =
|
||||
slower_schedule = False
|
||||
enable_tos = False
|
||||
|
|
|
@ -4,6 +4,7 @@ from datetime import datetime
|
|||
|
||||
from aiocqhttp.exceptions import ActionFailed
|
||||
|
||||
from config import Config
|
||||
from core.elements import MessageSession, Command, command_prefix, ExecutionLockList, RegexCommand, ErrorMessage
|
||||
from core.exceptions import AbuseWarning, FinishedException, InvalidCommandFormatError, InvalidHelpDocTypeError
|
||||
from core.loader import ModulesManager
|
||||
|
@ -13,6 +14,9 @@ from core.tos import warn_target
|
|||
from core.utils import removeIneffectiveText, removeDuplicateSpace
|
||||
from database import BotDBUtil
|
||||
|
||||
|
||||
enable_tos = Config('enable_tos')
|
||||
|
||||
counter_same = {} # 命令使用次数计数(重复使用单一命令)
|
||||
counter_all = {} # 命令使用次数计数(使用所有命令)
|
||||
|
||||
|
@ -210,7 +214,7 @@ async def parser(msg: MessageSession, require_enable_modules: bool = True, prefi
|
|||
continue
|
||||
except FinishedException as e:
|
||||
Logger.info(f'Successfully finished session from {identify_str}, returns: {str(e)}')
|
||||
if msg.target.targetFrom != 'QQ|Guild' or command_first_word != 'module':
|
||||
if msg.target.targetFrom != 'QQ|Guild' or command_first_word != 'module' and enable_tos:
|
||||
await msg_counter(msg, msg.trigger_msg)
|
||||
continue
|
||||
except Exception as e:
|
||||
|
@ -268,14 +272,16 @@ async def parser(msg: MessageSession, require_enable_modules: bool = True, prefi
|
|||
except FinishedException as e:
|
||||
Logger.info(
|
||||
f'Successfully finished session from {identify_str}, returns: {str(e)}')
|
||||
await msg_counter(msg, msg.trigger_msg)
|
||||
if enable_tos:
|
||||
await msg_counter(msg, msg.trigger_msg)
|
||||
continue
|
||||
ExecutionLockList.remove(msg)
|
||||
except AbuseWarning as e:
|
||||
await warn_target(msg, str(e))
|
||||
temp_ban_counter[msg.target.senderId] = {'count': 1,
|
||||
'ts': datetime.now().timestamp()}
|
||||
return
|
||||
if enable_tos:
|
||||
await warn_target(msg, str(e))
|
||||
temp_ban_counter[msg.target.senderId] = {'count': 1,
|
||||
'ts': datetime.now().timestamp()}
|
||||
return
|
||||
except Exception:
|
||||
Logger.error(traceback.format_exc())
|
||||
ExecutionLockList.remove(msg)
|
||||
|
|
|
@ -21,6 +21,7 @@ from .utils.rc import rc
|
|||
from .utils.rc_qq import rc_qq
|
||||
from .wikilib import WikiLib, WhatAreUDoingError, PageInfo, InvalidWikiError, QueryInfo
|
||||
|
||||
|
||||
wiki = on_command('wiki',
|
||||
alias={'wiki_start_site': 'wiki set',
|
||||
'interwiki': 'wiki iw'},
|
||||
|
|
|
@ -14,6 +14,8 @@ from core.logger import Logger
|
|||
from core.utils import get_url
|
||||
from .dbutils import WikiSiteInfo as DBSiteInfo, Audit
|
||||
|
||||
from config import Config
|
||||
|
||||
|
||||
class InvalidPageIDError(Exception):
|
||||
pass
|
||||
|
@ -364,7 +366,8 @@ class WikiLib:
|
|||
if self.wiki_info.in_blocklist and not self.wiki_info.in_allowlist:
|
||||
ban = True
|
||||
if _tried > 5:
|
||||
raise WhatAreUDoingError
|
||||
if Config('enable_tos'):
|
||||
raise WhatAreUDoingError
|
||||
section = None
|
||||
if title is not None:
|
||||
if title == '':
|
||||
|
|
Reference in a new issue