Run pre-commit hooks
This commit is contained in:
parent
43081763d8
commit
49c557e0d9
|
@ -187,13 +187,13 @@ async def _(event: Event):
|
|||
|
||||
@bot.on_message('group')
|
||||
async def _(event: Event):
|
||||
result = BotDBUtil.GroupBlockList.check(f'QQ|Group|{str(event.group_id)}')
|
||||
if result:
|
||||
res = Locale(lang).t('tos.message.in_group_blocklist')
|
||||
if Config('issue_url'):
|
||||
res += '\n' + Locale(lang).t('tos.message.appeal', issue_url=Config('issue_url'))
|
||||
await bot.send(event=event, message=res)
|
||||
await bot.call_action('set_group_leave', group_id=event.group_id)
|
||||
result = BotDBUtil.GroupBlockList.check(f'QQ|Group|{str(event.group_id)}')
|
||||
if result:
|
||||
res = Locale(lang).t('tos.message.in_group_blocklist')
|
||||
if Config('issue_url'):
|
||||
res += '\n' + Locale(lang).t('tos.message.appeal', issue_url=Config('issue_url'))
|
||||
await bot.send(event=event, message=res)
|
||||
await bot.call_action('set_group_leave', group_id=event.group_id)
|
||||
|
||||
|
||||
qq_host = Config("qq_host")
|
||||
|
|
|
@ -7,4 +7,4 @@ from bots.discord.slash_parser import slash_parser
|
|||
@client.slash_command(name="bilibili", description="Send video ID for video info.")
|
||||
@discord.option(name="bid", description="Bilibili video ID.")
|
||||
async def bilibili(ctx: discord.ApplicationContext, bid: str):
|
||||
await slash_parser(ctx, bid)
|
||||
await slash_parser(ctx, bid)
|
||||
|
|
|
@ -11,4 +11,4 @@ async def mcv(ctx: discord.ApplicationContext):
|
|||
|
||||
@client.slash_command(name="mcbv", description="Get the latest version of Minecraft: Bedrock Edition on Mojira.")
|
||||
async def mcbv(ctx: discord.ApplicationContext):
|
||||
await slash_parser(ctx, '')
|
||||
await slash_parser(ctx, '')
|
||||
|
|
|
@ -6,7 +6,10 @@ from bots.discord.slash_parser import slash_parser
|
|||
|
||||
@client.slash_command(name="user", description="Get information about a MediaWiki user.")
|
||||
@discord.option(name="username", description="The username, support Interwiki.")
|
||||
@discord.option(name="enable_profile", choices=['false', 'true'], description="Whether to get extra information about sites using SocialProFile extension.")
|
||||
@discord.option(name="enable_profile",
|
||||
choices=['false',
|
||||
'true'],
|
||||
description="Whether to get extra information about sites using SocialProFile extension.")
|
||||
async def user(ctx: discord.ApplicationContext, username: str, enable_profile: str):
|
||||
p = "-p" if enable_profile == "true" else ""
|
||||
await slash_parser(ctx, f"{username} {p}")
|
||||
|
|
|
@ -126,7 +126,7 @@ async def _(event):
|
|||
if tiny_id == GuildAccountInfo.tiny_id:
|
||||
return
|
||||
reply_id = None
|
||||
match_reply = re.match(r'^\[CQ:reply,id=(-?\d+).*\].*', event.message)
|
||||
match_reply = re.match(r'^\\[CQ:reply,id=(-?\\d+).*\\].*', event.message)
|
||||
if match_reply:
|
||||
reply_id = int(match_reply.group(1))
|
||||
target_id = f'QQ|Guild|{str(event.guild_id)}|{str(event.channel_id)}'
|
||||
|
|
|
@ -70,7 +70,7 @@ class FormattedTime:
|
|||
self.seconds = seconds
|
||||
self.timezone = timezone
|
||||
|
||||
def to_str(self, msg: MessageSession=None):
|
||||
def to_str(self, msg: MessageSession = None):
|
||||
ftime_template = []
|
||||
if msg:
|
||||
if self.date:
|
||||
|
@ -260,7 +260,7 @@ class Embed(EmbedT):
|
|||
else:
|
||||
raise TypeError(f"Invalid type {type(f)} for EmbedField")
|
||||
|
||||
def to_message_chain(self, msg: MessageSession=None):
|
||||
def to_message_chain(self, msg: MessageSession = None):
|
||||
text_lst = []
|
||||
if self.title:
|
||||
text_lst.append(self.title)
|
||||
|
|
|
@ -30,7 +30,7 @@ class MessageSession(MessageSessionT):
|
|||
forward = False
|
||||
delete = True
|
||||
wait = True
|
||||
|
||||
|
||||
async def send_message(self, message_chain, quote=True, disable_secret_check=False,
|
||||
allow_split_image=True, callback=None) -> FinishedSession:
|
||||
message_chain = MessageChain(message_chain)
|
||||
|
@ -71,7 +71,7 @@ class MessageSession(MessageSessionT):
|
|||
if append_instruction:
|
||||
print(self.locale.t("message.wait.prompt.next_message"))
|
||||
send = await self.send_message(message_chain)
|
||||
|
||||
|
||||
c = await aioconsole.ainput('Confirm: ')
|
||||
if message_chain and delete:
|
||||
await send.delete()
|
||||
|
@ -94,7 +94,7 @@ class MessageSession(MessageSessionT):
|
|||
sender_from='TEST', client_name='TEST', message_id=0,
|
||||
reply_id=None),
|
||||
session=Session(message=c, target='TEST|Console|0', sender='TEST|0'))
|
||||
|
||||
|
||||
async def wait_anyone(self, message_chain=None, quote=True, delete=False, timeout=120):
|
||||
send = None
|
||||
if message_chain:
|
||||
|
|
|
@ -38,6 +38,7 @@ async def check_temp_ban(target):
|
|||
else:
|
||||
return False
|
||||
|
||||
|
||||
async def remove_temp_ban(target):
|
||||
if await check_temp_ban(target):
|
||||
del temp_ban_counter[target]
|
||||
|
@ -120,8 +121,8 @@ async def parser(msg: Bot.MessageSession, require_enable_modules: bool = True, p
|
|||
if get_custom_alias:
|
||||
get_display_alias = get_custom_alias.get(command_split[0])
|
||||
if get_display_alias:
|
||||
command_split[0] = get_display_alias # 将自定义别名替换为命令
|
||||
msg.trigger_msg = ' '.join(command_split) # 重新连接消息
|
||||
command_split[0] = get_display_alias # 将自定义别名替换为命令
|
||||
msg.trigger_msg = ' '.join(command_split) # 重新连接消息
|
||||
|
||||
msg.prefixes = command_prefix.copy() # 复制一份作为基础命令前缀
|
||||
get_custom_prefix = msg.options.get('command_prefix') # 获取自定义命令前缀
|
||||
|
@ -359,8 +360,7 @@ async def parser(msg: Bot.MessageSession, require_enable_modules: bool = True, p
|
|||
Logger.debug(f'Tos is disabled, check the configuration if it is not work as expected.')
|
||||
if enable_analytics:
|
||||
BotDBUtil.Analytics(msg).add(msg.trigger_msg, command_first_word, 'normal')
|
||||
|
||||
|
||||
|
||||
except AbuseWarning as e:
|
||||
await tos_abuse_warning(msg, e)
|
||||
|
||||
|
@ -383,7 +383,7 @@ async def parser(msg: Bot.MessageSession, require_enable_modules: bool = True, p
|
|||
Locale(lang).t('error.message.report', module=msg.trigger_msg) + tb, disable_secret_check=True)
|
||||
if command_first_word in current_unloaded_modules:
|
||||
await msg.send_message(
|
||||
msg.locale.t('parser.module.unloaded', module=command_first_word))
|
||||
msg.locale.t('parser.module.unloaded', module=command_first_word))
|
||||
elif command_first_word in err_modules:
|
||||
await msg.send_message(msg.locale.t('error.module.unloaded', module=command_first_word))
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ report_targets = Config('report_targets')
|
|||
WARNING_COUNTS = Config('tos_warning_counts', 5)
|
||||
|
||||
|
||||
async def warn_target(msg: Bot.MessageSession, reason = None):
|
||||
async def warn_target(msg: Bot.MessageSession, reason=None):
|
||||
if WARNING_COUNTS >= 1 and not msg.check_super_user():
|
||||
current_warns = int(msg.target.sender_info.query.warns) + 1
|
||||
msg.target.sender_info.edit('warns', current_warns)
|
||||
|
@ -40,7 +40,7 @@ async def pardon_user(user: str):
|
|||
BotDBUtil.SenderInfo(user).edit('warns', 0)
|
||||
|
||||
|
||||
async def warn_user(user: str, count = 1):
|
||||
async def warn_user(user: str, count=1):
|
||||
current_warns = int(BotDBUtil.SenderInfo(user).query.warns) + count
|
||||
BotDBUtil.SenderInfo(user).edit('warns', current_warns)
|
||||
if current_warns > WARNING_COUNTS and WARNING_COUNTS >= 1:
|
||||
|
@ -48,7 +48,7 @@ async def warn_user(user: str, count = 1):
|
|||
return current_warns
|
||||
|
||||
|
||||
async def tos_report(sender, target, reason = None, banned = False):
|
||||
async def tos_report(sender, target, reason=None, banned=False):
|
||||
locale = Locale(lang)
|
||||
if report_targets:
|
||||
warn_template = [locale.t("tos.message.report", sender=sender, target=target)]
|
||||
|
|
|
@ -103,8 +103,9 @@ async def msgchain2image(message_chain: Union[List, MessageChain], msg: MessageS
|
|||
data = await fi.read()
|
||||
try:
|
||||
ftt = ft.match(data)
|
||||
lst.append(f'<img src="data:{ftt.mime};base64,{
|
||||
(base64.encodebytes(data)).decode("utf-8")}" width="720" />')
|
||||
lst.append(f'< img src="data: {ftt.mime}
|
||||
base64, {
|
||||
(base64.encodebytes(data)).decode("utf-8")}" width="720" / >')
|
||||
except TypeError:
|
||||
traceback.print_exc()
|
||||
if isinstance(m, Voice):
|
||||
|
@ -135,12 +136,12 @@ async def msgchain2image(message_chain: Union[List, MessageChain], msg: MessageS
|
|||
except aiohttp.ClientConnectorError:
|
||||
if use_local:
|
||||
pic = await download_to_cache(webrender('element_screenshot', use_local=False),
|
||||
status_code=200,
|
||||
method='POST',
|
||||
headers={'Content-Type': 'application/json'},
|
||||
post_data=html_,
|
||||
request_private_ip=True
|
||||
)
|
||||
status_code=200,
|
||||
method='POST',
|
||||
headers={'Content-Type': 'application/json'},
|
||||
post_data=html_,
|
||||
request_private_ip=True
|
||||
)
|
||||
else:
|
||||
Logger.info('[Webrender] Generation Failed.')
|
||||
return False
|
||||
|
|
|
@ -8,6 +8,7 @@ from core.utils.ip import IP
|
|||
web_render = CFG.get_url('web_render')
|
||||
web_render_local = CFG.get_url('web_render_local')
|
||||
|
||||
|
||||
class WebRender:
|
||||
status = False
|
||||
local = False
|
||||
|
@ -56,4 +57,4 @@ async def check_web_render():
|
|||
except Exception:
|
||||
Logger.error('[Webrender] Webrender is not working as expected.')
|
||||
Logger.error(traceback.format_exc())
|
||||
WebRender.status = False
|
||||
WebRender.status = False
|
||||
|
|
|
@ -304,7 +304,6 @@ class BotDBUtil:
|
|||
else:
|
||||
return False
|
||||
|
||||
|
||||
class Data:
|
||||
def __init__(self, msg: Union[MessageSession, FetchTarget, str]):
|
||||
if isinstance(msg, MessageSession):
|
||||
|
|
|
@ -51,6 +51,7 @@ else:
|
|||
|
||||
a = module('ask', developers=['Dianliang233'], desc='{ask.help.desc}')
|
||||
|
||||
|
||||
@a.command('[-4] <question> {{ask.help}}')
|
||||
@a.regex(r'^(?:question||问|問)[\::]\s?(.+?)[??]$', flags=re.I, desc='{ask.help.regex}')
|
||||
async def _(msg: Bot.MessageSession):
|
||||
|
@ -129,7 +130,7 @@ async def _(msg: Bot.MessageSession):
|
|||
content = block['content']['code']
|
||||
try:
|
||||
chain.append(Image(PILImage.open(io.BytesIO(await generate_code_snippet(content,
|
||||
block['content']['language'])))))
|
||||
block['content']['language'])))))
|
||||
except Exception as e:
|
||||
chain.append(Plain(msg.locale.t('ask.message.text2img.error', text=content)))
|
||||
|
||||
|
@ -142,13 +143,14 @@ async def _(msg: Bot.MessageSession):
|
|||
else:
|
||||
await msg.finish(msg.locale.t('message.cooldown', time=int(c), cd_time=60))
|
||||
|
||||
|
||||
def parse_markdown(md: str):
|
||||
regex = r'(```[\s\S]*?\n```|\\\[[\s\S]*?\\\]|[^\n]+)'
|
||||
|
||||
blocks = []
|
||||
for match in re.finditer(regex, md):
|
||||
content = match.group(1)
|
||||
|
||||
|
||||
if content.startswith('```'):
|
||||
block = 'code'
|
||||
try:
|
||||
|
@ -165,9 +167,11 @@ def parse_markdown(md: str):
|
|||
|
||||
return blocks
|
||||
|
||||
|
||||
enc = tiktoken.encoding_for_model('gpt-3.5-turbo')
|
||||
INSTRUCTIONS_LENGTH = len(enc.encode(INSTRUCTIONS))
|
||||
SPECIAL_TOKEN_LENGTH = 109
|
||||
|
||||
|
||||
def count_token(text: str):
|
||||
return len(enc.encode(text, allowed_special="all")) + SPECIAL_TOKEN_LENGTH + INSTRUCTIONS_LENGTH
|
||||
|
|
|
@ -15,7 +15,7 @@ bili = module('bilibili', alias='bili', developers=['DoroWolf'],
|
|||
options_desc={'-i': '{bilibili.help.option.i}'},
|
||||
exclude_from=['Discord|Channel'])
|
||||
@bili.command('<bid> {{bilibili.help}}', available_for=['Discord|Channel'])
|
||||
async def _(msg: Bot.MessageSession, bid: str, get_detail = False):
|
||||
async def _(msg: Bot.MessageSession, bid: str, get_detail=False):
|
||||
if msg.parsed_msg.get('-i', False):
|
||||
get_detail = True
|
||||
if bid[:2].upper() == "BV":
|
||||
|
|
|
@ -10,7 +10,7 @@ headers = {
|
|||
}
|
||||
|
||||
|
||||
async def get_video_info(msg: Bot.MessageSession, query, get_detail = False, use_embed = False):
|
||||
async def get_video_info(msg: Bot.MessageSession, query, get_detail=False, use_embed=False):
|
||||
if msg.target.sender_from in ['Discord|Client']:
|
||||
use_embed = True
|
||||
try:
|
||||
|
|
|
@ -36,4 +36,4 @@ async def regex_bugtracker(msg: Bot.MessageSession):
|
|||
if screenshot:
|
||||
await msg.finish(Image(screenshot))
|
||||
else:
|
||||
await msg.finish()
|
||||
await msg.finish()
|
||||
|
|
|
@ -101,12 +101,12 @@ async def _(msg: Bot.MessageSession, color: str = None):
|
|||
align='center',
|
||||
spacing=20)
|
||||
await msg.finish(Embed(color=int(color_hex[1:], 16),
|
||||
image=BImage(img),
|
||||
fields=[EmbedField('HEX', color_hex, inline=True),
|
||||
EmbedField('RGB', color_rgb, inline=True),
|
||||
EmbedField('HSL', color_hsl, inline=True),
|
||||
EmbedField(css_color_name, css_color_name_raw[0]),
|
||||
EmbedField(material_color_name, material_color_name_raw[0])]))
|
||||
image=BImage(img),
|
||||
fields=[EmbedField('HEX', color_hex, inline=True),
|
||||
EmbedField('RGB', color_rgb, inline=True),
|
||||
EmbedField('HSL', color_hsl, inline=True),
|
||||
EmbedField(css_color_name, css_color_name_raw[0]),
|
||||
EmbedField(material_color_name, material_color_name_raw[0])]))
|
||||
|
||||
|
||||
def get_luminance(color: webcolors.HTML5SimpleColor):
|
||||
|
|
|
@ -96,9 +96,9 @@ async def _(msg: Bot.MessageSession):
|
|||
data_ = {}
|
||||
for m in range(12):
|
||||
new = datetime.now().replace(day=1, hour=0, minute=0, second=0) + relativedelta(months=1) - \
|
||||
relativedelta(months=12 - m - 1)
|
||||
relativedelta(months=12 - m - 1)
|
||||
old = datetime.now().replace(day=1, hour=0, minute=0, second=0) + relativedelta(months=1) - \
|
||||
relativedelta(months=12 - m)
|
||||
relativedelta(months=12 - m)
|
||||
get_ = BotDBUtil.Analytics.get_count_by_times(new, old, module_)
|
||||
data_[old.month] = get_
|
||||
data_x = []
|
||||
|
|
|
@ -30,8 +30,8 @@ m = module('module',
|
|||
'load <module> ...',
|
||||
'unload <module> ...',
|
||||
'list [-l] {{core.help.module.list}}'],
|
||||
options_desc={'-l': '{help.option.l}'},
|
||||
exclude_from=['QQ|Guild'])
|
||||
options_desc={'-l': '{help.option.l}'},
|
||||
exclude_from=['QQ|Guild'])
|
||||
async def _(msg: Bot.MessageSession):
|
||||
if msg.parsed_msg.get('list', False):
|
||||
legacy = False
|
||||
|
@ -437,10 +437,10 @@ async def _(msg: Bot.MessageSession):
|
|||
if module_.developers:
|
||||
appends.append(msg.locale.t('message.delimiter').join(module_.developers))
|
||||
if module_.base and not (
|
||||
module_.hide or module_.required_superuser or module_.required_base_superuser):
|
||||
module_.hide or module_.required_superuser or module_.required_base_superuser):
|
||||
essential.append(appends)
|
||||
if x in target_enabled_list and not (
|
||||
module_.hide or module_.required_superuser or module_.required_base_superuser):
|
||||
module_.hide or module_.required_superuser or module_.required_base_superuser):
|
||||
m.append(appends)
|
||||
if essential:
|
||||
tables.append(ImageTable(
|
||||
|
@ -472,15 +472,15 @@ async def _(msg: Bot.MessageSession):
|
|||
help_msg = [msg.locale.t("core.message.help.legacy.base")]
|
||||
essential = []
|
||||
for x in module_list:
|
||||
if module_list[x].base and not (module_list[x].hide or
|
||||
module_list[x].required_superuser or module_list[x].required_base_superuser):
|
||||
if module_list[x].base and not (
|
||||
module_list[x].hide or module_list[x].required_superuser or module_list[x].required_base_superuser):
|
||||
essential.append(module_list[x].bind_prefix)
|
||||
help_msg.append(' | '.join(essential))
|
||||
help_msg.append(msg.locale.t("core.message.help.legacy.external"))
|
||||
module_ = []
|
||||
for x in module_list:
|
||||
if x in target_enabled_list and not (module_list[x].hide or
|
||||
module_list[x].required_superuser or module_list[x].required_base_superuser):
|
||||
if x in target_enabled_list and not (
|
||||
module_list[x].hide or module_list[x].required_superuser or module_list[x].required_base_superuser):
|
||||
module_.append(x)
|
||||
help_msg.append(' | '.join(module_))
|
||||
help_msg.append(
|
||||
|
@ -507,7 +507,7 @@ async def modules_help(msg: Bot.MessageSession, legacy):
|
|||
help_msg = [msg.locale.t("core.message.module.list.prompt", prefix=msg.prefixes[0])]
|
||||
if Config('help_url'):
|
||||
help_msg.append(msg.locale.t(
|
||||
"core.message.help.more_information.document",
|
||||
"core.message.help.more_information.document",
|
||||
url=Config('help_url')))
|
||||
if msg.Feature.image and not legacy:
|
||||
try:
|
||||
|
@ -572,7 +572,7 @@ async def modules_help(msg: Bot.MessageSession, legacy):
|
|||
if x[0] == '_':
|
||||
continue
|
||||
if module_list[x].base or module_list[x].hide or \
|
||||
module_list[x].required_superuser or module_list[x].required_base_superuser:
|
||||
module_list[x].required_superuser or module_list[x].required_base_superuser:
|
||||
continue
|
||||
module_.append(module_list[x].bind_prefix)
|
||||
help_msg.append(' | '.join(module_))
|
||||
|
|
|
@ -217,6 +217,7 @@ async def _(msg: Bot.MessageSession, target: str):
|
|||
|
||||
res = module('reset', required_superuser=True, base=True)
|
||||
|
||||
|
||||
@res.command()
|
||||
async def reset(msg: Bot.MessageSession):
|
||||
confirm = await msg.wait_confirm(msg.locale.t("core.message.confirm"), append_instruction=False)
|
||||
|
@ -330,6 +331,7 @@ if Info.subprocess:
|
|||
|
||||
exit_ = module('exit', required_superuser=True, base=True, available_for=['TEST|Console'])
|
||||
|
||||
|
||||
@exit_.command()
|
||||
async def _(msg: Bot.MessageSession):
|
||||
confirm = await msg.wait_confirm(msg.locale.t("core.message.confirm"), append_instruction=False, delete=False)
|
||||
|
@ -525,6 +527,7 @@ if Config('enable_petal'):
|
|||
|
||||
lagrange = module('lagrange', required_superuser=True, base=True)
|
||||
|
||||
|
||||
@lagrange.command()
|
||||
async def _(msg: Bot.MessageSession):
|
||||
await msg.finish(f'Keepalive: {str(Temp.data.get("lagrange_keepalive", "None"))}\n'
|
||||
|
|
|
@ -69,6 +69,7 @@ admin = module('admin',
|
|||
'ban list': 'admin ban list'},
|
||||
desc='{core.help.admin.desc}')
|
||||
|
||||
|
||||
@admin.command([
|
||||
'add <user> {{core.help.admin.add}}',
|
||||
'remove <user> {{core.help.admin.remove}}',
|
||||
|
|
|
@ -6,7 +6,7 @@ dice = module('dice', alias=['rd', 'roll'], developers=['Light-Beacon', 'DoroWol
|
|||
|
||||
|
||||
@dice.command('<dices> [<dc>] {{dice.help}}')
|
||||
async def _(msg: Bot.MessageSession, dices: str, dc = None):
|
||||
async def _(msg: Bot.MessageSession, dices: str, dc=None):
|
||||
await msg.finish(await process_expression(msg, dices, dc))
|
||||
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ class Dice(DiceItemBase):
|
|||
if not dice_sides.isdigit():
|
||||
raise DiceValueError(msg,
|
||||
msg.locale.t("dice.message.error.value.sides.invalid"),
|
||||
dice_sides)
|
||||
dice_sides)
|
||||
if not dice_adv.isdigit():
|
||||
raise DiceValueError(msg,
|
||||
msg.locale.t("dice.message.error.value.advantage.invalid"),
|
||||
|
@ -157,7 +157,7 @@ class Dice(DiceItemBase):
|
|||
output += f'={result}'
|
||||
if len(output) > MAX_OUTPUT_LEN:
|
||||
output = msg.locale.t("dice.message.too_long")
|
||||
self.detail = output
|
||||
self.detail = output
|
||||
self.result = result
|
||||
|
||||
|
||||
|
@ -175,7 +175,6 @@ class FudgeDice(DiceItemBase):
|
|||
msg.locale.t("dice.message.error.value.count.out_of_range", max=MAX_DICE_COUNT),
|
||||
self.count)
|
||||
|
||||
|
||||
def GetArgs(self, msg):
|
||||
dice_code = self.code.upper() # 便于识别
|
||||
dice_count = '4' # 骰子数量
|
||||
|
@ -213,7 +212,7 @@ class FudgeDice(DiceItemBase):
|
|||
output += f'={result}'
|
||||
if len(output) > MAX_OUTPUT_LEN:
|
||||
output = msg.locale.t("dice.message.too_long")
|
||||
self.detail = output
|
||||
self.detail = output
|
||||
self.result = result
|
||||
|
||||
|
||||
|
@ -244,7 +243,7 @@ class BonusPunishDice(DiceItemBase):
|
|||
dice_count = temp[1]
|
||||
elif 'P' in dice_code:
|
||||
positive = True
|
||||
temp = dice_code.split('P')
|
||||
temp = dice_code.split('P')
|
||||
if temp[1]:
|
||||
dice_count = temp[1]
|
||||
|
||||
|
@ -295,12 +294,13 @@ class BonusPunishDice(DiceItemBase):
|
|||
output += f'={result}'
|
||||
if len(output) > MAX_OUTPUT_LEN:
|
||||
output = msg.locale.t("dice.message.too_long")
|
||||
self.detail = output
|
||||
self.detail = output
|
||||
self.result = result
|
||||
|
||||
|
||||
class WODDice(DiceItemBase):
|
||||
"""无限骰子项"""
|
||||
|
||||
def __init__(self, msg, dice_code: str):
|
||||
|
||||
dice_code = dice_code.replace(' ', '')
|
||||
|
@ -348,17 +348,22 @@ class WODDice(DiceItemBase):
|
|||
if not dice_success_line.isdigit():
|
||||
raise DiceValueError(msg,
|
||||
msg.locale.t("dice.message.error.value.dice_success_line.invalid"),
|
||||
dice_success_line)
|
||||
dice_success_line)
|
||||
if not dice_success_line_max.isdigit():
|
||||
raise DiceValueError(msg,
|
||||
msg.locale.t("dice.message.error.value.dice_success_line.invalid"),
|
||||
dice_success_line_max)
|
||||
dice_success_line_max)
|
||||
if not dice_sides.isdigit():
|
||||
raise DiceValueError(msg,
|
||||
msg.locale.t("dice.message.error.value.sides.invalid"),
|
||||
dice_sides)
|
||||
|
||||
return (int(dice_count), int(dice_add_line), int(dice_success_line), int(dice_success_line_max), int(dice_sides))
|
||||
dice_sides)
|
||||
|
||||
return (
|
||||
int(dice_count),
|
||||
int(dice_add_line),
|
||||
int(dice_success_line),
|
||||
int(dice_success_line_max),
|
||||
int(dice_sides))
|
||||
|
||||
def Roll(self, msg):
|
||||
output = self.code
|
||||
|
@ -368,7 +373,7 @@ class WODDice(DiceItemBase):
|
|||
dice_count = self.count
|
||||
success_line = self.success_line
|
||||
success_line_max = self.success_line_max
|
||||
|
||||
|
||||
output_buffer = '=['
|
||||
while dice_count:
|
||||
dice_results = []
|
||||
|
@ -377,13 +382,13 @@ class WODDice(DiceItemBase):
|
|||
# 生成随机序列
|
||||
for i in range(dice_count):
|
||||
dice_results.append(secrets.randbelow(int(self.sides)) + 1)
|
||||
|
||||
|
||||
if success_line and success_line <= dice_results[i]:
|
||||
indexes.append(i)
|
||||
if success_line_max and success_line_max >= dice_results[i]:
|
||||
indexes.append(i)
|
||||
indexes = list(set(indexes))
|
||||
|
||||
|
||||
if add_line:
|
||||
if dice_results[i] >= add_line:
|
||||
dice_exceed_results.append(True)
|
||||
|
@ -417,17 +422,18 @@ class WODDice(DiceItemBase):
|
|||
if self.count >= MAX_OUTPUT_CNT:
|
||||
output_buffer = '=[' + msg.locale.t("dice.message.output.too_long", length=self.count) + ']'
|
||||
output += output_buffer
|
||||
|
||||
|
||||
result = success_count
|
||||
output += f'={result}'
|
||||
if len(output) > MAX_OUTPUT_LEN:
|
||||
output = msg.locale.t("dice.message.too_long")
|
||||
self.detail = output
|
||||
self.detail = output
|
||||
self.result = result
|
||||
|
||||
|
||||
class DXDice(DiceItemBase):
|
||||
"""双重十字骰子项"""
|
||||
|
||||
def __init__(self, msg, dice_code: str):
|
||||
|
||||
dice_code = dice_code.replace(' ', '')
|
||||
|
@ -471,7 +477,7 @@ class DXDice(DiceItemBase):
|
|||
if not dice_sides.isdigit():
|
||||
raise DiceValueError(msg,
|
||||
msg.locale.t("dice.message.error.value.sides.invalid"),
|
||||
dice_sides)
|
||||
dice_sides)
|
||||
return (int(dice_count), int(dice_add_line), int(dice_sides))
|
||||
|
||||
def Roll(self, msg):
|
||||
|
@ -480,7 +486,7 @@ class DXDice(DiceItemBase):
|
|||
dice_rounds = 0
|
||||
add_line = self.add_line
|
||||
dice_count = self.count
|
||||
|
||||
|
||||
output_buffer = '=['
|
||||
while dice_count:
|
||||
dice_results = []
|
||||
|
@ -513,10 +519,10 @@ class DXDice(DiceItemBase):
|
|||
if self.count >= MAX_OUTPUT_CNT:
|
||||
output_buffer = '=[' + msg.locale.t("dice.message.output.too_long", length=self.count) + ']'
|
||||
output += output_buffer
|
||||
|
||||
|
||||
result = (dice_rounds - 1) * self.sides + max(dice_results)
|
||||
output += f'={result}'
|
||||
if len(output) > MAX_OUTPUT_LEN:
|
||||
output = msg.locale.t("dice.message.too_long")
|
||||
self.detail = output
|
||||
self.detail = output
|
||||
self.result = result
|
||||
|
|
|
@ -47,15 +47,15 @@ se = SimpleEval()
|
|||
se.functions.update(math_funcs)
|
||||
|
||||
|
||||
async def process_expression(msg, expr: str, dc, use_markdown = False):
|
||||
async def process_expression(msg, expr: str, dc, use_markdown=False):
|
||||
if not all([MAX_DICE_COUNT > 0, MAX_ROLL_TIMES > 0, MAX_OUTPUT_CNT > 0,
|
||||
MAX_OUTPUT_LEN > 0, MAX_DETAIL_CNT > 0, MAX_ITEM_COUNT > 0]):
|
||||
raise ConfigValueError(msg.locale.t("error.config.invalid"))
|
||||
if msg.target.sender_from in ['Discord|Client', 'Kook|User']:
|
||||
use_markdown = True
|
||||
if use_markdown:
|
||||
expr = expr.replace('*', '\*')
|
||||
expr = expr.replace(r'\\*', '\*')
|
||||
expr = expr.replace('*', '\\*')
|
||||
expr = expr.replace(r'\\*', '\\*')
|
||||
|
||||
dice_list, count, times, err = parse_dice_expression(msg, expr)
|
||||
if err:
|
||||
|
@ -68,7 +68,7 @@ def parse_dice_expression(msg, dices):
|
|||
dice_item_list = []
|
||||
math_func_pattern = '(' + '|'.join(re.escape(func) for func in math_funcs.keys()) + ')' # 数学函数
|
||||
errmsg = None
|
||||
|
||||
|
||||
# 切分骰子表达式
|
||||
if '#' in dices:
|
||||
times = dices.partition('#')[0]
|
||||
|
@ -83,7 +83,7 @@ def parse_dice_expression(msg, dices):
|
|||
dice_expr_list = [item for item in dice_expr_list if item] # 清除空白元素
|
||||
for item in range(len(dice_expr_list)):
|
||||
if dice_expr_list[item][-1].upper() == 'D' and dice_expr_list[item] not in math_funcs.keys()\
|
||||
and msg.data.options.get('dice_default_sides'):
|
||||
and msg.data.options.get('dice_default_sides'):
|
||||
dice_expr_list[item] += str(msg.data.options.get('dice_default_sides'))
|
||||
|
||||
for i, item in enumerate(dice_expr_list): # 将所有骰子项切片转为大写
|
||||
|
@ -102,7 +102,7 @@ def parse_dice_expression(msg, dices):
|
|||
if len(dice_item_list) > MAX_ITEM_COUNT:
|
||||
errmsg = msg.locale.t('dice.message.error.value.too_long')
|
||||
return None, None, None, DiceValueError(msg, msg.locale.t('dice.message.error') + errmsg).message
|
||||
|
||||
|
||||
dice_count = 0
|
||||
# 初始化骰子序列
|
||||
for j, item in enumerate(dice_expr_list):
|
||||
|
@ -133,6 +133,8 @@ def parse_dice_expression(msg, dices):
|
|||
return dice_expr_list, dice_count, int(times), None
|
||||
|
||||
# 在数字与数字之间加上乘号
|
||||
|
||||
|
||||
def insert_multiply(lst, use_markdown=False):
|
||||
result = []
|
||||
asterisk = '/*' if use_markdown else '*'
|
||||
|
@ -140,18 +142,20 @@ def insert_multiply(lst, use_markdown=False):
|
|||
if i == 0:
|
||||
result.append(lst[i])
|
||||
else:
|
||||
if lst[i-1][-1].isdigit() and lst[i][0].isdigit():
|
||||
if lst[i - 1][-1].isdigit() and lst[i][0].isdigit():
|
||||
result.append(asterisk)
|
||||
elif lst[i-1][-1] == ')' and lst[i][0] == '(':
|
||||
elif lst[i - 1][-1] == ')' and lst[i][0] == '(':
|
||||
result.append(asterisk)
|
||||
elif lst[i-1][-1].isdigit() and lst[i][0] == '(':
|
||||
elif lst[i - 1][-1].isdigit() and lst[i][0] == '(':
|
||||
result.append(asterisk)
|
||||
elif lst[i-1][-1] == ')' and lst[i][0].isdigit():
|
||||
elif lst[i - 1][-1] == ')' and lst[i][0].isdigit():
|
||||
result.append(asterisk)
|
||||
result.append(lst[i])
|
||||
return result
|
||||
|
||||
# 开始投掷并生成消息
|
||||
|
||||
|
||||
def generate_dice_message(msg, expr, dice_expr_list, dice_count, times, dc, use_markdown=False):
|
||||
success_num = 0
|
||||
fail_num = 0
|
||||
|
@ -185,7 +189,7 @@ def generate_dice_message(msg, expr, dice_expr_list, dice_count, times, dc, use_
|
|||
try:
|
||||
if dice_res_list:
|
||||
dice_res = ''.join(dice_res_list)
|
||||
dice_res = dice_res.replace('\*', '*')
|
||||
dice_res = dice_res.replace('\\*', '*')
|
||||
Logger.debug(dice_res)
|
||||
result = int(se.eval(dice_res))
|
||||
else:
|
||||
|
|
|
@ -9,10 +9,10 @@ t = module('embed_test', required_superuser=True)
|
|||
@t.handle()
|
||||
async def _(msg: Bot.MessageSession):
|
||||
await msg.finish(Embed(title='Embed Test', description='This is a test embed.',
|
||||
url='https://minecraft.fandom.com/zh/wiki/Minecraft_Wiki',
|
||||
color=0x00ff00, timestamp=datetime.datetime.now().timestamp(),
|
||||
author='oasisakari',
|
||||
footer='Test',
|
||||
image=Image('https://avatars.githubusercontent.com/u/68471503?s=200&v=4'),
|
||||
fields=[EmbedField('oaoa', 'aaaaa'),
|
||||
EmbedField('oaoa', 'aaaaa', inline=True)]))
|
||||
url='https://minecraft.fandom.com/zh/wiki/Minecraft_Wiki',
|
||||
color=0x00ff00, timestamp=datetime.datetime.now().timestamp(),
|
||||
author='oasisakari',
|
||||
footer='Test',
|
||||
image=Image('https://avatars.githubusercontent.com/u/68471503?s=200&v=4'),
|
||||
fields=[EmbedField('oaoa', 'aaaaa'),
|
||||
EmbedField('oaoa', 'aaaaa', inline=True)]))
|
||||
|
|
|
@ -69,4 +69,4 @@ Created {time_diff(result['created_at'])} ago | Updated {time_diff(result['updat
|
|||
if str(e).startswith('404'):
|
||||
await msg.finish(msg.locale.t("github.message.repo.not_found"))
|
||||
else:
|
||||
traceback.print_exc()
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -46,4 +46,4 @@ Account Created {time_diff(result['created_at'])} ago | Latest activity {time_di
|
|||
if str(e).startswith('404'):
|
||||
await msg.finish(msg.locale.t("github.message.repo.not_found"))
|
||||
else:
|
||||
traceback.print_exc()
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -222,4 +222,4 @@ async def _(msg: Bot.MessageSession, username: str):
|
|||
async def _(msg: Bot.MessageSession):
|
||||
unbind = DivingProberBindInfoManager(msg).remove_bind_info()
|
||||
if unbind:
|
||||
await msg.finish(msg.locale.t('maimai.message.unbind.success'))
|
||||
await msg.finish(msg.locale.t('maimai.message.unbind.success'))
|
||||
|
|
|
@ -335,7 +335,7 @@ async def query_song_info(msg, query, username):
|
|||
async def _(msg: Bot.MessageSession, plate: str, username: str = None):
|
||||
await query_plate(msg, plate, username)
|
||||
|
||||
|
||||
|
||||
async def query_plate(msg, plate, username):
|
||||
if not username:
|
||||
if msg.target.sender_from == "QQ":
|
||||
|
@ -444,7 +444,6 @@ async def _(msg: Bot.MessageSession, level: str, page: str, username: str = None
|
|||
await msg.finish([Plain(output.strip())])
|
||||
|
||||
|
||||
|
||||
@mai.command('random <diff+level> [<dx_type>] {{maimai.help.random.filter}}')
|
||||
async def _(msg: Bot.MessageSession, dx_type: str = None):
|
||||
condit = msg.parsed_msg['<diff+level>']
|
||||
|
|
|
@ -40,11 +40,11 @@ async def _(msg: Bot.MessageSession):
|
|||
await msg.finish(msg.locale.t("maimai.message.music_not_found"))
|
||||
|
||||
await msg.finish(await get_info(music, Plain(msg.locale.t("maimai.message.song",
|
||||
artist=music['basic_info']['artist'],
|
||||
genre=music['basic_info']['genre'],
|
||||
bpm=music['basic_info']['bpm'],
|
||||
version=music['basic_info']['from'],
|
||||
level='/'.join((str(ds) for ds in music['ds']))))))
|
||||
artist=music['basic_info']['artist'],
|
||||
genre=music['basic_info']['genre'],
|
||||
bpm=music['basic_info']['bpm'],
|
||||
version=music['basic_info']['from'],
|
||||
level='/'.join((str(ds) for ds in music['ds']))))))
|
||||
|
||||
|
||||
@mai_regex.regex(re.compile(r"(?:id)?(\d+)\s?有什(?:么别|麼別)名", flags=re.I), desc='{maimai.help.maimai_regex.alias}')
|
||||
|
|
|
@ -3,8 +3,8 @@ from core.component import module
|
|||
from .mcv import mcv, mcbv, mcdv, mcev, mclgv
|
||||
|
||||
m = module('mcv',
|
||||
developers=['OasisAkari', 'Dianliang233'],
|
||||
recommend_modules=['mcbv'])
|
||||
developers=['OasisAkari', 'Dianliang233'],
|
||||
recommend_modules=['mcbv'])
|
||||
|
||||
|
||||
@m.command('{{mcv.help.mcv}}')
|
||||
|
@ -13,8 +13,8 @@ async def mcv_loader(msg: Bot.MessageSession):
|
|||
|
||||
|
||||
mb = module('mcbv',
|
||||
developers=['OasisAkari', 'Dianliang233'],
|
||||
recommend_modules=['mcv'])
|
||||
developers=['OasisAkari', 'Dianliang233'],
|
||||
recommend_modules=['mcv'])
|
||||
|
||||
|
||||
@mb.command('{{mcv.help.mcbv}}')
|
||||
|
@ -23,8 +23,8 @@ async def mcbv_loader(msg: Bot.MessageSession):
|
|||
|
||||
|
||||
md = module('mcdv',
|
||||
developers=['OasisAkari', 'Dianliang233'],
|
||||
hide=True)
|
||||
developers=['OasisAkari', 'Dianliang233'],
|
||||
hide=True)
|
||||
|
||||
|
||||
@md.command('{{mcv.help.mcdv}}')
|
||||
|
@ -33,8 +33,8 @@ async def mcdv_loader(msg: Bot.MessageSession):
|
|||
|
||||
|
||||
me = module('mcev',
|
||||
developers=['OasisAkari', 'Dianliang233'],
|
||||
hide=True)
|
||||
developers=['OasisAkari', 'Dianliang233'],
|
||||
hide=True)
|
||||
|
||||
|
||||
@me.command('{{mcv.help.mcev}}')
|
||||
|
@ -43,8 +43,8 @@ async def mcev_loader(msg: Bot.MessageSession):
|
|||
|
||||
|
||||
mlg = module('mclgv',
|
||||
developers=['OasisAkari', 'Dianliang233'],
|
||||
hide=True)
|
||||
developers=['OasisAkari', 'Dianliang233'],
|
||||
hide=True)
|
||||
|
||||
|
||||
@mlg.command('{{mcv.help.mclgv}}')
|
||||
|
|
|
@ -15,9 +15,9 @@ async def urban(term: str, locale: Locale):
|
|||
try:
|
||||
url = 'http://api.urbandictionary.com/v0/define?term=' + term
|
||||
text = await get_url(webrender('source', url), 200, headers={'accept': '*/*',
|
||||
'accept-encoding': 'gzip, deflate',
|
||||
'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,en-GB;q=0.6',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62'},
|
||||
'accept-encoding': 'gzip, deflate',
|
||||
'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,en-GB;q=0.6',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62'},
|
||||
request_private_ip=True)
|
||||
Logger.debug(text)
|
||||
data = json.loads(text)['list']
|
||||
|
|
|
@ -39,7 +39,7 @@ async def _(msg: Bot.MessageSession, tweet: str):
|
|||
await msg.finish(msg.locale.t('tweet.message.invalid'))
|
||||
else:
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
res_json = json.loads(res)
|
||||
if not res_json['data']:
|
||||
await msg.finish(msg.locale.t('tweet.message.not_found'))
|
||||
|
|
|
@ -63,25 +63,25 @@ async def find_solution(numbers):
|
|||
try:
|
||||
if (calc(exp) == 24 or 0 < 24 - calc(exp) < 1e-13):
|
||||
return exp
|
||||
except:
|
||||
except BaseException:
|
||||
pass
|
||||
exp = '({}{}{}){}({}{}{})'.format(perm[0], expr[0], perm[1], expr[1], perm[2], expr[2], perm[3])
|
||||
try:
|
||||
if (calc(exp) == 24 or 0 < 24 - calc(exp) < 1e-13):
|
||||
return exp
|
||||
except:
|
||||
except BaseException:
|
||||
pass
|
||||
exp = '{}{}({}{}({}{}{}))'.format(perm[0], expr[0], perm[1], expr[1], perm[2], expr[2], perm[3])
|
||||
try:
|
||||
if (calc(exp) == 24 or 0 < 24 - calc(exp) < 1e-13):
|
||||
return exp
|
||||
except:
|
||||
except BaseException:
|
||||
pass
|
||||
exp = '{}{}({}{}{}){}{}'.format(perm[0], expr[0], perm[1], expr[1], perm[2], expr[2], perm[3])
|
||||
try:
|
||||
if (calc(exp) == 24 or 0 < 24 - calc(exp) < 1e-13):
|
||||
return exp
|
||||
except:
|
||||
except BaseException:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
@ -109,7 +109,7 @@ play_state = {}
|
|||
|
||||
|
||||
@tf.command('{{twenty_four.help}}')
|
||||
async def _(msg: Bot.MessageSession, use_markdown = False):
|
||||
async def _(msg: Bot.MessageSession, use_markdown=False):
|
||||
if msg.target.sender_from in ['Discord|Client', 'Kook|User']:
|
||||
use_markdown = True
|
||||
if msg.target.target_id in play_state and play_state[msg.target.target_id]['active']:
|
||||
|
@ -133,14 +133,14 @@ async def _(msg: Bot.MessageSession, use_markdown = False):
|
|||
if (g_msg := await gained_petal(msg, 2)):
|
||||
send += '\n' + g_msg
|
||||
if use_markdown:
|
||||
send.replace('*', '\*')
|
||||
send.replace('*', '\\*')
|
||||
await answer.finish(send)
|
||||
elif check_valid(expr):
|
||||
result = calc(expr)
|
||||
if not result:
|
||||
await answer.finish(msg.locale.t('twenty_four.message.incorrect.invalid'))
|
||||
elif (result == 24 or 0 < 24 - result < 1e-13 ) \
|
||||
and contains_all_numbers(expr, numbers):
|
||||
elif (result == 24 or 0 < 24 - result < 1e-13) \
|
||||
and contains_all_numbers(expr, numbers):
|
||||
send = msg.locale.t('twenty_four.message.correct')
|
||||
if (g_msg := await gained_petal(msg, 2)):
|
||||
send += '\n' + g_msg
|
||||
|
|
|
@ -6,14 +6,14 @@ from modules.wiki.utils.dbutils import WikiTargetInfo
|
|||
from .user import get_user_info
|
||||
|
||||
usr = module('user',
|
||||
developers=['OasisAkari'],
|
||||
recommend_modules='wiki'
|
||||
)
|
||||
developers=['OasisAkari'],
|
||||
recommend_modules='wiki'
|
||||
)
|
||||
|
||||
|
||||
@usr.command('<username> [-p] {{user.help.desc}}',
|
||||
options_desc={'-p': '{user.help.option.p}'})
|
||||
async def user(msg: Bot.MessageSession, username: str, profile = False):
|
||||
options_desc={'-p': '{user.help.option.p}'})
|
||||
async def user(msg: Bot.MessageSession, username: str, profile=False):
|
||||
if msg.parsed_msg.get('-p', False):
|
||||
profile = True
|
||||
target = WikiTargetInfo(msg)
|
||||
|
|
|
@ -21,7 +21,7 @@ async def get_user_info(msg: Bot.MessageSession, wikiurl, username, profile=Fals
|
|||
if match_interwiki:
|
||||
if match_interwiki.group(1) in wiki.wiki_info.interwiki:
|
||||
await get_user_info(msg, wiki.wiki_info.interwiki[match_interwiki.group(1)],
|
||||
match_interwiki.group(2), profile)
|
||||
match_interwiki.group(2), profile)
|
||||
data = {}
|
||||
base_user_info = (await wiki.get_json(action='query', list='users', ususers=username,
|
||||
usprop='groups|blockinfo|registration|editcount|gender'))['query']['users'][0]
|
||||
|
@ -155,9 +155,9 @@ async def get_user_info(msg: Bot.MessageSession, wikiurl, username, profile=Fals
|
|||
if blocked_by := data.get('blocked_by', False):
|
||||
msgs.append(msg.locale.t('user.message.blocked', user=user))
|
||||
msgs.append(msg.locale.t('user.message.blocked.detail',
|
||||
blocked_by=blocked_by,
|
||||
blocked_time=data['blocked_time'],
|
||||
blocked_expires=data['blocked_expires']))
|
||||
blocked_by=blocked_by,
|
||||
blocked_time=data['blocked_time'],
|
||||
blocked_expires=data['blocked_expires']))
|
||||
msgs.append(msg.locale.t('user.message.blocked.reason') + data['blocked_reason'])
|
||||
|
||||
if url := data.get('url', False):
|
||||
|
|
|
@ -7,7 +7,7 @@ from modules.wiki.utils.dbutils import BotAccount as BotAccountDB
|
|||
from modules.wiki.utils.wikilib import WikiLib
|
||||
|
||||
wb = module('wiki_bot', required_superuser=True,
|
||||
alias='wbot')
|
||||
alias='wbot')
|
||||
|
||||
|
||||
@wb.handle('login <apilink> <account> <password>')
|
||||
|
@ -49,4 +49,4 @@ async def _(msg: Bot.MessageSession):
|
|||
@wb.hook('login_wiki_bots')
|
||||
async def _(fetch: Bot.FetchTarget, ctx: Bot.ModuleHookContext):
|
||||
Logger.debug('Received login_wiki_bots hook: ' + str(ctx.args['cookies']))
|
||||
BotAccount.cookies.update(ctx.args['cookies'])
|
||||
BotAccount.cookies.update(ctx.args['cookies'])
|
||||
|
|
|
@ -13,6 +13,7 @@ from .rc_qq import rc_qq
|
|||
|
||||
rc_ = module('rc', developers=['OasisAkari'], recommend_modules='wiki')
|
||||
|
||||
|
||||
@rc_.command()
|
||||
@rc_.command('[-l] {{wiki.help.rc}}',
|
||||
options_desc={'-l': '{help.option.l}'},
|
||||
|
@ -50,8 +51,8 @@ ab_ = module('ab', developers=['OasisAkari'], recommend_modules='wiki')
|
|||
|
||||
@ab_.command()
|
||||
@ab_.command('[-l] {{wiki.help.ab}}',
|
||||
options_desc={'-l': '{help.option.l}'},
|
||||
available_for=['QQ', 'QQ|Group'])
|
||||
options_desc={'-l': '{help.option.l}'},
|
||||
available_for=['QQ', 'QQ|Group'])
|
||||
async def ab_loader(msg: Bot.MessageSession):
|
||||
start_wiki = WikiTargetInfo(msg).get_start_wiki()
|
||||
if not start_wiki:
|
||||
|
@ -75,7 +76,7 @@ async def ab_loader(msg: Bot.MessageSession):
|
|||
|
||||
|
||||
@ab_.command('{{wiki.help.ab}}',
|
||||
exclude_from=['QQ', 'QQ|Group'])
|
||||
exclude_from=['QQ', 'QQ|Group'])
|
||||
async def ab_loader(msg: Bot.MessageSession):
|
||||
start_wiki = WikiTargetInfo(msg).get_start_wiki()
|
||||
if not start_wiki:
|
||||
|
|
|
@ -12,7 +12,8 @@ async def rc(msg: Bot.MessageSession, wiki_url):
|
|||
d = []
|
||||
for x in query['query']['recentchanges'][:10]:
|
||||
if 'title' in x:
|
||||
d.append(f"•{msg.ts2strftime(strptime2ts(x['timestamp']), date=False, timezone=False)} - {x['title']} .. {x['user']}")
|
||||
d.append(
|
||||
f"•{msg.ts2strftime(strptime2ts(x['timestamp']), date=False, timezone=False)} - {x['title']} .. {x['user']}")
|
||||
y = await check(*d)
|
||||
y = '\n'.join(z['content'] for z in y)
|
||||
if y.find("<吃掉了>") != -1 or y.find("<全部吃掉了>") != -1:
|
||||
|
|
|
@ -248,7 +248,6 @@ async def query_pages(session: Union[Bot.MessageSession, QueryInfo], title: Unio
|
|||
i_msg_lst.append(Plain(session.locale.t('wiki.message.invalid_section.select')))
|
||||
i_msg_lst.append(Plain(session.locale.t('message.reply.prompt')))
|
||||
|
||||
|
||||
async def _callback(msg: Bot.MessageSession):
|
||||
display = msg.as_display(text_only=True)
|
||||
if display.isdigit():
|
||||
|
|
|
@ -61,4 +61,4 @@ async def _(msg: Bot.MessageSession, question: str):
|
|||
if str(e).startswith('501'):
|
||||
await msg.finish(msg.locale.t('wolframalpha.message.incomprehensible'))
|
||||
else:
|
||||
traceback.print_exc()
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -44,11 +44,11 @@ async def check_crowdin():
|
|||
if not first and not CrowdinActivityRecords.check(identify):
|
||||
await JobQueue.trigger_hook_all('mc_crowdin', message=[Embed(title='New Crowdin Updates', description=m).to_dict()])
|
||||
else:
|
||||
detail_url = f"https://crowdin.com/backend/project_actions/activity_stream_details?request_type=project&type={
|
||||
act["type"]}×tamp={
|
||||
act["timestamp"]}&offset=0&user_id={
|
||||
act["user_id"]}&project_id={
|
||||
act["project_id"]}&language_id=0&after_build=0&before_build=0"
|
||||
detail_url = f"https: // crowdin.com / backend / project_actions / activity_stream_details?request_type = project & type = {
|
||||
act["type"]} & timestamp = {
|
||||
act["timestamp"]} & offset = 0 & user_id = {
|
||||
act["user_id"]} & project_id = {
|
||||
act["project_id"]} & language_id = 0 & after_build = 0 & before_build = 0"
|
||||
get_detail_json: dict = await get_url(detail_url, 200, attempt=1, headers=headers,
|
||||
fmt='json')
|
||||
if get_detail_json:
|
||||
|
|
Reference in a new issue