diff --git a/dme.py b/dme.py index 936d383..73c8356 100644 --- a/dme.py +++ b/dme.py @@ -70,38 +70,48 @@ async def dme(context): except: pass count_buffer = 0 - async for message in context.client.iter_messages(context.chat_id, from_user="me"): - if count_buffer == count: - break - if message.forward or message.via_bot or message.sticker or message.contact or message.poll or message.game or message.geo: - pass - elif message.text or message.voice: - if not message.text == dme_msg: - try: - await message.edit(dme_msg) - except: - pass - elif message.document or message.photo or message.file or message.audio or message.video or message.gif: - if target_file: - if not message.text == dme_msg: - try: - await message.edit(dme_msg, file=target_file) - except: - pass - else: + try: + async for message in context.client.iter_messages(context.chat_id, from_user="me"): + if count_buffer == count: + break + if message.forward or message.via_bot or message.sticker or message.contact or message.poll or message.game or message.geo: + pass + elif message.text or message.voice: if not message.text == dme_msg: try: await message.edit(dme_msg) except: pass - else: + elif message.document or message.photo or message.file or message.audio or message.video or message.gif: + if target_file: + if not message.text == dme_msg: + try: + await message.edit(dme_msg, file=target_file) + except: + pass + else: + if not message.text == dme_msg: + try: + await message.edit(dme_msg) + except: + pass + else: + pass + await message.delete() + count_buffer += 1 + except ValueError: + try: + await context.edit('出错了呜呜呜 ~ 无法识别的对话') + except: pass - await message.delete() - count_buffer += 1 + return count -= 1 count_buffer -= 1 await log(f"批量删除了自行发送的 {str(count_buffer)} / {str(count)} 条消息。") - notification = await send_prune_notify(context, count_buffer, count) + try: + notification = await send_prune_notify(context, count_buffer, count) + except: + return await sleep(.5) await notification.delete() diff --git a/fuckadmin.py b/fuckadmin.py index 295e87d..74d78ae 100644 --- a/fuckadmin.py +++ b/fuckadmin.py @@ -56,7 +56,7 @@ async def fuck_admin(context): if day < 7: day = 7 text += '由于输入的数据过小,时间自动设置为 7 天。\n' - except KeyError: + except (KeyError or ValueError): day = 7 text += '由于输入的数据错误,时间自动设置为 7 天。\n' else: diff --git a/list.json b/list.json index c273deb..755dbcd 100644 --- a/list.json +++ b/list.json @@ -12,7 +12,7 @@ }, { "name": "dme", - "version": "1.121", + "version": "1.122", "section": "chat", "maintainer": "xtaodada", "size": "4.3 kb", @@ -272,7 +272,7 @@ }, { "name": "neteaseshuffle", - "version": "1.11", + "version": "1.111", "section": "daily", "maintainer": "TNTcraftHIM", "size": "3.0 kb", @@ -332,7 +332,7 @@ }, { "name": "stickertopic", - "version": "1.111", + "version": "1.12", "section": "chat", "maintainer": "TNTcraftHIM", "size": "3.5 kb", @@ -552,7 +552,7 @@ }, { "name": "pic2sticker", - "version": "1.0", + "version": "1.01", "section": "chat", "maintainer": "xtaodada", "size": "4.7 kb", @@ -572,7 +572,7 @@ }, { "name": "fuckadmin", - "version": "1.1", + "version": "1.11", "section": "daily", "maintainer": "xtaodada", "size": "2.9 kb", diff --git a/neteaseshuffle.py b/neteaseshuffle.py index 5fc057e..106fb45 100644 --- a/neteaseshuffle.py +++ b/neteaseshuffle.py @@ -22,8 +22,11 @@ async def ns(context): "http://api.uomg.com/api/rand.music?sort=%E7%83%AD%E6%AD%8C%E6%A6%9C&format=json") if req.status_code == 200: req = json.loads(req.content) - songid = req["data"]["url"][45:] - music = req['data']['url'] + try: + songid = req["data"]["url"][45:] + music = req['data']['url'] + except KeyError: + continue headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, ' 'like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063', "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng," diff --git a/pic2sticker.py b/pic2sticker.py index 7a64e8b..d440082 100644 --- a/pic2sticker.py +++ b/pic2sticker.py @@ -1,7 +1,7 @@ """ PagerMaid module to handle sticker collection. """ from io import BytesIO -from telethon.tl.types import DocumentAttributeFilename, MessageMediaPhoto +from telethon.tl.types import DocumentAttributeFilename, MessageMediaPhoto, MessageMediaWebPage from PIL import Image, ImageOps from math import floor from pagermaid import bot, redis, redis_status @@ -27,6 +27,12 @@ async def pic2sticker(context): if isinstance(message.media, MessageMediaPhoto): photo = BytesIO() photo = await bot.download_media(message.photo, photo) + elif isinstance(message.media, MessageMediaWebPage): + try: + await context.edit(lang('sticker_type_not_support')) + except: + pass + return elif "image" in message.media.document.mime_type.split('/'): photo = BytesIO() try: diff --git a/stickertopic.py b/stickertopic.py index 5c35eb0..47cf4c2 100644 --- a/stickertopic.py +++ b/stickertopic.py @@ -1,7 +1,7 @@ from time import sleep from os import remove from io import BytesIO -from telethon.tl.types import DocumentAttributeFilename, MessageMediaPhoto +from telethon.tl.types import DocumentAttributeFilename, MessageMediaPhoto, MessageMediaWebPage from PIL import Image from pagermaid import bot from pagermaid.listener import listener @@ -38,6 +38,11 @@ async def stickertopic(context): if isinstance(message.media, MessageMediaPhoto): photo = BytesIO() photo = await bot.download_media(message.photo, photo) + elif isinstance(message.media, MessageMediaWebPage): + await context.edit("出错了呜呜呜 ~ 目标不是贴纸 。") + sleep(2) + await context.delete() + return elif "image" in message.media.document.mime_type.split('/'): photo = BytesIO() await context.edit("正在转换...\n████40%")