From 5a860c04c335b5db2d4f67189ca8737e018ba3c0 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 12 Feb 2021 16:28:20 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=F0=9F=93=9D=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20ci=E3=80=81=E6=A0=BC=E5=BC=8F=E5=8C=96=20xtao-some?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 2 +- telegram_update.py | 13 +++++-------- telegram_update_beta.py | 13 +++++-------- xtao-some.py | 43 ++++++++++++++++------------------------- 4 files changed, 28 insertions(+), 43 deletions(-) diff --git a/list.json b/list.json index 59f0a1d..ac0db39 100644 --- a/list.json +++ b/list.json @@ -62,7 +62,7 @@ }, { "name": "xtao-some", - "version": "1.13", + "version": "1.14", "section": "daily", "maintainer": "xtaodada", "size": "18.8 kb", diff --git a/telegram_update.py b/telegram_update.py index 12cc638..ad93e65 100644 --- a/telegram_update.py +++ b/telegram_update.py @@ -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) diff --git a/telegram_update_beta.py b/telegram_update_beta.py index 270e291..63dd87a 100644 --- a/telegram_update_beta.py +++ b/telegram_update_beta.py @@ -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) diff --git a/xtao-some.py b/xtao-some.py index a53d5b5..9fda6e3 100644 --- a/xtao-some.py +++ b/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('', '**').replace('', '**') + wiki_content = wiki_json['query']['search'][0]['snippet'].replace('', '**').replace( + '', '**') 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