Archived
1
0
Fork 0

Merge pull request #20 from TopRealm/conflict

Resolve conflicts from Teahouse-Studios/akari-bot
This commit is contained in:
ZoruaFox 2023-11-28 19:18:46 +08:00 committed by GitHub
commit 6d7dc29a4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 429 additions and 438 deletions

View file

@ -14,8 +14,7 @@ from aiocqhttp import MessageSegment
from bots.aiocqhttp.client import bot from bots.aiocqhttp.client import bot
from bots.aiocqhttp.info import client_name from bots.aiocqhttp.info import client_name
from config import Config from config import Config
from core.builtins import Bot, ErrorMessage, base_superuser_list from core.builtins import Bot, base_superuser_list, command_prefix, ErrorMessage, Image, Plain, Temp, Voice
from core.builtins import Plain, Image, Voice, Temp, command_prefix
from core.builtins.message import MessageSession as MessageSessionT from core.builtins.message import MessageSession as MessageSessionT
from core.builtins.message.chain import MessageChain from core.builtins.message.chain import MessageChain
from core.exceptions import SendMessageFailed from core.exceptions import SendMessageFailed

View file

@ -14,8 +14,7 @@ from aiocqhttp import MessageSegment
from bots.lagrange.client import bot from bots.lagrange.client import bot
from bots.lagrange.info import client_name from bots.lagrange.info import client_name
from config import Config from config import Config
from core.builtins import Bot, ErrorMessage, base_superuser_list from core.builtins import Bot, base_superuser_list, command_prefix, ErrorMessage, Image, Plain, Temp, Voice
from core.builtins import Plain, Image, Voice, Temp, command_prefix
from core.builtins.message import MessageSession as MessageSessionT from core.builtins.message import MessageSession as MessageSessionT
from core.builtins.message.chain import MessageChain from core.builtins.message.chain import MessageChain
from core.exceptions import SendMessageFailed from core.exceptions import SendMessageFailed

View file

@ -59,8 +59,8 @@ tos_temp_ban_time = 300
enable_analytics = true enable_analytics = true
enable_eval = true enable_eval = true
enable_get_petal = true enable_get_petal = true
gained_petal_limit = 10 petal_gained_limit = 10
lost_petal_limit = 5 petal_lost_limit = 5
coin_limit = 10000 coin_limit = 10000
coin_faceup_rate = 4997 coin_faceup_rate = 4997
coin_facedown_rate = 4997 coin_facedown_rate = 4997

View file

@ -1,6 +1,5 @@
import os import os
import json import json
from datetime import datetime, timedelta from datetime import datetime, timedelta
from decimal import Decimal from decimal import Decimal
@ -71,7 +70,7 @@ async def count_petal(tokens):
async def gained_petal(msg: Bot.MessageSession, amount): async def gained_petal(msg: Bot.MessageSession, amount):
if Config('openai_api_key') and Config('enable_get_petal'): if Config('openai_api_key') and Config('enable_get_petal'):
limit = Config('gained_petal_limit', 10) limit = Config('petal_gained_limit', 10)
p = get_stored_list(msg.target.client_name, 'gainedpetal') p = get_stored_list(msg.target.client_name, 'gainedpetal')
if not p: if not p:
p = [{}] p = [{}]
@ -101,7 +100,7 @@ async def gained_petal(msg: Bot.MessageSession, amount):
async def lost_petal(msg: Bot.MessageSession, amount): async def lost_petal(msg: Bot.MessageSession, amount):
if Config('openai_api_key') and Config('enable_get_petal'): if Config('openai_api_key') and Config('enable_get_petal'):
limit = Config('lost_petal_limit', 5) limit = Config('petal_lost_limit', 5)
p = get_stored_list(msg.target.client_name, 'lostpetal') p = get_stored_list(msg.target.client_name, 'lostpetal')
if not p: if not p:
p = [{}] p = [{}]

View file

@ -34,7 +34,7 @@ async def init_async(start_scheduler=True) -> None:
logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING) logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING)
await load_secret() await load_secret()
try: try:
Info.version = os.popen('git rev-parse HEAD', 'r').read()[0:6] Info.version = os.popen('git rev-parse HEAD', 'r').read()
except Exception as e: except Exception as e:
Logger.warn(f'Failed to get git commit hash, is it a git repository?') Logger.warn(f'Failed to get git commit hash, is it a git repository?')
Logger.info(f'Hello, {bot_name}!') Logger.info(f'Hello, {bot_name}!')

View file

@ -20,7 +20,7 @@
"error.message.report": "The following error occurred while executing \"${module}\": ", "error.message.report": "The following error occurred while executing \"${module}\": ",
"error.message.timeout": "An error occurred: Message sending timed out. Please retry the command later or wait for the result to be returned.", "error.message.timeout": "An error occurred: Message sending timed out. Please retry the command later or wait for the result to be returned.",
"error.module.helpdoc.invalid": "\"${module}\" module provided invalid help information. Please contact the developers to solve this issue.", "error.module.helpdoc.invalid": "\"${module}\" module provided invalid help information. Please contact the developers to solve this issue.",
"error.module.unbound": "\"${module}\" module isn't bound with any commands and doesn't have a description. Please get in touch with the developers to solve this issue.", "error.module.unbound": "\"${module}\" module is unbound with any commands and doesn't have the description. Pease contact the developers to solve this issue.",
"error.module.unloaded": "\"${module}\" module failed to load. Please contact the developers to resolve this issue.", "error.module.unloaded": "\"${module}\" module failed to load. Please contact the developers to resolve this issue.",
"error.prompt": "An error occurred: ${error_msg}\nReport this issue: ", "error.prompt": "An error occurred: ${error_msg}\nReport this issue: ",
"error.prompt.noreport": "An error occurred while executing the command:\n${err_msg}\nThis error is not caused by the bot (e.g. the API request went wrong) and thus should not be reported to developers.", "error.prompt.noreport": "An error occurred while executing the command:\n${err_msg}\nThis error is not caused by the bot (e.g. the API request went wrong) and thus should not be reported to developers.",
@ -33,7 +33,7 @@
"game.message.running": "This game is currently in progress.", "game.message.running": "This game is currently in progress.",
"game.message.stop": "Stopped.", "game.message.stop": "Stopped.",
"game.message.stop.none": "This game is not in progress.", "game.message.stop.none": "This game is not in progress.",
"i18n.prompt.fallback.failed": "(If you're seeing this strange string, it means something we got wrong again!\nPlease send the problem back to\n${url}\nso that we can fix it in time.)", "i18n.prompt.fallback.failed": "(If you're seeing this strange string, it means something we've messed up!\nPlease send the issue back to\n${url}\nso that we can fix it in time.)",
"language": "English", "language": "English",
"message.cooldown": "${time} second(s) have passed since the last execution. The cooldown time of this command are ${cd_time} second(s).", "message.cooldown": "${time} second(s) have passed since the last execution. The cooldown time of this command are ${cd_time} second(s).",
"message.delimiter": ", ", "message.delimiter": ", ",

View file

@ -3,8 +3,7 @@ import os
import urllib.parse import urllib.parse
from config import CFG from config import CFG
from core.builtins import Bot from core.builtins import Bot, Image, Plain
from core.builtins import Plain, Image
from core.component import module from core.component import module
from core.logger import Logger from core.logger import Logger
from core.utils.http import get_url from core.utils.http import get_url

View file

@ -1,7 +1,6 @@
from datetime import datetime from datetime import datetime
from core.builtins import Bot from core.builtins import Bot, Image, Plain
from core.builtins import Image, Plain
from core.utils.http import get_url from core.utils.http import get_url

View file

@ -7,8 +7,7 @@ from PIL import ImageFont
from config import Config, CFG from config import Config, CFG
from core.builtins import Url from core.builtins import Url
from core.logger import Logger from core.logger import Logger
from core.utils.http import download_to_cache from core.utils.http import download_to_cache, get_url
from core.utils.http import get_url
web_render = CFG.get_url('web_render') web_render = CFG.get_url('web_render')
web_render_local = CFG.get_url('web_render_local') web_render_local = CFG.get_url('web_render_local')

View file

@ -9,8 +9,7 @@ from PIL import Image as PILImage
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from tenacity import retry, stop_after_attempt from tenacity import retry, stop_after_attempt
from core.builtins import Bot from core.builtins import Bot, Image, Plain
from core.builtins import Image, Plain
from core.component import module from core.component import module
from core.logger import Logger from core.logger import Logger
from core.petal import gained_petal from core.petal import gained_petal

View file

@ -1,54 +1,55 @@
from core.builtins import Bot, Image from core.builtins import Bot, Image, command_prefix
from core.component import module from core.component import module
from core.utils.image_table import image_table_render, ImageTable from core.utils.image_table import image_table_render, ImageTable
ali = module('alias', required_admin=True, base=True) ali = module('alias', required_admin=True, base=True)
@ali.command('add <alias> <command> {{core.help.alias.add}}', 'remove <alias> {{core.help.alias.remove}}', @ali.command('add <alias> <command> {{core.help.alias.add}}',
'remove <alias> {{core.help.alias.remove}}',
'reset {{core.help.alias.reset}}', 'reset {{core.help.alias.reset}}',
'list {{core.help.alias.list}}') 'list {{core.help.alias.list}}')
async def set_alias(msg: Bot.MessageSession): async def set_alias(msg: Bot.MessageSession):
alias = msg.options.get('command_alias') aliases = msg.options.get('command_alias')
arg1 = msg.parsed_msg.get('<alias>', False) alias = msg.parsed_msg.get('<alias>', False)
arg2 = msg.parsed_msg.get('<command>', False) command = msg.parsed_msg.get('<command>', False)
if alias is None: if aliases is None:
alias = {} aliases = {}
if 'add' in msg.parsed_msg: if 'add' in msg.parsed_msg:
if arg1 not in alias: if alias not in aliases:
has_prefix = False has_prefix = False
for prefixes in msg.prefixes: for prefixes in msg.prefixes:
if arg2.startswith(prefixes): if command.startswith(prefixes):
has_prefix = True has_prefix = True
break break
if not has_prefix: if not has_prefix:
await msg.send_message(msg.locale.t("core.message.alias.add.invalid_prefix")) await msg.finish(msg.locale.t("core.message.alias.add.invalid_prefix"))
return command = command_prefix[0] + command[1:]
alias[arg1] = arg2 aliases[alias] = command
msg.data.edit_option('command_alias', alias) msg.data.edit_option('command_alias', aliases)
await msg.send_message(msg.locale.t("core.message.alias.add.success", arg1=arg1, arg2=arg2)) await msg.finish(msg.locale.t("core.message.alias.add.success", alias=alias, command=command))
else: else:
await msg.send_message(msg.locale.t("core.message.alias.add.already_in", arg1=arg1)) await msg.finish(msg.locale.t("core.message.alias.add.already", alias=alias))
elif 'remove' in msg.parsed_msg: elif 'remove' in msg.parsed_msg:
if arg1 in alias: if alias in aliases:
del alias[arg1] del aliases[alias]
msg.data.edit_option('command_alias', alias) msg.data.edit_option('command_alias', aliases)
await msg.send_message(msg.locale.t("core.message.alias.remove.success", arg1=arg1)) await msg.finish(msg.locale.t("core.message.alias.remove.success", alias=alias))
else: else:
await msg.send_message(msg.locale.t("core.message.alias.remove.not_found", arg1=arg1)) await msg.finish(msg.locale.t("core.message.alias.remove.not_found", alias=alias))
elif 'reset' in msg.parsed_msg: elif 'reset' in msg.parsed_msg:
msg.data.edit_option('command_alias', {}) msg.data.edit_option('command_alias', {})
await msg.send_message(msg.locale.t("core.message.alias.reset.success")) await msg.finish(msg.locale.t("core.message.alias.reset.success"))
elif 'list' in msg.parsed_msg: elif 'list' in msg.parsed_msg:
if len(alias) == 0: if len(aliases) == 0:
await msg.send_message(msg.locale.t("core.message.alias.list.none")) await msg.finish(msg.locale.t("core.message.alias.list.none"))
else: else:
table = ImageTable([[k, alias[k]] for k in alias], table = ImageTable([[k, aliases[k]] for k in aliases],
[msg.locale.t("core.message.alias.list.table.header.alias"), [msg.locale.t("core.message.alias.list.table.header.alias"),
msg.locale.t("core.message.alias.list.table.header.command")]) msg.locale.t("core.message.alias.list.table.header.command")])
img = await image_table_render(table) img = await image_table_render(table)
if img: if img:
await msg.send_message([msg.locale.t("core.message.alias.list.lists"), Image(img)]) await msg.finish([msg.locale.t("core.message.alias.list"), Image(img)])
else: else:
await msg.send_message(f'{msg.locale.t("core.message.alias.list.lists")}\n' await msg.finish(f'{msg.locale.t("core.message.alias.list")}\n'
+ '\n'.join([f'{k} -> {alias[k]}' for k in alias])) + '\n'.join([f'{k} -> {aliases[k]}' for k in aliases]))

View file

@ -1,16 +1,16 @@
{ {
"core.help.admin": "Commands available to group administrators.", "core.help.admin": "Commands available to group administrators.",
"core.help.admin.add": "Set members as robot administrators, implement the function of managing the robot without setting members as group administrators. It's no longer needed to set up it when you are already a group administrator.", "core.help.admin.add": "Set members as bot administrators, implement the function of managing the robot without setting members as group administrators. It's no longer needed to set up it when you are already a group administrator.",
"core.help.admin.ban": "Limit someone to use robot in the group.", "core.help.admin.ban": "Limit someone to use bot in the group.",
"core.help.admin.list": "List all robot administrators.", "core.help.admin.list": "List all bot administrators.",
"core.help.admin.unban": "Unlimit someone to use robot in the group.", "core.help.admin.unban": "Remove limit someone to use bot in the group.",
"core.help.alias.add": "Add custom command alias.", "core.help.alias.add": "Add custom command alias.",
"core.help.alias.list": "List custom command alias.", "core.help.alias.list": "List custom command alias.",
"core.help.alias.remove": "Remove custom command alias.", "core.help.alias.remove": "Remove custom command alias.",
"core.help.alias.reset": "Reset custom command alias.", "core.help.alias.reset": "Reset custom command alias.",
"core.help.leave": "Let the robot leave the group.", "core.help.leave": "Let the bot leave the group.",
"core.help.locale": "View the robot running language.", "core.help.locale": "View bot running language.",
"core.help.locale.set": "Set the robot running language.", "core.help.locale.set": "Set bot running language.",
"core.help.module.disable": "Disable single/multiple module(s).", "core.help.module.disable": "Disable single/multiple module(s).",
"core.help.module.disable_all": "Disable all modules.", "core.help.module.disable_all": "Disable all modules.",
"core.help.module.enable": "Enable single/multiple module(s).", "core.help.module.enable": "Enable single/multiple module(s).",
@ -19,45 +19,45 @@
"core.help.module.help.detail": "View details of a module.", "core.help.module.help.detail": "View details of a module.",
"core.help.module.help.legacy": "View help list. (Legacy)", "core.help.module.help.legacy": "View help list. (Legacy)",
"core.help.module.list": "View all available modules.", "core.help.module.list": "View all available modules.",
"core.help.mute": "Make the robot stop sending message.", "core.help.mute": "Make the bot stop sending message.",
"core.help.option.module.g": "Perform global operations of the channels.", "core.help.option.module.g": "Perform global operations of the channels.",
"core.help.petal": "Get the number of petals in the current group.", "core.help.petal": "Get the number of petals in the current group.",
"core.help.ping": "Get robot status.", "core.help.ping": "Get bot status.",
"core.help.prefix.add": "Set custom command prefix.", "core.help.prefix.add": "Set custom command prefix.",
"core.help.prefix.list": "List custom command prefixes.", "core.help.prefix.list": "List custom command prefixes.",
"core.help.prefix.remove": "Remove custom command prefix.", "core.help.prefix.remove": "Remove custom command prefix.",
"core.help.prefix.reset": "Reset custom command prefix.", "core.help.prefix.reset": "Reset custom command prefix.",
"core.help.toggle.check": "Toggles whether to display command check prompts.", "core.help.toggle.check": "Toggles whether to display command check prompts.",
"core.help.toggle.typing": "Toggle whether to display input prompts.", "core.help.toggle.typing": "Toggle whether to display input prompts.",
"core.help.version": "View robot version.", "core.help.version": "View bot version.",
"core.help.whoami": "Get the ID of the user account that sent the command inside the robot.", "core.help.whoami": "Get the ID of the user account that sent the command inside the bot.",
"core.message.abuse.ban.success": "Successfully banned ${user}.", "core.message.abuse.ban.success": "Successfully banned ${user}.",
"core.message.abuse.check.warns": "${user} has been warned ${warns} time(s).", "core.message.abuse.check.warns": "${user} has been warned ${warns} time(s).",
"core.message.abuse.clear.success": "Successfully cleared warning for ${user}.", "core.message.abuse.clear.success": "Successfully cleared warning for ${user}.",
"core.message.abuse.revoke.success": "Successfully removed ${counts} warning(s) for ${user}. This user has been warned ${warn_counts} time(s).", "core.message.abuse.revoke.success": "Successfully removed ${counts} warning(s) for ${user}. This user has been warned ${warn_counts} time(s).",
"core.message.abuse.unban.success": "Successfully unbanned ${user}.", "core.message.abuse.unban.success": "Successfully unbanned ${user}.",
"core.message.abuse.untempban.success": "Successfully removed temporary limit on ${user}.", "core.message.abuse.untempban.success": "Successfully removed temporary limit on ${user}.",
"core.message.abuse.warn.success": "Successfully warned ${user} ${counts} time(s). This user has been warned ${warn_counts} time(s).", "core.message.abuse.warn.success": "Successfully warned ${user} ${counts} time(s). This user has been warned ${warn_counts} time(s).",
"core.message.admin.add.success": "Success: Has set ${user} to robot administrator.", "core.message.admin.add.success": "Success: ${user} was set as bot administrator.",
"core.message.admin.already": "This member is already a robot administrator.", "core.message.admin.already": "This member is already a bot administrator.",
"core.message.admin.ban.already": "This member has been banned from using robot.", "core.message.admin.ban.already": "This member has been banned from using bot.",
"core.message.admin.ban.not_yet": "This member has not been banned from using robot.", "core.message.admin.ban.not_yet": "This member has not been banned from using bot.",
"core.message.admin.ban.self": "You cannot do this for yourself!", "core.message.admin.ban.self": "You cannot do this for yourself!",
"core.message.admin.invalid": "Invalid ID format. The format should be \"${target}|<User ID>\".", "core.message.superuser.invalid": "Invalid ID format. The format should be \"${target}|<User ID>\".",
"core.message.admin.list": "Robot administrators manually set in the current group: ", "core.message.admin.list": "Bot administrators manually set in the current group: ",
"core.message.admin.list.none": "There are currently no manual robot administrators.", "core.message.admin.list.none": "There are currently no manual bot administrators.",
"core.message.admin.remove.success": "Success: Removed ${user} from robot administrator.", "core.message.admin.remove.success": "Success: Removed ${user} from bot administrator.",
"core.message.alias.add.already_in": "\"${arg1}\" alias already exists in custom alias list.", "core.message.alias.add.already": "\"${alias}\" alias already exists in custom alias list.",
"core.message.alias.add.invalid_prefix": "The command corresponding to the added alias must start with a command prefix, please check.", "core.message.alias.add.invalid_prefix": "The command corresponding to the added alias must start with a command prefix. Please check your input.",
"core.message.alias.add.success": "Custom command alias added: ${arg1} -> ${arg2}", "core.message.alias.add.success": "Custom command alias added: ${alias} -> ${command}",
"core.message.alias.list.lists": "Custom command alias list: ", "core.message.alias.list": "Custom command alias list: ",
"core.message.alias.list.none": "The custom command alias list is empty.", "core.message.alias.list.none": "The custom command alias list is empty.",
"core.message.alias.list.table.header.alias": "Alias", "core.message.alias.list.table.header.alias": "Alias",
"core.message.alias.list.table.header.command": "Command", "core.message.alias.list.table.header.command": "Command",
"core.message.alias.remove.not_found": "\"${arg1}\" alias does not exist in custom alias list.", "core.message.alias.remove.not_found": "\"${alias}\" alias does not exist in custom alias list.",
"core.message.alias.remove.success": "Removed custom command alias: ${arg1}", "core.message.alias.remove.success": "Removed custom command alias: ${alias}",
"core.message.alias.reset.success": "The custom command alias has been reset.", "core.message.alias.reset.success": "The custom command alias has been reset.",
"core.message.analytics.counts": "Number of times the commands have executed (from ${first_record}): ${counts}", "core.message.analytics.counts": "Number of commands have executed (from ${first_record}): ${counts}\nNumber of commands have executed today: ${counts_today}",
"core.message.analytics.days": "Last 30 days for command \"${module}\" calls (from ${first_record}): ", "core.message.analytics.days": "Last 30 days for command \"${module}\" calls (from ${first_record}): ",
"core.message.analytics.days.total": "Last 30 days for all command calls (from ${first_record}): ", "core.message.analytics.days.total": "Last 30 days for all command calls (from ${first_record}): ",
"core.message.analytics.disabled": "Analytics command is not enabled.", "core.message.analytics.disabled": "Analytics command is not enabled.",
@ -65,7 +65,7 @@
"core.message.analytics.year.total": "Last year for all command calls (from ${first_record}): ", "core.message.analytics.year.total": "Last year for all command calls (from ${first_record}): ",
"core.message.config.write.failed": "Failed. Try to use escaped quotes or check the input.", "core.message.config.write.failed": "Failed. Try to use escaped quotes or check the input.",
"core.message.forward_msg.disable": "Forward message disabled.", "core.message.forward_msg.disable": "Forward message disabled.",
"core.message.forward_msg.disabled": "Forward message is disabled.\n", "core.message.forward_msg.disabled": "Forward message disabled.",
"core.message.forward_msg.enable": "Forward message enabled.", "core.message.forward_msg.enable": "Forward message enabled.",
"core.message.leave.success": "Goodbye.", "core.message.leave.success": "Goodbye.",
"core.message.locale": "Current language: ", "core.message.locale": "Current language: ",
@ -100,10 +100,10 @@
"core.message.module.help.table.header.help": "Help", "core.message.module.help.table.header.help": "Help",
"core.message.module.load.error": "An error occurred: This module has been loaded or does not exist.", "core.message.module.load.error": "An error occurred: This module has been loaded or does not exist.",
"core.message.module.load.failed": "Failed to load module.", "core.message.module.load.failed": "Failed to load module.",
"core.message.module.load.success": "Loaded module(s) ${modules} successfully.", "core.message.module.load.success": "Successfully loaded module(s): ${module}",
"core.message.module.module.help": "Help information for module \"${module}\": ", "core.message.module.module.help": "Help information for module \"${module}\": ",
"core.message.module.recommends": "It is recommended to enable the following module(s) at the same time: \n${msgs}\nProceed?", "core.message.module.recommends": "It is recommended to enable the following module(s) at the same time: \n${msgs}\nProceed?",
"core.message.module.reload.confirm": "This operation will reload the following modules: \n${modules}\nContinue?", "core.message.module.reload.confirm": "This operation will reload the following modules at the same time: \n${modules}\nContinue?",
"core.message.module.reload.confirm.base": "You are trying to reload the base modules! Continue?", "core.message.module.reload.confirm.base": "You are trying to reload the base modules! Continue?",
"core.message.module.reload.failed": "Failed to reload module.", "core.message.module.reload.failed": "Failed to reload module.",
"core.message.module.reload.no_more": "No remaining files were found.", "core.message.module.reload.no_more": "No remaining files were found.",
@ -124,40 +124,40 @@
"core.message.petal.modify.self": " Successfully modified ${add_petal} petals for this group, now this group has ${petal} petals.", "core.message.petal.modify.self": " Successfully modified ${add_petal} petals for this group, now this group has ${petal} petals.",
"core.message.petal.no_petals": "There are not enough petals in the group. If you need to add petals, please go here to send your application:", "core.message.petal.no_petals": "There are not enough petals in the group. If you need to add petals, please go here to send your application:",
"core.message.petal.self": "${petal} petal(s) remain in this group.", "core.message.petal.self": "${petal} petal(s) remain in this group.",
"core.message.ping.detail": "System startup time: ${system_boot_time}\nRobot is running: ${bot_running_time}\nPython version: ${python_version}\nProcessor model: ${cpu_brand}\nCurrent processor usage: ${cpu_usage}%\nPhysical memory: ${ram}M Utilized: ${ram_percent}%\nSwap memory: ${swap}M Utilized: ${swap_percent}%\nDisk capacity: ${disk_space}G/${disk_space_total}G", "core.message.ping.detail": "System startup time: ${system_boot_time}\nBot is running: ${bot_running_time}\nPython version: ${python_version}\nProcessor model: ${cpu_brand}\nCurrent processor usage: ${cpu_usage}%\nPhysical memory: ${ram}M Utilized: ${ram_percent}%\nSwap memory: ${swap}M Utilized: ${swap_percent}%\nDisk capacity: ${disk_space}G/${disk_space_total}G",
"core.message.ping.failed": "Failed to fetch.", "core.message.ping.failed": "Failed to fetch.",
"core.message.prefix.add.already": "This command already exists in the custom prefix list.", "core.message.prefix.add.already": "This command prefix already exists in the custom prefix list.",
"core.message.prefix.add.success": "Custom command prefix has been added: ${prefix}\nHelp documents will be displayed by default using this prefix.", "core.message.prefix.add.success": "Custom command prefix added: ${prefix}",
"core.message.prefix.list": "Custom command prefix: ${prefixes}", "core.message.prefix.list": "Custom command prefix: ${prefixes}",
"core.message.prefix.list.none": "The custom command prefix is empty.", "core.message.prefix.list.none": "The custom command prefix is empty.",
"core.message.prefix.remove.not_found": "This command prefix does not exist in the custom prefix list.", "core.message.prefix.remove.not_found": "This command prefix does not exist in the custom prefix list.",
"core.message.prefix.remove.success": "Custom command prefix removed: ", "core.message.prefix.remove.success": "Custom command prefix removed: ${prefix}",
"core.message.prefix.reset": "The custom command prefix has been reset.", "core.message.prefix.reset": "The custom command prefix has been reset.",
"core.message.raise": "Test exception.", "core.message.raise": "Test exception.",
"core.message.restart.prompt": "Since the robot is restarting, your command execution have been forcibly cancelled.\nPlease re-execute the command later.", "core.message.restart.prompt": "Since the bot is restarting, your command execution have been forcibly cancelled.\nPlease re-execute the command later.",
"core.message.restart.restarting": "Restarting...", "core.message.restart.restarting": "Restarting...",
"core.message.restart.timeout": "Waiting timeout, force restarting...", "core.message.restart.timeout": "Waiting timeout, force restarting...",
"core.message.restart.wait": "There are ${count} command(s) being executed, the bot will restart after the execution.", "core.message.restart.wait": "There are ${count} command(s) being executed. The bot will restart after the execution.",
"core.message.resume.clear": "All messages cleared.", "core.message.resume.clear": "All messages cleared.",
"core.message.resume.done": "Resume complete.", "core.message.resume.done": "Resume complete.",
"core.message.resume.nothing": "No messages to be resumed.", "core.message.resume.nothing": "No messages to be resumed.",
"core.message.resume.processing": "Resuming ${counts} messages...", "core.message.resume.processing": "Resuming ${counts} message(s)...",
"core.message.resume.skip": "Skip a message, resuming ${counts} messages...", "core.message.resume.skip": "Skip a message, resuming ${counts} message(s)...",
"core.message.set.confirm.init": "This group is not initialized. Are you sure you want to do it?", "core.message.set.confirm.init": "This group is not initialized. Are you sure you want to do it?",
"core.message.set.help.option.success": "The following parameters were set for the object: ${k} -> ${v}", "core.message.set.help.option.success": "The following parameters were set for the object: ${k} -> ${v}",
"core.message.set.invalid": "Invalid ID format.", "core.message.set.invalid": "Invalid ID format.",
"core.message.set.module.success": "The following modules were successfully configured for the object: ", "core.message.set.module.success": "The following modules were successfully configured for the object: ",
"core.message.superuser.invalid": "Invalid ID format. Please use command \"${prefix}whoami\" to view user ID.", "core.message.admin.invalid": "Invalid ID format. Use \"${prefix}whoami\" to view user ID.",
"core.message.toggle.check.disable": "Check prompt disabled.", "core.message.toggle.check.disable": "Check prompt disabled.",
"core.message.toggle.check.enable": "Check prompt enabled.", "core.message.toggle.check.enable": "Check prompt enabled.",
"core.message.toggle.typing.disable": "Input prompt disabled.", "core.message.toggle.typing.disable": "Input prompt disabled.",
"core.message.toggle.typing.enable": "Input prompt enabled.", "core.message.toggle.typing.enable": "Input prompt enabled.",
"core.message.update.failed": "Failed to fetch update from GitHub. Please try again later.", "core.message.update.failed": "Failed to fetch update from GitHub. Please try again later.",
"core.message.version": "Current robot version: ${commit}", "core.message.version": "Current bot version: ${commit}",
"core.message.version.unknown": "Unable to get version. This instance may not be deployed using Git.", "core.message.version.unknown": "Unable to get version. This instance may not be deployed using Git.",
"core.message.whoami": "Your ID: ${senderid}\nConversation ID: ${targetid}", "core.message.whoami": "Your ID: ${senderid}\nConversation ID: ${targetid}",
"core.message.whoami.admin": "(You have admin permission for this conversation)", "core.message.whoami.admin": "(You have admin permission for this conversation)",
"core.message.whoami.botadmin": "(You have robot admin permission for this conversation)", "core.message.whoami.botadmin": "(You have bot admin permission for this conversation)",
"core.message.whoami.superuser": "(You have superuser permission)", "core.message.whoami.superuser": "(You have superuser permission)",
"core.help.admin.remove": "Unmember robot administrator." "core.help.admin.remove": "Remove bot administrator from member."
} }

View file

@ -43,19 +43,19 @@
"core.message.admin.ban.already": "此成员已被设置禁止使用机器人。", "core.message.admin.ban.already": "此成员已被设置禁止使用机器人。",
"core.message.admin.ban.not_yet": "此成员没有被设置禁止使用机器人。", "core.message.admin.ban.not_yet": "此成员没有被设置禁止使用机器人。",
"core.message.admin.ban.self": "你不可以对自己进行此操作!", "core.message.admin.ban.self": "你不可以对自己进行此操作!",
"core.message.admin.invalid": "ID 格式错误,格式应为“${target}|<用户 ID>”。", "core.message.superuser.invalid": "ID 格式错误,格式应为“${target}|<用户 ID>”。",
"core.message.admin.list": "当前在群内手动设置的机器人管理员:\n", "core.message.admin.list": "当前在群内手动设置的机器人管理员:\n",
"core.message.admin.list.none": "当前没有手动设置的机器人管理员。", "core.message.admin.list.none": "当前没有手动设置的机器人管理员。",
"core.message.admin.remove.success": "成功:已将 ${user} 移出机器人管理员。", "core.message.admin.remove.success": "成功:已将 ${user} 移出机器人管理员。",
"core.message.alias.add.already_in": "“${arg1}”别名已存在于自定义别名列表。", "core.message.alias.add.already": "“${alias}”别名已存在于自定义别名列表。",
"core.message.alias.add.invalid_prefix": "添加的别名对应的命令必须以命令前缀开头,请检查。", "core.message.alias.add.invalid_prefix": "添加的别名对应的命令必须以命令前缀开头,请检查输入。",
"core.message.alias.add.success": "已添加自定义命令别名:${arg1} -> ${arg2}", "core.message.alias.add.success": "已添加自定义命令别名:${alias} -> ${command}",
"core.message.alias.list.lists": "自定义命令别名列表:", "core.message.alias.list": "自定义命令别名列表:",
"core.message.alias.list.none": "自定义命令别名列表为空。", "core.message.alias.list.none": "自定义命令别名列表为空。",
"core.message.alias.list.table.header.alias": "别名", "core.message.alias.list.table.header.alias": "别名",
"core.message.alias.list.table.header.command": "命令", "core.message.alias.list.table.header.command": "命令",
"core.message.alias.remove.not_found": "“${arg1}”别名不存在于自定义别名列表。", "core.message.alias.remove.not_found": "“${alias}”别名不存在于自定义别名列表。",
"core.message.alias.remove.success": "已移除自定义命令别名:${arg1}", "core.message.alias.remove.success": "已移除自定义命令别名:${alias}",
"core.message.alias.reset.success": "已重置自定义命令别名列表。", "core.message.alias.reset.success": "已重置自定义命令别名列表。",
"core.message.analytics.counts": "机器人已执行命令次数(自 ${first_record} 开始统计):${counts}\n今日已执行命令次数${counts_today}", "core.message.analytics.counts": "机器人已执行命令次数(自 ${first_record} 开始统计):${counts}\n今日已执行命令次数${counts_today}",
"core.message.analytics.days": "最近 30 天的“${module}”命令调用次数统计(自 ${first_record} 开始统计):", "core.message.analytics.days": "最近 30 天的“${module}”命令调用次数统计(自 ${first_record} 开始统计):",
@ -131,7 +131,7 @@
"core.message.prefix.list": "自定义命令前缀:${prefixes}", "core.message.prefix.list": "自定义命令前缀:${prefixes}",
"core.message.prefix.list.none": "自定义命令前缀为空。", "core.message.prefix.list.none": "自定义命令前缀为空。",
"core.message.prefix.remove.not_found": "此命令前缀不存在于自定义前缀列表。", "core.message.prefix.remove.not_found": "此命令前缀不存在于自定义前缀列表。",
"core.message.prefix.remove.success": "已移除自定义命令前缀:", "core.message.prefix.remove.success": "已移除自定义命令前缀:${prefix}",
"core.message.prefix.reset": "已重置自定义命令前缀列表。", "core.message.prefix.reset": "已重置自定义命令前缀列表。",
"core.message.raise": "异常测试。", "core.message.raise": "异常测试。",
"core.message.restart.prompt": "由于机器人正在重启,您此次执行命令的后续操作已被强制取消。\n请稍后重新执行命令对此带来的不便我们深感抱歉。", "core.message.restart.prompt": "由于机器人正在重启,您此次执行命令的后续操作已被强制取消。\n请稍后重新执行命令对此带来的不便我们深感抱歉。",
@ -147,7 +147,7 @@
"core.message.set.help.option.success": "成功为对象设置了以下参数:${k} -> ${v}", "core.message.set.help.option.success": "成功为对象设置了以下参数:${k} -> ${v}",
"core.message.set.invalid": "ID 格式错误。", "core.message.set.invalid": "ID 格式错误。",
"core.message.set.module.success": "成功为对象配置了以下模块:", "core.message.set.module.success": "成功为对象配置了以下模块:",
"core.message.superuser.invalid": "ID 格式错误,请对象使用“${prefix}whoami”查看用户 ID。", "core.message.admin.invalid": "ID 格式错误,请使用“${prefix}whoami”查看用户 ID。",
"core.message.toggle.check.disable": "已关闭错字检查提示。", "core.message.toggle.check.disable": "已关闭错字检查提示。",
"core.message.toggle.check.enable": "已开启错字检查提示。", "core.message.toggle.check.enable": "已开启错字检查提示。",
"core.message.toggle.typing.disable": "已关闭输入提示。", "core.message.toggle.typing.disable": "已关闭输入提示。",

View file

@ -43,19 +43,19 @@
"core.message.admin.ban.already": "此成員已被禁止使用機器人。", "core.message.admin.ban.already": "此成員已被禁止使用機器人。",
"core.message.admin.ban.not_yet": "此成員沒有被禁止使用機器人。", "core.message.admin.ban.not_yet": "此成員沒有被禁止使用機器人。",
"core.message.admin.ban.self": "你不可以對自己進行此操作!", "core.message.admin.ban.self": "你不可以對自己進行此操作!",
"core.message.admin.invalid": "ID 格式錯誤,格式應為「${target}|<使用者 ID>」。", "core.message.superuser.invalid": "ID 格式錯誤,格式應為「${target}|<使用者 ID>」。",
"core.message.admin.list": "目前在群組內手動設定的機器人管理員:\n", "core.message.admin.list": "目前在群組內手動設定的機器人管理員:\n",
"core.message.admin.list.none": "目前沒有手動設定的機器人管理員。", "core.message.admin.list.none": "目前沒有手動設定的機器人管理員。",
"core.message.admin.remove.success": "成功:已將 ${user} 移出機器人管理員。", "core.message.admin.remove.success": "成功:已將 ${user} 移出機器人管理員。",
"core.message.alias.add.already_in": "「${arg1}」別名已存在於自訂別名列表。", "core.message.alias.add.already": "「${alias}」別名已存在於自訂別名列表。",
"core.message.alias.add.invalid_prefix": "新增的別名對應的指令必須以指令前綴開頭,請檢查。", "core.message.alias.add.invalid_prefix": "新增的別名對應的指令必須以指令前綴開頭,請校對輸入。",
"core.message.alias.add.success": "已新增自訂指令別名:${arg1} -> ${arg2}", "core.message.alias.add.success": "已新增自訂指令別名:${alias} -> ${command}",
"core.message.alias.list.lists": "自訂指令別名列表:", "core.message.alias.list": "自訂指令別名列表:",
"core.message.alias.list.none": "自訂指令別名列表為空。", "core.message.alias.list.none": "自訂指令別名列表為空。",
"core.message.alias.list.table.header.alias": "別名", "core.message.alias.list.table.header.alias": "別名",
"core.message.alias.list.table.header.command": "指令", "core.message.alias.list.table.header.command": "指令",
"core.message.alias.remove.not_found": "「${arg1}」別名不存在於自訂別名列表。", "core.message.alias.remove.not_found": "「${alias}」別名不存在於自訂別名列表。",
"core.message.alias.remove.success": "已移除自訂指令別名:${arg1}", "core.message.alias.remove.success": "已移除自訂指令別名:${alias}",
"core.message.alias.reset.success": "已重設自訂指令別名列表。", "core.message.alias.reset.success": "已重設自訂指令別名列表。",
"core.message.analytics.counts": "機器人已執行指令次數(自 ${first_record} 開始統計):${counts}\n今日已執行指令次數${counts_today}", "core.message.analytics.counts": "機器人已執行指令次數(自 ${first_record} 開始統計):${counts}\n今日已執行指令次數${counts_today}",
"core.message.analytics.days": "最近 30 日的「${module}」指令呼叫次數統計(自 ${first_record} 開始統計):", "core.message.analytics.days": "最近 30 日的「${module}」指令呼叫次數統計(自 ${first_record} 開始統計):",
@ -131,7 +131,7 @@
"core.message.prefix.list": "自訂指令前綴:${prefixes}", "core.message.prefix.list": "自訂指令前綴:${prefixes}",
"core.message.prefix.list.none": "自訂指令前綴為空。", "core.message.prefix.list.none": "自訂指令前綴為空。",
"core.message.prefix.remove.not_found": "此指令前綴不存在於自訂前綴列表。", "core.message.prefix.remove.not_found": "此指令前綴不存在於自訂前綴列表。",
"core.message.prefix.remove.success": "已移除自訂指令前綴:", "core.message.prefix.remove.success": "已移除自訂指令前綴:${prefix}",
"core.message.prefix.reset": "已重設自訂指令前綴列表。", "core.message.prefix.reset": "已重設自訂指令前綴列表。",
"core.message.raise": "例外測試。", "core.message.raise": "例外測試。",
"core.message.restart.prompt": "由於機器人正在重新啟動,您此次執行指令的後續操作已被取消。\n請稍後重新執行指令對此帶來的不便我們深感抱歉。", "core.message.restart.prompt": "由於機器人正在重新啟動,您此次執行指令的後續操作已被取消。\n請稍後重新執行指令對此帶來的不便我們深感抱歉。",
@ -147,7 +147,7 @@
"core.message.set.help.option.success": "成功為物件設定了以下參數:${k} -> ${v}", "core.message.set.help.option.success": "成功為物件設定了以下參數:${k} -> ${v}",
"core.message.set.invalid": "ID 格式錯誤。", "core.message.set.invalid": "ID 格式錯誤。",
"core.message.set.module.success": "成功為物件配置了以下模組:", "core.message.set.module.success": "成功為物件配置了以下模組:",
"core.message.superuser.invalid": "ID 格式錯誤,請使用「${prefix}whoami」指令檢視使用者 ID。", "core.message.admin.invalid": "ID 格式錯誤,請使用「${prefix}whoami」指令檢視使用者 ID。",
"core.message.toggle.check.disable": "已停用指令錯誤檢查提醒。", "core.message.toggle.check.disable": "已停用指令錯誤檢查提醒。",
"core.message.toggle.check.enable": "已啟用指令錯誤檢查提醒。", "core.message.toggle.check.enable": "已啟用指令錯誤檢查提醒。",
"core.message.toggle.typing.disable": "已停用輸入提醒。", "core.message.toggle.typing.disable": "已停用輸入提醒。",

View file

@ -31,10 +31,14 @@ m = module('module',
'reload <module> ...', 'reload <module> ...',
'load <module> ...', 'load <module> ...',
'unload <module> ...', 'unload <module> ...',
'list {{core.help.module.list}}'], exclude_from=['QQ|Guild']) 'list {{core.help.module.list}}',
'list legacy {{core.help.module.list.legacy}}'], exclude_from=['QQ|Guild'])
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
if msg.parsed_msg.get('list', False): if msg.parsed_msg.get('list', False):
await modules_help(msg) legacy = False
if 'legacy' in msg.parsed_msg:
legacy = True
await modules_help(msg, legacy)
await config_modules(msg) await config_modules(msg)
@ -45,11 +49,15 @@ async def _(msg: Bot.MessageSession):
'reload <module> ...', 'reload <module> ...',
'load <module> ...', 'load <module> ...',
'unload <module> ...', 'unload <module> ...',
'list {{core.help.module.list}}'], options_desc={'-g': '{core.help.option.module.g}'}, 'list {{core.help.module.list}}',
'list legacy {{core.help.module.list.legacy}}'], options_desc={'-g': '{core.help.option.module.g}'},
available_for=['QQ|Guild']) available_for=['QQ|Guild'])
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
if msg.parsed_msg.get('list', False): if msg.parsed_msg.get('list', False):
await modules_help(msg) legacy = False
if 'legacy' in msg.parsed_msg:
legacy = True
await modules_help(msg, legacy)
await config_modules(msg) await config_modules(msg)
@ -360,13 +368,14 @@ async def bot_help(msg: Bot.MessageSession):
await msg.finish(msg.locale.t("core.message.module.help.not_found")) await msg.finish(msg.locale.t("core.message.module.help.not_found"))
@hlp.command('{{core.help.module.help}}') @hlp.command(['{{core.help.module.help}}',
'legacy {{core.help.module.help.legacy}}')
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
module_list = ModulesManager.return_modules_list( module_list = ModulesManager.return_modules_list(
target_from=msg.target.target_from) target_from=msg.target.target_from)
target_enabled_list = msg.enabled_modules target_enabled_list = msg.enabled_modules
legacy_help = True legacy_help = True
if msg.Feature.image: if 'legacy' not in msg.parsed_msg and msg.Feature.image:
try: try:
tables = [] tables = []
essential = [] essential = []
@ -455,37 +464,11 @@ async def _(msg: Bot.MessageSession):
await msg.finish('\n'.join(help_msg)) await msg.finish('\n'.join(help_msg))
@hlp.command('legacy {{core.help.module.help.legacy}}') async def modules_help(msg: Bot.MessageSession, legacy):
async def _(msg: Bot.MessageSession):
module_list = ModulesManager.return_modules_list(
target_from=msg.target.target_from)
target_enabled_list = msg.enabled_modules
help_msg = [msg.locale.t("core.message.module.help.legacy.base")]
essential = []
for x in module_list:
if module_list[x].base and not (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.module.help.legacy.external"))
module_ = []
for x in module_list:
if x in target_enabled_list and not (
module_list[x].required_superuser or module_list[x].required_base_superuser):
module_.append(x)
help_msg.append(' | '.join(module_))
help_msg.append(
msg.locale.t(
"core.message.module.help.legacy.more_information",
prefix=msg.prefixes[0],
help_url=Config('help_url')))
await msg.finish('\n'.join(help_msg))
async def modules_help(msg: Bot.MessageSession):
module_list = ModulesManager.return_modules_list( module_list = ModulesManager.return_modules_list(
target_from=msg.target.target_from) target_from=msg.target.target_from)
legacy_help = True legacy_help = True
if msg.Feature.image: if msg.Feature.image and not legacy:
try: try:
tables = [] tables = []
m = [] m = []

View file

@ -10,30 +10,30 @@ p = module('prefix', required_admin=True, base=True)
'list {{core.help.prefix.list}}') 'list {{core.help.prefix.list}}')
async def set_prefix(msg: Bot.MessageSession): async def set_prefix(msg: Bot.MessageSession):
prefixes = msg.options.get('command_prefix') prefixes = msg.options.get('command_prefix')
arg1 = msg.parsed_msg.get('<prefix>', False) prefix = msg.parsed_msg.get('<prefix>', False)
if prefixes is None: if prefixes is None:
prefixes = [] prefixes = []
if 'add' in msg.parsed_msg: if 'add' in msg.parsed_msg:
if arg1: if prefix:
if arg1 not in prefixes: if prefix not in prefixes:
prefixes.append(arg1) prefixes.append(prefix)
msg.data.edit_option('command_prefix', prefixes) msg.data.edit_option('command_prefix', prefixes)
await msg.send_message(msg.locale.t("core.message.prefix.add.success", prefix=arg1)) await msg.finish(msg.locale.t("core.message.prefix.add.success", prefix=prefix))
else: else:
await msg.send_message(msg.locale.t("core.message.prefix.add.already")) await msg.finish(msg.locale.t("core.message.prefix.add.already"))
elif 'remove' in msg.parsed_msg: elif 'remove' in msg.parsed_msg:
if arg1: if prefix:
if arg1 in prefixes: if prefix in prefixes:
prefixes.remove(arg1) prefixes.remove(prefix)
msg.data.edit_option('command_prefix', prefixes) msg.data.edit_option('command_prefix', prefixes)
await msg.send_message(msg.locale.t("core.message.prefix.remove.success") + arg1) await msg.finish(msg.locale.t("core.message.prefix.remove.success", prefix=prefix))
else: else:
await msg.send_message(msg.locale.t("core.message.prefix.remove.not_found")) await msg.finish(msg.locale.t("core.message.prefix.remove.not_found"))
elif 'reset' in msg.parsed_msg: elif 'reset' in msg.parsed_msg:
msg.data.edit_option('command_prefix', []) msg.data.edit_option('command_prefix', [])
await msg.send_message(msg.locale.t("core.message.prefix.reset")) await msg.finish(msg.locale.t("core.message.prefix.reset"))
elif 'list' in msg.parsed_msg: elif 'list' in msg.parsed_msg:
if len(prefixes) == 0: if len(prefixes) == 0:
await msg.send_message(msg.locale.t("core.message.prefix.list.none")) await msg.finish(msg.locale.t("core.message.prefix.list.none"))
else: else:
await msg.finish(msg.locale.t('core.message.prefix.list', prefixes=', '.join(prefixes))) await msg.finish(msg.locale.t('core.message.prefix.list', prefixes=', '.join(prefixes)))

View file

@ -27,7 +27,7 @@ su = module('superuser', alias='su', developers=['OasisAkari', 'Dianliang233'],
async def add_su(msg: Bot.MessageSession): async def add_su(msg: Bot.MessageSession):
user = msg.parsed_msg['<UserID>'] user = msg.parsed_msg['<UserID>']
if not user.startswith(f'{msg.target.sender_from}|'): if not user.startswith(f'{msg.target.sender_from}|'):
await msg.finish(msg.locale.t("core.message.superuser.invalid", prefix=msg.prefixes[0])) await msg.finish(msg.locale.t("core.message.superuser.invalid", target=msg.target.sender_from))
if user: if user:
if BotDBUtil.SenderInfo(user).edit('isSuperUser', True): if BotDBUtil.SenderInfo(user).edit('isSuperUser', True):
await msg.finish(msg.locale.t("success")) await msg.finish(msg.locale.t("success"))
@ -37,7 +37,7 @@ async def add_su(msg: Bot.MessageSession):
async def del_su(msg: Bot.MessageSession): async def del_su(msg: Bot.MessageSession):
user = msg.parsed_msg['<UserID>'] user = msg.parsed_msg['<UserID>']
if not user.startswith(f'{msg.target.sender_from}|'): if not user.startswith(f'{msg.target.sender_from}|'):
await msg.finish(msg.locale.t("core.message.superuser.invalid", prefix=msg.prefixes[0])) await msg.finish(msg.locale.t("core.message.superuser.invalid", target=msg.target.sender_from))
if user == msg.target.sender_id: if user == msg.target.sender_id:
confirm = await msg.wait_confirm(msg.locale.t("core.message.confirm"), append_instruction=False) confirm = await msg.wait_confirm(msg.locale.t("core.message.confirm"), append_instruction=False)
if not confirm: if not confirm:
@ -295,36 +295,38 @@ if Info.subprocess:
write_version_cache(msg) write_version_cache(msg)
restart() restart()
upd = module('update', developers=['OasisAkari'], required_superuser=True, base=True)
if Info.version:
upd = module('update', developers=['OasisAkari'], required_superuser=True, base=True)
def pull_repo(): def pull_repo():
return os.popen('git pull', 'r').read()[:-1] return os.popen('git pull', 'r').read()[:-1]
def update_dependencies(): def update_dependencies():
poetry_install = os.popen('poetry install').read()[:-1] poetry_install = os.popen('poetry install').read()[:-1]
if poetry_install != '': if poetry_install != '':
return poetry_install return poetry_install
pip_install = os.popen('pip install -r requirements.txt').read()[:-1] pip_install = os.popen('pip install -r requirements.txt').read()[:-1]
if len(pip_install) > 500: if len(pip_install) > 500:
return '...' + pip_install[-500:] return '...' + pip_install[-500:]
return return
@upd.handle() @upd.handle()
async def update_bot(msg: Bot.MessageSession): async def update_bot(msg: Bot.MessageSession):
confirm = await msg.wait_confirm(msg.locale.t("core.message.confirm"), append_instruction=False) confirm = await msg.wait_confirm(msg.locale.t("core.message.confirm"), append_instruction=False)
if confirm: if confirm:
pull_repo_result = pull_repo() pull_repo_result = pull_repo()
if pull_repo_result != '': if pull_repo_result != '':
await msg.send_message(pull_repo_result) await msg.send_message(pull_repo_result)
await msg.send_message(update_dependencies()) await msg.send_message(update_dependencies())
else: else:
await msg.finish(msg.locale.t("core.message.update.failed")) await msg.finish(msg.locale.t("core.message.update.failed"))
if Info.subprocess: if Info.version and Info.subprocess:
upds = module('update&restart', developers=['OasisAkari'], required_superuser=True, alias='u&r', base=True) upds = module('update&restart', developers=['OasisAkari'], required_superuser=True, alias='u&r', base=True)
@upds.handle() @upds.handle()
@ -416,7 +418,7 @@ say = module('say', developers=['OasisAkari'], required_superuser=True, base=Tru
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
await msg.finish(msg.parsed_msg['<display_msg>'], quote=False) await msg.finish(msg.parsed_msg['<display_msg>'], quote=False)
rse = module('raise', developers=['OasisAkari, DoroWolf'], required_superuser=True, base=True) rse = module('raise', developers=['OasisAkari'], required_superuser=True, base=True)
@rse.handle() @rse.handle()
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):

View file

@ -21,7 +21,7 @@ ver = module('version', base=True, desc='{core.help.version}', developers=['Oasi
@ver.handle() @ver.handle()
async def bot_version(msg: Bot.MessageSession): async def bot_version(msg: Bot.MessageSession):
if Info.version: if Info.version:
await msg.finish(msg.locale.t('core.message.version', commit=Info.version)) await msg.finish(msg.locale.t('core.message.version', commit=Info.version[0:6]))
else: else:
await msg.finish(msg.locale.t('core.message.version.unknown')) await msg.finish(msg.locale.t('core.message.version.unknown'))
@ -90,7 +90,7 @@ async def config_gu(msg: Bot.MessageSession):
await msg.finish(msg.locale.t("core.message.admin.list.none")) await msg.finish(msg.locale.t("core.message.admin.list.none"))
user = msg.parsed_msg['<UserID>'] user = msg.parsed_msg['<UserID>']
if not user.startswith(f'{msg.target.sender_from}|'): if not user.startswith(f'{msg.target.sender_from}|'):
await msg.finish(msg.locale.t('core.message.admin.invalid', target=msg.target.sender_from)) await msg.finish(msg.locale.t('core.message.admin.invalid', prefix=msg.prefixes[0]))
if 'add' in msg.parsed_msg: if 'add' in msg.parsed_msg:
if user and user not in msg.custom_admins: if user and user not in msg.custom_admins:
if msg.data.add_custom_admin(user): if msg.data.add_custom_admin(user):
@ -111,7 +111,7 @@ async def config_gu(msg: Bot.MessageSession):
async def config_ban(msg: Bot.MessageSession): async def config_ban(msg: Bot.MessageSession):
user = msg.parsed_msg['<UserID>'] user = msg.parsed_msg['<UserID>']
if not user.startswith(f'{msg.target.sender_from}|'): if not user.startswith(f'{msg.target.sender_from}|'):
await msg.finish(msg.locale.t('core.message.admin.invalid', target=msg.target.sender_from)) await msg.finish(msg.locale.t('core.message.admin.invalid', prefix=msg.prefixes[0]))
if user == msg.target.sender_id: if user == msg.target.sender_id:
await msg.finish(msg.locale.t("core.message.admin.ban.self")) await msg.finish(msg.locale.t("core.message.admin.ban.self"))
if 'ban' in msg.parsed_msg: if 'ban' in msg.parsed_msg:
@ -131,6 +131,7 @@ async def config_ban(msg: Bot.MessageSession):
locale = module('locale', base=True, developers=['Dianliang233', 'Light-Beacon']) locale = module('locale', base=True, developers=['Dianliang233', 'Light-Beacon'])
@locale.handle('{{core.help.locale}}') @locale.handle('{{core.help.locale}}')
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
avaliable_lang = msg.locale.t("message.delimiter").join(get_available_locales()) avaliable_lang = msg.locale.t("message.delimiter").join(get_available_locales())

View file

@ -1,5 +1,4 @@
from core.builtins import Bot from core.builtins import Bot, Image
from core.builtins import Image
from core.component import module from core.component import module
from core.utils.cooldown import CoolDown from core.utils.cooldown import CoolDown
from .dbutils import CytoidBindInfoManager from .dbutils import CytoidBindInfoManager
@ -7,17 +6,18 @@ from .profile import cytoid_profile
from .rating import get_rating from .rating import get_rating
from .utils import get_profile_name from .utils import get_profile_name
cytoid = module('cytoid', desc='{cytoid.help.desc}', ctd = module('cytoid', desc='{cytoid.help.desc}',
developers=['OasisAkari'], alias='ctd') developers=['OasisAkari'], alias='ctd')
@cytoid.handle('profile [<UserID>] {{cytoid.help.profile}}') @ctd.handle('profile [<UserID>] {{cytoid.help.profile}}')
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
if msg.parsed_msg['profile']: if msg.parsed_msg['profile']:
await cytoid_profile(msg) await cytoid_profile(msg)
@cytoid.handle('(b30|r30) [<UserID>] {{cytoid.help.b30}}') @ctd.handle('b30 [<UserID>] {{cytoid.help.b30}}',
'r30 [<UserID>] {{cytoid.help.r30}}')
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
if 'b30' in msg.parsed_msg: if 'b30' in msg.parsed_msg:
query = 'b30' query = 'b30'
@ -48,10 +48,11 @@ async def _(msg: Bot.MessageSession):
if img['status']: if img['status']:
qc.reset() qc.reset()
else: else:
await msg.finish(msg.locale.t('cytoid.message.b30.cooldown', time=int(c))) res = msg.locale.t('message.cooldown', time=int(c), cd_time='150') + msg.locale.t('cytoid.message.b30.cooldown')
await msg.finish(res)
@cytoid.handle('bind <username> {{cytoid.help.bind}}') @ctd.handle('bind <username> {{cytoid.help.bind}}')
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
code: str = msg.parsed_msg['<username>'].lower() code: str = msg.parsed_msg['<username>'].lower()
getcode = await get_profile_name(code) getcode = await get_profile_name(code)
@ -67,7 +68,7 @@ async def _(msg: Bot.MessageSession):
await msg.finish(msg.locale.t('cytoid.message.bind.failed')) await msg.finish(msg.locale.t('cytoid.message.bind.failed'))
@cytoid.handle('unbind {{cytoid.help.unbind}}') @ctd.handle('unbind {{cytoid.help.unbind}}')
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
unbind = CytoidBindInfoManager(msg).remove_bind_info() unbind = CytoidBindInfoManager(msg).remove_bind_info()
if unbind: if unbind:

View file

@ -1,10 +1,11 @@
{ {
"cytoid.help.b30": "查询 Cytoid 用户的 B30/R30 列表。", "cytoid.help.b30": "查询 Cytoid 用户的 B30 列表。",
"cytoid.help.bind": "绑定 Cytoid 用户。", "cytoid.help.bind": "绑定 Cytoid 用户。",
"cytoid.help.desc": "查询 Cytoid 相关内容。", "cytoid.help.desc": "查询 Cytoid 相关内容。",
"cytoid.help.profile": "查询一个用户的基本信息。", "cytoid.help.profile": "查询一个用户的基本信息。",
"cytoid.help.r30": "查询 Cytoid 用户的 R30 列表。",
"cytoid.help.unbind": "解绑用户。", "cytoid.help.unbind": "解绑用户。",
"cytoid.message.b30.cooldown": "距离上次执行已过去 ${time} 秒,本命令的冷却时间为 150 秒。(据官方人员所述,此 API 的调用十分昂贵,故手动做出此限制,请谅解。)", "cytoid.message.b30.cooldown": "(据官方人员所述,此 API 的调用十分昂贵,故手动做出此限制,请谅解。)",
"cytoid.message.bind.failed": "绑定失败,请检查输入。", "cytoid.message.bind.failed": "绑定失败,请检查输入。",
"cytoid.message.bind.success": "绑定成功:", "cytoid.message.bind.success": "绑定成功:",
"cytoid.message.unbind.success": "解绑成功。", "cytoid.message.unbind.success": "解绑成功。",

View file

@ -1,10 +1,11 @@
{ {
"cytoid.help.b30": "查询 Cytoid 用户的 B30/R30 列表。", "cytoid.help.b30": "查询 Cytoid 用户的 B30 列表。",
"cytoid.help.bind": "绑定 Cytoid 用户。", "cytoid.help.bind": "绑定 Cytoid 用户。",
"cytoid.help.desc": "查询 Cytoid 相关内容。", "cytoid.help.desc": "查询 Cytoid 相关内容。",
"cytoid.help.profile": "查询一个用户的基本信息。", "cytoid.help.profile": "查询一个用户的基本信息。",
"cytoid.help.r30": "查询 Cytoid 用户的 R30 列表。",
"cytoid.help.unbind": "解绑用户。", "cytoid.help.unbind": "解绑用户。",
"cytoid.message.b30.cooldown": "距离上次执行已过去 ${time} 秒,本命令的冷却时间为 150 秒。(据官方人员所述,此 API 的调用十分昂贵,故手动做出此限制,请谅解。)", "cytoid.message.b30.cooldown": "(据官方人员所述,此 API 的调用十分昂贵,故手动做出此限制,请谅解。)",
"cytoid.message.bind.failed": "绑定失败,请检查输入。", "cytoid.message.bind.failed": "绑定失败,请检查输入。",
"cytoid.message.bind.success": "绑定成功:", "cytoid.message.bind.success": "绑定成功:",
"cytoid.message.unbind.success": "解绑成功。", "cytoid.message.unbind.success": "解绑成功。",

View file

@ -1,10 +1,11 @@
{ {
"cytoid.help.b30": "查詢 Cytoid 使用者的 B30/R30 列表。", "cytoid.help.b30": "查詢 Cytoid 使用者的 B30 列表。",
"cytoid.help.bind": "绑定 Cytoid 使用者。", "cytoid.help.bind": "绑定 Cytoid 使用者。",
"cytoid.help.desc": "查詢 Cytoid 相關內容。", "cytoid.help.desc": "查詢 Cytoid 相關內容。",
"cytoid.help.profile": "查詢一個使用者的基本資訊。", "cytoid.help.profile": "查詢一個使用者的基本資訊。",
"cytoid.help.r30": "查詢 Cytoid 使用者的 R30 列表。",
"cytoid.help.unbind": "解除綁定使用者。", "cytoid.help.unbind": "解除綁定使用者。",
"cytoid.message.b30.cooldown": "距上次執行已過去 ${time} 秒,此指令的冷卻時間為 150 秒。(據官方人員所述,此 API 的呼叫十分昂貴,故手動做出此限制,請諒解。)", "cytoid.message.b30.cooldown": "(據官方人員所述,此 API 的呼叫非常昂貴,故手動做出此限制,請諒解。)",
"cytoid.message.bind.failed": "綁定失敗,請校對輸入。", "cytoid.message.bind.failed": "綁定失敗,請校對輸入。",
"cytoid.message.bind.success": "綁定成功:", "cytoid.message.bind.success": "綁定成功:",
"cytoid.message.unbind.success": "解除綁定成功。", "cytoid.message.unbind.success": "解除綁定成功。",

View file

@ -1,7 +1,6 @@
import ujson as json import ujson as json
from core.builtins import Bot from core.builtins import Bot, Image, Plain
from core.builtins import Plain, Image
from core.utils.http import get_url from core.utils.http import get_url
from .dbutils import CytoidBindInfoManager from .dbutils import CytoidBindInfoManager

View file

@ -1,8 +1,7 @@
import asyncio import asyncio
import traceback import traceback
from core.builtins import Bot from core.builtins import Bot, Image, Plain, Url
from core.builtins import Image, Plain, Url
from core.dirty_check import rickroll from core.dirty_check import rickroll
from core.utils.http import get_url, download_to_cache from core.utils.http import get_url, download_to_cache
from modules.github.utils import time_diff, dirty_check, darkCheck from modules.github.utils import time_diff, dirty_check, darkCheck

View file

@ -12,7 +12,7 @@
"maimai.help.maimai_regex.plate": "<名牌板>进度 [<用户名>] 查看用户的名牌板完成进度。", "maimai.help.maimai_regex.plate": "<名牌板>进度 [<用户名>] 查看用户的名牌板完成进度。",
"maimai.help.maimai_regex.process": "<难度> <目标>进度 [<用户名>] 查看用户在对应等级的评价完成进度。", "maimai.help.maimai_regex.process": "<难度> <目标>进度 [<用户名>] 查看用户在对应等级的评价完成进度。",
"maimai.help.maimai_regex.random": "随个[dx|标准][绿黄红紫白]<难度> 随机一首指定条件的歌曲。", "maimai.help.maimai_regex.random": "随个[dx|标准][绿黄红紫白]<难度> 随机一首指定条件的歌曲。",
"maimai.help.maimai_regex.song": "<ID 或别名>是什么歌 输入 ID 或别名查询歌曲信息", "maimai.help.maimai_regex.song": "<ID 或别名>是什么歌 输入 ID 或别名查询歌曲信息ID 需要加入前缀“id”。",
"maimai.help.plate": "查看用户的名牌板完成进度。", "maimai.help.plate": "查看用户的名牌板完成进度。",
"maimai.help.process": "查看用户在对应等级的评价完成进度。", "maimai.help.process": "查看用户在对应等级的评价完成进度。",
"maimai.help.random": "随机一首歌曲。", "maimai.help.random": "随机一首歌曲。",
@ -21,7 +21,7 @@
"maimai.help.scoreline": "查询歌曲的分数线。", "maimai.help.scoreline": "查询歌曲的分数线。",
"maimai.help.scorelist": "查看用户在对应等级的分数列表。", "maimai.help.scorelist": "查看用户在对应等级的分数列表。",
"maimai.help.search": "根据歌名(或一部分)搜索歌曲。", "maimai.help.search": "根据歌名(或一部分)搜索歌曲。",
"maimai.help.song": "查询 Maimai 歌曲或谱面信息。", "maimai.help.song": "查询 Maimai 歌曲或谱面信息ID 需要加入前缀“id”。",
"maimai.message.alias": "${title} 的别名:", "maimai.message.alias": "${title} 的别名:",
"maimai.message.alias.alias_not_found": "未找到符合要求的别名。", "maimai.message.alias.alias_not_found": "未找到符合要求的别名。",
"maimai.message.alias.file_not_found": "未找到别名文件,请使用“${prefix}maimai update”初始化文件。", "maimai.message.alias.file_not_found": "未找到别名文件,请使用“${prefix}maimai update”初始化文件。",
@ -31,7 +31,7 @@
"maimai.message.error.non_digital": "发生错误:歌曲 ID 必须为数字!", "maimai.message.error.non_digital": "发生错误:歌曲 ID 必须为数字!",
"maimai.message.forbidden": "此用户禁止了其他人获取数据。", "maimai.message.forbidden": "此用户禁止了其他人获取数据。",
"maimai.message.info.no_record": "未游玩过此谱面", "maimai.message.info.no_record": "未游玩过此谱面",
"maimai.message.level": "以下为难度 ${level} 的曲目列表:", "maimai.message.level": "以下为 ${level} 的曲目列表:",
"maimai.message.music_not_found": "未找到符合要求的歌曲。", "maimai.message.music_not_found": "未找到符合要求的歌曲。",
"maimai.message.no_username": "请提供用户名!", "maimai.message.no_username": "请提供用户名!",
"maimai.message.plate": "您的${plate}剩余进度如下:\nBasic 剩余 ${song_remain_basic} 首,\nAdvanced 剩余 ${song_remain_advanced} 首,\nExpert 剩余 ${song_remain_expert} 首,\nMaster 剩余 ${song_remain_master} 首", "maimai.message.plate": "您的${plate}剩余进度如下:\nBasic 剩余 ${song_remain_basic} 首,\nAdvanced 剩余 ${song_remain_advanced} 首,\nExpert 剩余 ${song_remain_expert} 首,\nMaster 剩余 ${song_remain_master} 首",
@ -41,17 +41,17 @@
"maimai.message.plate.greater_13p.last": "剩余等级大于 13+ 的曲目:", "maimai.message.plate.greater_13p.last": "剩余等级大于 13+ 的曲目:",
"maimai.message.plate.last": "剩余曲目:", "maimai.message.plate.last": "剩余曲目:",
"maimai.message.plate.plate_not_found": "名牌板不存在,请检查输入。", "maimai.message.plate.plate_not_found": "名牌板不存在,请检查输入。",
"maimai.message.plate.remaster": "Re:MASTER 剩余 ${song_remain_remaster} 首", "maimai.message.plate.remaster": "\nRe:MASTER 剩余 ${song_remain_remaster} 首",
"maimai.message.process": "您还有 ${song_remain} 首 ${process} 级曲目没有达成 ${goal}。", "maimai.message.process": "您还有 ${song_remain} 首 ${process} 级曲目没有达成 ${goal}。",
"maimai.message.process.completed": "您已达成 ${process} 级曲目全谱面 ${goal}。", "maimai.message.process.completed": "您已达成 ${process} 级曲目全谱面 ${goal}。",
"maimai.message.process.error.goal_invalid": "发生错误:无效的目标评级,请检查输入。", "maimai.message.process.error.goal_invalid": "发生错误:无效的目标评级,请检查输入。",
"maimai.message.process.error.level_invalid": "发生错误:无效的等级,请检查输入。", "maimai.message.process.error.level_invalid": "发生错误:无效的等级,请检查输入。",
"maimai.message.process.last": "您的 ${process} 级歌曲全谱面 ${goal} 剩余曲目如下:", "maimai.message.process.last": "您的 ${process} 级歌曲全谱面 ${goal} 剩余曲目如下:",
"maimai.message.process.less_than_8": "歌曲等级必须大于 8 级。", "maimai.message.process.less_than_8": "歌曲等级必须大于 8 级。",
"maimai.message.random.error": "发生错误:无法随机歌曲,请检查输入。", "maimai.message.random.error": "发生错误:随机歌曲失败,请检查输入。",
"maimai.message.rank": "截至 ${time}\n查分器共有 ${total_rank} 名用户,平均分数为 ${average_rating}。\n${user} 的分数为 ${rating},排名为 #${rank}\n已经超越了 ${surpassing_rate}% 的玩家。", "maimai.message.rank": "截至 ${time}\n查分器共有 ${total_rank} 名用户,平均分数为 ${average_rating}。\n${user} 的分数为 ${rating},排名为 #${rank}\n已经超越了 ${surpassing_rate}% 的玩家。",
"maimai.message.scoreline": "分数线 ${scoreline}% 允许的最多 TAP GREAT 数量为 ${tap_great}(每个-${tap_great_prop}%\nBREAK 2550一共 ${brk} 个)等价于 ${b2t_2550_great} 个 TAP GREAT-${b2t_2550_great_prop}%\nBREAK 2000一共 ${brk} 个)等价于 ${b2t_2000_great} 个 TAP GREAT-${b2t_2000_great_prop}%", "maimai.message.scoreline": "分数线 ${scoreline}% 允许的最多 TAP GREAT 数量为 ${tap_great}(每个-${tap_great_prop}%\nBREAK 2550一共 ${brk} 个)等价于 ${b2t_2550_great} 个 TAP GREAT-${b2t_2550_great_prop}%\nBREAK 2000一共 ${brk} 个)等价于 ${b2t_2000_great} 个 TAP GREAT-${b2t_2000_great_prop}%",
"maimai.message.scoreline.error": "发生错误:无法计算结果,请检查输入。", "maimai.message.scoreline.error": "发生错误:计算结果失败,请检查输入。",
"maimai.message.scorelist": "以下为 ${user} 的 ${level} 级分数列表:", "maimai.message.scorelist": "以下为 ${user} 的 ${level} 级分数列表:",
"maimai.message.search": "“${keyword}”的搜索结果:", "maimai.message.search": "“${keyword}”的搜索结果:",
"maimai.message.song": "艺术家:${artist}\n分类${genre}\nBPM${bpm}\n版本${version}\n难度${level}", "maimai.message.song": "艺术家:${artist}\n分类${genre}\nBPM${bpm}\n版本${version}\n难度${level}",

View file

@ -48,10 +48,10 @@
"maimai.message.process.error.level_invalid": "发生错误:无效的等级,请检查输入。", "maimai.message.process.error.level_invalid": "发生错误:无效的等级,请检查输入。",
"maimai.message.process.last": "您的 ${process} 级歌曲全谱面 ${goal} 剩余曲目如下:", "maimai.message.process.last": "您的 ${process} 级歌曲全谱面 ${goal} 剩余曲目如下:",
"maimai.message.process.less_than_8": "歌曲等级必须大于 8 级。", "maimai.message.process.less_than_8": "歌曲等级必须大于 8 级。",
"maimai.message.random.error": "发生错误:无法随机歌曲,请检查输入。", "maimai.message.random.error": "发生错误:随机歌曲失败,请检查输入。",
"maimai.message.rank": "截至 ${time}\n查分器共有 ${total_rank} 名用户,平均分数为 ${average_rating}。\n${user} 的分数为 ${rating},排名为 #${rank}\n已经超越了 ${surpassing_rate}% 的玩家。", "maimai.message.rank": "截至 ${time}\n查分器共有 ${total_rank} 名用户,平均分数为 ${average_rating}。\n${user} 的分数为 ${rating},排名为 #${rank}\n已经超越了 ${surpassing_rate}% 的玩家。",
"maimai.message.scoreline": "分数线 ${scoreline}% 允许的最多 TAP GREAT 数量为 ${tap_great}(每个-${tap_great_prop}%\nBREAK 2550一共 ${brk} 个)等价于 ${b2t_2550_great} 个 TAP GREAT-${b2t_2550_great_prop}%\nBREAK 2000一共 ${brk} 个)等价于 ${b2t_2000_great} 个 TAP GREAT-${b2t_2000_great_prop}%", "maimai.message.scoreline": "分数线 ${scoreline}% 允许的最多 TAP GREAT 数量为 ${tap_great}(每个-${tap_great_prop}%\nBREAK 2550一共 ${brk} 个)等价于 ${b2t_2550_great} 个 TAP GREAT-${b2t_2550_great_prop}%\nBREAK 2000一共 ${brk} 个)等价于 ${b2t_2000_great} 个 TAP GREAT-${b2t_2000_great_prop}%",
"maimai.message.scoreline.error": "发生错误:无法计算结果,请检查输入。", "maimai.message.scoreline.error": "发生错误:计算结果失败,请检查输入。",
"maimai.message.scorelist": "以下为 ${user} 的 ${level} 级分数列表:", "maimai.message.scorelist": "以下为 ${user} 的 ${level} 级分数列表:",
"maimai.message.search": "“${keyword}”的搜索结果:", "maimai.message.search": "“${keyword}”的搜索结果:",
"maimai.message.song": "艺术家:${artist}\n分类${genre}\nBPM${bpm}\n版本${version}\n难度${level}", "maimai.message.song": "艺术家:${artist}\n分类${genre}\nBPM${bpm}\n版本${version}\n难度${level}",

View file

@ -4,7 +4,7 @@
"maimai.help.base": "依據定數或定數範圍內搜尋歌曲。", "maimai.help.base": "依據定數或定數範圍內搜尋歌曲。",
"maimai.help.desc": "查詢 Maimai 相關的內容。", "maimai.help.desc": "查詢 Maimai 相關的內容。",
"maimai.help.id": "依據 ID 查詢歌曲或譜面資訊。", "maimai.help.id": "依據 ID 查詢歌曲或譜面資訊。",
"maimai.help.info": "查詢歌曲的相關譜面成績ID 需要加入前綴「id」空格用「_」替代。", "maimai.help.info": "查詢歌曲的相關譜面成績ID 需要加入前綴「id」。",
"maimai.help.level": "依據等級搜尋歌曲。", "maimai.help.level": "依據等級搜尋歌曲。",
"maimai.help.maimai_regex.alias": "<ID> 有什麼別名 查詢歌曲的別名。", "maimai.help.maimai_regex.alias": "<ID> 有什麼別名 查詢歌曲的別名。",
"maimai.help.maimai_regex.desc": "更方便地使用 Maimai 相關指令。", "maimai.help.maimai_regex.desc": "更方便地使用 Maimai 相關指令。",
@ -49,9 +49,9 @@
"maimai.message.process.last": "您的 ${process} 級歌曲全譜面 ${goal} 剩餘曲目如下:", "maimai.message.process.last": "您的 ${process} 級歌曲全譜面 ${goal} 剩餘曲目如下:",
"maimai.message.process.less_than_8": "歌曲等級必須大於 8 級。", "maimai.message.process.less_than_8": "歌曲等級必須大於 8 級。",
"maimai.message.random.error": "發生錯誤:無法隨機歌曲,請校對輸入。", "maimai.message.random.error": "發生錯誤:無法隨機歌曲,請校對輸入。",
"maimai.message.rank": "截至 ${time}\n查分器共有 ${total_rank} 名使用者,平均分數為 ${average_rating}\n${user} 的分數為 ${rating},排名為 #${rank}\n已經超越了 ${surpassing_rate}% 的玩家。", "maimai.message.rank": "截至 ${time}\n查分器共有 ${total_rank} 名使用者,平均分數為 ${average_rating}\n${user} 的分數為 ${rating},排名為 #${rank}\n已經超越了 ${surpassing_rate}% 的玩家。",
"maimai.message.scoreline": "分數線 ${scoreline}% 允許的最多 TAP GREAT 數量為 ${tap_great}(每個-${tap_great_prop}%\nBREAK 2550一共 ${brk} 個)相當於 ${b2t_2550_great} 個 TAP GREAT-${b2t_2550_great_prop}%\nBREAK 2000一共 ${brk} 個)相當於 ${b2t_2000_great} 個 TAP GREAT-${b2t_2000_great_prop}%", "maimai.message.scoreline": "分數線 ${scoreline}% 允許的最多 TAP GREAT 數量為 ${tap_great}(每個-${tap_great_prop}%\nBREAK 2550一共 ${brk} 個)相當於 ${b2t_2550_great} 個 TAP GREAT-${b2t_2550_great_prop}%\nBREAK 2000一共 ${brk} 個)相當於 ${b2t_2000_great} 個 TAP GREAT-${b2t_2000_great_prop}%",
"maimai.message.scoreline.error": "發生錯誤:無法計算結果,請校對輸入。", "maimai.message.scoreline.error": "發生錯誤:計算結果失敗,請校對輸入。",
"maimai.message.scorelist": "以下為 ${user} 的 ${level} 級分數列表:", "maimai.message.scorelist": "以下為 ${user} 的 ${level} 級分數列表:",
"maimai.message.search": "「${keyword}」的搜尋結果:", "maimai.message.search": "「${keyword}」的搜尋結果:",
"maimai.message.song": "藝術家:${artist}\n分類${genre}\nBPM${bpm}\n版本${version}\n難度${level}", "maimai.message.song": "藝術家:${artist}\n分類${genre}\nBPM${bpm}\n版本${version}\n難度${level}",

View file

@ -116,7 +116,7 @@ async def _(msg: Bot.MessageSession):
BImage(f"https://www.diving-fish.com/covers/{get_cover_len5_id(music['id'])}.png"), Plain(output)]) BImage(f"https://www.diving-fish.com/covers/{get_cover_len5_id(music['id'])}.png"), Plain(output)])
@mai_regex.handle(re.compile(r"(?:id)?(\d+)\s?有什(么别|麼別)名", flags=re.I), desc='{maimai.help.maimai_regex.alias}') @mai_regex.handle(re.compile(r"(?:id)?(\d+)\s?有什(?:么别|麼別)名", flags=re.I), desc='{maimai.help.maimai_regex.alias}')
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
sid = msg.matched_msg.groups()[0] sid = msg.matched_msg.groups()[0]
music = (await total_list.get()).by_id(sid) music = (await total_list.get()).by_id(sid)
@ -140,23 +140,23 @@ async def _(msg: Bot.MessageSession):
level='/'.join((str(ds) for ds in music['ds']))))]) level='/'.join((str(ds) for ds in music['ds']))))])
@mai_regex.handle(re.compile(r"(随个|隨個)\s?((?:dx|DX|sd|SD|标准|標準)\s?)?([绿綠黄黃红紅紫白]?)\s?([0-9]+\+?)"), @mai_regex.handle(re.compile(r"(?:随个|隨個)\s?((?:dx|DX|sd|SD|标准|標準)\s?)?([绿綠黄黃红紅紫白]?)\s?([0-9]+\+?)"),
desc="{maimai.help.maimai_regex.random}") desc="{maimai.help.maimai_regex.random}")
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
res = msg.matched_msg res = msg.matched_msg
if res: if res:
try: try:
if res.groups()[1] in ["dx", "DX"]: if res.groups()[0] in ["dx", "DX"]:
tp = ["DX"] tp = ["DX"]
elif res.groups()[1] in ["sd", "SD"] or res.groups()[1] in ["标准", "標準"]: elif res.groups()[0] in ["sd", "SD", "标准", "標準"]:
tp = ["SD"] tp = ["SD"]
else: else:
tp = ["SD", "DX"] tp = ["SD", "DX"]
level = res.groups()[3] level = res.groups()[2]
if res.groups()[2] == "": if res.groups()[1] == "":
music_data = (await total_list.get()).filter(level=level, type=tp) music_data = (await total_list.get()).filter(level=level, type=tp)
else: else:
music_data = (await total_list.get()).filter(level=level, diff=[get_diff(res.groups()[2])], music_data = (await total_list.get()).filter(level=level, diff=[get_diff(res.groups()[1])],
type=tp) type=tp)
if len(music_data) == 0: if len(music_data) == 0:
rand_result = msg.locale.t("maimai.message.music_not_found") rand_result = msg.locale.t("maimai.message.music_not_found")
@ -191,7 +191,7 @@ async def _(msg: Bot.MessageSession):
await msg.finish(output.strip()) await msg.finish(output.strip())
@mai_regex.handle(re.compile(r"([0-9]+\+?)\s(.+)\s?[进進]度\s?(.+)?"), desc='{maimai.help.maimai_regex.process}') @mai_regex.handle(re.compile(r"([0-9]+\+?)\s?(.+)\s?[进進]度\s?(.+)?"), desc='{maimai.help.maimai_regex.process}')
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
goal_list = [ goal_list = [
"A", "A",
@ -214,7 +214,7 @@ async def _(msg: Bot.MessageSession):
level = msg.matched_msg.groups()[0] level = msg.matched_msg.groups()[0]
goal = msg.matched_msg.groups()[1] goal = msg.matched_msg.groups()[1]
username = msg.matched_msg.groups()[2] username = msg.matched_msg.groups()[2]
if goal is None: if not goal:
return return
if username is None and msg.target.sender_from == "QQ": if username is None and msg.target.sender_from == "QQ":
payload = {'qq': msg.session.sender} payload = {'qq': msg.session.sender}

View file

@ -1,5 +1,4 @@
from core.builtins import Bot from core.builtins import Bot, Plain, Image, Url
from core.builtins import Plain, Image, Url
from core.component import module from core.component import module
from .mojang_api import * from .mojang_api import *

View file

@ -9,7 +9,8 @@ ncmusic = module('ncmusic',
support_languages=['zh_cn']) support_languages=['zh_cn'])
@ncmusic.handle('search <keyword> {{ncmusic.help.search}}') @ncmusic.handle(['search <keyword> {{ncmusic.help.search}}',
'search legacy <keyword> {{ncmusic.help.search.legacy}}'])
async def search(msg: Bot.MessageSession, keyword: str): async def search(msg: Bot.MessageSession, keyword: str):
url = f"https://ncmusic.akari-bot.top/search?keywords={keyword}" url = f"https://ncmusic.akari-bot.top/search?keywords={keyword}"
result = await get_url(url, 200, fmt='json') result = await get_url(url, 200, fmt='json')
@ -20,7 +21,7 @@ async def search(msg: Bot.MessageSession, keyword: str):
songs = result['result']['songs'][:10] songs = result['result']['songs'][:10]
if msg.Feature.image: if 'legacy' not in msg.parsed_msg and msg.Feature.image:
send_msg = [Plain(msg.locale.t('ncmusic.message.search.result') + '\n')] send_msg = [Plain(msg.locale.t('ncmusic.message.search.result') + '\n')]
data = [[ data = [[

View file

@ -1,5 +1,6 @@
{ {
"ncmusic.help.search": "搜索网易云音乐。", "ncmusic.help.search": "搜索网易云音乐。",
"ncmusic.help.search.legacy": "搜索网易云音乐。(旧版)",
"ncmusic.help.info": "获取音乐详细信息。", "ncmusic.help.info": "获取音乐详细信息。",
"ncmusic.message.info": "歌名:${name}${id}\n专辑名${album}${album_id}\n歌手${artists}\n歌曲详情页${detail}", "ncmusic.message.info": "歌名:${name}${id}\n专辑名${album}${album_id}\n歌手${artists}\n歌曲详情页${detail}",
"ncmusic.message.search.collapse": "…仅显示前 10 条内容。", "ncmusic.message.search.collapse": "…仅显示前 10 条内容。",

View file

@ -1,5 +1,6 @@
{ {
"ncmusic.help.search": "搜尋網易雲音樂。", "ncmusic.help.search": "搜尋網易雲音樂。",
"ncmusic.help.search.legacy": "搜尋網易雲音樂。(舊版)",
"ncmusic.help.info": "取得音樂詳細資訊。", "ncmusic.help.info": "取得音樂詳細資訊。",
"ncmusic.message.info": "歌名:${name}${id}\n專輯名${album}${album_id}\n歌手${artists}\n歌曲詳情頁${detail}", "ncmusic.message.info": "歌名:${name}${id}\n專輯名${album}${album_id}\n歌手${artists}\n歌曲詳情頁${detail}",
"ncmusic.message.search.collapse": "…僅顯示前 10 條內容。", "ncmusic.message.search.collapse": "…僅顯示前 10 條內容。",

View file

@ -2,8 +2,7 @@ import os.path
import shutil import shutil
import traceback import traceback
from core.builtins import Bot from core.builtins import Bot, Image
from core.builtins import Image
from core.component import module from core.component import module
from core.utils.cache import random_cache_path from core.utils.cache import random_cache_path
from core.utils.http import get_url, download_to_cache from core.utils.http import get_url, download_to_cache

View file

@ -2,8 +2,7 @@ import os
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
from core.builtins import Bot from core.builtins import Bot, Image as Img
from core.builtins import Image as Img
from core.component import module from core.component import module
from core.utils.cache import random_cache_path from core.utils.cache import random_cache_path

View file

@ -1,7 +1,7 @@
{ {
"server.help": "取得 MinecraftJava 版/基岩版伺服器 motd。", "server.help": "取得 MinecraftJava 版/基岩版伺服器 motd。",
"server.help.option.p": "顯示玩家列表", "server.help.option.p": "列出玩家列表",
"server.help.option.r": "顯示原始資訊", "server.help.option.r": "列出原始資訊",
"server.help.revoke": "是否啟用自動回收功能(預設為是)。", "server.help.revoke": "是否啟用自動回收功能(預設為是)。",
"server.message.error": "查詢呼叫 API 時發生錯誤。", "server.message.error": "查詢呼叫 API 時發生錯誤。",
"server.message.error.local_ip": "發生錯誤:無效的域名或 IP 位址。", "server.message.error.local_ip": "發生錯誤:無效的域名或 IP 位址。",

View file

@ -1,105 +1,103 @@
import re import re
import traceback import traceback
import aiohttp import aiohttp
import ujson as json import ujson as json
from core.builtins import ErrorMessage from core.builtins import ErrorMessage
from core.logger import Logger from core.logger import Logger
async def server(msg, address, raw=False, showplayer=False, mode='j'): async def server(msg, address, raw=False, showplayer=False, mode='j'):
match_object = re.match(r'(.*)[\s:](.*)', address, re.M | re.I) match_object = re.match(r'(.*)[\s:](.*)', address, re.M | re.I)
servers = [] servers = []
n = '\n' n = '\n'
if match_object: if match_object:
serip = match_object.group(1) serip = match_object.group(1)
port1 = match_object.group(2) port1 = match_object.group(2)
port2 = match_object.group(2) port2 = match_object.group(2)
else: else:
serip = address serip = address
port1 = '25565' port1 = '25565'
port2 = '19132' port2 = '19132'
if mode == 'j': if mode == 'j':
try: try:
url = 'http://motd.wd-api.com/v1/java?host=' + serip + '&port=' + port1 url = 'http://motd.wd-api.com/v1/java?host=' + serip + '&port=' + port1
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.get(url, timeout=aiohttp.ClientTimeout(total=20)) as req: async with session.get(url, timeout=aiohttp.ClientTimeout(total=20)) as req:
if req.status != 200: if req.status != 200:
Logger.error(await req.text()) Logger.error(await req.text())
else: else:
jejson = json.loads(await req.text()) jejson = json.loads(await req.text())
try: try:
servers.append('[JE]') servers.append('[JE]')
if 'description' in jejson: if 'description' in jejson:
description = jejson['description'] description = jejson['description']
if 'text' in description: if 'text' in description and description['text'] != '':
servers.append(str(description['text'])) servers.append(str(description['text']))
elif 'extra' in description: if 'extra' in description and description['extra'] != '':
extra = description['extra'] extra = description['extra']
text = [] text = []
for item in extra[:]: for item in extra[:]:
text.append(str(item['text'])) text.append(str(item['text']))
servers.append(''.join(text)) servers.append(''.join(text))
else:
servers.append(str(description)) if 'players' in jejson:
onlinesplayer = f"{msg.locale.t('server.message.player')}{str(jejson['players']['online'])} / {str(jejson['players']['max'])}"
if 'players' in jejson: servers.append(onlinesplayer)
onlinesplayer = f"{msg.locale.t('server.message.player')}{str(jejson['players']['online'])} / {str(jejson['players']['max'])}" if showplayer:
servers.append(onlinesplayer) playerlist = []
if showplayer: if 'sample' in jejson['players']:
playerlist = [] for x in jejson['players']['sample']:
if 'sample' in jejson['players']: playerlist.append(x['name'])
for x in jejson['players']['sample']: servers.append(
playerlist.append(x['name']) msg.locale.t('server.message.player.current') + '\n' + '\n'.join(
servers.append( playerlist))
msg.locale.t('server.message.player.current') + '\n' + '\n'.join( else:
playerlist)) if jejson['players']['online'] == 0:
else: servers.append(msg.locale.t('server.message.player.current.none'))
if jejson['players']['online'] == 0: if 'version' in jejson:
servers.append(msg.locale.t('server.message.player.current.none')) versions = msg.locale.t('server.message.version') + jejson['version']['name']
if 'version' in jejson: servers.append(versions)
versions = msg.locale.t('server.message.version') + jejson['version']['name'] servers.append(serip + ':' + port1)
servers.append(versions) except Exception:
servers.append(serip + ':' + port1) traceback.print_exc()
except Exception: servers.append(str(ErrorMessage(msg.locale.t('server.message.error'))))
traceback.print_exc() except Exception:
servers.append(str(ErrorMessage(msg.locale.t('server.message.error')))) traceback.print_exc()
except Exception: if raw:
traceback.print_exc() return n.join(servers)
if raw: return re.sub(r'§\w', "", n.join(servers))
return n.join(servers) if mode == 'b':
return re.sub(r'§\w', "", n.join(servers)) try:
if mode == 'b': beurl = 'http://motd.wd-api.com/v1/bedrock?host=' + serip + '&port=' + port2
try: async with aiohttp.ClientSession() as session2:
beurl = 'http://motd.wd-api.com/v1/bedrock?host=' + serip + '&port=' + port2 async with session2.get(beurl, timeout=aiohttp.ClientTimeout(total=20)) as req:
async with aiohttp.ClientSession() as session2: if req.status != 200:
async with session2.get(beurl, timeout=aiohttp.ClientTimeout(total=20)) as req: Logger.debug(await req.text())
if req.status != 200: else:
Logger.debug(await req.text()) bemotd = await req.text()
else: bejson = json.loads(bemotd)
bemotd = await req.text() unpack_data = bejson['data'].split(';')
bejson = json.loads(bemotd) edition = unpack_data[0]
unpack_data = bejson['data'].split(';') motd_1 = unpack_data[1]
edition = unpack_data[0] version_name = unpack_data[3]
motd_1 = unpack_data[1] player_count = unpack_data[4]
version_name = unpack_data[3] max_players = unpack_data[5]
player_count = unpack_data[4] motd_2 = unpack_data[7]
max_players = unpack_data[5] game_mode = unpack_data[8]
motd_2 = unpack_data[7] bemsg = '[BE]\n' + \
game_mode = unpack_data[8] motd_1 + ' - ' + motd_2 + \
bemsg = '[BE]\n' + \ '\n' + msg.locale.t('server.message.player') + player_count + '/' + max_players + \
motd_1 + ' - ' + motd_2 + \ '\n' + msg.locale.t('server.message.version') + edition + version_name + \
'\n' + msg.locale.t('server.message.player') + player_count + '/' + max_players + \ '\n' + msg.locale.t('server.message.gamemode') + game_mode
'\n' + msg.locale.t('server.message.version') + edition + version_name + \ servers.append(bemsg)
'\n' + msg.locale.t('server.message.gamemode') + game_mode servers.append(serip + ':' + port2)
servers.append(bemsg)
servers.append(serip + ':' + port2) except Exception:
traceback.print_exc()
except Exception: if raw:
traceback.print_exc() return n.join(servers)
if raw: return re.sub(r'§\w', "", n.join(servers))
return n.join(servers)
return re.sub(r'§\w', "", n.join(servers))

View file

@ -1,11 +1,12 @@
import re import re
from html import unescape from html import unescape
from bs4 import BeautifulSoup
import ujson as json import ujson as json
from core.builtins import Bot from core.builtins import Bot, Plain, Image, Url
from core.builtins import Plain, Image, Url
from core.component import module from core.component import module
from core.logger import Logger
from core.utils.http import get_url from core.utils.http import get_url
from core.utils.i18n import Locale from core.utils.i18n import Locale
from core.utils.image import msgchain2image from core.utils.image import msgchain2image
@ -17,23 +18,28 @@ from .teahouse import get_rss as get_teahouse_rss
async def get_weekly(with_img=False, zh_tw=False): async def get_weekly(with_img=False, zh_tw=False):
locale = Locale('zh_cn' if not zh_tw else 'zh_tw') locale = Locale('zh_cn' if not zh_tw else 'zh_tw')
result = json.loads(await get_url( result = json.loads(await get_url(
'https://zh.minecraft.wiki/api.php?action=parse&page=Minecraft_Wiki/weekly&prop=text|revid|images&format=json' + 'https://zh.minecraft.wiki/api.php?action=parse&page=Minecraft_Wiki&prop=text|revid|images&format=json' +
('&variant=zh-tw' if zh_tw else ''), ('&variant=zh-tw' if zh_tw else ''),
200)) 200))
html = result['parse']['text']['*'] b_result = BeautifulSoup(result['parse']['text']['*'], 'html.parser')
text = re.sub(r'<p>', '\n', html) # 分段 html = b_result.find('div', id='fp-section-weekly')
content = html.find('div', class_='weekly-content')
text = re.sub(r'<p>', '\n', str(content)) # 分段
text = re.sub(r'<(.*?)>', '', text, flags=re.DOTALL) # 移除所有 HTML 标签 text = re.sub(r'<(.*?)>', '', text, flags=re.DOTALL) # 移除所有 HTML 标签
text = re.sub(r'\n\n\n', '\n\n', text) # 移除不必要的空行 text = re.sub(r'\n\n\n', '\n\n', text) # 移除不必要的空行
text = re.sub(r'\n*$', '', text) text = re.sub(r'\n*$', '', text)
text = unescape(text) text = unescape(text)
img = result['parse']['images'] img = html.find('div', class_='weekly-image').find(class_='image')
page = re.findall(r'(?<=<b><a href=").*?(?=")', html)
img_filename = re.match(r'/w/(.*)', img.attrs['href'])
page = re.findall(r'(?<=<b><a href=").*?(?=")', str(content))
msg_list = [Plain(locale.t("weekly.message.error.expired") if page[ msg_list = [Plain(locale.t("weekly.message.error.expired") if page[
0] == '/zh/wiki/%E7%8E%BB%E7%92%83' else locale.t( 0] == '/w/%E7%8E%BB%E7%92%83' else locale.t(
"weekly.message", text=text))] "weekly.message", text=text))]
imglink = None imglink = None
if img: if img_filename:
get_image = await (WikiLib('https://zh.minecraft.wiki/wiki/')).parse_page_info('File:' + img[0]) get_image = await (WikiLib('https://zh.minecraft.wiki/')).parse_page_info(img_filename.group(1))
if get_image.status: if get_image.status:
imglink = get_image.file imglink = get_image.file
msg_list.append( msg_list.append(
@ -42,7 +48,7 @@ async def get_weekly(with_img=False, zh_tw=False):
"weekly.message.link", "weekly.message.link",
img=imglink if imglink is not None else locale.t("none"), img=imglink if imglink is not None else locale.t("none"),
article=str( article=str(
Url(f'https://minecraft.fandom.com{page[0]}')), Url(f'https://zh.minecraft.wiki{page[0]}')),
link=str( link=str(
Url(f'https://zh.minecraft.wiki/wiki/?oldid={str(result["parse"]["revid"])}'))))) Url(f'https://zh.minecraft.wiki/wiki/?oldid={str(result["parse"]["revid"])}')))))
if imglink is not None and with_img: if imglink is not None and with_img:
@ -53,13 +59,14 @@ async def get_weekly(with_img=False, zh_tw=False):
async def get_weekly_img(with_img=False, zh_tw=False): async def get_weekly_img(with_img=False, zh_tw=False):
locale = Locale('zh_cn' if not zh_tw else 'zh_tw') locale = Locale('zh_cn' if not zh_tw else 'zh_tw')
img = await generate_screenshot_v2('https://zh.minecraft.wiki/wiki/Minecraft_Wiki/weekly' + img = await generate_screenshot_v2('https://zh.minecraft.wiki/wiki/Minecraft_Wiki/' +
('?variant=zh-tw' if zh_tw else ''), content_mode=True, allow_special_page=True) ('?variant=zh-tw' if zh_tw else ''), content_mode=False, allow_special_page=True,
element=['div#fp-section-weekly'])
msg_ = [] msg_ = []
if img: if img:
msg_.append(Image(path=img)) msg_.append(Image(path=img))
if with_img: if with_img:
result = json.loads(await get_url( """result = json.loads(await get_url(
'https://zh.minecraft.wiki/api.php?action=parse&page=Minecraft_Wiki/weekly&prop=images&format=json' + 'https://zh.minecraft.wiki/api.php?action=parse&page=Minecraft_Wiki/weekly&prop=images&format=json' +
('&variant=zh-tw' if zh_tw else ''), ('&variant=zh-tw' if zh_tw else ''),
200)) 200))
@ -67,7 +74,7 @@ async def get_weekly_img(with_img=False, zh_tw=False):
if img: if img:
get_image = await (WikiLib('https://zh.minecraft.wiki/wiki/')).parse_page_info('File:' + img[0]) get_image = await (WikiLib('https://zh.minecraft.wiki/wiki/')).parse_page_info('File:' + img[0])
if get_image.status: if get_image.status:
msg_.append(Plain(locale.t("weekly.message.image", img=get_image.file))) msg_.append(Plain(locale.t("weekly.message.image", img=get_image.file)))"""
return msg_ return msg_

View file

@ -1,3 +1,5 @@
from datetime import datetime
from config import Config from config import Config
from core.builtins import Bot, Plain, Image from core.builtins import Bot, Plain, Image
from core.component import module from core.component import module
@ -12,17 +14,16 @@ if Config('enable_urlmanager'):
@aud.handle(['trust <apiLink>', 'block <apiLink>']) @aud.handle(['trust <apiLink>', 'block <apiLink>'])
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
req = msg.parsed_msg date = datetime.now().strftime("%Y-%m-%d")
op = msg.session.sender api = msg.parsed_msg['<apiLink>']
api = req['<apiLink>']
check = await WikiLib(api).check_wiki_available() check = await WikiLib(api).check_wiki_available()
if check.available: if check.available:
api = check.value.api api = check.value.api
if req.get('trust', False): if msg.parsed_msg.get('trust', False):
res = Audit(api).add_to_AllowList(op) res = Audit(api).add_to_AllowList(date)
list_name = msg.locale.t('wiki.message.wiki_audit.list_name.allowlist') list_name = msg.locale.t('wiki.message.wiki_audit.list_name.allowlist')
else: else:
res = Audit(api).add_to_BlockList(op) res = Audit(api).add_to_BlockList(date)
list_name = msg.locale.t('wiki.message.wiki_audit.list_name.blocklist') list_name = msg.locale.t('wiki.message.wiki_audit.list_name.blocklist')
if not res: if not res:
await msg.finish(msg.locale.t('wiki.message.wiki_audit.add.failed', list_name=list_name) + api) await msg.finish(msg.locale.t('wiki.message.wiki_audit.add.failed', list_name=list_name) + api)
@ -35,32 +36,27 @@ if Config('enable_urlmanager'):
@aud.handle(['distrust <apiLink>', 'unblock <apiLink>']) @aud.handle(['distrust <apiLink>', 'unblock <apiLink>'])
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
req = msg.parsed_msg api = msg.parsed_msg['<apiLink>'] # 已关闭的站点无法验证有效性
api = req['<apiLink>'] if msg.parsed_msg.get('distrust', False):
check = await WikiLib(api).check_wiki_available() res = Audit(api).remove_from_AllowList()
if check.available: if res is None:
api = check.value.api await msg.finish(msg.locale.t('wiki.message.wiki_audit.remove.failed.other') + api)
if req.get('distrust', False): list_name = msg.locale.t('wiki.message.wiki_audit.list_name.allowlist')
res = Audit(api).remove_from_AllowList()
if res is None:
await msg.finish(msg.locale.t('wiki.message.wiki_audit.remove.failed.other') + api)
list_name = msg.locale.t('wiki.message.wiki_audit.list_name.allowlist')
else:
res = Audit(api).remove_from_BlockList()
list_name = msg.locale.t('wiki.message.wiki_audit.list_name.blocklist')
if not res:
await msg.finish(msg.locale.t('wiki.message.wiki_audit.remove.failed', list_name=list_name) + api)
else:
await msg.finish(msg.locale.t('wiki.message.wiki_audit.remove.success', list_name=list_name) + api)
else: else:
result = msg.locale.t('wiki.message.error.query') + \ res = Audit(api).remove_from_BlockList()
('\n' + msg.locale.t('wiki.message.error.info') + check.message if check.message != '' else '') list_name = msg.locale.t('wiki.message.wiki_audit.list_name.blocklist')
await msg.finish(result) if not res:
await msg.finish(msg.locale.t('wiki.message.wiki_audit.remove.failed', list_name=list_name) + api)
else:
await msg.finish(msg.locale.t('wiki.message.wiki_audit.remove.success', list_name=list_name) + api)
else:
result = msg.locale.t('wiki.message.error.query') + \
('\n' + msg.locale.t('wiki.message.error.info') + check.message if check.message != '' else '')
await msg.finish(result)
@aud.handle('query <apiLink>') @aud.handle('query <apiLink>')
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
req = msg.parsed_msg api = msg.parsed_msg['<apiLink>']
api = req['<apiLink>']
check = await WikiLib(api).check_wiki_available() check = await WikiLib(api).check_wiki_available()
if check.available: if check.available:
api = check.value.api api = check.value.api
@ -82,18 +78,18 @@ if Config('enable_urlmanager'):
('\n' + msg.locale.t('wiki.message.error.info') + check.message if check.message != '' else '') ('\n' + msg.locale.t('wiki.message.error.info') + check.message if check.message != '' else '')
await msg.finish(result) await msg.finish(result)
@aud.handle('list') @aud.handle(['list', 'list legacy'])
async def _(msg: Bot.MessageSession): async def _(msg: Bot.MessageSession):
allow_list = Audit.get_allow_list() allow_list = Audit.get_allow_list()
block_list = Audit.get_block_list() block_list = Audit.get_block_list()
legacy = True legacy = True
if msg.Feature.image: if 'legacy' not in msg.parsed_msg and msg.Feature.image:
send_msgs = [] send_msgs = []
allow_columns = [[x[0], x[1]] for x in allow_list] allow_columns = [[x[0], x[1]] for x in allow_list]
if allow_columns: if allow_columns:
allow_table = ImageTable(data=allow_columns, headers=[ allow_table = ImageTable(data=allow_columns, headers=[
msg.locale.t('wiki.message.wiki_audit.list.table.header.apilink'), msg.locale.t('wiki.message.wiki_audit.list.table.header.apilink'),
msg.locale.t('wiki.message.wiki_audit.list.table.header.operator') msg.locale.t('wiki.message.wiki_audit.list.table.header.date')
]) ])
if allow_table: if allow_table:
allow_image = await image_table_render(allow_table) allow_image = await image_table_render(allow_table)
@ -104,7 +100,7 @@ if Config('enable_urlmanager'):
if block_columns: if block_columns:
block_table = ImageTable(data=block_columns, headers=[ block_table = ImageTable(data=block_columns, headers=[
msg.locale.t('wiki.message.wiki_audit.list.table.header.apilink'), msg.locale.t('wiki.message.wiki_audit.list.table.header.apilink'),
msg.locale.t('wiki.message.wiki_audit.list.table.header.operator') msg.locale.t('wiki.message.wiki_audit.list.table.header.date')
]) ])
if block_table: if block_table:
block_image = await image_table_render(block_table) block_image = await image_table_render(block_table)
@ -117,8 +113,8 @@ if Config('enable_urlmanager'):
if legacy: if legacy:
wikis = [msg.locale.t('wiki.message.wiki_audit.list.allowlist')] wikis = [msg.locale.t('wiki.message.wiki_audit.list.allowlist')]
for al in allow_list: for al in allow_list:
wikis.append(f'{al[0]} (by {al[1]})') wikis.append(f'{al[0]} ({al[1]})')
wikis.append(msg.locale.t('wiki.message.wiki_audit.list.blocklist')) wikis.append(msg.locale.t('wiki.message.wiki_audit.list.blocklist'))
for bl in block_list: for bl in block_list:
wikis.append(f'{bl[0]} (by {bl[1]})') wikis.append(f'{bl[0]} ({bl[1]})')
await msg.finish('\n'.join(wikis)) await msg.finish('\n'.join(wikis))

View file

@ -2,7 +2,8 @@
"tos.reason.too_many_redirects": "Causes the bot to redirect the page too many times.", "tos.reason.too_many_redirects": "Causes the bot to redirect the page too many times.",
"tos.reason.wiki_abuse": "More than 15 pages are queried at one time.", "tos.reason.wiki_abuse": "More than 15 pages are queried at one time.",
"wiki.help": "Query a wiki page.", "wiki.help": "Query a wiki page.",
"wiki.help.ab.desc": "Get recent abuse logs for the default wiki.", "wiki.help.ab": "Get recent abuse logs for the default wiki.",
"wiki.help.ab.legacy": "Get recent abuse logs for the default wiki. (Legacy)",
"wiki.help.fandom": "Toggles whether to use Fandom global Interwiki queries.", "wiki.help.fandom": "Toggles whether to use Fandom global Interwiki queries.",
"wiki.help.headers.remove": "Remove custom request headers.", "wiki.help.headers.remove": "Remove custom request headers.",
"wiki.help.headers.reset": "Reset custom request headers.", "wiki.help.headers.reset": "Reset custom request headers.",
@ -16,17 +17,18 @@
"wiki.help.iw.remove": "Remove custom Interwiki.", "wiki.help.iw.remove": "Remove custom Interwiki.",
"wiki.help.newbie.desc": "Get recent newbie logs for the default wiki.", "wiki.help.newbie.desc": "Get recent newbie logs for the default wiki.",
"wiki.help.option.l": "Find the corresponding language version of this page, and return the current language if no result.", "wiki.help.option.l": "Find the corresponding language version of this page, and return the current language if no result.",
"wiki.help.prefix.reset": "Reset custom command prefix.", "wiki.help.prefix.reset": "Reset custom wiki prefix.",
"wiki.help.prefix.set": "Set custom command prefix.", "wiki.help.prefix.set": "Set custom wiki prefix.",
"wiki.help.rc.desc": "Get a list of recent changes to the default wiki.", "wiki.help.rc": "Get a list of recent changes to the default wiki.",
"wiki.help.rc.legacy": "Get a list of recent changes to the default wiki. (Legacy)",
"wiki.help.redlink": "Toggle whether to return the edit link when the page does not exist.", "wiki.help.redlink": "Toggle whether to return the edit link when the page does not exist.",
"wiki.help.search": "Search a wiki page.", "wiki.help.search": "Search a wiki page.",
"wiki.help.set": "Set up initial wiki.", "wiki.help.set": "Set up start wiki.",
"wiki.help.wiki_inline.desc": "When enabled, containing [[ ]] or {{ }} in the message will be automatically parsed and the wiki will be automatically queried, such as [[Creeper]].", "wiki.help.wiki_inline.desc": "When enabled, containing [[ ]] or {{ }} in the message will be automatically parsed, and the wiki will be automatically queried. (e.g., [[Creeper]])",
"wiki.help.wiki_inline.mediawiki": "Enter a title within ≺ ≻ or ⧼ ⧽ to automatically query the MediaWiki namespace for pages.", "wiki.help.wiki_inline.mediawiki": "Enter a title within ≺ ≻ or ⧼ ⧽ to automatically query the MediaWiki namespace for pages.",
"wiki.help.wiki_inline.page": "Enter a title within [[ ]] to automatically query the page.", "wiki.help.wiki_inline.page": "Enter a title within [[ ]] to automatically query the page.",
"wiki.help.wiki_inline.template": "nter a title within {{ }} to automatically query the template.", "wiki.help.wiki_inline.template": "Enter a title within {{ }} to automatically query the template.",
"wiki.help.wiki_inline.url": "Send the URL of the wiki page to generate the Infobox image", "wiki.help.wiki_inline.url": "Send the URL of the wiki page to generate the Infobox image.",
"wiki.message.ab.qq.title": "滥用过滤器日志", "wiki.message.ab.qq.title": "滥用过滤器日志",
"wiki.message.ab.qq.title.address": "滥用过滤器日志地址", "wiki.message.ab.qq.title.address": "滥用过滤器日志地址",
"wiki.message.ab.slice": "•${title} - ${user} at ${time}\n Filter description: ${filter_name}\n Actions taken: ${result}", "wiki.message.ab.slice": "•${title} - ${user} at ${time}\n Filter description: ${filter_name}\n Actions taken: ${result}",
@ -38,27 +40,27 @@
"wiki.message.fandom.disable": "Disabled to use Fandom global Interwiki queries.", "wiki.message.fandom.disable": "Disabled to use Fandom global Interwiki queries.",
"wiki.message.fandom.enable": "Enabled to use Fandom global Interwiki queries.", "wiki.message.fandom.enable": "Enabled to use Fandom global Interwiki queries.",
"wiki.message.flies": "This page includes the following files:", "wiki.message.flies": "This page includes the following files:",
"wiki.message.headers.show": "The following request headers are currently set:\n${headers}\nTo customize, use \"${prefix}wiki headers add\".\nExample:\n${prefix}wiki headers set {\"accept-language\": \"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6\"}", "wiki.message.headers.show": "The following request headers are currently set:\n${headers}\nTo customize, use \"${prefix}wiki headers add\".\nExample:\n${prefix}wiki headers add {\"accept-language\": \"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6\"}",
"wiki.message.headers.reset.success": "The request headers have been reset.", "wiki.message.headers.reset.success": "The request headers have been reset.",
"wiki.message.headers.add.failed": "Fail to update the request headers, please check your input.", "wiki.message.headers.add.failed": "Fail to update the request headers. Please check your input.",
"wiki.message.headers.add.success": "The request headers have been updated: ${headers}", "wiki.message.headers.add.success": "The request headers have been updated: ${headers}",
"wiki.message.id.error": "An error occurred: Page ID must be numeric.", "wiki.message.id.error": "An error occurred: Page ID must be numeric.",
"wiki.message.id.not_found": "Page with page ID ${id} not found.", "wiki.message.id.not_found": "Page with page ID ${id} not found.",
"wiki.message.invalid_namespace": "There is no namespace named ${namespace} on this wiki, please check your input.", "wiki.message.invalid_namespace": "There is no namespace named ${namespace} on this wiki. Please check your input.",
"wiki.message.iw.add.success": "Custom Interwiki added:\n ${iw} -> ${name}", "wiki.message.iw.add.success": "Custom Interwiki added:\n ${iw} -> ${name}",
"wiki.message.iw.get.not_found": "Interwiki not found: ${iw}", "wiki.message.iw.get.not_found": "Interwiki not found: ${iw}",
"wiki.message.iw.list": "Use \"${prefix}wiki iw get <Interwiki>\" to get the corresponding link to Interwiki.", "wiki.message.iw.list": "Use \"${prefix}wiki iw get <Interwiki>\" to get the corresponding link to Interwiki.",
"wiki.message.iw.list.legacy": "The following Interwiki(s) are currently set up:\n", "wiki.message.iw.list.legacy": "The following Interwiki(s) are currently set up:\n",
"wiki.message.iw.list.prompt": "Here are the custom Interwiki(s) set up for bot. To view the Interwiki for the initial wiki, see: ${url}", "wiki.message.iw.list.prompt": "Here are the custom Interwiki(s) set up for bot. To view the Interwiki for the start wiki, see: ${url}",
"wiki.message.iw.none": "There is currently no Interwiki. Can be added using \"${prefix}wiki iw add\".", "wiki.message.iw.none": "There is currently no Interwiki. Can be added using \"${prefix}wiki iw add\".",
"wiki.message.iw.remove.success": "Custom Interwiki removed: ${iw}", "wiki.message.iw.remove.success": "Custom Interwiki removed: ${iw}",
"wiki.message.magic_word": "Note: The robot does not currently support magic words.", "wiki.message.magic_word": "Note: The bot does not currently support magic words.",
"wiki.message.not_found": "[${title}] not found.", "wiki.message.not_found": "[${title}] not found.",
"wiki.message.not_found.autofix": "Note: [${title}] does not exist. Did you mean: [${redirected_title}]?", "wiki.message.not_found.autofix": "Note: [${title}] does not exist. Did you mean: [${redirected_title}]?",
"wiki.message.not_found.autofix.choice": "Note: [${title}] does not exist. Did you mean: ", "wiki.message.not_found.autofix.choice": "Note: [${title}] does not exist. Did you mean: ",
"wiki.message.not_found.autofix.choice.prompt": "Please directly send the specified number to obtain the corresponding content. If you reply \"Yes\", the content of ${number} will be selected by default. Sending other content means canceling the operation.", "wiki.message.not_found.autofix.choice.prompt": "Please directly send the specified number to obtain the corresponding content. If you reply \"Yes\", the content of ${number} will be selected by default. Sending other content means canceling the operation.",
"wiki.message.not_found.autofix.confirm": "Note: [${title}] does not exist. Did you mean [${redirected_title}]?", "wiki.message.not_found.autofix.confirm": "Note: [${title}] does not exist. Did you mean [${redirected_title}]?",
"wiki.message.not_set": "Initial wiki not set.", "wiki.message.not_set": "Start wiki not set.",
"wiki.message.prefix.reset.success": "The prefix have been reset.", "wiki.message.prefix.reset.success": "The prefix have been reset.",
"wiki.message.prefix.set.success": "The prefix have been updated: ${wiki_prefix}", "wiki.message.prefix.set.success": "The prefix have been updated: ${wiki_prefix}",
"wiki.message.rc.qq.title": "最近更改", "wiki.message.rc.qq.title": "最近更改",
@ -73,20 +75,20 @@
"wiki.message.rollback": "无法发送转发消息,已自动回滚至传统样式。", "wiki.message.rollback": "无法发送转发消息,已自动回滚至传统样式。",
"wiki.message.search": "Search results: ", "wiki.message.search": "Search results: ",
"wiki.message.search.prompt": "Reply with the number to query the corresponding page.", "wiki.message.search.prompt": "Reply with the number to query the corresponding page.",
"wiki.message.set.default": "There is no initial wiki set. Defaulted to the Chinese Minecraft Wiki. Use \"${prefix}wiki set\" to set a custom initial wiki.\nExample: ${prefix}wiki set https://zh.minecraft.wiki/", "wiki.message.set.default": "There is no start wiki set. Defaulted to the Chinese Minecraft Wiki. Use \"${prefix}wiki set\" to set a custom start wiki.\nExample: ${prefix}wiki set https://zh.minecraft.wiki/",
"wiki.message.set.success": "Successfully set up initial wiki: ${name}", "wiki.message.set.success": "Successfully set up start wiki: ${name}",
"wiki.message.utils.banned": "检测到外来信息介入,请前往滥用日志查看所有消息。", "wiki.message.utils.banned": "检测到外来信息介入,请前往滥用日志查看所有消息。",
"wiki.message.utils.collapse": "…show only the first 5 items.", "wiki.message.utils.collapse": "…show only the first 5 items.",
"wiki.message.utils.qq.prompt": "Tips复制粘贴下面的任一消息到聊天窗口发送可获取此次改动详细信息的截图。", "wiki.message.utils.qq.prompt": "Tips复制粘贴下面的任一消息到聊天窗口发送可获取此次改动详细信息的截图。",
"wiki.message.utils.time.infinity": "Infinity", "wiki.message.utils.time.infinity": "Infinity",
"wiki.message.utils.wikilib.error.empty": "An error occurred: API returned no contents. Please contact the site administrator for reasons.", "wiki.message.utils.wikilib.error.empty": "An error occurred: API returned no contents. Please contact the site administrator for reasons.",
"wiki.message.utils.wikilib.error.empty_title": "An error occurred: The requested page title is empty or contains only the name of a namespace.", "wiki.message.utils.wikilib.error.empty_title": "An error occurred: The requested page title is empty or contains only the name of a namespace.",
"wiki.message.utils.wikilib.error.invalid_character": "An error occurred: The requested page title contains unsupported characters: \"[\".", "wiki.message.utils.wikilib.error.invalid_character": "An error occurred: The requested page title contains unsupported characters: \"${char}\".",
"wiki.message.utils.wikilib.get_failed.api": "An error occurred while getting information from API:", "wiki.message.utils.wikilib.get_failed.api": "An error occurred while getting information from API:",
"wiki.message.utils.wikilib.get_failed.cloudflare": "CloudFlare blocked the request from bot. Please contact site administrator to resolve this issue.", "wiki.message.utils.wikilib.get_failed.cloudflare": "CloudFlare blocked the request from bot. Please contact site administrator to resolve this issue.",
"wiki.message.utils.wikilib.get_failed.forbidden": "The server rejected the request from bot.", "wiki.message.utils.wikilib.get_failed.forbidden": "The server rejected the request from bot.",
"wiki.message.utils.wikilib.get_failed.moegirl": "The API interface of Moegirlpedia is unstable. Please try again later or visit the site directly.", "wiki.message.utils.wikilib.get_failed.moegirl": "The API interface of Moegirlpedia is unstable. Please try again later or visit the site directly.",
"wiki.message.utils.wikilib.get_failed.no_http_or_https_headers": "The link given does not specify protocol headers (the link should start with \"http://\" or \"https://\").", "wiki.message.utils.wikilib.get_failed.no_http_or_https_headers": "The link given does not specify protocol headers (The link should start with \"http://\" or \"https://\").",
"wiki.message.utils.wikilib.get_failed.not_a_mediawiki": "This site may not be a valid Mediawiki: ", "wiki.message.utils.wikilib.get_failed.not_a_mediawiki": "This site may not be a valid Mediawiki: ",
"wiki.message.utils.wikilib.get_failed.timeout": "Timeout trying to establish connection.", "wiki.message.utils.wikilib.get_failed.timeout": "Timeout trying to establish connection.",
"wiki.message.utils.wikilib.no_textextracts": "Warning: This wiki not enabled TextExtracts, and the page preview content returned will be the unprocessed raw Wikitext text.", "wiki.message.utils.wikilib.no_textextracts": "Warning: This wiki not enabled TextExtracts, and the page preview content returned will be the unprocessed raw Wikitext text.",
@ -95,7 +97,7 @@
"wiki.message.wiki_audit.list.allowlist": "Existing Whitelist:", "wiki.message.wiki_audit.list.allowlist": "Existing Whitelist:",
"wiki.message.wiki_audit.list.blocklist": "Existing Blacklist:", "wiki.message.wiki_audit.list.blocklist": "Existing Blacklist:",
"wiki.message.wiki_audit.list.table.header.apilink": "API Link", "wiki.message.wiki_audit.list.table.header.apilink": "API Link",
"wiki.message.wiki_audit.list.table.header.operator": "Operator", "wiki.message.wiki_audit.list.table.header.date": "Add date",
"wiki.message.wiki_audit.list_name.allowlist": "Whitelist", "wiki.message.wiki_audit.list_name.allowlist": "Whitelist",
"wiki.message.wiki_audit.list_name.blocklist": "Blacklist", "wiki.message.wiki_audit.list_name.blocklist": "Blacklist",
"wiki.message.wiki_audit.query.allowlist": "Already exists in whitelist.", "wiki.message.wiki_audit.query.allowlist": "Already exists in whitelist.",

View file

@ -2,7 +2,8 @@
"tos.reason.too_many_redirects": "使机器人重定向页面的次数过多。", "tos.reason.too_many_redirects": "使机器人重定向页面的次数过多。",
"tos.reason.wiki_abuse": "一次性查询的页面超过 15 个。", "tos.reason.wiki_abuse": "一次性查询的页面超过 15 个。",
"wiki.help": "查询一个 Wiki 页面。", "wiki.help": "查询一个 Wiki 页面。",
"wiki.help.ab.desc": "获取默认 Wiki 的最近滥用日志。", "wiki.help.ab": "获取默认 Wiki 的最近滥用日志。",
"wiki.help.ab.legacy": "获取默认 Wiki 的最近滥用日志。(旧版)",
"wiki.help.fandom": "切换是否使用 Fandom 全局 Interwiki 查询。", "wiki.help.fandom": "切换是否使用 Fandom 全局 Interwiki 查询。",
"wiki.help.headers.remove": "删除自定义请求标头。", "wiki.help.headers.remove": "删除自定义请求标头。",
"wiki.help.headers.reset": "重置自定义请求标头。", "wiki.help.headers.reset": "重置自定义请求标头。",
@ -18,7 +19,8 @@
"wiki.help.option.l": "查找本页面的对应语言版本,若无结果则返回当前语言。", "wiki.help.option.l": "查找本页面的对应语言版本,若无结果则返回当前语言。",
"wiki.help.prefix.reset": "重置自定义前缀。", "wiki.help.prefix.reset": "重置自定义前缀。",
"wiki.help.prefix.set": "设置自定义前缀。", "wiki.help.prefix.set": "设置自定义前缀。",
"wiki.help.rc.desc": "获取默认 Wiki 的最近更改。", "wiki.help.rc": "获取默认 Wiki 的最近更改。",
"wiki.help.rc.legacy": "获取默认 Wiki 的最近更改。(旧版)",
"wiki.help.redlink": "切换是否在页面不存在时返回编辑链接。", "wiki.help.redlink": "切换是否在页面不存在时返回编辑链接。",
"wiki.help.search": "搜索一个 Wiki 页面。", "wiki.help.search": "搜索一个 Wiki 页面。",
"wiki.help.set": "设置起始查询 Wiki。", "wiki.help.set": "设置起始查询 Wiki。",
@ -38,7 +40,7 @@
"wiki.message.fandom.disable": "已关闭 Fandom 全局 Interwiki 查询。", "wiki.message.fandom.disable": "已关闭 Fandom 全局 Interwiki 查询。",
"wiki.message.fandom.enable": "已开启 Fandom 全局 Interwiki 查询。", "wiki.message.fandom.enable": "已开启 Fandom 全局 Interwiki 查询。",
"wiki.message.flies": "此页面包括以下文件:\n", "wiki.message.flies": "此页面包括以下文件:\n",
"wiki.message.headers.show": "当前设置了以下请求标头:\n${headers}\n如需自定义请使用“${prefix}wiki headers add”。\n示例\n${prefix}wiki headers set {\"accept-language\": \"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6\"}", "wiki.message.headers.show": "当前设置了以下请求标头:\n${headers}\n如需自定义请使用“${prefix}wiki headers add”。\n示例\n${prefix}wiki headers add {\"accept-language\": \"zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6\"}",
"wiki.message.headers.reset.success": "已重置请求时所使用的请求标头。", "wiki.message.headers.reset.success": "已重置请求时所使用的请求标头。",
"wiki.message.headers.add.failed": "更新请求标头失败,请检查输入。", "wiki.message.headers.add.failed": "更新请求标头失败,请检查输入。",
"wiki.message.headers.add.success": "已更新请求时所使用的请求标头:${headers}", "wiki.message.headers.add.success": "已更新请求时所使用的请求标头:${headers}",
@ -95,7 +97,7 @@
"wiki.message.wiki_audit.list.allowlist": "现有白名单:", "wiki.message.wiki_audit.list.allowlist": "现有白名单:",
"wiki.message.wiki_audit.list.blocklist": "现有黑名单:", "wiki.message.wiki_audit.list.blocklist": "现有黑名单:",
"wiki.message.wiki_audit.list.table.header.apilink": "API 链接", "wiki.message.wiki_audit.list.table.header.apilink": "API 链接",
"wiki.message.wiki_audit.list.table.header.operator": "操作者", "wiki.message.wiki_audit.list.table.header.date": "添加日期",
"wiki.message.wiki_audit.list_name.allowlist": "白名单", "wiki.message.wiki_audit.list_name.allowlist": "白名单",
"wiki.message.wiki_audit.list_name.blocklist": "黑名单", "wiki.message.wiki_audit.list_name.blocklist": "黑名单",
"wiki.message.wiki_audit.query.allowlist": "已存在于白名单。", "wiki.message.wiki_audit.query.allowlist": "已存在于白名单。",
@ -105,6 +107,6 @@
"wiki.message.wiki_audit.remove.failed": "失败,此 Wiki 不存在于${list_name}中:", "wiki.message.wiki_audit.remove.failed": "失败,此 Wiki 不存在于${list_name}中:",
"wiki.message.wiki_audit.remove.failed.other": "失败,此 Wiki 不存在于白名单中,此 Wiki 的白名单可能来自其他同一域名的 Wiki", "wiki.message.wiki_audit.remove.failed.other": "失败,此 Wiki 不存在于白名单中,此 Wiki 的白名单可能来自其他同一域名的 Wiki",
"wiki.message.wiki_audit.remove.success": "成功从${list_name}删除:", "wiki.message.wiki_audit.remove.success": "成功从${list_name}删除:",
"wiki.message.wiki_audit.untrust": "注意:此 Wiki 当前没有加入机器人的白名单列表中,查询此 Wiki 时将会对返回内容进行限制。\n需取消限制,请在此处申请白名单:\n", "wiki.message.wiki_audit.untrust": "注意:此 Wiki 当前没有加入机器人的白名单列表中,查询此 Wiki 时将会对返回内容进行限制。\n需取消限制,请在此处申请白名单:\n",
"wiki.message.wiki_inline.flies": "此页面包括以下文件:${file}" "wiki.message.wiki_inline.flies": "此页面包括以下文件:${file}"
} }

View file

@ -2,7 +2,8 @@
"tos.reason.too_many_redirects": "使機器人重新導向頁面的次數過多。", "tos.reason.too_many_redirects": "使機器人重新導向頁面的次數過多。",
"tos.reason.wiki_abuse": "一次性查詢的頁面超過 15 個。", "tos.reason.wiki_abuse": "一次性查詢的頁面超過 15 個。",
"wiki.help": "查詢一個 Wiki 頁面。", "wiki.help": "查詢一個 Wiki 頁面。",
"wiki.help.ab.desc": "取得預設 Wiki 的近期過濾器日誌。", "wiki.help.ab": "取得預設 Wiki 的近期過濾器日誌。",
"wiki.help.ab.legacy": "取得預設 Wiki 的近期過濾器日誌。(舊版)",
"wiki.help.fandom": "切換是否使用 Fandom 全域 Interwiki 查詢。", "wiki.help.fandom": "切換是否使用 Fandom 全域 Interwiki 查詢。",
"wiki.help.headers.remove": "刪除自訂請求標頭。", "wiki.help.headers.remove": "刪除自訂請求標頭。",
"wiki.help.headers.reset": "重設自訂請求標頭。", "wiki.help.headers.reset": "重設自訂請求標頭。",
@ -18,7 +19,8 @@
"wiki.help.option.l": "查找本頁面的對應語言版本,若無結果則返回目前語言。", "wiki.help.option.l": "查找本頁面的對應語言版本,若無結果則返回目前語言。",
"wiki.help.prefix.reset": "重設自訂前綴。", "wiki.help.prefix.reset": "重設自訂前綴。",
"wiki.help.prefix.set": "設定自訂前綴。", "wiki.help.prefix.set": "設定自訂前綴。",
"wiki.help.rc.desc": "取得預設 Wiki 的近期變更。", "wiki.help.rc": "取得預設 Wiki 的近期變更。",
"wiki.help.rc.legacy": "取得預設 Wiki 的近期變更。(舊版)",
"wiki.help.redlink": "切換是否在頁面不存在時返回編輯連結。", "wiki.help.redlink": "切換是否在頁面不存在時返回編輯連結。",
"wiki.help.search": "搜尋一個 Wiki 頁面。", "wiki.help.search": "搜尋一個 Wiki 頁面。",
"wiki.help.set": "設定起始查詢 Wiki。", "wiki.help.set": "設定起始查詢 Wiki。",
@ -38,13 +40,13 @@
"wiki.message.fandom.disable": "已停用 Fandom 全域 Interwiki 查詢。", "wiki.message.fandom.disable": "已停用 Fandom 全域 Interwiki 查詢。",
"wiki.message.fandom.enable": "已啟用 Fandom 全域 Interwiki 查詢。", "wiki.message.fandom.enable": "已啟用 Fandom 全域 Interwiki 查詢。",
"wiki.message.flies": "此頁面含有以下檔案:", "wiki.message.flies": "此頁面含有以下檔案:",
"wiki.message.headers.show": "目前設定了以下請求標頭:\n${headers}\n如需自訂請使用「${prefix}wiki headers add」。 \n示例\n${prefix}wiki headers set {\"accept-language\": \"zh-TW,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6\"}", "wiki.message.headers.show": "目前設定了以下請求標頭:\n${headers}\n如需自訂請使用「${prefix}wiki headers add」。 \n示例\n${prefix}wiki headers add {\"accept-language\": \"zh-TW,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6\"}",
"wiki.message.headers.reset.success": "已重設請求時所使用的請求標頭。", "wiki.message.headers.reset.success": "已重設請求時所使用的請求標頭。",
"wiki.message.headers.add.failed": "更新请請求標頭失敗,请檢查輸入。", "wiki.message.headers.add.failed": "更新請求標頭失敗,请校對輸入。",
"wiki.message.headers.add.success": "已更新請求時所使用的請求標頭:${headers}", "wiki.message.headers.add.success": "已更新請求時所使用的請求標頭:${headers}",
"wiki.message.id.error": "發生錯誤:頁面 ID 必須為數字。", "wiki.message.id.error": "發生錯誤:頁面 ID 必須為數字。",
"wiki.message.id.not_found": "未找到頁面 ID 為 ${id} 的頁面。", "wiki.message.id.not_found": "未找到頁面 ID 為 ${id} 的頁面。",
"wiki.message.invalid_namespace": "此 Wiki 上沒有名為 ${namespace} 的命名空間,请檢查輸入。", "wiki.message.invalid_namespace": "此 Wiki 上沒有名為 ${namespace} 的命名空間,请校對輸入。",
"wiki.message.iw.add.success": "已新增自訂 Interwiki\n${iw} -> ${name}", "wiki.message.iw.add.success": "已新增自訂 Interwiki\n${iw} -> ${name}",
"wiki.message.iw.get.not_found": "未找到 Interwiki${iw}", "wiki.message.iw.get.not_found": "未找到 Interwiki${iw}",
"wiki.message.iw.list": "使用 「${prefix}wiki iw get <Interwiki>」可以取得 Interwiki 對應的連結。", "wiki.message.iw.list": "使用 「${prefix}wiki iw get <Interwiki>」可以取得 Interwiki 對應的連結。",
@ -57,7 +59,7 @@
"wiki.message.not_found.autofix": "提示:[${title}]不存在,您可能要找的是:[${redirected_title}]。", "wiki.message.not_found.autofix": "提示:[${title}]不存在,您可能要找的是:[${redirected_title}]。",
"wiki.message.not_found.autofix.choice": "提示:[${title}]不存在,您是否想要找的是:", "wiki.message.not_found.autofix.choice": "提示:[${title}]不存在,您是否想要找的是:",
"wiki.message.not_found.autofix.choice.prompt": "請直接傳送指定編號取得對應內容,若回覆「是」,則預設選擇 ${number} 號內容,传送其他內容則代表取消操作。", "wiki.message.not_found.autofix.choice.prompt": "請直接傳送指定編號取得對應內容,若回覆「是」,則預設選擇 ${number} 號內容,传送其他內容則代表取消操作。",
"wiki.message.not_found.autofix.confirm": "提示:[${title}]不存在,您是否要找的是[${redirected_title}]", "wiki.message.not_found.autofix.confirm": "提示:[${title}]不存在,您是否要找的是[${redirected_title}]",
"wiki.message.not_set": "未設定起始 Wiki。", "wiki.message.not_set": "未設定起始 Wiki。",
"wiki.message.prefix.reset.success": "已重設請求時所使用的前綴。", "wiki.message.prefix.reset.success": "已重設請求時所使用的前綴。",
"wiki.message.prefix.set.success": "成功:已更新請求時所使用的前綴:${wiki_prefix}", "wiki.message.prefix.set.success": "成功:已更新請求時所使用的前綴:${wiki_prefix}",
@ -95,7 +97,7 @@
"wiki.message.wiki_audit.list.allowlist": "現有白名單:", "wiki.message.wiki_audit.list.allowlist": "現有白名單:",
"wiki.message.wiki_audit.list.blocklist": "現有黑名單:", "wiki.message.wiki_audit.list.blocklist": "現有黑名單:",
"wiki.message.wiki_audit.list.table.header.apilink": "API 連結", "wiki.message.wiki_audit.list.table.header.apilink": "API 連結",
"wiki.message.wiki_audit.list.table.header.operator": "操作員", "wiki.message.wiki_audit.list.table.header.date": "新增日期",
"wiki.message.wiki_audit.list_name.allowlist": "白名單", "wiki.message.wiki_audit.list_name.allowlist": "白名單",
"wiki.message.wiki_audit.list_name.blocklist": "黑名單", "wiki.message.wiki_audit.list_name.blocklist": "黑名單",
"wiki.message.wiki_audit.query.allowlist": "已存在於白名單。", "wiki.message.wiki_audit.query.allowlist": "已存在於白名單。",
@ -105,6 +107,6 @@
"wiki.message.wiki_audit.remove.failed": "失敗,此 Wiki 不存在於${list_name}中:", "wiki.message.wiki_audit.remove.failed": "失敗,此 Wiki 不存在於${list_name}中:",
"wiki.message.wiki_audit.remove.failed.other": "失敗,此 Wiki 不存在於白名單中,此 Wiki 的白名單可能來自其他同一域名的 Wiki", "wiki.message.wiki_audit.remove.failed.other": "失敗,此 Wiki 不存在於白名單中,此 Wiki 的白名單可能來自其他同一域名的 Wiki",
"wiki.message.wiki_audit.remove.success": "成功從${list_name}刪除:", "wiki.message.wiki_audit.remove.success": "成功從${list_name}刪除:",
"wiki.message.wiki_audit.untrust": "注意:此 Wiki 目前沒有加入機器人的白名單列表中,查詢此 Wiki 時將會對返回內容進行限制。\n需取消限制,請在此處申請白名單:", "wiki.message.wiki_audit.untrust": "注意:此 Wiki 目前沒有加入機器人的白名單列表中,查詢此 Wiki 時將會對返回內容進行限制。\n需取消限制,請在此處申請白名單:",
"wiki.message.wiki_inline.flies": "此頁面含有以下檔案:${file}" "wiki.message.wiki_inline.flies": "此頁面含有以下檔案:${file}"
} }

View file

@ -10,16 +10,17 @@ from .newbie import newbie
from .rc import rc from .rc import rc
from .rc_qq import rc_qq from .rc_qq import rc_qq
rc_ = module('rc', desc='{wiki.help.rc.desc}', developers=['OasisAkari']) rc_ = module('rc', developers=['OasisAkari'])
@rc_.handle() @rc_.handle('{wiki.help.rc}')
@rc_.handle('legacy {wiki.help.rc.legacy}')
async def rc_loader(msg: Bot.MessageSession): async def rc_loader(msg: Bot.MessageSession):
start_wiki = WikiTargetInfo(msg).get_start_wiki() start_wiki = WikiTargetInfo(msg).get_start_wiki()
if start_wiki is None: if start_wiki is None:
return await msg.finish(msg.locale.t('wiki.message.not_set')) return await msg.finish(msg.locale.t('wiki.message.not_set'))
legacy = True legacy = True
if msg.Feature.forward and msg.target.target_from == 'QQ|Group': if msg.Feature.forward and msg.target.target_from == 'QQ|Group' and 'legacy' not in msg.parsed_msg:
try: try:
nodelist = await rc_qq(start_wiki) nodelist = await rc_qq(start_wiki)
await msg.fake_forward_msg(nodelist) await msg.fake_forward_msg(nodelist)
@ -27,22 +28,22 @@ async def rc_loader(msg: Bot.MessageSession):
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()
await msg.send_message(msg.locale.t('wiki.message.rollback')) await msg.send_message(msg.locale.t('wiki.message.rollback'))
legacy = True
if legacy: if legacy:
res = await rc(msg, start_wiki) res = await rc(msg, start_wiki)
await msg.finish(res) await msg.finish(res)
a = module('ab', desc='{wiki.help.ab.desc}', developers=['OasisAkari']) a = module('ab', developers=['OasisAkari'])
@a.handle() @a.handle('{wiki.help.ab}')
@rc_.handle('legacy {wiki.help.ab.legacy}')
async def ab_loader(msg: Bot.MessageSession): async def ab_loader(msg: Bot.MessageSession):
start_wiki = WikiTargetInfo(msg).get_start_wiki() start_wiki = WikiTargetInfo(msg).get_start_wiki()
if start_wiki is None: if start_wiki is None:
return await msg.finish(msg.locale.t('wiki.message.not_set')) return await msg.finish(msg.locale.t('wiki.message.not_set'))
legacy = True legacy = True
if msg.Feature.forward and msg.target.target_from == 'QQ|Group': if msg.Feature.forward and msg.target.target_from == 'QQ|Group' and 'legacy' not in msg.parsed_msg:
try: try:
nodelist = await ab_qq(start_wiki) nodelist = await ab_qq(start_wiki)
await msg.fake_forward_msg(nodelist) await msg.fake_forward_msg(nodelist)
@ -50,7 +51,6 @@ async def ab_loader(msg: Bot.MessageSession):
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()
await msg.send_message(msg.locale.t('wiki.message.rollback')) await msg.send_message(msg.locale.t('wiki.message.rollback'))
legacy = True
if legacy: if legacy:
res = await ab(msg, start_wiki) res = await ab(msg, start_wiki)
await msg.finish(res) await msg.finish(res)

View file

@ -157,10 +157,10 @@ class Audit:
@retry(stop=stop_after_attempt(3), reraise=True) @retry(stop=stop_after_attempt(3), reraise=True)
@auto_rollback_error @auto_rollback_error
def add_to_AllowList(self, op) -> bool: def add_to_AllowList(self, date) -> bool:
if self.inAllowList: if self.inAllowList:
return False return False
session.add_all([WikiAllowList(apiLink=self.api_link, operator=op)]) session.add_all([WikiAllowList(apiLink=self.api_link, addDate=date)])
session.commit() session.commit()
session.expire_all() session.expire_all()
return True return True
@ -179,10 +179,10 @@ class Audit:
@retry(stop=stop_after_attempt(3), reraise=True) @retry(stop=stop_after_attempt(3), reraise=True)
@auto_rollback_error @auto_rollback_error
def add_to_BlockList(self, op) -> bool: def add_to_BlockList(self, date) -> bool:
if self.inBlockList: if self.inBlockList:
return False return False
session.add_all([WikiBlockList(apiLink=self.api_link, operator=op)]) session.add_all([WikiBlockList(apiLink=self.api_link, addDate=date)])
session.commit() session.commit()
session.expire_all() session.expire_all()
return True return True
@ -201,10 +201,10 @@ class Audit:
@retry(stop=stop_after_attempt(3), reraise=True) @retry(stop=stop_after_attempt(3), reraise=True)
@auto_rollback_error @auto_rollback_error
def get_allow_list() -> list: def get_allow_list() -> list:
return session.query(WikiAllowList.apiLink, WikiAllowList.operator) return session.query(WikiAllowList.apiLink, WikiAllowList.addDate)
@staticmethod @staticmethod
@retry(stop=stop_after_attempt(3), reraise=True) @retry(stop=stop_after_attempt(3), reraise=True)
@auto_rollback_error @auto_rollback_error
def get_block_list() -> list: def get_block_list() -> list:
return session.query(WikiBlockList.apiLink, WikiBlockList.operator) return session.query(WikiBlockList.apiLink, WikiBlockList.addDate)

View file

@ -32,14 +32,14 @@ class WikiAllowList(Base):
__tablename__ = table_prefix + 'WikiAllowList' __tablename__ = table_prefix + 'WikiAllowList'
__table_args__ = {'extend_existing': True} __table_args__ = {'extend_existing': True}
apiLink = Column(String(512), primary_key=True) apiLink = Column(String(512), primary_key=True)
operator = Column(String(512)) addDate = Column(String(512))
class WikiBlockList(Base): class WikiBlockList(Base):
__tablename__ = table_prefix + 'WikiBlockList' __tablename__ = table_prefix + 'WikiBlockList'
__table_args__ = {'extend_existing': True} __table_args__ = {'extend_existing': True}
apiLink = Column(String(512), primary_key=True) apiLink = Column(String(512), primary_key=True)
operator = Column(String(512)) addDate = Column(String(512))
Session.create() Session.create()

View file

@ -2,7 +2,7 @@ import os
import re import re
import traceback import traceback
import uuid import uuid
from typing import Union from typing import Union, List
from urllib.parse import urljoin from urllib.parse import urljoin
import aiohttp import aiohttp
@ -22,8 +22,11 @@ assets_path = os.path.abspath('./assets/')
font = ImageFont.truetype(f'{assets_path}/LXGWWenKaiMono-Regular.ttf', 15) font = ImageFont.truetype(f'{assets_path}/LXGWWenKaiMono-Regular.ttf', 15)
async def generate_screenshot_v2(page_link, section=None, allow_special_page=False, content_mode=False, use_local=True): async def generate_screenshot_v2(page_link, section=None, allow_special_page=False, content_mode=False, use_local=True,
element=None):
elements_ = elements.copy() elements_ = elements.copy()
if element is not None and isinstance(element, List):
elements_ += element
if not web_render_local: if not web_render_local:
if not web_render: if not web_render:
Logger.warn('[Webrender] Webrender is not configured.') Logger.warn('[Webrender] Webrender is not configured.')

View file

@ -14,7 +14,6 @@ from modules.wiki.utils.screenshot_image import generate_screenshot_v1, generate
from modules.wiki.utils.wikilib import WikiLib, WhatAreUDoingError, PageInfo, InvalidWikiError, QueryInfo from modules.wiki.utils.wikilib import WikiLib, WhatAreUDoingError, PageInfo, InvalidWikiError, QueryInfo
generate_screenshot_v2_blocklist = ['https://mzh.moegirl.org.cn', 'https://zh.moegirl.org.cn'] generate_screenshot_v2_blocklist = ['https://mzh.moegirl.org.cn', 'https://zh.moegirl.org.cn']
special_namespace = ['special', '特殊'] special_namespace = ['special', '特殊']
random_title = ['random', '随机页面', '隨機頁面'] random_title = ['random', '随机页面', '隨機頁面']