ACGM,COSM,MEIZI插件全部更新失败重试与多线程支持!

This commit is contained in:
TNTcraftHIM 2020-09-02 15:48:41 +08:00
parent 3373703e2a
commit e129d7932c
4 changed files with 141 additions and 131 deletions

View File

@ -12,7 +12,9 @@ async def joke(context):
await context.edit("获取中 . . .")
status = False
for _ in range (20): #最多重试20次
website = random.randint(0, 5)
website = random.randint(0, 6)
filename = str(random.random()) + ".png"
try:
if website == 0:
img = requests.get("http://api.btstu.cn/sjbz/?lx=m_dongman")
elif website == 1:
@ -33,22 +35,23 @@ async def joke(context):
img = requests.get(img)
if img.status_code != 200:
continue #如果返回不正常就赶紧下一回
with open(r'tu.png', 'wb') as f:
await context.edit("正在上传图片")
with open(filename, 'wb') as f:
await context.edit("上传中 . . .")
f.write(img.content)
await context.client.send_file(
context.chat_id,
"tu.png",
filename,
reply_to=None,
caption=None
)
try:
remove('tu.png')
remove(filename)
except:
pass
status = True
break #成功了就赶紧结束啦!
except:
continue
if not status:
await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器 。")
sleep(2)

View File

@ -1,4 +1,4 @@
from random import randint
from random import randint, random
from time import sleep
from requests import get
from pagermaid.listener import listener
@ -12,6 +12,8 @@ async def joke(context):
status = False
for _ in range (20): #最多重试20次
website = randint(0, 6)
filename = str(random()) + ".png"
try:
if website == 0:
img = get("https://api.helloworld.la/xiezhen_cosplay.php")
elif website == 1:
@ -31,22 +33,23 @@ async def joke(context):
img = get(img.content)
if img.status_code != 200:
continue #再试一次
with open(r'tu.png', 'wb') as f:
await context.edit("正在上传图片")
with open(filename, 'wb') as f:
await context.edit("上传中 . . .")
f.write(img.content)
await context.client.send_file(
context.chat_id,
"tu.png",
filename,
reply_to=None,
caption=None
)
try:
remove('tu.png')
remove(filename)
except:
pass
status = True
break #成功了就赶紧结束啦!
except:
continue
if not status:
await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器 。")
sleep(2)

View File

@ -212,30 +212,30 @@
},
{
"name": "cosplay-multi",
"version": "1.1",
"section": "profile",
"version": "1.2",
"section": "daily",
"maintainer": "TNTcraftHIM",
"size": "2.0 kb",
"size": "2.2 kb",
"supported": true,
"des-short": "多网站随机获取Cos图",
"des": "在不同的几个网站中随机获取Cosplay图片解决了cosplay单个API流量用尽后无法获取的问题。命令cosm。"
},
{
"name": "meizi",
"version": "1.5",
"section": "profile",
"version": "1.6",
"section": "daily",
"maintainer": "TNTcraftHIM",
"size": "3.7 kb",
"size": "4.0 kb",
"supported": true,
"des-short": "多网站随机获取写真",
"des": "从不同的网站中调取妹子写真/视频但是无漏点放心使用安全版ghs。命令mzsp。"
},
{
"name": "acg-multi",
"version": "1.2",
"section": "profile",
"version": "1.3",
"section": "daily",
"maintainer": "TNTcraftHIM",
"size": "2.3 kb",
"size": "2.5 kb",
"supported": true,
"des-short": "多网站随机获取ACG图",
"des": "从几个不同的图库中随机获取二刺螈bushiACG图片基本都是手机尺寸的图。命令acgm。"

View File

@ -12,6 +12,8 @@ async def mz(context):
status = False
for _ in range (20): #最多重试20次
website = random.randint(0, 13)
filename = str(random.random()) + ".png"
try:
if website == 0:
img = get("https://mm.52.mk/img")
elif website == 1:
@ -41,22 +43,23 @@ async def mz(context):
elif website == 13:
img = get("https://uploadbeta.com/api/pictures/random/?key=%E6%80%A7%E6%84%9F")
if img.status_code == 200:
with open(r'tu.png', 'wb') as f:
await context.edit("正在上传图片")
with open(filename, 'wb') as f:
await context.edit("上传中 . . .")
f.write(img.content)
await context.client.send_file(
context.chat_id,
"tu.png",
filename,
reply_to=None,
caption=None
)
try:
remove('tu.png')
remove(filename)
except:
pass
status = True
break #成功了就赶紧结束啦!
except:
continue
if not status:
await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器(没有妹子看啦!) 。")
sleep(2)
@ -69,18 +72,19 @@ async def sp(context):
status = False
for _ in range (20): #最多重试20次
vid = get("https://mv.52.mk/video.php")
filename = str(random.random()) + ".mp4"
if vid.status_code == 200:
with open(r'vid.mp4', 'wb') as f:
await context.edit("正在上传视频")
with open(filename, 'wb') as f:
await context.edit("上传中 . . .")
f.write(vid.content)
await context.client.send_file(
context.chat_id,
"vid.mp4",
filename,
reply_to=None,
caption=None
)
try:
remove('vid.mp4')
remove(filename)
except:
pass
status = True