From da293de502d365e2af24e490fd99af47bd6a1d8b Mon Sep 17 00:00:00 2001 From: cdle <50124752+cdle@users.noreply.github.com> Date: Sun, 30 Jan 2022 22:12:58 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20silly=5Fgirl=20=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E7=BB=B4=E6=8A=A4=20(#213)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- silly_girl.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/silly_girl.py b/silly_girl.py index 0949ce9..5b4b34f 100644 --- a/silly_girl.py +++ b/silly_girl.py @@ -1,5 +1,3 @@ -import asyncio - from pagermaid.listener import listener from pagermaid import persistent_vars, bot from pagermaid.utils import client, alias_command @@ -25,7 +23,6 @@ persistent_vars.update( } ) - @listener(is_plugin=True, outgoing=True, command=alias_command("sillyGirl"), ignore_edited=True, parameters="") async def sillyGirl(context): fd = os.open("sillyGirl.egg", os.O_RDWR | os.O_CREAT) @@ -92,24 +89,30 @@ async def poll(data): init = "?init=true" req_data = await client.post(persistent_vars["sillyGirl"]['url']+"/pgm"+init, json=data) except Exception as e: - await persistent_vars["sillyGirl"]['context'].edit('出错了呜呜呜 ~ 无法访问 傻妞 ') - await asyncio.sleep(1) return if not req_data.status_code == 200: - await persistent_vars["sillyGirl"]['context'].edit('出错了呜呜呜 ~ 无法访问 傻妞 ') - await asyncio.sleep(1) return try: replies = json.loads(req_data.text) results = [] + print(replies) for reply in replies: if reply["whiltelist"] != "": persistent_vars["sillyGirl"]['whiltelist'] = reply["whiltelist"] await persistent_vars["sillyGirl"]['context'].edit("获取白名单中...") continue if reply["delete"]: + await bot.edit_message(reply["chat_id"], reply["id"], "打错字了,呱呱~") await bot.delete_messages(reply["chat_id"], [reply["id"]]) continue + if reply["id"] != 0: + try: + await bot.edit_message(reply["chat_id"], reply["id"], reply["text"]) + continue + except Exception as e: + print(e) + continue + text = reply["text"] images = reply["images"] chat_id = reply["chat_id"] @@ -134,10 +137,6 @@ async def poll(data): if persistent_vars["sillyGirl"]['init'] == False: persistent_vars["sillyGirl"]['init'] = True await persistent_vars["sillyGirl"]['context'].edit("傻妞连接成功,愉快玩耍吧。") + await persistent_vars["sillyGirl"]['context'].delete() except Exception as e: - try: - await persistent_vars["sillyGirl"]['context'].edit('出错了呜呜呜 ~ 无法访问 傻妞 ') - except: - return - await asyncio.sleep(1) return