From d77ce5d7e798f354128dc05306659b2896f0ee8e Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 26 Jan 2022 19:48:31 +0800 Subject: [PATCH] =?UTF-8?q?xtao-some=20=E4=BF=AE=E5=A4=8D=20guess=20?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E8=8E=B7=E5=8F=96=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 2 +- xtao-some.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/list.json b/list.json index e561e61..c151c31 100644 --- a/list.json +++ b/list.json @@ -52,7 +52,7 @@ }, { "name": "xtao-some", - "version": "1.221", + "version": "1.23", "section": "daily", "maintainer": "xtaodada", "size": "12.9 kb", diff --git a/xtao-some.py b/xtao-some.py index 0c828a8..5483baf 100644 --- a/xtao-some.py +++ b/xtao-some.py @@ -3,7 +3,7 @@ import json, requests, re from urllib.parse import urlparse from pagermaid import bot, log, version from pagermaid.listener import listener, config -from pagermaid.utils import clear_emojis, obtain_message, attach_log, alias_command +from pagermaid.utils import clear_emojis, obtain_message, attach_log, alias_command, client from telethon.errors import ChatAdminRequiredError from telethon.errors.rpcerrorlist import FloodWaitError, UserAdminInvalidError from telethon.tl.types import ChannelParticipantsAdmins, ChannelParticipantsBots, ChannelParticipantAdmin @@ -14,12 +14,12 @@ from telethon.tl.types import ChannelParticipantsAdmins, ChannelParticipantsBots async def guess(context): reply = await context.get_reply_message() await context.edit("获取中 . . .") - if not reply: - context.edit("宁需要回复一句话") - return True - text = {'text': str(reply.message.replace("/guess ", "").replace(" ", ""))} - guess_json = json.loads( - requests.post("https://lab.magiconch.com/api/nbnhhsh/guess", data=text, verify=False).content.decode("utf-8")) + try: + text = await obtain_message(context) + except: + return await context.edit("请先输入一个缩写。") + text = {'text': text} + guess_json = (await client.post("https://lab.magiconch.com/api/nbnhhsh/guess", json=text)).json() guess_res = [] if not len(guess_json) == 0: for num in range(0, len(guess_json)):