mirror of
https://github.com/MuRuLOSE/limoka.git
synced 2026-06-18 15:14:18 +02:00
Commited backup
This commit is contained in:
70
AmoreForever/amoremods/telegraphup.py
Normal file
70
AmoreForever/amoremods/telegraphup.py
Normal file
@@ -0,0 +1,70 @@
|
||||
# █ █ █ █▄▀ ▄▀█ █▀▄▀█ █▀█ █▀█ █ █
|
||||
# █▀█ █ █ █ █▀█ █ ▀ █ █▄█ █▀▄ █▄█
|
||||
|
||||
# 🔒 Licensed under the GNU GPLv3
|
||||
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
|
||||
# 👤 https://t.me/hikamoru
|
||||
|
||||
# meta developer: @hikamorumods
|
||||
# meta pic: https://te.legra.ph/file/5ef64ee0466032d8a4687.png
|
||||
# meta banner: hhttps://raw.githubusercontent.com/AmoreForever/assets/master/Telegraphup.jpg
|
||||
|
||||
from .. import loader, utils
|
||||
import requests
|
||||
from telethon.tl.types import DocumentAttributeFilename
|
||||
|
||||
|
||||
@loader.tds
|
||||
class Telegraphup(loader.Module):
|
||||
"""Upload video and photo to telegraph"""
|
||||
|
||||
strings = {
|
||||
"name": "Telegraph",
|
||||
"pls_reply": "⚠️ Reply to photo or video/gif",
|
||||
}
|
||||
|
||||
@loader.sudo
|
||||
async def thupcmd(self, message):
|
||||
"""<reply photo or video>"""
|
||||
if message.is_reply:
|
||||
reply_message = await message.get_reply_message()
|
||||
data = await check_media(reply_message)
|
||||
if isinstance(data, bool):
|
||||
await message.edit(self.strings("pls_reply"))
|
||||
return
|
||||
else:
|
||||
await message.edit(self.strings("pls_reply"))
|
||||
return
|
||||
|
||||
file = await message.client.download_media(data, bytes)
|
||||
path = requests.post(
|
||||
"https://te.legra.ph/upload", files={"file": ("file", file, None)}
|
||||
).json()
|
||||
try:
|
||||
amore = "https://te.legra.ph" + path[0]["src"]
|
||||
except KeyError:
|
||||
amore = path["error"]
|
||||
await utils.answer(message, f"😸 Your file uploaded: <code>{amore}</code>")
|
||||
|
||||
|
||||
async def check_media(reply_message):
|
||||
if reply_message and reply_message.media:
|
||||
if reply_message.photo:
|
||||
data = reply_message.photo
|
||||
elif reply_message.document:
|
||||
if (
|
||||
DocumentAttributeFilename(file_name="AnimatedSticker.tgs")
|
||||
in reply_message.media.document.attributes
|
||||
):
|
||||
return False
|
||||
if reply_message.audio or reply_message.voice:
|
||||
return False
|
||||
data = reply_message.media.document
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
if not data or data is None:
|
||||
return False
|
||||
else:
|
||||
return data
|
||||
Reference in New Issue
Block a user