mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 07:47:39 +00:00
xtao-some 修复 wiki 无法使用的问题
This commit is contained in:
parent
268dae9fd8
commit
9b57f94dab
@ -62,13 +62,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "xtao-some",
|
"name": "xtao-some",
|
||||||
"version": "1.203",
|
"version": "1.21",
|
||||||
"section": "daily",
|
"section": "daily",
|
||||||
"maintainer": "xtaodada",
|
"maintainer": "xtaodada",
|
||||||
"size": "18.8 kb",
|
"size": "12.9 kb",
|
||||||
"supported": true,
|
"supported": true,
|
||||||
"des-short": "一大堆便民功能。",
|
"des-short": "一大堆便民功能。",
|
||||||
"des": "超多功能 例如 -ip -ipping -guess -getdel -get_bots 等。"
|
"des": "超多功能 例如 -ip -ipping -guess -getdel -get_bots -wiki 等。"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "yb-dl",
|
"name": "yb-dl",
|
||||||
|
15
xtao-some.py
15
xtao-some.py
@ -42,7 +42,6 @@ async def guess(context):
|
|||||||
description="查询维基百科词条",
|
description="查询维基百科词条",
|
||||||
parameters="<词组>")
|
parameters="<词组>")
|
||||||
async def wiki(context):
|
async def wiki(context):
|
||||||
lang = config['application_language'].replace('zh-cn', 'zh')
|
|
||||||
await context.edit("获取中 . . .")
|
await context.edit("获取中 . . .")
|
||||||
try:
|
try:
|
||||||
message = await obtain_message(context)
|
message = await obtain_message(context)
|
||||||
@ -61,18 +60,8 @@ async def wiki(context):
|
|||||||
wiki_content = wiki_json['query']['search'][0]['snippet'].replace('<span class=\"searchmatch\">', '**').replace(
|
wiki_content = wiki_json['query']['search'][0]['snippet'].replace('<span class=\"searchmatch\">', '**').replace(
|
||||||
'</span>', '**')
|
'</span>', '**')
|
||||||
wiki_time = wiki_json['query']['search'][0]['timestamp'].replace('T', ' ').replace('Z', ' ')
|
wiki_time = wiki_json['query']['search'][0]['timestamp'].replace('T', ' ').replace('Z', ' ')
|
||||||
try:
|
message = '词条: [' + wiki_title + '](https://zh.wikipedia.org/zh-cn/' + wiki_title + ')\n\n' + \
|
||||||
await context.edit("正在生成翻译中 . . .")
|
wiki_content + '...\n\n此词条最后修订于 ' + wiki_time
|
||||||
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0"
|
|
||||||
headers = {"user-agent": USER_AGENT}
|
|
||||||
wiki_content = json.loads(requests.get("https://xtaolink.cn/git/m/t.php?lang=" + lang + '&text=' +
|
|
||||||
clear_emojis(wiki_content), headers=headers)
|
|
||||||
.content.decode("utf-8"))['data']['target_text']
|
|
||||||
message = '词条: [' + wiki_title + '](https://zh.wikipedia.org/zh-cn/' + wiki_title + ')\n\n' + \
|
|
||||||
wiki_content + '...\n\n此词条最后修订于 ' + wiki_time
|
|
||||||
except ValueError:
|
|
||||||
await context.edit("出错了呜呜呜 ~ 找不到目标语言,请更正配置文件中的错误。")
|
|
||||||
return
|
|
||||||
await context.edit(message)
|
await context.edit(message)
|
||||||
else:
|
else:
|
||||||
await context.edit("没有匹配到相关词条")
|
await context.edit("没有匹配到相关词条")
|
||||||
|
Loading…
Reference in New Issue
Block a user