silly_girl 避免请求频繁,提高稳定性 (#17)

Co-authored-by: omg-xtao <100690902+omg-xtao@users.noreply.github.com>
This commit is contained in:
cdle 2022-08-30 15:38:55 +08:00 committed by GitHub
parent ceb184bddc
commit 4e5c3d0bd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -852,7 +852,7 @@
},
{
"name": "silly_girl",
"version": "1.04",
"version": "1.041",
"section": "chat",
"maintainer": "cdle",
"size": "3 kb",

View File

@ -1,3 +1,4 @@
from asyncio import sleep
from pagermaid.listener import listener
from pagermaid import persistent_vars, bot
from pagermaid.utils import client, alias_command
@ -88,8 +89,10 @@ async def poll(data):
init = "&init=true"
req_data = await client.post(persistent_vars["sillyGirl"]['url']+"/pgm?token="+persistent_vars["sillyGirl"]['token']+init, json=data)
except Exception as e:
await sleep(1)
return
if not req_data.status_code == 200:
await sleep(1)
return
try:
replies = json.loads(req_data.text)
@ -137,5 +140,5 @@ async def poll(data):
await persistent_vars["sillyGirl"]['context'].edit("傻妞连接成功,愉快玩耍吧。")
await persistent_vars["sillyGirl"]['context'].delete()
except Exception as e:
await sleep(1)
return