mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 00:35:36 +00:00
👷📝 修复 ci、格式化 xtao-some
This commit is contained in:
parent
1a5b40451a
commit
5a860c04c3
@ -62,7 +62,7 @@
|
||||
},
|
||||
{
|
||||
"name": "xtao-some",
|
||||
"version": "1.13",
|
||||
"version": "1.14",
|
||||
"section": "daily",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "18.8 kb",
|
||||
|
@ -3,14 +3,11 @@ from requests import get, post
|
||||
|
||||
token = str(sys.argv[1])
|
||||
main = json.loads(get("https://api.github.com/repos/xtaodada/PagerMaid_Plugins/commits/master").content)
|
||||
push_content = {}
|
||||
push_content['chat_id'] = '-1001441461877'
|
||||
push_content['disable_web_page_preview'] = 'True'
|
||||
push_content['parse_mode'] = 'markdown'
|
||||
push_content['text'] = "#更新日志 #" + main['commit']['author'][
|
||||
'name'].replace('_', '') + ' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/xtaodada/PagerMaid_Plugins/compare/' + \
|
||||
main[
|
||||
'sha'] + '): ' + main['commit']['message']
|
||||
text = "#更新日志 #" + main['commit']['author']['name'].replace('_', '') + \
|
||||
' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/Xtao-Labs/PagerMaid_Plugins/commit/' + \
|
||||
main['sha'] + '): ' + main['commit']['message']
|
||||
push_content = {'chat_id': '-1001441461877', 'disable_web_page_preview': 'True', 'parse_mode': 'markdown',
|
||||
'text': text}
|
||||
url = 'https://api.telegram.org/bot' + token + '/sendMessage'
|
||||
try:
|
||||
main_req = post(url, data=push_content)
|
||||
|
@ -3,14 +3,11 @@ from requests import get, post
|
||||
|
||||
token = str(sys.argv[1])
|
||||
main = json.loads(get("https://api.github.com/repos/xtaodada/PagerMaid_Plugins/commits/beta").content)
|
||||
push_content = {}
|
||||
push_content['chat_id'] = '-1001441461877'
|
||||
push_content['disable_web_page_preview'] = 'True'
|
||||
push_content['parse_mode'] = 'markdown'
|
||||
push_content['text'] = "#更新日志 #beta #" + main['commit']['author'][
|
||||
'name'].replace('_', '') + ' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/xtaodada/PagerMaid_Plugins/compare/' + \
|
||||
main[
|
||||
'sha'] + '): ' + main['commit']['message']
|
||||
text = "#更新日志 #beta #" + main['commit']['author']['name'].replace('_', '') + \
|
||||
' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/Xtao-Labs/PagerMaid_Plugins/commit/' + \
|
||||
main['sha'] + '): ' + main['commit']['message']
|
||||
push_content = {'chat_id': '-1001441461877', 'disable_web_page_preview': 'True', 'parse_mode': 'markdown',
|
||||
'text': text}
|
||||
url = 'https://api.telegram.org/bot' + token + '/sendMessage'
|
||||
try:
|
||||
main_req = post(url, data=push_content)
|
||||
|
43
xtao-some.py
43
xtao-some.py
@ -38,23 +38,6 @@ async def guess(context):
|
||||
await context.edit("没有匹配到拼音首字母缩写")
|
||||
|
||||
|
||||
@listener(is_plugin=True, outgoing=True, command="admin",
|
||||
description="一键 AT 本群管理员(仅在群组中有效)")
|
||||
async def admin(context):
|
||||
await context.edit('正在获取管理员列表中...')
|
||||
chat = await context.get_chat()
|
||||
try:
|
||||
admins = await context.client.get_participants(chat, filter=ChannelParticipantsAdmins)
|
||||
except:
|
||||
await context.edit('请在群组中使用。')
|
||||
return True
|
||||
admin_list = []
|
||||
for admin in admins:
|
||||
if admin.first_name is not None:
|
||||
admin_list.extend(['[' + admin.first_name + '](tg://user?id=' + str(admin.id) + ')'])
|
||||
await context.edit(' , '.join(admin_list))
|
||||
|
||||
|
||||
@listener(is_plugin=True, outgoing=True, command="wiki",
|
||||
description="查询维基百科词条",
|
||||
parameters="<词组>")
|
||||
@ -67,21 +50,26 @@ async def wiki(context):
|
||||
await context.edit("出错了呜呜呜 ~ 无效的参数。")
|
||||
return
|
||||
try:
|
||||
wiki_json = json.loads(requests.get("https://zh.wikipedia.org/w/api.php?action=query&list=search&format=json&formatversion=2&srsearch=" + message).content.decode(
|
||||
"utf-8"))
|
||||
wiki_json = json.loads(requests.get("https://zh.wikipedia.org/w/api.php?action=query&list=search&format=json"
|
||||
"&formatversion=2&srsearch=" + message).content.decode(
|
||||
"utf-8"))
|
||||
except:
|
||||
await context.edit("出错了呜呜呜 ~ 无法访问到维基百科。")
|
||||
return
|
||||
if not len(wiki_json['query']['search']) == 0:
|
||||
wiki_title = wiki_json['query']['search'][0]['title']
|
||||
wiki_content = wiki_json['query']['search'][0]['snippet'].replace('<span class=\"searchmatch\">', '**').replace('</span>', '**')
|
||||
wiki_content = wiki_json['query']['search'][0]['snippet'].replace('<span class=\"searchmatch\">', '**').replace(
|
||||
'</span>', '**')
|
||||
wiki_time = wiki_json['query']['search'][0]['timestamp'].replace('T', ' ').replace('Z', ' ')
|
||||
try:
|
||||
await context.edit("正在生成翻译中 . . .")
|
||||
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
|
||||
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
|
||||
@ -106,7 +94,8 @@ async def ipinfo(context):
|
||||
else:
|
||||
url = url.path
|
||||
ipinfo_json = json.loads(requests.get(
|
||||
"http://ip-api.com/json/" + url + "?fields=status,message,country,regionName,city,lat,lon,isp,org,as,mobile,proxy,hosting,query").content.decode(
|
||||
"http://ip-api.com/json/" + url + "?fields=status,message,country,regionName,city,lat,lon,isp,"
|
||||
"org,as,mobile,proxy,hosting,query").content.decode(
|
||||
"utf-8"))
|
||||
if ipinfo_json['status'] == 'fail':
|
||||
pass
|
||||
@ -143,7 +132,8 @@ async def ipinfo(context):
|
||||
else:
|
||||
url = url.path
|
||||
ipinfo_json = json.loads(requests.get(
|
||||
"http://ip-api.com/json/" + url + "?fields=status,message,country,regionName,city,lat,lon,isp,org,as,mobile,proxy,hosting,query").content.decode(
|
||||
"http://ip-api.com/json/" + url + "?fields=status,message,country,regionName,city,lat,lon,isp,org,as,"
|
||||
"mobile,proxy,hosting,query").content.decode(
|
||||
"utf-8"))
|
||||
if ipinfo_json['status'] == 'fail':
|
||||
pass
|
||||
@ -247,8 +237,9 @@ async def tx_t(context):
|
||||
try:
|
||||
await context.edit("正在生成翻译中 . . .")
|
||||
tx_json = json.loads(requests.get(
|
||||
"https://xtaolink.cn/git/m/t.php?lang=" + lang + '&text=' + clear_emojis(message), headers=headers).content.decode(
|
||||
"utf-8"))
|
||||
"https://xtaolink.cn/git/m/t.php?lang=" + lang + '&text=' + clear_emojis(message),
|
||||
headers=headers).content.decode(
|
||||
"utf-8"))
|
||||
if not tx_json['msg'] == 'ok':
|
||||
context.edit("出错了呜呜呜 ~ 翻译出错")
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user