mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-25 20:38:51 +00:00
vip 修复 redis 连接不上时的报错
This commit is contained in:
parent
74d38a0ee1
commit
67ac0fe0f0
@ -342,7 +342,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "vip",
|
"name": "vip",
|
||||||
"version": "0.50",
|
"version": "0.51",
|
||||||
"section": "chat",
|
"section": "chat",
|
||||||
"maintainer": "xtaodada",
|
"maintainer": "xtaodada",
|
||||||
"size": "4.0 kb",
|
"size": "4.0 kb",
|
||||||
|
12
vip.py
12
vip.py
@ -1,5 +1,5 @@
|
|||||||
import io
|
import io
|
||||||
|
from redis.exceptions import ConnectionError
|
||||||
from requests import get
|
from requests import get
|
||||||
from os import remove
|
from os import remove
|
||||||
from telethon.tl.types import MessageMediaPhoto
|
from telethon.tl.types import MessageMediaPhoto
|
||||||
@ -93,7 +93,11 @@ async def pixiv(context):
|
|||||||
await context.edit('镜像源序号错误。')
|
await context.edit('镜像源序号错误。')
|
||||||
return
|
return
|
||||||
if 0 < num < 4:
|
if 0 < num < 4:
|
||||||
|
try:
|
||||||
redis.set("pixiv_num", num)
|
redis.set("pixiv_num", num)
|
||||||
|
except ConnectionError:
|
||||||
|
await context.edit('redis 数据库离线 无法更改镜像源。')
|
||||||
|
return
|
||||||
await context.edit('镜像源已更改。')
|
await context.edit('镜像源已更改。')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -102,12 +106,14 @@ async def pixiv(context):
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
if not redis_status:
|
if not redis_status:
|
||||||
num = 1
|
num = 3
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
num = int(redis.get("pixiv_num").decode())
|
num = int(redis.get("pixiv_num").decode())
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
num = 1
|
num = 3
|
||||||
|
except ConnectionError:
|
||||||
|
num = 3
|
||||||
try:
|
try:
|
||||||
message = await obtain_message(context)
|
message = await obtain_message(context)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
Loading…
Reference in New Issue
Block a user