Archived
1
0
Fork 0
This commit is contained in:
yzhh 2023-04-11 18:46:06 +08:00
commit 7363b95e56
9 changed files with 42 additions and 12 deletions

View file

@ -34,13 +34,14 @@ def private_ip_check(url: str):
f'Attempt of requesting private IP addresses is not allowed, requesting {hostname}.') f'Attempt of requesting private IP addresses is not allowed, requesting {hostname}.')
async def get_url(url: str, status_code: int = False, headers: dict = None, fmt=None, timeout=20, attempt=3, async def get_url(url: str, status_code: int = False, headers: dict = None, params: dict = None, fmt=None, timeout=20, attempt=3,
request_private_ip=False, logging_err_resp=True): request_private_ip=False, logging_err_resp=True):
"""利用AioHttp获取指定url的内容。 """利用AioHttp获取指定url的内容。
:param url: 需要获取的url :param url: 需要获取的url
:param status_code: 指定请求到的状态码若不符则抛出ValueError :param status_code: 指定请求到的状态码若不符则抛出ValueError
:param headers: 请求时使用的http头 :param headers: 请求时使用的http头
:param params: 请求时使用的参数
:param fmt: 指定返回的格式 :param fmt: 指定返回的格式
:param timeout: 超时时间 :param timeout: 超时时间
:param attempt: 指定请求尝试次数 :param attempt: 指定请求尝试次数
@ -60,7 +61,7 @@ async def get_url(url: str, status_code: int = False, headers: dict = None, fmt=
connector=TCPConnector(verify_ssl=False) if debug else None, ) as session: connector=TCPConnector(verify_ssl=False) if debug else None, ) as session:
try: try:
async with session.get(url, timeout=aiohttp.ClientTimeout(total=timeout), headers=headers, async with session.get(url, timeout=aiohttp.ClientTimeout(total=timeout), headers=headers,
proxy=proxy) as req: proxy=proxy, params=params) as req:
Logger.debug(f'[{req.status}] {url}') Logger.debug(f'[{req.status}] {url}')
if logging_resp: if logging_resp:
Logger.debug(await req.read()) Logger.debug(await req.read())

View file

@ -6,7 +6,6 @@
"github.user.message.not_found": "The given user cannot be found; please check your input.", "github.user.message.not_found": "The given user cannot be found; please check your input.",
"github.search.help": "Searching repositories on GitHub.", "github.search.help": "Searching repositories on GitHub.",
"github.search.message": "Successfully to search for ${result} results:", "github.search.message": "Successfully to search for ${result} results:",
"github.search.message.more_information": "Truncated due to chat limits; ${more_result} more results may not be shown.",
"github.search.message.not_found": "The given repository cannot be found; please check your input.", "github.search.message.not_found": "The given repository cannot be found; please check your input.",
"github.message.error": "An error occurred: The given repository cannot be found; please check your spelling.", "github.message.error": "An error occurred: The given repository cannot be found; please check your spelling.",
"github.search.message.more_information": "Truncated due to chat limits; ${more_result} more results may not be shown." "github.search.message.more_information": "Truncated due to chat limits; ${more_result} more results may not be shown."

View file

@ -1,7 +1,8 @@
{ {
"weekly.help": "Get the weekly page of Chinese Minecraft Wiki.", "weekly.help": "Get the weekly page of Chinese Minecraft Wiki.",
"weekly.image.help": "获取中文 Minecraft Wiki 的每周页面(图片版)。",
"weekly.message": "Weekly page:\n\n${text}", "weekly.message": "Weekly page:\n\n${text}",
"weekly.message.link": "\nImage: ${img}\n\nArticle Link: ${article}\nWeekly Pages: ${link}", "weekly.message.link": "\nImage: ${img}\n\nArticle Link: ${article}\nWeekly Pages: ${link}",
"weekly.message.expired": "An error occurred: The weekly page has expired. Please contact Chinese Minecraft Wiki to update.", "weekly.message.expired": "An error occurred: The weekly page has expired. Please contact Chinese Minecraft Wiki to update.",
"weekly.teahouse.help": "Get Teahouse Weekly." "weekly.teahouse.help": "Get Teahouse Weekly."
} }

View file

@ -1,7 +1,8 @@
{ {
"weekly.help": "取得中文 Minecraft Wiki 的每週頁面。", "weekly.help": "取得中文 Minecraft Wiki 的每週頁面。",
"weekly.image.help": "取得中文 Minecraft Wiki 的每週頁面(圖片版)。",
"weekly.message": "本週頁面:\n\n${text}", "weekly.message": "本週頁面:\n\n${text}",
"weekly.message.link": "\n圖片${img}\n\n頁面連結${article}\n每週頁面${link}", "weekly.message.link": "\n圖片${img}\n\n頁面連結${article}\n每週頁面${link}",
"weekly.message.expired": "發生錯誤:本週頁面已過期,請聯絡中文 Minecraft Wiki 更新。", "weekly.message.expired": "發生錯誤:本週頁面已過期,請聯絡中文 Minecraft Wiki 更新。",
"weekly.teahouse.help": "取得茶館週報。" "weekly.teahouse.help": "取得茶館週報。"
} }

View file

@ -1,4 +1,5 @@
{ {
"weekly_rss.help.desc": "When enabled, you will subscribe to the weekly page of Chinese Minecraft Wiki. (updated every Monday at 8:30)", "weekly_rss.help.desc": "When enabled, you will subscribe to the weekly page of Chinese Minecraft Wiki. (updated every Monday at 8:30)",
"teahouse_weekly_rss.help.desc": "When enabled, you will subscribe to the weekly page of Teahouse Weekly. (Updated every Monday at 8:30)" "teahouse_weekly_rss.help.desc": "When enabled, you will subscribe to the weekly page of Teahouse Weekly. (Updated every Monday at 8:30)",
} "weekly_rss.prompt": "如需获取每周页面的文字版本及链接,请使用 ~weekly 命令。"
}

View file

@ -1,4 +1,5 @@
{ {
"weekly_rss.help.desc": "啟用後將訂閱中文 Minecraft Wiki 的每週頁面。(每週一 8:30 更新)", "weekly_rss.help.desc": "啟用後將訂閱中文 Minecraft Wiki 的每週頁面。(每週一 8:30 更新)",
"teahouse_weekly_rss.help.desc": "啟用後將訂閱茶館週報的每週頁面。(每週一 8:30 更新)" "teahouse_weekly_rss.help.desc": "啟用後將訂閱茶館週報的每週頁面。(每週一 8:30 更新)",
} "weekly_rss.prompt": "如需获取每周页面的文字版本及链接,请使用 ~weekly 命令。"
}

View file

@ -74,4 +74,4 @@
"wiki.message.error.query": "发生错误:无法查询此 Wiki。", "wiki.message.error.query": "发生错误:无法查询此 Wiki。",
"wiki.message.error.set": "发生错误:无法设置此 Wiki。", "wiki.message.error.set": "发生错误:无法设置此 Wiki。",
"wiki.message.error.info": "详细信息:" "wiki.message.error.info": "详细信息:"
} }

View file

@ -47,5 +47,31 @@
"wiki.fandom.enable.help": "开启 Fandom 全局 Interwiki 查询。", "wiki.fandom.enable.help": "开启 Fandom 全局 Interwiki 查询。",
"wiki.fandom.disable.help": "关闭 Fandom 全局 Interwiki 查询。", "wiki.fandom.disable.help": "关闭 Fandom 全局 Interwiki 查询。",
"wiki.fandom.enable.message": "已开启 Fandom 全局 Interwiki 查询。", "wiki.fandom.enable.message": "已开启 Fandom 全局 Interwiki 查询。",
"wiki.fandom.disable.message": "已关闭 Fandom 全局 Interwiki 查询。" "wiki.fandom.disable.message": "已关闭 Fandom 全局 Interwiki 查询。",
"wiki.redlink.enable.help": "开启页面不存在时返回编辑链接。",
"wiki.redlink.disable.help": "关闭页面不存在时返回编辑链接。",
"wiki.redlink.enable.message": "已开启页面不存在时返回编辑链接。",
"wiki.redlink.disable.message": "已关闭页面不存在时返回编辑链接。",
"wiki.redlink.message.not_found": "(页面不存在)",
"wiki.redlink.message.not_found.uneditable": "[${title}] 页面不存在。",
"wiki.prefix.reset.message.success": "成功:已重置请求时所使用的前缀。",
"wiki.help": "查询一个 Wiki 页面,若查询“随机页面”则随机一个页面。",
"wiki.help.l": "查找本页面的对应语言版本,若无结果则返回当前语言。",
"wiki.id.help": "根据页面 ID 查询一个 Wiki 页面。",
"wiki.id.message.error": "发生错误:页面 ID 必须为数字。",
"wiki.id.message.not_found": "找不到页面 ID 为 ${id} 的页面。",
"wiki.message.redirect": "(重定向[${title}] -> [${redirected_title}]",
"wiki.message.redirect.autofix": "(已指定 [${title}] 更正为 [${redirected_title}]。)",
"wiki.message.redirect.template_to_page": "[${title}] 不存在,已自动重定向至 [${redirected_title}]",
"wiki.message.invalid_namespace": "此 Wiki 上没有名为 ${namespace} 的命名空间,请检查拼写后重试。",
"wiki.message.not_found": "找不到 [${title}]。",
"wiki.message.magic_word": "机器人暂不支持魔术字。",
"tos.reason.too_many_redirects": "使机器人重定向页面的次数过多。",
"tos.reason.wiki_abuse": "一次性查询的页面超过 15 个。",
"wiki.message.untrust": "注意:此 Wiki 当前没有加入机器人的白名单列表中,查询此 Wiki 时将会对返回内容进行限制。\n若需取消限制请在此处申请白名单\n",
"wiki.message.error.add": "发生错误:无法添加此 Wiki。",
"wiki.message.error.blocked": "发生错误:${name} 处于黑名单中。",
"wiki.message.error.query": "发生错误:无法查询此 Wiki。",
"wiki.message.error.set": "发生错误:无法设置此 Wiki。",
"wiki.message.error.info": "详细信息:"
} }

View file

@ -74,4 +74,4 @@
"wiki.message.error.query": "發生錯誤:無法查詢此 Wiki。", "wiki.message.error.query": "發生錯誤:無法查詢此 Wiki。",
"wiki.message.error.set": "發生錯誤:無法設定此 Wiki。", "wiki.message.error.set": "發生錯誤:無法設定此 Wiki。",
"wiki.message.error.info": "詳細資訊:" "wiki.message.error.info": "詳細資訊:"
} }