Archived
1
0
Fork 0

add wa safecheck

This commit is contained in:
多羅狼 2024-01-27 18:39:05 +08:00 committed by GitHub
parent f3150a3951
commit 26960be27e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 38 additions and 26 deletions

View file

@ -1,17 +1,17 @@
{
"dice.help": "Roll the specified dice. You can specify the number of dice rolls and DC check.",
"dice.help.desc": "Random dice.",
"dice.help.rule": "Modify the check rule of DC.",
"dice.help.option.dc": "Check when the result of each roll. If the result meets the DC, the check is a success, otherwise is a failure.",
"dice.help.option.klx": "The output of the smallest sum of x dice points.",
"dice.help.option.kx": "The output of the biggest sum of x dice points.",
"dice.help.option.m": "The number of dice, output The sum of all its points, default 1.",
"dice.help.option.N": "Repeat the polynomial operation N times (roll N times) and then output N results.",
"dice.help.option.n": "The number of sides of the dice.",
"dice.help.option.N": "Repeat the polynomial operation N times (roll N times) and then output N results.",
"dice.help.option.polynomial": "Format \"[<N>x][<m>]d<n>[k(l)<x>][±<y>]...\", e.g., \"10d4-2d20\" will output the sum of the points of 10 4-sided dice minus the sum of the points of 2 20-sided dice.",
"dice.help.option.polynomial.title": "Polynomial",
"dice.help.option.y": "The polynomial can be an integer (adjustment value). e.g., \"d20+5\" will output the result of adding 5 to the number of a 20-sided die.",
"dice.help.regex.desc": "(扔|投|掷|丢)<m>个[<n>面]骰子 Roll the specified dice.",
"dice.help.rule": "Modify the check rule of DC.",
"dice.message.dc.check": "▷ Check Success: ${success} Check Failure: ${failed}",
"dice.message.dc.failed": " Failed!",
"dice.message.dc.success": " Success!",
@ -29,15 +29,15 @@
"dice.message.error.value.m.invalid": "Invalid number of dice.",
"dice.message.error.value.n.d1": "D...D1?",
"dice.message.error.value.n.invalid": "Invalid number of sides of the die.",
"dice.message.error.value.n.out_of_range": "The number of dice cannot be less than 1 or greater than ${max}.",
"dice.message.error.value.n.less_2": "The number of sides of the die cannot be less than 2.",
"dice.message.error.value.N.out_of_range": "The number of die rolls cannot be less than 1 or greater than ${max}.",
"dice.message.error.value.n.out_of_range": "The number of dice cannot be less than 1 or greater than ${max}.",
"dice.message.error.value.too_long": "The number of items in the dice polynomial exceeds the limit.",
"dice.message.error.value.y.invalid": "Invalid adjustment value",
"dice.message.error.value.y.out_of_range": "The adjustment value cannot be less than ${min} or greater than ${max}.",
"dice.message.output": "Your result: ",
"dice.message.output.too_long": "${length} items have been omitted",
"dice.message.rule.disable": "The check rule has been changed to forward.",
"dice.message.rule.enable": "The check rule has been changed to reverse.",
"dice.message.too_long": "Output is too long...",
"dice.message.error.value.y.invalid": "Invalid adjustment value",
"dice.message.error.value.y.out_of_range": "The adjustment value cannot be less than ${min} or greater than ${max}.",
"dice.message.error.value.n.less_2": "The number of sides of the die cannot be less than 2."
}
"dice.message.too_long": "Output is too long..."
}

View file

@ -1,17 +1,17 @@
{
"dice.help": "投掷指定骰子,可指定投骰次数与 DC 判断判定。",
"dice.help.desc": "随机骰子。",
"dice.help.rule": "修改 DC 的判定规则。",
"dice.help.option.dc": "在每一次投掷输出结果时进行判定,若结果符合 DC 则判定为成功,否则判定失败。",
"dice.help.option.klx": "表示输出其最小的 x 个骰子点数之和。",
"dice.help.option.kx": "表示输出其最大的 x 个骰子点数之和。",
"dice.help.option.m": "表示骰子数量,输出其所有点数之和,省略则默认 1。",
"dice.help.option.N": "将多项式的操作重复 N 次(投骰 N 次),之后输出 N 个结果。",
"dice.help.option.n": "表示骰子面数。",
"dice.help.option.N": "将多项式的操作重复 N 次(投骰 N 次),之后输出 N 个结果。",
"dice.help.option.polynomial": "格式为“[<N>x][<m>]d<n>[k(l)<x>][±<y>]...”如“10d4-2d20”会输出 10 个 4 面骰所有点数之和减去 2 个 20 面骰点数之和。",
"dice.help.option.polynomial.title": "多项式",
"dice.help.option.y": "多项式中可以是整数即调节值如“d20+5”会输出 1 个 20 面骰的点数加上 5 的结果。",
"dice.help.regex.desc": "(扔|投|掷|丢)<m>个[<n>面]骰子[<N>次] 投掷指定骰子。",
"dice.help.rule": "修改 DC 的判定规则。",
"dice.message.dc.check": "▷ 判定成功数量:${success} 判定失败数量:${failed}",
"dice.message.dc.failed": " 判定失败!",
"dice.message.dc.success": " 判定成功!",
@ -29,15 +29,15 @@
"dice.message.error.value.m.invalid": "无效的骰子数量。",
"dice.message.error.value.n.d1": "1……1 面的骰子?",
"dice.message.error.value.n.invalid": "无效的骰子面数。",
"dice.message.error.value.n.out_of_range": "骰子数量不得小于 1 或大于 ${max}。",
"dice.message.error.value.n.less_2": "骰子面数不得小于 2。",
"dice.message.error.value.N.out_of_range": "投骰次数不得小于 1 或大于 ${max}。",
"dice.message.error.value.n.out_of_range": "骰子数量不得小于 1 或大于 ${max}。",
"dice.message.error.value.too_long": "骰子多项式项数超过限制。",
"dice.message.error.value.y.invalid": "无效的调节值项。",
"dice.message.error.value.y.out_of_range": "调节值不得小于 ${min} 或大于 ${max}。",
"dice.message.output": "你掷得的结果是:",
"dice.message.output.too_long": "数量过大,已省略 ${length} 条数据",
"dice.message.rule.disable": "判定规则已更改为正向。",
"dice.message.rule.enable": "判定规则已更改为反向。",
"dice.message.too_long": "输出过长……",
"dice.message.error.value.y.invalid": "无效的调节值项。",
"dice.message.error.value.y.out_of_range": "调节值不得小于 ${min} 或大于 ${max}。",
"dice.message.error.value.n.less_2": "骰子面数不得小于 2。"
"dice.message.too_long": "输出过长……"
}

View file

@ -1,17 +1,17 @@
{
"dice.help": "投擲指定骰子,可指定投骰次數與 dc 判斷判定。",
"dice.help.desc": "隨機骰子。",
"dice.help.rule": "修改 DC 的判定規則。",
"dice.help.option.dc": "在每一次投擲輸出結果時進行判定,若結果符合 DC 則判定成功,否則判定失敗。",
"dice.help.option.klx": "表示輸出其最小之 x 個骰子點數之和。",
"dice.help.option.kx": "表示輸出其最大之 x 個骰子點數之和。",
"dice.help.option.m": "表示骰子數量,輸出其所有點數之和,省略則預設 1。",
"dice.help.option.N": "將多項式的行為重複 N 次(投骰 N 次),之後輸出 N 個結果。",
"dice.help.option.n": "表示骰子面數。",
"dice.help.option.N": "將多項式的行為重複 N 次(投骰 N 次),之後輸出 N 個結果。",
"dice.help.option.polynomial": "格式為「[<N>#][<m>]d<n>[k(l)<x>][±<y>]...」如「10d4-2d20」會輸出 10 個 4 面骰所有點數之和減去 2 個 20 面骰點數之和。",
"dice.help.option.polynomial.title": "多項式",
"dice.help.option.y": "多項式中可以是整數即調整值如「d20+5」會輸出 1 個 20 面骰的點數加上 5 的結果。",
"dice.help.regex.desc": "(扔|投|擲|丟)<m>個[<n>面]骰子[<N>次] 投擲指定骰子。",
"dice.help.rule": "修改 DC 的判定規則。",
"dice.message.dc.check": "▷ 判定成功數量:${success} 判定失敗數量:${failed}",
"dice.message.dc.failed": " 判定失敗!",
"dice.message.dc.success": " 判定成功!",
@ -29,15 +29,15 @@
"dice.message.error.value.m.invalid": "無效的骰子數量。",
"dice.message.error.value.n.d1": "1……1 面的骰子?",
"dice.message.error.value.n.invalid": "無效的骰子面數。",
"dice.message.error.value.n.out_of_range": "骰子數量不得小於 1 或大於 ${max}。",
"dice.message.error.value.n.less_2": "骰子面數不得小於 2。",
"dice.message.error.value.N.out_of_range": "投骰次數不得小於 1 或大於 ${max}。",
"dice.message.error.value.n.out_of_range": "骰子數量不得小於 1 或大於 ${max}。",
"dice.message.error.value.too_long": "骰子多項式項數超過限制。",
"dice.message.error.value.y.invalid": "無效的調整值項。",
"dice.message.error.value.y.out_of_range": "調整值不得小於 ${min} 或大於 ${max}。",
"dice.message.output": "你掷得的結果是:",
"dice.message.output.too_long": "數量過大,已省略 ${length} 條資訊",
"dice.message.rule.disable": "判定規則已更改為正向。",
"dice.message.rule.enable": "判定規則已更改為反向。",
"dice.message.too_long": "輸出過長……",
"dice.message.error.value.y.invalid": "無效的調整值項。",
"dice.message.error.value.y.out_of_range": "調整值不得小於 ${min} 或大於 ${max}。",
"dice.message.error.value.n.less_2": "骰子面數不得小於 2。"
"dice.message.too_long": "輸出過長……"
}

View file

@ -18,7 +18,7 @@ async def _(msg: Bot.MessageSession, ip_address: str):
except BaseException:
await msg.finish(msg.locale.t('ip.message.error.unknown'))
res = await check_ip(ip_address)
await msg.finish(await format_ip(msg, res))
await msg.finish(await format_ip(msg, res), disable_secret_check=True)
async def check_ip(ip: str):

View file

@ -5,9 +5,10 @@ from PIL import Image
from config import Config
from core.builtins import Bot, Image as BImage
from core.component import module
from core.dirty_check import check_bool, rickroll
from core.dirty_check import rickroll
from core.exceptions import ConfigValueError
from core.utils.http import download_to_cache, get_url
from .check import safe_check
appid = Config('wolfram_alpha_appid')
@ -22,7 +23,7 @@ w = module(
@w.handle('<query> {{wolframalpha.help}}')
async def _(msg: Bot.MessageSession, query: str):
if await check_bool(query):
if await safe_check(query):
await msg.finish(rickroll(msg))
url_query = urllib.parse.quote(query)
if not appid:
@ -44,7 +45,7 @@ async def _(msg: Bot.MessageSession, query: str):
@w.handle('ask <question> {{wolframalpha.help.ask}}')
async def _(msg: Bot.MessageSession, question: str):
if await check_bool(question):
if await safe_check(question):
await msg.finish(rickroll(msg))
url_query = urllib.parse.quote(question)
if not appid:

View file

@ -0,0 +1,11 @@
unsafe_word_list = [
"ip",
"where am i",
"where i am",
]
async def safe_check(msg, query):
for word in unsafe_word_list:
if word in query.lower():
return False
return True