mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 17:44:50 +00:00
Change view
This commit is contained in:
parent
5e80d07e3d
commit
5e054cd1af
4 changed files with 179 additions and 13 deletions
158
misskaty/helper/html_view.py
Normal file
158
misskaty/helper/html_view.py
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
import base64, json, os
|
||||
from .tools import get_random_string
|
||||
from .http import http
|
||||
from misskaty import GH_TOKEN
|
||||
|
||||
hmtl_content = """
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{fileName}</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap"
|
||||
rel="stylesheet" />
|
||||
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" />
|
||||
<style>
|
||||
* {
|
||||
font-family: "Ubuntu", sans-serif;
|
||||
list-style: none;
|
||||
text-decoration: none;
|
||||
outline: none !important;
|
||||
color: white;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
body {
|
||||
background-color: #0D1117;
|
||||
}
|
||||
.container {
|
||||
margin: 0vh 1vw;
|
||||
margin-bottom: 1vh;
|
||||
padding: 1vh 3vw;
|
||||
display: list-item;
|
||||
flex-direction: column;
|
||||
border: 2px solid rgba(255, 255, 255, 0.11);
|
||||
border-radius: 20px;
|
||||
background-color: #161b22;
|
||||
align-items: center;
|
||||
}
|
||||
.container.center {
|
||||
text-align: center;
|
||||
}
|
||||
.container.start {
|
||||
text-align: start;
|
||||
}
|
||||
.rfontsize {
|
||||
font-size: 1rem;
|
||||
}
|
||||
.forhover:hover {
|
||||
filter: invert(0.3);
|
||||
}
|
||||
.dlinks {
|
||||
margin-top: 2.5vh;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{msg}
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
html_template = """
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{title}</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap"
|
||||
rel="stylesheet" />
|
||||
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" />
|
||||
<style>
|
||||
* {
|
||||
font-family: "Ubuntu", sans-serif;
|
||||
list-style: none;
|
||||
text-decoration: none;
|
||||
outline: none !important;
|
||||
color: white;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
body {
|
||||
background-color: #0D1117;
|
||||
}
|
||||
.container {
|
||||
margin: 0vh 1vw;
|
||||
margin-bottom: 1vh;
|
||||
padding: 1vh 3vw;
|
||||
display: list-item;
|
||||
flex-direction: column;
|
||||
border: 2px solid rgba(255, 255, 255, 0.11);
|
||||
border-radius: 20px;
|
||||
background-color: #161b22;
|
||||
align-items: center;
|
||||
}
|
||||
.container.center {
|
||||
text-align: center;
|
||||
}
|
||||
.container.start {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.rfontsize {
|
||||
font-size: 1rem;
|
||||
}
|
||||
.withhover:hover {
|
||||
filter: invert(0.3);
|
||||
}
|
||||
.topmarginxl {
|
||||
margin-top: 2.5vh;
|
||||
display: inline-block;
|
||||
}
|
||||
.topmarginsm {
|
||||
margin-top: 1vh;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{msg}
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
async def postToWeb(file, name):
|
||||
fpath = base64.b64encode(open(file, "rb").read())
|
||||
|
||||
headers = {
|
||||
'Accept': 'application/vnd.github+json',
|
||||
'Authorization': f'Bearer {GH_TOKEN}',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
|
||||
data = {"message":"Added new HTML File","committer":{"name":"Yasir Aris M","email":"mail@yasir.eu.org"},"content": f"{fpath.decode('ascii')}"}
|
||||
|
||||
response = await http.put(f"https://api.github.com/repos/yasirarism/HTMLPaste/contents/{name}", headers=headers, data=json.dumps(data))
|
||||
return f"https://yasirarism.github.io/HTMLPaste/{name}"
|
||||
|
||||
async def getMediaWeb(title, text):
|
||||
msg = ""
|
||||
fname = get_random_string(7)
|
||||
msg += '<span class="container center rfontsize">' \
|
||||
f'<h4>MediaInfo From {title}</h4></span>'
|
||||
msg += '<span class="container center rfontsize">' \
|
||||
f'<b>MediaInfo</b></span>'
|
||||
msg += '<span class="container start rfontsize">' \
|
||||
f"<div>{text}</div></span>"
|
||||
with open(f"{fname}.html", 'w', encoding='utf-8') as f:
|
||||
f.write(msg)
|
||||
res = await postToWeb(f"{fname}.html", fname)
|
||||
os.remove(f"{fname}.html")
|
||||
return res
|
||||
|
|
@ -41,11 +41,11 @@ async def genss(client, message):
|
|||
if media is None:
|
||||
return await message.reply("Reply to a Telegram Video or document as video to generate screenshoot!")
|
||||
process = await message.reply_text("`Processing, please wait..`")
|
||||
if DL_TASK.get(message.from_user.id):
|
||||
return await process.edit("Sorry to avoid flood and error, bot only process one task at a time.")
|
||||
|
||||
if DL_TASK.get(message.from_user.id):
|
||||
return await process.edit("Sorry to avoid flood and error, bot only process one task per user at a time.")
|
||||
if not DL_TASK.get(message.from_user.id):
|
||||
DL_TASK[message.from_user.id] = 1
|
||||
DL_TASK[message.from_user.id] = True
|
||||
|
||||
c_time = time.time()
|
||||
the_real_download_location = await replied.download(
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ from pyrogram import filters
|
|||
from pyrogram.errors import FloodWait
|
||||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||
|
||||
from misskaty import app, DL_TASK
|
||||
from misskaty import app, DL_TASK, CUSTOM_VIEW, GH_TOKEN
|
||||
from misskaty.helper.html_view import getMediaWeb
|
||||
from misskaty.helper.media_helper import post_to_telegraph, runcmd
|
||||
from misskaty.helper.pyro_progress import progress_for_pyrogram
|
||||
from misskaty.vars import COMMAND_HANDLER
|
||||
|
|
@ -29,12 +30,11 @@ async def mediainfo(client, message):
|
|||
file_info = get_file_id(message.reply_to_message)
|
||||
if file_info is None:
|
||||
return await process.edit_text("Balas ke format media yang valid")
|
||||
async with DL_TASK:
|
||||
if not DL_TASK.get(message.from_user.id):
|
||||
DL_TASK[message.from_user.id] = asyncio.Lock()
|
||||
|
||||
if DL_TASK.get(message.from_user.id):
|
||||
return await process.edit("Sorry to avoid flood and error, bot only process one task at a time.")
|
||||
|
||||
if DL_TASK.get(message.from_user.id):
|
||||
return await process.edit("Sorry to avoid flood and error, bot only process one task per user at a time.")
|
||||
if not DL_TASK.get(message.from_user.id):
|
||||
DL_TASK[message.from_user.id] = 1
|
||||
|
||||
c_time = time.time()
|
||||
file_path = await message.reply_to_message.download(
|
||||
|
|
@ -53,7 +53,10 @@ async def mediainfo(client, message):
|
|||
"""
|
||||
title = "MissKaty Bot Mediainfo"
|
||||
text_ = file_info.message_type
|
||||
link = post_to_telegraph(title, body_text)
|
||||
if CUSTOM_VIEW and GH_TOKEN is not None:
|
||||
link = await getMediaWeb(title, body_text)
|
||||
else:
|
||||
link = post_to_telegraph(title, body_text)
|
||||
markup = InlineKeyboardMarkup([[InlineKeyboardButton(text=text_, url=link)]])
|
||||
try:
|
||||
await message.reply("ℹ️ <b>MEDIA INFO</b>", reply_markup=markup, quote=True)
|
||||
|
|
@ -78,12 +81,15 @@ async def mediainfo(client, message):
|
|||
<img src='https://telegra.ph/file/72c99bbc89bbe4e178cc9.jpg' />
|
||||
<pre>{output}</pre>
|
||||
"""
|
||||
tgraph = post_to_telegraph(title, body_text)
|
||||
if CUSTOM_VIEW and GH_TOKEN is not None:
|
||||
link = await getMediaWeb(title, body_text)
|
||||
else:
|
||||
link = post_to_telegraph(title, body_text)
|
||||
# siteurl = "https://spaceb.in/api/v1/documents/"
|
||||
# response = await http.post(siteurl, data={"content": output, "extension": 'txt'} )
|
||||
# response = response.json()
|
||||
# spacebin = "https://spaceb.in/"+response['payload']['id']
|
||||
markup = InlineKeyboardMarkup([[InlineKeyboardButton(text="💬 Telegraph", url=tgraph)]])
|
||||
markup = InlineKeyboardMarkup([[InlineKeyboardButton(text="💬 Telegraph", url=link)]])
|
||||
with io.BytesIO(str.encode(output)) as out_file:
|
||||
out_file.name = "MissKaty_Mediainfo.txt"
|
||||
await message.reply_document(
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ SUDO = list(
|
|||
)
|
||||
SUPPORT_CHAT = environ.get("SUPPORT_CHAT", "YasirPediaChannel")
|
||||
NIGHTMODE = environ.get("NIGHTMODE", False)
|
||||
CUSTOM_VIEW = environ.get("CUSTOM_VIEW", False)
|
||||
GH_TOKEN = environ.get("GH_TOKEN", None)
|
||||
OPENAI_API = getConfig("OPENAI_API")
|
||||
|
||||
## Config For AUtoForwarder
|
||||
|
|
|
|||
Loading…
Reference in a new issue