Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
DoroWolf committed Jan 16, 2025
1 parent 6400fd5 commit e63a821
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
7 changes: 3 additions & 4 deletions core/dirty_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,11 @@ async def check_bool(*text: Union[str, List[str]]) -> bool:
return False


def rickroll(msg: Bot.MessageSession) -> str:
def rickroll() -> str:
"""合规检查失败时输出的Rickroll消息。
:param msg: 消息会话。
:returns: Rickroll消息。
"""
if Config("enable_rickroll", True) and Config("rickroll_msg", cfg_type=str):
return msg.locale.t_str(Config("rickroll_msg", cfg_type=str))
return msg.locale.t("error.message.chain.unsafe")
return Config("rickroll_msg", cfg_type=str)
return "[i18n:error.message.chain.unsafe]"
2 changes: 1 addition & 1 deletion modules/ask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def _(msg: Bot.MessageSession):
question = msg.matched_msg[0]
# gpt4 = False
if await check_bool(question):
await msg.finish(rickroll(msg))
await msg.finish(rickroll())

thread = await client.beta.threads.create(
messages=[{"role": "user", "content": question}]
Expand Down
3 changes: 2 additions & 1 deletion modules/bilibili/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ async def _(msg: Bot.MessageSession):
@bili.regex(r"(?:http[s]?://)?(?:bili(?:22|33|2233)\.cn|b23\.tv)/([A-Za-z0-9]{7})(?:/.*?|)",
mode="A",
desc="{bilibili.help.regex.url}",
text_only=False,
show_typing=False,
text_only=False
)
async def _(msg: Bot.MessageSession):
matched = msg.matched_msg[:5]
Expand Down
2 changes: 1 addition & 1 deletion modules/github/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def repo(msg: Bot.MessageSession, name: str):
message
)
if is_dirty:
await msg.finish(rickroll(msg))
await msg.finish(rickroll())
else:
await msg.send_message([Plain(message)])

Expand Down
2 changes: 1 addition & 1 deletion modules/github/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ async def search(msg: Bot.MessageSession, keyword: str):

is_dirty = await dirty_check(message) or dark_check(message)
if is_dirty:
await msg.finish(rickroll(msg))
await msg.finish(rickroll())

await msg.finish(message)
2 changes: 1 addition & 1 deletion modules/github/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def user(msg: Bot.MessageSession, name: str):

is_dirty = await dirty_check(message, result["login"]) or dark_check(message)
if is_dirty:
await msg.finish(rickroll(msg))
await msg.finish(rickroll())

await msg.finish(message)
except ValueError as e:
Expand Down
2 changes: 1 addition & 1 deletion modules/langconv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ async def _(msg: Bot.MessageSession, language: str, content: str):
lc = {"zh-cn": lc_zh_cn, "zh-hk": lc_zh_hk, "zh-tw": lc_zh_tw}[language]
res = lc.convert(content)
if await check_bool(res):
await msg.finish(rickroll(msg))
await msg.finish(rickroll())
await msg.finish(res)
2 changes: 1 addition & 1 deletion modules/summary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def _(msg: Bot.MessageSession):
msgs = data["messages"]
texts = [f'\n{m["sender"]["nickname"]}{m["content"]}' for m in msgs]
if await check_bool("".join(texts)):
await msg.finish(rickroll(msg))
await msg.finish(rickroll())

char_count = sum(len(i) for i in texts)
wait_msg = await msg.send_message(
Expand Down
2 changes: 1 addition & 1 deletion modules/tweet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def _(msg: Bot.MessageSession, tweet: str):
res_json["data"]["user"]["name"],
res_json["data"]["user"]["screen_name"],
):
await msg.finish(rickroll(msg))
await msg.finish(rickroll())

css = """
main {
Expand Down
2 changes: 1 addition & 1 deletion modules/wiki/utils/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,5 @@ async def get_user_info(msg: Bot.MessageSession, wikiurl, username):

res = "\n".join(msgs)
if await check_bool(res):
await msg.finish(rickroll(msg))
await msg.finish(rickroll())
await msg.finish(res)
4 changes: 2 additions & 2 deletions modules/wolframalpha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@w.command("<query> {{wolframalpha.help}}")
async def _(msg: Bot.MessageSession, query: str):
if await secret_check(query):
await msg.finish(rickroll(msg))
await msg.finish(rickroll())
url_query = urllib.parse.quote(query)
if not appid:
raise ConfigValueError(msg.locale.t("error.config.secret.not_found"))
Expand All @@ -50,7 +50,7 @@ async def _(msg: Bot.MessageSession, query: str):
@w.command("ask <question> {{wolframalpha.help.ask}}")
async def _(msg: Bot.MessageSession, question: str):
if await secret_check(question):
await msg.finish(rickroll(msg))
await msg.finish(rickroll())
url_query = urllib.parse.quote(question)
if not appid:
raise ConfigValueError(msg.locale.t("error.config.secret.not_found"))
Expand Down

0 comments on commit e63a821

Please sign in to comment.