mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 05:54:12 +00:00
fix some bugs
This commit is contained in:
parent
e2e781cb85
commit
cfd94e667a
12
dme.py
12
dme.py
@ -2,7 +2,7 @@
|
||||
from asyncio import sleep
|
||||
from os import path, remove
|
||||
from os.path import exists
|
||||
from PIL import Image
|
||||
from PIL import Image, UnidentifiedImageError
|
||||
from pagermaid import redis, log, redis_status
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import alias_command
|
||||
@ -20,14 +20,18 @@ async def dme(context):
|
||||
remove('plugins/dme.jpg')
|
||||
target_file = reply.photo
|
||||
await context.client.download_media(
|
||||
await context.get_reply_message(), file = "plugins/dme.jpg"
|
||||
await context.get_reply_message(), file="plugins/dme.jpg"
|
||||
)
|
||||
await context.edit("替换图片设置完成。")
|
||||
elif reply and reply.sticker:
|
||||
if exists('plugins/dme.jpg'):
|
||||
remove('plugins/dme.jpg')
|
||||
await context.client.download_media(reply.media.document, file = "plugins/dme.webp")
|
||||
im = Image.open("plugins/dme.webp")
|
||||
await context.client.download_media(reply.media.document, file="plugins/dme.webp")
|
||||
try:
|
||||
im = Image.open("plugins/dme.webp")
|
||||
except UnidentifiedImageError:
|
||||
await context.edit("替换图片设置发生错误。")
|
||||
return
|
||||
im.save('plugins/dme.png', "png")
|
||||
remove('plugins/dme.webp')
|
||||
target_file = await context.client.upload_file('plugins/dme.png')
|
||||
|
5
eat.py
5
eat.py
@ -7,6 +7,7 @@ from requests import get
|
||||
from random import randint
|
||||
from telethon.tl.functions.users import GetFullUserRequest
|
||||
from telethon.tl.types import MessageEntityMentionName
|
||||
from telethon.errors.rpcerrorlist import ChatSendStickersForbiddenError
|
||||
from struct import error as StructError
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import alias_command
|
||||
@ -138,6 +139,8 @@ async def eat(context):
|
||||
return
|
||||
except TypeError:
|
||||
await context.edit("此用户未设置头像或头像对您不可见。")
|
||||
except ChatSendStickersForbiddenError:
|
||||
await context.edit("此群组无法发送贴纸。")
|
||||
else:
|
||||
try:
|
||||
await context.client.send_file(
|
||||
@ -155,3 +158,5 @@ async def eat(context):
|
||||
return
|
||||
except TypeError:
|
||||
await context.edit("此用户未设置头像或头像对您不可见。")
|
||||
except ChatSendStickersForbiddenError:
|
||||
await context.edit("此群组无法发送贴纸。")
|
||||
|
16
list.json
16
list.json
@ -12,7 +12,7 @@
|
||||
},
|
||||
{
|
||||
"name": "dme",
|
||||
"version": "1.11",
|
||||
"version": "1.12",
|
||||
"section": "chat",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "4.3 kb",
|
||||
@ -72,7 +72,7 @@
|
||||
},
|
||||
{
|
||||
"name": "yb-dl",
|
||||
"version": "1.01",
|
||||
"version": "1.02",
|
||||
"section": "daily",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "18.8 kb",
|
||||
@ -82,7 +82,7 @@
|
||||
},
|
||||
{
|
||||
"name": "throwit",
|
||||
"version": "1.611",
|
||||
"version": "1.612",
|
||||
"section": "profile",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "6.9 kb",
|
||||
@ -142,7 +142,7 @@
|
||||
},
|
||||
{
|
||||
"name": "nthmsg",
|
||||
"version": "1.01",
|
||||
"version": "1.02",
|
||||
"section": "chat",
|
||||
"maintainer": "seiuneko",
|
||||
"size": "0.9 kb",
|
||||
@ -192,7 +192,7 @@
|
||||
},
|
||||
{
|
||||
"name": "whois",
|
||||
"version": "1.13",
|
||||
"version": "1.131",
|
||||
"section": "daily",
|
||||
"maintainer": "KorenKrita",
|
||||
"size": "1.1 kb",
|
||||
@ -202,7 +202,7 @@
|
||||
},
|
||||
{
|
||||
"name": "eat",
|
||||
"version": "1.02",
|
||||
"version": "1.03",
|
||||
"section": "profile",
|
||||
"maintainer": "SF_PICK",
|
||||
"size": "6.4 kb",
|
||||
@ -342,7 +342,7 @@
|
||||
},
|
||||
{
|
||||
"name": "vip",
|
||||
"version": "0.3",
|
||||
"version": "0.31",
|
||||
"section": "chat",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "4.0 kb",
|
||||
@ -492,7 +492,7 @@
|
||||
},
|
||||
{
|
||||
"name": "rape",
|
||||
"version": "1.02",
|
||||
"version": "1.03",
|
||||
"section": "chat",
|
||||
"maintainer": "Pentacene",
|
||||
"size": "4.0 kb",
|
||||
|
@ -17,6 +17,10 @@ async def nthmsg(context):
|
||||
m = object()
|
||||
async for m in context.client.iter_messages(context.chat_id, from_user="me", reverse=True, limit=n):
|
||||
pass
|
||||
r = await context.client(
|
||||
functions.channels.ExportMessageLinkRequest(channel=m.to_id, id=m.id, grouped=True))
|
||||
try:
|
||||
r = await context.client(
|
||||
functions.channels.ExportMessageLinkRequest(channel=m.to_id, id=m.id, grouped=True))
|
||||
except AttributeError:
|
||||
await context.edit('获取失败。')
|
||||
return
|
||||
await context.edit(r.link)
|
||||
|
6
rape.py
6
rape.py
@ -63,7 +63,11 @@ async def rape(context):
|
||||
if context.arguments == '':
|
||||
return
|
||||
else:
|
||||
userid = int(context.arguments)
|
||||
try:
|
||||
userid = int(context.arguments)
|
||||
except ValueError:
|
||||
await context.edit('无法识别的账号 id 。')
|
||||
return
|
||||
admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins)
|
||||
if context.sender in admins:
|
||||
try:
|
||||
|
@ -7,6 +7,7 @@ from requests import get
|
||||
from random import randint
|
||||
from telethon.tl.functions.users import GetFullUserRequest
|
||||
from telethon.tl.types import MessageEntityMentionName
|
||||
from telethon.errors.rpcerrorlist import ChatSendStickersForbiddenError
|
||||
from struct import error as StructError
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import alias_command
|
||||
@ -158,6 +159,8 @@ async def throwit(context):
|
||||
return
|
||||
except TypeError:
|
||||
await context.edit("此用户未设置头像或头像对您不可见。")
|
||||
except ChatSendStickersForbiddenError:
|
||||
await context.edit("此群组无法发送贴纸。")
|
||||
else:
|
||||
try:
|
||||
await context.client.send_file(
|
||||
@ -174,3 +177,5 @@ async def throwit(context):
|
||||
return
|
||||
except TypeError:
|
||||
await context.edit("此用户未设置头像或头像对您不可见。")
|
||||
except ChatSendStickersForbiddenError:
|
||||
await context.edit("此群组无法发送贴纸。")
|
||||
|
6
vip.py
6
vip.py
@ -79,13 +79,15 @@ async def pixiv(context):
|
||||
pixiv_albums = pixiv_list[1].split('|||')
|
||||
pixiv_album = []
|
||||
await context.edit("下载图片中 . . .")
|
||||
for i in range(0, len(pixiv_albums)):
|
||||
if len(pixiv_albums) > 8:
|
||||
await context.edit('获取的图片数大于 8 ,将只发送前8张图片,下载图片中 . . .')
|
||||
for i in range(0, min(len(pixiv_albums), 8)):
|
||||
r = get(pixiv_albums[i])
|
||||
with open("pixiv." + str(i) + ".jpg", "wb") as code:
|
||||
code.write(r.content)
|
||||
pixiv_album.extend(["pixiv." + str(i) + ".jpg"])
|
||||
await context.client.send_file(context.chat_id, pixiv_album,
|
||||
caption=pixiv_list[0])
|
||||
caption=pixiv_list[0])
|
||||
await context.delete()
|
||||
for i in pixiv_album:
|
||||
try:
|
||||
|
6
whois.py
6
whois.py
@ -16,7 +16,11 @@ async def whois(context):
|
||||
return
|
||||
req = get("https://tenapi.cn/whois/?url=" + message)
|
||||
if req.status_code == 200:
|
||||
data = json.loads(req.text)['data']
|
||||
try:
|
||||
data = json.loads(req.text)['data']
|
||||
except KeyError:
|
||||
await context.edit("出错了呜呜呜 ~ 可能是域名不正确。")
|
||||
return
|
||||
res = '域名: `' + data['url'] + '`\n注册商: `' + str(data['registrar']) + '`\n联系人: `' + str(
|
||||
data['registrant']) + '`\n联系邮箱: `' + str(data['mail']) + '`\n注册时间: `' + str(
|
||||
data['registration']) + '`\n过期时间: `' + str(data['expiration']) + '`\nDNS: ' + str(data['dns']).replace(
|
||||
|
13
yb-dl.py
13
yb-dl.py
@ -3,6 +3,7 @@
|
||||
from os import remove
|
||||
from os.path import exists
|
||||
from youtube_dl import YoutubeDL
|
||||
from youtube_dl.utils import DownloadError
|
||||
from re import compile as regex_compile
|
||||
from pagermaid import bot, log
|
||||
from pagermaid.listener import listener
|
||||
@ -26,16 +27,20 @@ async def ybdl(context):
|
||||
bilibili_pattern = regex_compile(r"^(http(s)?://)?((w){3}.)?bilibili(\.com)?/.+")
|
||||
youtube_pattern = regex_compile(r"^(http(s)?://)?((w){3}.)?youtu(be|.be)?(\.com)?/.+")
|
||||
if youtube_pattern.match(url):
|
||||
if not await fetch_video(url, context.chat_id, reply_id):
|
||||
await context.edit("出错了呜呜呜 ~ 视频下载失败。")
|
||||
await log(f"已拉取UTB视频,地址: {url}.")
|
||||
await context.edit("视频获取成功!")
|
||||
try:
|
||||
if not await fetch_video(url, context.chat_id, reply_id):
|
||||
await context.edit("出错了呜呜呜 ~ 视频下载失败。")
|
||||
await log(f"已拉取UTB视频,地址: {url}.")
|
||||
await context.edit("视频获取成功!")
|
||||
except DownloadError:
|
||||
await context.edit("视频下载失败,可能是视频受到 DRM 保护。")
|
||||
if bilibili_pattern.match(url):
|
||||
if not await fetch_video(url, context.chat_id, reply_id):
|
||||
await context.edit("出错了呜呜呜 ~ 视频下载失败。")
|
||||
await log(f"已拉取 Bilibili 视频,地址: {url}.")
|
||||
await context.edit("视频获取成功!")
|
||||
|
||||
|
||||
async def fetch_video(url, chat_id, reply_id):
|
||||
""" Extracts and uploads YouTube video. """
|
||||
youtube_dl_options = {
|
||||
|
Loading…
Reference in New Issue
Block a user