From a73f5eeef48756bbaaee3089996bd049aa288706 Mon Sep 17 00:00:00 2001 From: AAA <35992542+TNTcraftHIM@users.noreply.github.com> Date: Wed, 14 Oct 2020 23:26:00 +0800 Subject: [PATCH] =?UTF-8?q?acgm=20cosm=20meizi=20=E4=B8=89=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=A4=9A=E7=BA=BF=E7=A8=8B=E4=BC=98=E5=8C=96=EF=BC=88?= =?UTF-8?q?=E6=9B=B4=E5=BF=AB=E4=B9=90=E4=BA=86=EF=BC=89=20(#63)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: TNTcraftHIM --- acg-multi.py | 39 +++++++++++++++---------- cosplay-multi.py | 39 +++++++++++++++---------- list.json | 10 +++---- meizi.py | 76 ++++++++++++++++++++++++++++-------------------- 4 files changed, 97 insertions(+), 67 deletions(-) diff --git a/acg-multi.py b/acg-multi.py index 374ba80..ebc35f4 100644 --- a/acg-multi.py +++ b/acg-multi.py @@ -13,7 +13,7 @@ async def joke(context): status = False for _ in range (20): #最多重试20次 website = random.randint(0, 6) - filename = str(random.random()) + ".png" + filename = "acgm" + str(random.random())[2:] + ".png" try: if website == 0: img = requests.get("http://api.btstu.cn/sjbz/?lx=m_dongman") @@ -36,23 +36,32 @@ async def joke(context): if img.status_code != 200: continue #如果返回不正常就赶紧下一回 with open(filename, 'wb') as f: - await context.edit("上传中 . . .") f.write(img.content) - await context.client.send_file( - context.chat_id, - filename, - reply_to=None, - caption=None - ) - try: - remove(filename) - except: - pass + await context.edit("上传中 . . .") + await context.client.send_file(context.chat_id,filename) status = True break #成功了就赶紧结束啦! except: + try: + remove(filename) + except: + pass continue + try: + remove(filename) + except: + pass + try: + await context.delete() + except: + pass if not status: - await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器 。") - sleep(2) - await context.delete() + try: + remove(filename) + except: + pass + try: + await context.delete() + except: + pass + await context.client.send_message(context.chat_id,"出错了呜呜呜 ~ 试了好多好多次都无法访问到服务器 。") \ No newline at end of file diff --git a/cosplay-multi.py b/cosplay-multi.py index 7d479fd..00b14a2 100644 --- a/cosplay-multi.py +++ b/cosplay-multi.py @@ -12,7 +12,7 @@ async def joke(context): status = False for _ in range (20): #最多重试20次 website = randint(0, 6) - filename = str(random()) + ".png" + filename = "cosm" + str(random())[2:] + ".png" try: if website == 0: img = get("https://api.helloworld.la/xiezhen_cosplay.php") @@ -34,23 +34,32 @@ async def joke(context): if img.status_code != 200: continue #再试一次 with open(filename, 'wb') as f: - await context.edit("上传中 . . .") f.write(img.content) - await context.client.send_file( - context.chat_id, - filename, - reply_to=None, - caption=None - ) - try: - remove(filename) - except: - pass + await context.edit("上传中 . . .") + await context.client.send_file(context.chat_id,filename) status = True break #成功了就赶紧结束啦! except: + try: + remove(filename) + except: + pass continue + try: + remove(filename) + except: + pass + try: + await context.delete() + except: + pass if not status: - await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器 。") - sleep(2) - await context.delete() + try: + remove(filename) + except: + pass + try: + await context.delete() + except: + pass + await context.client.send_message(context.chat_id,"出错了呜呜呜 ~ 试了好多好多次都无法访问到服务器 。") diff --git a/list.json b/list.json index 61020ad..cac8659 100644 --- a/list.json +++ b/list.json @@ -212,17 +212,17 @@ }, { "name": "cosplay-multi", - "version": "1.2", + "version": "1.3", "section": "daily", "maintainer": "TNTcraftHIM", - "size": "2.2 kb", + "size": "2.4 kb", "supported": true, "des-short": "多网站随机获取Cos图", "des": "在不同的几个网站中随机获取Cosplay图片,解决了cosplay单个API流量用尽后无法获取的问题。命令:cosm。" }, { "name": "meizi", - "version": "1.6", + "version": "1.7", "section": "daily", "maintainer": "TNTcraftHIM", "size": "4.0 kb", @@ -232,10 +232,10 @@ }, { "name": "acg-multi", - "version": "1.3", + "version": "1.4", "section": "daily", "maintainer": "TNTcraftHIM", - "size": "2.5 kb", + "size": "2.4 kb", "supported": true, "des-short": "多网站随机获取ACG图", "des": "从几个不同的图库中随机获取二刺螈(bushi)ACG图片,基本都是手机尺寸的图。命令:acgm。" diff --git a/meizi.py b/meizi.py index 9e9b685..5d6a66e 100644 --- a/meizi.py +++ b/meizi.py @@ -12,7 +12,7 @@ async def mz(context): status = False for _ in range (20): #最多重试20次 website = random.randint(0, 13) - filename = str(random.random()) + ".png" + filename = "mz" + str(random.random())[2:] + ".png" try: if website == 0: 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") if img.status_code == 200: with open(filename, 'wb') as f: - await context.edit("上传中 . . .") f.write(img.content) - await context.client.send_file( - context.chat_id, - filename, - reply_to=None, - caption=None - ) - try: - remove(filename) - except: - pass + await context.edit("上传中 . . .") + await context.client.send_file(context.chat_id,filename) status = True break #成功了就赶紧结束啦! except: + try: + remove(filename) + except: + pass continue + try: + remove(filename) + except: + pass + try: + await context.delete() + except: + pass if not status: - await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器(没有妹子看啦!) 。") - sleep(2) - await context.delete() + await context.client.send_message(context.chat_id,"出错了呜呜呜 ~ 试了好多好多次都无法访问到服务器(没有妹子看啦!) 。") @listener(is_plugin=True, outgoing=True, command="sp", description="随机获取妹子的视频") @@ -71,26 +72,37 @@ async def sp(context): await context.edit("获取中 . . .") 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(filename, 'wb') as f: + try: + vid = get("https://mv.52.mk/video.php") + filename = "sp" + str(random.random())[2:] + ".mp4" + if vid.status_code == 200: + with open(filename, 'wb') as f: + f.write(vid.content) await context.edit("上传中 . . .") - f.write(vid.content) - await context.client.send_file( - context.chat_id, - filename, - reply_to=None, - caption=None - ) + await context.client.send_file(context.chat_id,filename) + status = True + break #成功了就赶紧结束啦! + except: try: remove(filename) except: pass - status = True - break #成功了就赶紧结束啦! - + continue + try: + remove(filename) + except: + pass + try: + await context.delete() + except: + pass if not status: - await context.edit("出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器(没有妹子视频看啦!) 。") - sleep(2) - await context.delete() \ No newline at end of file + try: + remove(filename) + except: + pass + try: + await context.delete() + except: + pass + await context.client.send_message(context.chat_id,"出错了呜呜呜 ~ 试了好多好多次都无法访问到服务器(没有妹子视频看啦!) 。") \ No newline at end of file