Archived
1
0
Fork 0
This commit is contained in:
yzhh 2023-07-14 16:26:46 +08:00
commit 37456039f1
38 changed files with 157 additions and 130 deletions

View file

@ -7,6 +7,7 @@ from config import Config
from core.builtins import Plain, Image, MessageSession as MS
from core.builtins.message.chain import MessageChain
from core.builtins.message.internal import Embed
from core.dirty_check import rickroll
from core.logger import Logger
from core.types import FinishedSession as FinS
@ -41,7 +42,8 @@ class MessageSession(MS):
) -> FinishedSession:
msgchain = MessageChain(msgchain)
if not msgchain.is_safe and not disable_secret_check:
return await self.sendMessage('https://wdf.ink/6Oup')
message = await rickroll()
return await self.sendMessage(message)
self.sent.append(msgchain)
count = 0
send = []

View file

@ -12,11 +12,10 @@ openai_api_key =
nl2c_model =
curseforge_api_key =
exchange_rate_api_key =
netease_cloud_music_api_url =
[cfg]
base_superuser = "QQ|2596322644"
debug = false
debug = False
cache_path = "./cache/"
command_prefix = ["~", ""]
confirm_command = ["是", "对", "對", "yes", "Yes", "YES", "y", "Y"]
@ -25,18 +24,20 @@ donate_url = "https://afdian.net/@teahouse"
help_url = "https://bot.teahouse.team"
issue_url = "https://github.com/Teahouse-Studios/bot/issues/new/choose"
wiki_whitelist_url = "https://s.wd-ljt.com/botwhitelist"
rickroll_url = "https://wdf.ink/6OUp"
web_render_local =
qq_account = 2314163511
qq_host = "127.0.0.1:11451"
qq_disable_temp_session = false
qq_enable_listening_self_message = false
web_render_local =
slower_schedule = false
enable_dirty_check = true
enable_urlmanager = true
enable_tos = false
enable_analytics = true
allow_request_private_ip = false
enable_eval = true
qq_disable_temp_session = False
qq_enable_listening_self_message = False
allow_request_private_ip = False
slower_schedule = False
enable_dirty_check = True
enable_urlmanager = True
enable_tos = False
enable_analytics = True
enable_eval = True
enable_rickroll = True
coin_limit = 10000
coin_faceup_rate = 4994
coin_facedown_rate = 4994

View file

@ -2,12 +2,7 @@ import os
from config import Config
if not (confirm_command := Config('confirm_command')):
confirm_command = ["", "", '确定', '是吧', '大概是',
'也许', '可能', '对的', '是的', '是呢', '对呢', '', '嗯呢', '对啊', '是啊',
'吼啊', '资瓷', '是呗', '也许吧', '对呗', '应该', '是呢', '是哦', '没错',
"", '確定', '對的', '對啊', '對呢', '對唄', '資瓷', '是唄', '也許', '也許吧', '應該', '沒錯',
'yes', 'y', 'yeah', 'yep', 'ok', 'okay', 'YES', 'Y', 'OK', 'Yes', 'Yeah', 'Yep', 'Okay',
'', '']
confirm_command = ["", "", "", "yes", "Yes", "YES", "y", "Y"]
if not (command_prefix := Config('command_prefix')):
command_prefix = ['~', ''] # 消息前缀

View file

@ -14,7 +14,7 @@ import aiohttp
from tenacity import retry, wait_fixed, stop_after_attempt
from config import Config
from core.builtins import EnableDirtyWordCheck
from core.builtins import Bot, EnableDirtyWordCheck
from core.logger import Logger
from database.local import DirtyWordCache
@ -38,7 +38,7 @@ def parse_data(result: dict):
for itemDetail in itemResult['details']:
if 'contexts' in itemDetail:
for itemContext in itemDetail["contexts"]:
content = re.sub(itemContext['context'], '<吃掉了>', content, flags=re.I)
content = re.sub(itemContext['context'], "<吃掉了>", content, flags=re.I)
status = False
else:
content = "<全部吃掉了>"
@ -156,3 +156,10 @@ async def check_bool(*text):
if not x['status']:
return True
return False
async def rickroll():
if Config("enable_rickroll"):
return Config("rickroll_url")
else:
return "<全部吃掉了>"

View file

@ -5,6 +5,8 @@
"core.help.none": "(此模块没有帮助信息)",
"core.help.options": "参数:",
"error": "发生错误:",
"error.config": "配置参数无效或未找到,请检查配置文件。",
"error.config.secret": "未找到 API 密钥,请检查配置文件。",
"error.loader.load.failed": "加载模块中发生了以下错误,对应模块未加载:${err_msg}",
"error.loader.load.success": "所有模块已正常加载。",
"error.message.chain.empty": "机器人尝试发送空消息链,请联系机器人开发者解决问题。",

View file

@ -5,9 +5,10 @@ from decimal import Decimal
from PIL import Image as PILImage
from langchain.callbacks import get_openai_callback
from config import Config
from core.builtins import Bot, Plain, Image
from core.component import module
from core.dirty_check import check_bool
from core.dirty_check import check_bool, rickroll
from core.exceptions import NoReportException
from .agent import agent_executor
from .formatting import generate_latex, generate_code_snippet
@ -30,6 +31,8 @@ a = module('ask', developers=['Dianliang233'], desc='{ask.help.desc}')
@a.regex(r'^(?:ask|问)[\:]? ?(.+?)[?]$', desc='{ask.help}')
async def _(msg: Bot.MessageSession):
is_superuser = msg.checkSuperUser()
if not Config('openai_api_key'):
raise Exception(msg.locale.t('error.config.secret'))
if not is_superuser and msg.data.petal < 0: # refuse
raise NoReportException(msg.locale.t('petal_'))
if hasattr(msg, 'parsed_msg'):
@ -37,7 +40,7 @@ async def _(msg: Bot.MessageSession):
else:
question = msg.matched_msg[0]
if await check_bool(question):
raise NoReportException('https://wdf.ink/6OUp')
raise NoReportException(await rickroll())
with get_openai_callback() as cb:
res = await agent_executor.arun(question)
tokens = cb.total_tokens
@ -58,7 +61,7 @@ async def _(msg: Bot.MessageSession):
chain.append(Image(PILImage.open(io.BytesIO(await generate_code_snippet(block['content']['code'], block['content']['language'])))))
if await check_bool(res):
raise NoReportException('https://wdf.ink/6OUp')
raise NoReportException(await rickroll())
await msg.finish(chain)

View file

@ -9,5 +9,5 @@
"bilibili.message": "标题:${title}\n类型${tname}\nUP 主:${owner}\n日期${time}",
"bilibili.message.detail": "标题:${title}${pages} | 类型:${tname}\nUP 主:${owner} | 粉丝:${fans}\n观看${view} | 弹幕:${danmaku} | 评论:${reply}\n喜欢${like} | 投币:${coin} | 收藏:${favorite} | 分享:${share}\n日期${time}",
"bilibili.message.error.invalid": "发生错误:视频编号无效,请检查输入。",
"bilibili.message.not_found": "到对应的视频。"
"bilibili.message.not_found": "找到对应的视频。"
}

View file

@ -9,5 +9,5 @@
"bilibili.message": "标题:${title}\n类型${tname}\nUP 主:${owner}\n日期${time}",
"bilibili.message.detail": "标题:${title}${pages} | 类型:${tname}\nUP 主:${owner} | 粉丝:${fans}\n观看${view} | 弹幕:${danmaku} | 评论:${reply}\n喜欢${like} | 投币:${coin} | 收藏:${favorite} | 分享:${share}\n日期${time}",
"bilibili.message.error.invalid": "发生错误:视频编号无效,请检查输入。",
"bilibili.message.not_found": "到对应的视频。"
"bilibili.message.not_found": "找到对应的视频。"
}

View file

@ -9,5 +9,5 @@
"bilibili.message": "標題:${title}\n類型${tname}\nUP 主:${owner}\n日期${time}",
"bilibili.message.detail": "標題:${title}${pages} | 類型:${tname}\nUP 主:${owner} | 追隨者:${fans}\n觀看${view} | 彈幕:${danmaku} | 留言:${reply}\n喜歡${like} | 投幣:${coin} | 收藏:${favorite} | 分享:${share}\n日期${time}",
"bilibili.message.error.invalid": "發生錯誤:影片編號無效,請校對輸入。",
"bilibili.message.not_found": "到對應的影片。"
"bilibili.message.not_found": "找到對應的影片。"
}

View file

@ -38,7 +38,7 @@ async def _(message: Bot.MessageSession):
async def flipCoins(count: int, msg):
if FACE_UP_RATE + FACE_DOWN_RATE > 10000 or FACE_UP_RATE < 0 or FACE_DOWN_RATE < 0 or MAX_COIN_NUM <= 0:
raise OverflowError(msg.locale.t("coin.message.error.config"))
raise OverflowError(msg.locale.t("error.config"))
if count > MAX_COIN_NUM:
return msg.locale.t("coin.message.error.out_of_range", max=count_max)
if count == 0:

View file

@ -16,6 +16,5 @@
"coin.message.mix.tail2": " ${tail} is/are tails",
"coin.message.prompt": "You toss ${count} coin(s)",
"coin.message.stand": "...\n...It is standing up!",
"coin.message.tail": "...\n... It is tails!",
"coin.message.error.config": "Coin probability error, please check your config."
"coin.message.tail": "...\n... It is tails!"
}

View file

@ -16,6 +16,5 @@
"coin.message.mix.tail2": "…有 ${tail} 枚是反面",
"coin.message.prompt": "你抛了 ${count} 枚硬币",
"coin.message.stand": "…\n…它立起来了",
"coin.message.tail": "…\n…是反面",
"coin.message.error.config": "硬币配置发生错误,请检查配置文件。"
"coin.message.tail": "…\n…是反面"
}

View file

@ -16,6 +16,5 @@
"coin.message.mix.tail2": "…有 ${tail} 枚是反面",
"coin.message.prompt": "你拋了 ${count} 枚硬幣",
"coin.message.stand": "…\n…它立起來了",
"coin.message.tail": "…\n…是反面",
"coin.message.error.config": "硬幣配置發生錯誤,請檢查配置文件。"
"coin.message.tail": "…\n…是反面"
}

View file

@ -1,21 +1,17 @@
import os
import platform
import time
from datetime import datetime
import psutil
from cpuinfo import get_cpu_info
import time
from config import Config
from core.builtins import Bot, PrivateAssets
from core.component import module
from core.utils.i18n import get_available_locales, Locale
from cpuinfo import get_cpu_info
from database import BotDBUtil
from datetime import datetime
version = module('version',
base=True,
desc='{core.help.version}',
developers=['OasisAkari', 'Dianliang233']
)
version = module('version', base=True, desc='{core.help.version}', developers=['OasisAkari', 'Dianliang233'])
@version.handle()
@ -30,11 +26,7 @@ async def bot_version(msg: Bot.MessageSession):
await msg.finish(msgs, msgs)
ping = module('ping',
base=True,
desc='{core.help.ping}',
developers=['OasisAkari']
)
ping = module('ping', base=True, desc='{core.help.ping}', developers=['OasisAkari'] )
started_time = datetime.now()
@ -201,14 +193,7 @@ async def _(msg: Bot.MessageSession):
await msg.finish(msg.locale.t('core.message.mute.enable') if msg.data.switch_mute() else msg.locale.t('core.message.mute.disable'))
leave = module(
'leave',
developers=['OasisAkari'],
base=True,
required_admin=True,
available_for='QQ|Group',
alias='dismiss',
desc='{core.help.leave}')
leave = module('leave', developers=['OasisAkari'], base=True, required_admin=True, available_for='QQ|Group', alias='dismiss', desc='{core.help.leave}')
@leave.handle()
@ -218,18 +203,18 @@ async def _(msg: Bot.MessageSession):
await msg.sendMessage(msg.locale.t('core.message.leave.success'))
await msg.call_api('set_group_leave', group_id=msg.session.target)
petal = module('petal', developers=['Dianliang233'], base=True, alias='petals',
desc='{core.help.petal}')
if Config('openai_api_key'):
petal = module('petal', developers=['Dianliang233'], base=True, alias='petals',
desc='{core.help.petal}')
@petal.handle()
async def _(msg: Bot.MessageSession):
await msg.finish(msg.locale.t('core.message.petal', petal=msg.data.petal))
@petal.handle()
async def _(msg: Bot.MessageSession):
await msg.finish(msg.locale.t('core.message.petal', petal=msg.data.petal))
@petal.handle('modify <petal>', required_admin=True)
async def _(msg: Bot.MessageSession):
petal = msg.parsed_msg['<petal>']
msg.data.modify_petal(int(petal))
await msg.finish(msg.locale.t('core.message.petal', petal=msg.data.petal))
@petal.handle('modify <petal>', required_admin=True)
async def _(msg: Bot.MessageSession):
petal = msg.parsed_msg['<petal>']
msg.data.modify_petal(int(petal))
await msg.finish(msg.locale.t('core.message.petal', petal=msg.data.petal))

View file

@ -183,7 +183,7 @@ class Dice(DiceItemBase):
async def GenerateMessage(msg, dices: str, times: int, dc: int):
if not all([MAX_DICE_COUNT > 0, MAX_ROLL_TIMES > 0, MAX_MOD_NUMBER >= MIN_MOD_NUMBER, MAX_OUTPUT_CNT > 0, MAX_OUTPUT_LEN > 0, MAX_DETAIL_CNT > 0, MAX_ITEM_COUNT > 0]):
raise OverflowError(msg.locale.t("dice.message.error.config"))
raise OverflowError(msg.locale.t("error.config"))
if re.search(r'[^0-9+\-DKL]', dices.upper()):
return DiceSyntaxError(msg, msg.locale.t('dice.message.error.syntax.invalid')).message
if times > MAX_ROLL_TIMES or times < 1:

View file

@ -37,6 +37,5 @@
"dice.message.error.value.too_long": "骰子多项式项数超过限制。",
"dice.message.output": "你掷得的结果是:",
"dice.message.output.too_long": "数量过大,已省略 ${length} 个数据。",
"dice.message.too_long": "输出过长……",
"dice.message.error.config": "骰子配置发生错误,请检查配置文件。"
"dice.message.too_long": "输出过长……"
}

View file

@ -37,6 +37,5 @@
"dice.message.error.value.too_long": "骰子多项式项数超过限制。",
"dice.message.output": "你掷得的结果是:",
"dice.message.output.too_long": "数量过大,已省略 ${length} 个数据。",
"dice.message.too_long": "输出过长……",
"dice.message.error.config": "骰子配置发生错误,请检查配置文件。"
"dice.message.too_long": "输出过长……"
}

View file

@ -37,6 +37,5 @@
"dice.message.error.value.too_long": "骰子多項式項數超過限制。",
"dice.message.output": "你掷得的結果是:",
"dice.message.output.too_long": "數量過大,已省略 ${length} 個資料。",
"dice.message.too_long": "輸出過長……",
"dice.message.error.config": "骰子配置發生錯誤,請檢查配置文件。"
"dice.message.too_long": "輸出過長……"
}

View file

@ -21,6 +21,9 @@ async def _(msg: Bot.MessageSession):
amount_str = base[:-3]
base_currency = base[-3:]
if not api_key:
raise Exception(msg.locale.t('error.config.secret'))
try:
if amount_str:
amount = float(amount_str)

View file

@ -8,5 +8,5 @@
"github.message.search.none": "搜尋成功,未找到結果。",
"github.message.search.more_information": "另有 ${more_result} 條結果未顯示。",
"github.message.search.not_found": "未找到儲存庫,請校對輸入。",
"github.message.user.not_found": "到使用者,請校對輸入。"
"github.message.user.not_found": "找到使用者,請校對輸入。"
}

View file

@ -4,6 +4,7 @@ import traceback
from core.builtins import Bot
from core.builtins import Image, Plain, Url, ErrorMessage
from core.utils.http import get_url, download_to_cache
from core.dirty_check import rickroll
from modules.github.utils import time_diff, dirty_check, darkCheck
@ -53,7 +54,7 @@ Created {time_diff(result['created_at'])} ago | Updated {time_diff(result['updat
is_dirty = await dirty_check(message, result['owner']['login']) or darkCheck(message)
if is_dirty:
message = 'https://wdf.ink/6OUp'
message = await rickroll()
await msg.finish([Plain(message)])
else:
await msg.sendMessage([Plain(message)])

View file

@ -2,6 +2,7 @@ import traceback
from core.builtins import Bot, Url, ErrorMessage
from core.utils.http import get_url
from core.dirty_check import rickroll
from modules.github.utils import dirty_check, darkCheck
@ -29,7 +30,7 @@ async def search(msg: Bot.MessageSession):
is_dirty = await dirty_check(message) or darkCheck(message)
if is_dirty:
message = 'https://wdf.ink/6OUp'
message = await rickroll()
await msg.finish(message)
except ValueError as e:

View file

@ -2,6 +2,7 @@ import traceback
from core.builtins import Url, ErrorMessage, Bot
from core.utils.http import get_url
from core.dirty_check import rickroll
from modules.github.utils import time_diff, dirty_check, darkCheck
@ -38,7 +39,7 @@ Account Created {time_diff(result['created_at'])} ago | Latest activity {time_di
is_dirty = await dirty_check(message, result['login']) or darkCheck(message)
if is_dirty:
message = 'https://wdf.ink/6OUp'
message = await rickroll()
await msg.finish(message)
except ValueError as e:

View file

@ -4,7 +4,7 @@ from langconv.language.zh import zh_cn, zh_hk, zh_tw
from core.builtins import Bot
from core.component import module
from core.dirty_check import check_bool
from core.dirty_check import check_bool, rickroll
from core.exceptions import NoReportException
l = module('langconv', developers=['Dianliang233'], alias={'lc': 'langconv'}, desc='{langconv.help}')
@ -25,5 +25,5 @@ async def _(msg: Bot.MessageSession, language: str, content: str):
stop = time.perf_counter_ns()
delta = (stop - start) / 1000000
if await check_bool(res):
raise NoReportException('https://wdf.ink/6OUp')
raise NoReportException(await rickroll())
await msg.finish(res + '\n' + msg.locale.t('langconv.message.running_time', time=delta))

View file

@ -3,7 +3,7 @@ from core.component import module
from core.logger import Logger
from core.utils.image import msgchain2image
from modules.maimai.libraries.maimai_best_50 import generate
from modules.maimai.libraries.maimaidx_api_data import get_alias, get_cover
from modules.maimai.libraries.maimaidx_api_data import update_alias, get_alias, get_cover
from modules.maimai.libraries.maimaidx_project import get_level_process, get_plate_process, get_player_score, get_rank, get_score_list
from modules.maimai.libraries.maimaidx_music import Music, TotalList
from .regex import *
@ -138,14 +138,17 @@ async def _(msg: Bot.MessageSession, keyword: str):
@mai.handle('alias <sid> {{maimai.help.alias}}')
async def _(msg: Bot.MessageSession, sid: str):
if not sid.isdigit():
await msg.finish(msg.locale.t('maimai.message.error.non_digital'))
if sid[:2].lower() == "id":
sid = id_or_alias[2:]
else:
await msg.finish(msg.locale.t('maimai.message.error.non_digital'))
music = (await total_list.get()).by_id(sid)
if not music:
await msg.finish(msg.locale.t("maimai.message.music_not_found"))
title = f"{music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''}"
alias = await get_alias(sid)
alias = await get_alias(msg, sid)
if len(alias) == 0:
await msg.finish(msg.locale.t("maimai.message.alias_not_found"))
await msg.finish(msg.locale.t("maimai.message.alias.alias_not_found"))
else:
result = msg.locale.t("maimai.message.alias", title=title) + "\n"
result += "\n".join(alias)
@ -169,7 +172,7 @@ async def _(msg: Bot.MessageSession, id_or_alias: str, username: str = None):
if id_or_alias[:2].lower() == "id":
sid = id_or_alias[2:]
else:
sid_list = await get_alias(id_or_alias, get_music=True)
sid_list = await get_alias(msg, id_or_alias, get_music=True)
if len(sid_list) == 0:
await msg.finish(msg.locale.t("maimai.message.music_not_found"))
elif len(sid_list) > 1:
@ -335,7 +338,7 @@ async def _(msg: Bot.MessageSession, id_or_alias: str, diff: str = None):
if id_or_alias[:2].lower() == "id":
sid = id_or_alias[2:]
else:
sid_list = await get_alias(id_or_alias, get_music=True)
sid_list = await get_alias(msg, id_or_alias, get_music=True)
if len(sid_list) == 0:
await msg.finish(msg.locale.t("maimai.message.music_not_found"))
elif len(sid_list) > 1:
@ -398,6 +401,11 @@ async def _(msg: Bot.MessageSession, id_or_alias: str, diff: str = None):
@mai.handle('scoreline <sid> <diff> <scoreline> {{maimai.help.scoreline}}')
async def _(msg: Bot.MessageSession, diff: str, sid: str, scoreline: float):
try:
if not sid.isdigit():
if sid[:2].lower() == "id":
sid = id_or_alias[2:]
else:
await msg.finish(msg.locale.t('maimai.message.error.non_digital'))
diff_index = get_diff(diff)
music = (await total_list.get()).by_id(sid)
chart = music['charts'][diff_index]
@ -426,3 +434,11 @@ async def _(msg: Bot.MessageSession, diff: str, sid: str, scoreline: float):
b2t_great_prop=b2t_great_prop)}''')
except Exception:
await msg.finish(msg.locale.t('maimai.message.scoreline.error', prefix=command_prefix[0]))
@mai.command('update', required_superuser=True)
async def _(msg: Bot.MessageSession):
if await update_alias():
await msg.finish(msg.locale.t("phigros.message.update.success"))
else:
await msg.finish(msg.locale.t("phigros.message.update.failed"))

View file

@ -1,13 +1,32 @@
import ujson as json
import os
from core.builtins import ErrorMessage
from core.utils.http import get_url, post_url
from .maimaidx_music import get_cover_len5_id
async def get_alias(input, get_music=False):
url = "https://download.fanyu.site/maimai/alias.json"
data = await get_url(url, 200, fmt='json')
assets_path = os.path.abspath('./assets/maimai')
async def update_alias():
try:
url = "https://download.fanyu.site/maimai/alias_uc.json"
data = await get_url(url, 200, fmt='json')
except:
return False
file_path = os.path.join(assets_path, "mai_alias.json")
with open(file_path, 'w') as file:
json.dump(data, file)
return True
async def get_alias(msg, input, get_music=False):
file_path = os.path.join(assets_path, "mai_alias.json")
if not os.path.exists(file_path):
await msg.finish(msg.locale.t("maimai.message.alias.file_not_found", prefix=msg.prefixes[0]))
with open(file_path, 'r') as file:
data = json.load(file)
result = []
if get_music:
@ -34,8 +53,6 @@ async def get_record(msg, payload):
await msg.finish(msg.locale.t("maimai.message.user_not_found"))
if str(e).startswith('403'):
await msg.finish(msg.locale.t("maimai.message.forbidden"))
else:
await msg.finish(ErrorMessage(str(e)))
return data
@ -52,8 +69,6 @@ async def get_plate(msg, payload):
await msg.finish(msg.locale.t("maimai.message.user_not_found"))
if str(e).startswith('403'):
await msg.finish(msg.locale.t("maimai.message.forbidden"))
else:
await msg.finish(ErrorMessage(str(e)))
return data
@ -61,7 +76,7 @@ def get_cover(sid):
cover_url = f"https://www.diving-fish.com/covers/{get_cover_len5_id(sid)}.png"
cover_dir = f"./assets/maimai/static/mai/cover/"
cover_path = cover_dir + f'{get_cover_len5_id(sid)}.png'
if sid == '11364':
if sid == '11364': #8-EM 的封面需要改动
return os.path.abspath(cover_path)
else:
return cover_url

View file

@ -22,7 +22,7 @@
"maimai.help.search": "根据歌名(或一部分)搜索歌曲。",
"maimai.help.song": "查询 Maimai 歌曲或谱面的信息。",
"maimai.message.alias": "${title} 的别名:",
"maimai.message.alias_not_found": "未找到符合要求的别名。",
"maimai.message.alias.alias_not_found": "未找到符合要求的别名。",
"maimai.message.base": "以下为定数 ${rating} 的曲目列表:",
"maimai.message.base.range": "以下为定数 ${rating}-${rating_max} 的曲目列表:",
"maimai.message.chart_not_found": "未找到符合要求的谱面。",

View file

@ -22,7 +22,8 @@
"maimai.help.search": "根据歌名(或一部分)搜索歌曲。",
"maimai.help.song": "查询 Maimai 歌曲或谱面信息ID 需要加入前缀“id”。",
"maimai.message.alias": "${title} 的别名:",
"maimai.message.alias_not_found": "未找到符合要求的别名。",
"maimai.message.alias.alias_not_found": "未找到符合要求的别名。",
"maimai.message.alias.file_not_found": "未找到别名文件,请使用“${prefix}maimai update”初始化文件。",
"maimai.message.base": "以下为定数 ${rating} 的曲目列表:",
"maimai.message.base.range": "以下为定数 ${rating}-${rating_max} 的曲目列表:",
"maimai.message.chart_not_found": "未找到符合要求的谱面。",
@ -49,7 +50,6 @@
"maimai.message.random.error": "发生错误:无法随机歌曲,请检查输入。",
"maimai.message.rank": "截至 ${time}\n查分器共有 ${total_rank} 名用户,平均分数为 ${average_rating}\n${user} 的分数为 ${rating},排名为 #${rank}\n你已经超越了 ${surpassing_rate}% 的玩家。",
"maimai.message.rank.not_found": "截至 ${time}\n查分器共有 ${total_rank} 名用户,平均分数为 ${average_rating}\n未找到 ${user} 的数据。",
"maimai.message.random.error": "发生错误:无法随机歌曲,请检查输入。",
"maimai.message.scoreline": "分数线 ${scoreline}% 允许的最多 TAP GREAT 数量为 ${tap_great}(每个-${tap_great_prop}%\nBREAK 2500一共 ${brk} 个)等价于 ${b2t_great} 个 TAP GREAT-${b2t_great_prop}%",
"maimai.message.scoreline.error": "发生错误:无法计算结果,请检查输入。",
"maimai.message.scorelist": "以下为 ${user} 的 ${level} 级分数列表:",
@ -59,5 +59,7 @@
"maimai.message.song.prompt": "以下是可能的结果:",
"maimai.message.song.sd": "${diff} ${level} (${ds})\nTAP${tap}\nHOLD${hold}\nSLIDE${slide}\nBREAK${brk}\n谱师${charter}",
"maimai.message.too_much": "结果过多(${length} 条),请缩小搜索范围。",
"maimai.message.update.failed": "更新失败。",
"maimai.message.update.success": "更新成功。",
"maimai.message.user_not_found": "未找到此玩家,请确保此玩家的用户名和查分器中的用户名相同。"
}

View file

@ -22,7 +22,7 @@
"maimai.help.search": "依據歌名(或一部分)搜尋歌曲。",
"maimai.help.song": "查詢 Maimai 歌曲或譜面的訊息。",
"maimai.message.alias": "${title} 的別名:",
"maimai.message.alias_not_found": "未找到符合要求的別名。",
"maimai.message.alias.alias_not_found": "未找到符合要求的別名。",
"maimai.message.base": "以下為定數 ${rating} 的曲目列表:",
"maimai.message.base.range": "以下為定數 ${rating}-${rating_max} 的曲目列表:",
"maimai.message.chart_not_found": "未找到符合要求的譜面。",

View file

@ -46,7 +46,7 @@ mai_regex = module('maimai_regex',
alias='mai_regex', developers=['DoroWolf'], support_languages=['zh_cn', 'zh_tw'])
@mai_regex.handle(re.compile(r"(.+)\s?是什([么麼])"), desc='{maimai.help.maimai_regex.song}')
@mai_regex.handle(re.compile(r"(.+)\s?是什[么麼]歌"), desc='{maimai.help.maimai_regex.song}')
async def _(msg: Bot.MessageSession):
name = msg.matched_msg.groups()[0]
if name[:2].lower() == "id":
@ -55,7 +55,7 @@ async def _(msg: Bot.MessageSession):
if not music:
await msg.finish(msg.locale.t("maimai.message.music_not_found"))
else:
sid_list = await get_alias(name, get_music=True)
sid_list = await get_alias(msg, name, get_music=True)
if len(sid_list) == 0:
await msg.finish(msg.locale.t("maimai.message.music_not_found"))
elif len(sid_list) > 1:
@ -79,16 +79,16 @@ async def _(msg: Bot.MessageSession):
level='/'.join((str(ds) for ds in music['ds']))))])
@mai_regex.handle(re.compile(r"(\d+)\s?有什(么别|麼別)名"), desc='{maimai.help.maimai_regex.alias}')
@mai_regex.handle(re.compile(r"(?:id)?(\d+)\s?有什(么别|麼別)名"), desc='{maimai.help.maimai_regex.alias}')
async def _(msg: Bot.MessageSession):
sid = msg.matched_msg.groups()[0]
music = (await total_list.get()).by_id(sid)
if not music:
await msg.finish(msg.locale.t("maimai.message.music_not_found"))
title = f"{music['id']}\u200B. {music['title']}{' (DX)' if music['type'] == 'DX' else ''}"
alias = await get_alias(sid)
alias = await get_alias(msg, sid)
if len(alias) == 0:
await msg.finish(msg.locale.t("maimai.message.alias_not_found"))
await msg.finish(msg.locale.t("maimai.message.alias.alias_not_found"))
else:
result = msg.locale.t("maimai.message.alias", title=title) + "\n"
result += "\n".join(alias)
@ -133,15 +133,15 @@ async def _(msg: Bot.MessageSession):
@mai_regex.handle(re.compile(r".*\s?(M|m)aimai?\s?.*(什么|什麼)"), desc='{maimai.help.maimai_regex.random}')
@mai_regex.handle(re.compile(r".*\s?[Mm]aimai?\s?.*(什么|什麼)"), desc='{maimai.help.maimai_regex.random}')
async def _(msg: Bot.MessageSession):
await msg.finish(song_txt((await total_list.get()).random()))
@mai_regex.handle(re.compile(r"(.?)([極极将舞神者]舞?)([进進])\s?(.+)?"), desc='{maimai.help.maimai_regex.plate}')
@mai_regex.handle(re.compile(r"(.?)([極极将舞神者]舞?)[进進]度\s?(.+)?"), desc='{maimai.help.maimai_regex.plate}')
async def _(msg: Bot.MessageSession):
plate = msg.matched_msg.groups()[0] + msg.matched_msg.groups()[1]
username = msg.matched_msg.groups()[3]
username = msg.matched_msg.groups()[2]
if username is None and msg.target.senderFrom == "QQ":
payload = {'qq': msg.session.sender}
else:
@ -161,12 +161,12 @@ async def _(msg: Bot.MessageSession):
await msg.finish(output.strip())
@mai_regex.handle(re.compile(r"([0-9]+\+?)\s?(.+)([进進])\s?(.+)?"), desc='{maimai.help.maimai_regex.process}')
@mai_regex.handle(re.compile(r"([0-9]+\+?)\s?(.+)[进進]度\s?(.+)?"), desc='{maimai.help.maimai_regex.process}')
async def _(msg: Bot.MessageSession):
goal_list = ["A", "AA", "AAA", "S", "S+", "SS", "SS+", "SSS", "SSS+", "FC", "FC+", "AP", "AP+", "FS", "FS+", "FDX", "FDX+"]
level = msg.matched_msg.groups()[0]
goal = msg.matched_msg.groups()[1]
username = msg.matched_msg.groups()[3]
username = msg.matched_msg.groups()[2]
if username is None and msg.target.senderFrom == "QQ":
payload = {'qq': msg.session.sender}
else:

View file

@ -3,8 +3,6 @@ from core.builtins import Bot, Plain, Image
from core.component import module
from core.utils.http import get_url
api_address = Config('netease_cloud_music_api_url')
ncmusic = module('ncmusic',
developers=['bugungu', 'DoroWolf'],
support_languages=['zh_cn'])
@ -14,7 +12,7 @@ ncmusic = module('ncmusic',
async def search(msg: Bot.MessageSession, keyword: str):
if not api_address:
await msg.finish(msg.locale.t('ncmusic.message.api_unconfigured'))
url = f"{api_address}search?keywords={keyword}"
url = f"https://autumnfish.cn/search?keywords={keyword}"
result = await get_url(url, 200, fmt='json')
if result['result']['songCount'] == 0:
@ -41,9 +39,7 @@ async def search(msg: Bot.MessageSession, keyword: str):
@ncmusic.handle('info <sid> {{ncmusic.help.info}}')
async def info(msg: Bot.MessageSession, sid: str):
if not api_address:
await msg.finish(msg.locale.t('ncmusic.message.api_unconfigured'))
url = f"{api_address}song/detail?ids={sid}"
url = f"https://autumnfish.cn/song/detail?ids={sid}"
result = await get_url(url, 200, fmt='json')
info = result['songs'][0]

View file

@ -5,7 +5,7 @@ import openai
from config import Config
from core.builtins import Bot
from core.component import module
from core.dirty_check import check_bool
from core.dirty_check import check_bool, rickroll
from core.logger import Logger
openai.api_key = Config('openai_api_key')
@ -63,5 +63,6 @@ async def _(msg: Bot.MessageSession):
output = completion['choices'][0]['message']['content']
await wait_msg.delete()
if await check_bool(output):
await msg.finish('https://wdf.ink/6OUp')
message = await rickroll()
await msg.finish(message)
await msg.finish(output, disable_secret_check=True)

View file

@ -6,7 +6,7 @@ from config import Config
from core.builtins import Bot
from core.builtins.message import Image
from core.component import module
from core.dirty_check import check_bool
from core.dirty_check import check_bool, rickroll
from core.utils.http import download_to_cache, get_url
web_render_local = Config('web_render_local')
@ -31,7 +31,8 @@ async def _(msg: Bot.MessageSession, tweet: str):
await msg.finish(msg.locale.t('tweet.message.not_found'))
else:
if await check_bool(res_json['pageProps']['tweet']['text'], res_json['pageProps']['tweet']['user']['name'], res_json['pageProps']['tweet']['user']['screen_name']):
await msg.finish('https://wdf.ink/6OUp')
message = await rickroll()
await msg.finish(message)
else:
css = '''
main {

View file

@ -57,7 +57,7 @@ async def has_solution(numbers):
expressions = list(itertools.product(operators, repeat=3))
for perm in permutations:
for expr in expressions:
for expr in expressions: # 穷举就完事了
exp = '((( {} {} {} ) {} {} ) {} {} )'.format(perm[0], expr[0], perm[1], expr[1], perm[2], expr[2], perm[3])
if calc(exp) == 24:
return True

View file

@ -16,7 +16,7 @@ async def ab(msg: Bot.MessageSession, wiki_url):
filter_name=x['filter'], result=x['result']))
y = await check(*d)
y = '\n'.join(z['content'] for z in y)
if y.find('<吃掉了>') != -1 or y.find('<全部吃掉了>') != -1:
if y.find("<吃掉了>") != -1 or y.find("<全部吃掉了>") != -1:
return f'{str(Url(pageurl))}\n{y}\n{msg.locale.t("wiki.message.utils.collapse")}\n{msg.locale.t("wiki.message.utils.banned")}'
else:
return f'{str(Url(pageurl))}\n{y}\n' + msg.locale.t("wiki.message.utils.collapse")

View file

@ -15,6 +15,6 @@ async def newbie(msg: Bot.MessageSession, wiki_url):
y = await check(*d)
y = '\n'.join(z['content'] for z in y)
g = f'{pageurl}\n{y}\n{msg.locale.t("wiki.message.utils.collapse")}'
if g.find('<吃掉了>') != -1 or g.find('<全部吃掉了>') != -1:
if g.find("<吃掉了>") != -1 or g.find("<全部吃掉了>") != -1:
g += f'\n{msg.locale.t("wiki.message.utils.banned")}'
return g

View file

@ -15,7 +15,7 @@ async def rc(msg: Bot.MessageSession, wiki_url):
' ' + UTC8(x['timestamp'], 'onlytime'))
y = await check(*d)
y = '\n'.join(z['content'] for z in y)
if y.find('<吃掉了>') != -1 or y.find('<全部吃掉了>') != -1:
if y.find("<吃掉了>") != -1 or y.find("<全部吃掉了>") != -1:
msg = f'{str(Url(pageurl))}\n{y}\n{msg.locale.t("wiki.message.utils.collapse")}\n{msg.locale.t("wiki.message.utils.banned")}'
else:
msg = f'{str(Url(pageurl))}\n{y}\n{msg.locale.t("wiki.message.utils.collapse")}'

View file

@ -5,7 +5,7 @@ import wolframalpha
from config import Config
from core.builtins import Bot, Image
from core.component import module
from core.dirty_check import check_bool
from core.dirty_check import check_bool, rickroll
client = wolframalpha.Client(Config('wolfram_alpha_appid'))
@ -34,6 +34,7 @@ async def _(msg: Bot.MessageSession):
images.append(pod.subpod['img']['@src'])
bot_images = [Image(image) for image in images]
if await check_bool(' '.join(answer)):
await msg.finish('https://wdf.ink/6OUp')
message = await rickroll()
await msg.finish(message)
else:
await msg.finish(['\n'.join(answer), *bot_images])