acgm cosm meizi 三插件多线程优化(更快乐了)

This commit is contained in:
TNTcraftHIM 2020-10-14 23:24:47 +08:00
parent ff6882ca25
commit 3783847f6b
4 changed files with 97 additions and 67 deletions

View File

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

View File

@ -12,7 +12,7 @@ async def joke(context):
status = False status = False
for _ in range (20): #最多重试20次 for _ in range (20): #最多重试20次
website = randint(0, 6) website = randint(0, 6)
filename = str(random()) + ".png" filename = "cosm" + str(random())[2:] + ".png"
try: try:
if website == 0: if website == 0:
img = get("https://api.helloworld.la/xiezhen_cosplay.php") img = get("https://api.helloworld.la/xiezhen_cosplay.php")
@ -34,23 +34,32 @@ async def joke(context):
if img.status_code != 200: if img.status_code != 200:
continue #再试一次 continue #再试一次
with open(filename, 'wb') as f: with open(filename, 'wb') as f:
await context.edit("上传中 . . .")
f.write(img.content) f.write(img.content)
await context.client.send_file( await context.edit("上传中 . . .")
context.chat_id, await context.client.send_file(context.chat_id,filename)
filename,
reply_to=None,
caption=None
)
try:
remove(filename)
except:
pass
status = True status = True
break #成功了就赶紧结束啦! break #成功了就赶紧结束啦!
except: except:
try:
remove(filename)
except:
pass
continue continue
try:
remove(filename)
except:
pass
try:
await context.delete()
except:
pass
if not status: if not status:
await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器 。") try:
sleep(2) remove(filename)
await context.delete() except:
pass
try:
await context.delete()
except:
pass
await context.client.send_message(context.chat_id,"出错了呜呜呜 ~ 试了好多好多次都无法访问到服务器 。")

View File

@ -212,17 +212,17 @@
}, },
{ {
"name": "cosplay-multi", "name": "cosplay-multi",
"version": "1.2", "version": "1.3",
"section": "daily", "section": "daily",
"maintainer": "TNTcraftHIM", "maintainer": "TNTcraftHIM",
"size": "2.2 kb", "size": "2.4 kb",
"supported": true, "supported": true,
"des-short": "多网站随机获取Cos图", "des-short": "多网站随机获取Cos图",
"des": "在不同的几个网站中随机获取Cosplay图片解决了cosplay单个API流量用尽后无法获取的问题。命令cosm。" "des": "在不同的几个网站中随机获取Cosplay图片解决了cosplay单个API流量用尽后无法获取的问题。命令cosm。"
}, },
{ {
"name": "meizi", "name": "meizi",
"version": "1.6", "version": "1.7",
"section": "daily", "section": "daily",
"maintainer": "TNTcraftHIM", "maintainer": "TNTcraftHIM",
"size": "4.0 kb", "size": "4.0 kb",
@ -232,10 +232,10 @@
}, },
{ {
"name": "acg-multi", "name": "acg-multi",
"version": "1.3", "version": "1.4",
"section": "daily", "section": "daily",
"maintainer": "TNTcraftHIM", "maintainer": "TNTcraftHIM",
"size": "2.5 kb", "size": "2.4 kb",
"supported": true, "supported": true,
"des-short": "多网站随机获取ACG图", "des-short": "多网站随机获取ACG图",
"des": "从几个不同的图库中随机获取二刺螈bushiACG图片基本都是手机尺寸的图。命令acgm。" "des": "从几个不同的图库中随机获取二刺螈bushiACG图片基本都是手机尺寸的图。命令acgm。"

View File

@ -12,7 +12,7 @@ async def mz(context):
status = False status = False
for _ in range (20): #最多重试20次 for _ in range (20): #最多重试20次
website = random.randint(0, 13) website = random.randint(0, 13)
filename = str(random.random()) + ".png" filename = "mz" + str(random.random())[2:] + ".png"
try: try:
if website == 0: if website == 0:
img = get("https://mm.52.mk/img") img = get("https://mm.52.mk/img")
@ -44,26 +44,27 @@ async def mz(context):
img = get("https://uploadbeta.com/api/pictures/random/?key=%E6%80%A7%E6%84%9F") img = get("https://uploadbeta.com/api/pictures/random/?key=%E6%80%A7%E6%84%9F")
if img.status_code == 200: if img.status_code == 200:
with open(filename, 'wb') as f: with open(filename, 'wb') as f:
await context.edit("上传中 . . .")
f.write(img.content) f.write(img.content)
await context.client.send_file( await context.edit("上传中 . . .")
context.chat_id, await context.client.send_file(context.chat_id,filename)
filename,
reply_to=None,
caption=None
)
try:
remove(filename)
except:
pass
status = True status = True
break #成功了就赶紧结束啦! break #成功了就赶紧结束啦!
except: except:
try:
remove(filename)
except:
pass
continue continue
try:
remove(filename)
except:
pass
try:
await context.delete()
except:
pass
if not status: if not status:
await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器(没有妹子看啦!) 。") await context.client.send_message(context.chat_id,"出错了呜呜呜 ~ 试了好多好多次都无法访问到服务器(没有妹子看啦!) 。")
sleep(2)
await context.delete()
@listener(is_plugin=True, outgoing=True, command="sp", @listener(is_plugin=True, outgoing=True, command="sp",
description="随机获取妹子的视频") description="随机获取妹子的视频")
@ -71,26 +72,37 @@ async def sp(context):
await context.edit("获取中 . . .") await context.edit("获取中 . . .")
status = False status = False
for _ in range (20): #最多重试20次 for _ in range (20): #最多重试20次
vid = get("https://mv.52.mk/video.php") try:
filename = str(random.random()) + ".mp4" vid = get("https://mv.52.mk/video.php")
if vid.status_code == 200: filename = "sp" + str(random.random())[2:] + ".mp4"
with open(filename, 'wb') as f: if vid.status_code == 200:
with open(filename, 'wb') as f:
f.write(vid.content)
await context.edit("上传中 . . .") await context.edit("上传中 . . .")
f.write(vid.content) await context.client.send_file(context.chat_id,filename)
await context.client.send_file( status = True
context.chat_id, break #成功了就赶紧结束啦!
filename, except:
reply_to=None,
caption=None
)
try: try:
remove(filename) remove(filename)
except: except:
pass pass
status = True continue
break #成功了就赶紧结束啦! try:
remove(filename)
except:
pass
try:
await context.delete()
except:
pass
if not status: if not status:
await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器(没有妹子视频看啦!) 。") try:
sleep(2) remove(filename)
await context.delete() except:
pass
try:
await context.delete()
except:
pass
await context.client.send_message(context.chat_id,"出错了呜呜呜 ~ 试了好多好多次都无法访问到服务器(没有妹子视频看啦!) 。")