This commit is contained in:
yasir 2023-01-28 13:18:12 +07:00
parent f2d36e75b3
commit 9585da00ed
2 changed files with 15 additions and 4 deletions

View file

@ -139,7 +139,7 @@ async def postToWeb(file, name):
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))
response = await http.put(f"https://api.github.com/repos/yasirarism/HTMLPaste/contents/{name}.html", headers=headers, data=json.dumps(data))
return f"https://yasirarism.github.io/HTMLPaste/{name}"
async def getMediaWeb(title, text):
@ -153,6 +153,9 @@ async def getMediaWeb(title, text):
f"<div>{text}</div></span>"
with open(f"{fname}.html", 'w', encoding='utf-8') as f:
f.write(hmtl_content.replace('{fileName}', f"{fname}.html").replace('{msg}', mssg))
res = await postToWeb(f"{fname}.html", fname)
os.remove(f"{fname}.html")
return res
try:
res = await postToWeb(f"{fname}.html", fname)
os.remove(f"{fname}.html")
return res
except:
return None

View file

@ -55,6 +55,12 @@ async def mediainfo(client, message):
text_ = file_info.message_type
if CUSTOM_VIEW and GH_TOKEN is not None:
link = await getMediaWeb(title, body_text)
if not link:
try:
osremove(file_path)
except:
pass
return await message.reply("Failed to post mediainfo result.")
else:
link = post_to_telegraph(title, body_text)
markup = InlineKeyboardMarkup([[InlineKeyboardButton(text=text_, url=link)]])
@ -83,6 +89,8 @@ async def mediainfo(client, message):
"""
if CUSTOM_VIEW and GH_TOKEN is not None:
link = await getMediaWeb(title, body_text)
if not link:
return await message.reply("Failed to post mediainfo result.")
else:
link = post_to_telegraph(title, body_text)
# siteurl = "https://spaceb.in/api/v1/documents/"