This commit is contained in:
Xtao_dada 2021-08-21 19:35:00 +08:00 committed by GitHub
parent 107fc1ffc2
commit 5611cb79e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 33 deletions

10
dme.py
View File

@ -70,6 +70,7 @@ async def dme(context):
except: except:
pass pass
count_buffer = 0 count_buffer = 0
try:
async for message in context.client.iter_messages(context.chat_id, from_user="me"): async for message in context.client.iter_messages(context.chat_id, from_user="me"):
if count_buffer == count: if count_buffer == count:
break break
@ -98,10 +99,19 @@ async def dme(context):
pass pass
await message.delete() await message.delete()
count_buffer += 1 count_buffer += 1
except ValueError:
try:
await context.edit('出错了呜呜呜 ~ 无法识别的对话')
except:
pass
return
count -= 1 count -= 1
count_buffer -= 1 count_buffer -= 1
await log(f"批量删除了自行发送的 {str(count_buffer)} / {str(count)} 条消息。") await log(f"批量删除了自行发送的 {str(count_buffer)} / {str(count)} 条消息。")
try:
notification = await send_prune_notify(context, count_buffer, count) notification = await send_prune_notify(context, count_buffer, count)
except:
return
await sleep(.5) await sleep(.5)
await notification.delete() await notification.delete()

View File

@ -56,7 +56,7 @@ async def fuck_admin(context):
if day < 7: if day < 7:
day = 7 day = 7
text += '由于输入的数据过小,时间自动设置为 7 天。\n' text += '由于输入的数据过小,时间自动设置为 7 天。\n'
except KeyError: except (KeyError or ValueError):
day = 7 day = 7
text += '由于输入的数据错误,时间自动设置为 7 天。\n' text += '由于输入的数据错误,时间自动设置为 7 天。\n'
else: else:

View File

@ -12,7 +12,7 @@
}, },
{ {
"name": "dme", "name": "dme",
"version": "1.121", "version": "1.122",
"section": "chat", "section": "chat",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "4.3 kb", "size": "4.3 kb",
@ -272,7 +272,7 @@
}, },
{ {
"name": "neteaseshuffle", "name": "neteaseshuffle",
"version": "1.11", "version": "1.111",
"section": "daily", "section": "daily",
"maintainer": "TNTcraftHIM", "maintainer": "TNTcraftHIM",
"size": "3.0 kb", "size": "3.0 kb",
@ -332,7 +332,7 @@
}, },
{ {
"name": "stickertopic", "name": "stickertopic",
"version": "1.111", "version": "1.12",
"section": "chat", "section": "chat",
"maintainer": "TNTcraftHIM", "maintainer": "TNTcraftHIM",
"size": "3.5 kb", "size": "3.5 kb",
@ -552,7 +552,7 @@
}, },
{ {
"name": "pic2sticker", "name": "pic2sticker",
"version": "1.0", "version": "1.01",
"section": "chat", "section": "chat",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "4.7 kb", "size": "4.7 kb",
@ -572,7 +572,7 @@
}, },
{ {
"name": "fuckadmin", "name": "fuckadmin",
"version": "1.1", "version": "1.11",
"section": "daily", "section": "daily",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "2.9 kb", "size": "2.9 kb",

View File

@ -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") "http://api.uomg.com/api/rand.music?sort=%E7%83%AD%E6%AD%8C%E6%A6%9C&format=json")
if req.status_code == 200: if req.status_code == 200:
req = json.loads(req.content) req = json.loads(req.content)
try:
songid = req["data"]["url"][45:] songid = req["data"]["url"][45:]
music = req['data']['url'] music = req['data']['url']
except KeyError:
continue
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, ' 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', '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," "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,"

View File

@ -1,7 +1,7 @@
""" PagerMaid module to handle sticker collection. """ """ PagerMaid module to handle sticker collection. """
from io import BytesIO 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 PIL import Image, ImageOps
from math import floor from math import floor
from pagermaid import bot, redis, redis_status from pagermaid import bot, redis, redis_status
@ -27,6 +27,12 @@ async def pic2sticker(context):
if isinstance(message.media, MessageMediaPhoto): if isinstance(message.media, MessageMediaPhoto):
photo = BytesIO() photo = BytesIO()
photo = await bot.download_media(message.photo, photo) 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('/'): elif "image" in message.media.document.mime_type.split('/'):
photo = BytesIO() photo = BytesIO()
try: try:

View File

@ -1,7 +1,7 @@
from time import sleep from time import sleep
from os import remove from os import remove
from io import BytesIO from io import BytesIO
from telethon.tl.types import DocumentAttributeFilename, MessageMediaPhoto from telethon.tl.types import DocumentAttributeFilename, MessageMediaPhoto, MessageMediaWebPage
from PIL import Image from PIL import Image
from pagermaid import bot from pagermaid import bot
from pagermaid.listener import listener from pagermaid.listener import listener
@ -38,6 +38,11 @@ async def stickertopic(context):
if isinstance(message.media, MessageMediaPhoto): if isinstance(message.media, MessageMediaPhoto):
photo = BytesIO() photo = BytesIO()
photo = await bot.download_media(message.photo, photo) 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('/'): elif "image" in message.media.document.mime_type.split('/'):
photo = BytesIO() photo = BytesIO()
await context.edit("正在转换...\n████40%") await context.edit("正在转换...\n████40%")