Archived
1
0
Fork 0

i18n weekly

This commit is contained in:
多羅狼 2023-04-05 12:06:12 +08:00 committed by GitHub
parent 06537e0385
commit 2eb7768b8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View file

@ -20,13 +20,12 @@ async def get_weekly(with_img=False):
text = re.sub(r'\n*$', '', text)
img = re.findall(r'(?<=src=")(.*?)(?=/revision/latest/scale-to-(width|height)-down/\d{3}\?cb=\d{14}?")', html)
page = re.findall(r'(?<=<b><a href=").*?(?=")', html)
msg_list = [Plain('发生错误:本周页面已过期,请联系中文 Minecraft Wiki 更新。' if page[
0] == '/zh/wiki/%E7%8E%BB%E7%92%83' else '本周的每周页面:\n\n' + text)]
msg_list = [Plain(msg.locale.t("weekly.message.expired") if page[
0] == '/zh/wiki/%E7%8E%BB%E7%92%83' else msg.locale.t("weekly.message", text=text))]
if img:
msg_list.append(Plain(f'图片:' + str(Url(f'{img[0][0]}?format=original')) +
f'\n\n页面链接:' + str(Url(f'https://minecraft.fandom.com{page[0]}')) +
f'\n每周页面:' + str(
Url(f'https://minecraft.fandom.com/zh/wiki/?oldid={str(result["parse"]["revid"])}'))))
msg_list.append(Plain(msg.locale.t("weekly.message.link", img=str(Url(f'{img[0][0]}?format=original')),
article=str(Url(f'https://minecraft.fandom.com{page[0]}')),
link=str(Url(f'https://minecraft.fandom.com/zh/wiki/?oldid={str(result["parse"]["revid"])}')))))
if with_img:
msg_list.append(Image(path=img[0][0]))
@ -36,13 +35,13 @@ async def get_weekly(with_img=False):
wky = module('weekly', developers=['Dianliang233'])
@wky.handle('{获取中文 Minecraft Wiki 的每周页面}')
@wky.handle('{{weekly.help}}')
async def _(msg: Bot.MessageSession):
weekly = await get_weekly(True if msg.target.clientName == 'QQ' else False)
await msg.finish(weekly)
@wky.handle('teahouse {获取茶馆周报}')
@wky.handle('teahouse {{weekly.teahouse.help}}')
async def _(msg: Bot.MessageSession):
weekly = await get_teahouse_rss()
await msg.finish(weekly)

View file

@ -0,0 +1,7 @@
{
"weekly.help": "获取中文 Minecraft Wiki 的每周页面。",
"weekly.message": "本周的每周页面:\n\n${text})",
"weekly.message.link": "\n图片${img}\n\n页面链接${article}\n每周页面${link})",
"weekly.message.expired": "发生错误:本周页面已过期,请联系中文 Minecraft Wiki 更新。",
"weekly.teahouse.help": "获取茶馆周报。"
}