Archived
1
0
Fork 0
This commit is contained in:
多羅狼 2023-05-27 18:19:24 +08:00 committed by GitHub
parent a6d8192e1e
commit 9aecb24ec7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 21 deletions

View file

@ -15,6 +15,8 @@
"error.message.paused": "群消息发送被服务器拦截,已暂停群消息发送,使用“${prefix}resume”恢复推送。",
"error.module.helpdoc.invalid": "${module} 模块的帮助信息有误,请联系开发者处理。",
"error.module.unbound": "模块 ${module} 未绑定任何命令且无简介,请联系开发者处理。",
"error.range.notnumber": "发生错误:无效的数字区间。",
"error.range.invalid": "发生错误:最小值不能大于最大值。",
"error.prompt": "发生错误:${error_msg}\n错误汇报地址",
"error.prompt.noreport": "执行命令时发生错误:\n${err_msg}\n此问题并非机器人程序错误API 请求出错等),请勿将此消息报告给机器人开发者。",
"error.prompt.report": "执行命令时发生错误,请报告机器人开发者:\n${err_msg}\n错误汇报地址",

View file

@ -17,7 +17,7 @@ async def _(msg: Bot.MessageSession):
except AttributeError:
set_type = None
url = 'https://v1.hitokoto.cn/?'
if set_type is not None:
if not set_type:
if set_type not in hitokoto_types:
await msg.finish(msg.locale.t('hitokoto.message.error.type'))
else:

View file

@ -39,21 +39,28 @@ mai = module('maimai', developers=['mai-bot', 'OasisAkari'], alias=['mai'],
@mai.handle('inner <rating> [<rating_max>] {{maimai.help.inner}}')
async def _(msg: Bot.MessageSession):
if '<rating_max>' not in msg.parsed_msg:
result_set = await inner_level_q(float(msg.parsed_msg['<rating>']))
try:
rating = float(msg.parsed_msg['<rating>'])
try:
rating_max = float(msg.parsed_msg.get('<rating_max>'))
except AttributeError:
rating_max = None
except ValueError:
return await msg.finish(msg.locale.t('error.range.notnumber'))
if rating > rating_max:
return await msg.finish(msg.locale.t('error.range.invalid'))
if not rating_max:
result_set = await inner_level_q(rating)
s = msg.locale.t("maimai.message.inner", rating=round(rating, 1)) + "\n"
else:
result_set = await inner_level_q(float(msg.parsed_msg['<rating>']), float(msg.parsed_msg['<rating_max>']))
s = ""
result_set = await inner_level_q(rating, rating_max)
s = msg.locale.t("maimai.message.inner.range", rating=round(rating, 1), rating_max=round(rating_max, 1)) + "\n"
for elem in result_set:
s += f"{elem[0]}. {elem[1]} {elem[3]} {elem[4]}({elem[2]})\n"
if len(result_set) > 150:
return await msg.finish(msg.locale.t("maimai.message.too_much", length=len(result_set)))
elif len(result_set) > 50:
img = text_to_image(s)
if img:
await msg.finish([BImage(img)])
else:
await msg.finish(s.strip())
img = text_to_image(s)
await msg.finish([BImage(img)])

View file

@ -11,6 +11,6 @@
"maimai.message.forbidden": "此用户禁止了其他人获取数据。",
"maimai.message.chart_not_found": "未找到该谱面。",
"maimai.message.b50.waiting": "加载时间较长,请稍等……",
"maimai.message.inline": "以下为定数 ${rating} 的曲目列表:",
"maimai.message.inline.range": "以下为定数 ${rating}-${rating_max} 的曲目列表:"
"maimai.message.inner": "以下为定数 ${rating} 的曲目列表:",
"maimai.message.inner.range": "以下为定数 ${rating}-${rating_max} 的曲目列表:"
}

View file

@ -15,9 +15,9 @@ async def _(msg: Bot.MessageSession):
_min = int(msg.parsed_msg['<min>'])
_max = int(msg.parsed_msg['<max>'])
except ValueError:
return await msg.finish(msg.locale.t('random.message.number.error.invalid'))
return await msg.finish(msg.locale.t('error.range.notnumber'))
if _min > _max:
return await msg.finish(msg.locale.t('random.message.number.error.out_of_range'))
return await msg.finish(msg.locale.t('error.range.invalid'))
random = secrets.randbelow(_max - _min + 1) + _min
await msg.finish('' + str(random))

View file

@ -9,7 +9,5 @@
"random.help.shuffle": "Shuffle the order of a given set.",
"random.help.string": "生成随机字符串,默认为字母和数字组合。",
"random.help.uuid": "Generate random UUID (v4).",
"random.message.number.error.invalid": "发生错误:无效的数字区间。",
"random.message.number.error.out_of_range": "发生错误:最小值大于最大值。",
"random.message.string.error.invalid": "发生错误:长度必须为小于 100 的正整数。"
}

View file

@ -9,7 +9,5 @@
"random.help.shuffle": "打乱集合的顺序。",
"random.help.string": "生成随机字符串,默认为字母和数字组合。",
"random.help.uuid": "生成随机 UUIDv4。",
"random.message.number.error.invalid": "发生错误:无效的数字区间。",
"random.message.number.error.out_of_range": "发生错误:最小值大于最大值。",
"random.message.string.error.invalid": "发生错误:长度必须为小于 100 的正整数。"
}

View file

@ -9,7 +9,5 @@
"random.help.shuffle": "打亂集合的順序。",
"random.help.string": "產生隨機字串,預設為字母或數字組合。",
"random.help.uuid": "產生隨機 UUIDv4。",
"random.message.number.error.invalid": "發生錯誤:無效的數字區間。",
"random.message.number.error.out_of_range": "發生錯誤:最小值大於最大值。",
"random.message.string.error.invalid": "發生錯誤:長度必須為小於 100 的正整數。"
}