forked from UsergeTeam/Userge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix rmdir + add hash , base64 , telegraph
- Loading branch information
Showing
11 changed files
with
153 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
tree | ||
wget | ||
wget2 | ||
pv | ||
jq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >. | ||
# | ||
# This file is part of < https://github.com/UsergeTeam/Userge > project, | ||
# and is released under the "GNU v3.0 License Agreement". | ||
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE > | ||
# | ||
# All rights reserved. | ||
|
||
|
||
import pybase64 | ||
|
||
from userge import userge, Message | ||
from userge.utils import runcmd | ||
|
||
|
||
@userge.on_cmd("hash", about={ | ||
'header': "find hash of text", | ||
'description': "Find the md5, sha1, sha256, sha512 of the string when written into a txt file", | ||
'usage': "{tr}hash [text or reply to msg]"}) | ||
async def gethash(message: Message): | ||
input_ = message.input_or_reply_str | ||
if not input_: | ||
await message.err("input not found!") | ||
return | ||
with open("hash.txt", "w+") as hashtxt: | ||
hashtxt.write(input_) | ||
md5 = (await runcmd("md5sum hash.txt"))[0].split()[0] | ||
sha1 = (await runcmd("sha1sum hash.txt"))[0].split()[0] | ||
sha256 = (await runcmd("sha256sum hash.txt"))[0].split()[0] | ||
sha512 = (await runcmd("sha512sum hash.txt"))[0].split()[0] | ||
await runcmd("rm hash.txt") | ||
ans = (f"**Text** : `{input_}`\n**MD5** : `{md5}`\n**SHA1** : `{sha1}`\n" | ||
f"**SHA256** : `{sha256}`\n**SHA512** : `{sha512}`") | ||
await message.edit_or_send_as_file(ans, filename="hash.txt", caption="hash.txt") | ||
|
||
|
||
@userge.on_cmd("base64", about={ | ||
'header': "Find the base64 encoding of the given string", | ||
'usage': "{tr}base64 [text or reply to msg] : encode\n" | ||
"{tr}base64 -d [text or reply to msg] : decode"}, del_pre=True) | ||
async def endecrypt(message: Message): | ||
if message.reply_to_message: | ||
input_ = message.reply_to_message.text | ||
else: | ||
input_ = message.filtered_input_str | ||
if not input_: | ||
await message.err("input not found!") | ||
return | ||
if 'd' in message.flags: | ||
out = str(pybase64.b64decode(bytes(input_, "utf-8"), validate=True))[2:-1] | ||
await message.edit(f"**Decoded** : `{out}`") | ||
else: | ||
out = str(pybase64.b64encode(bytes(input_, "utf-8")))[2:-1] | ||
await message.edit(f"**Encoded** : `{out}`") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >. | ||
# | ||
# This file is part of < https://github.com/UsergeTeam/Userge > project, | ||
# and is released under the "GNU v3.0 License Agreement". | ||
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE > | ||
# | ||
# All rights reserved. | ||
|
||
|
||
import os | ||
import time | ||
|
||
from telegraph import upload_file | ||
|
||
from userge import userge, Message, Config | ||
from userge.utils import progress | ||
|
||
_T_LIMIT = 5242880 | ||
|
||
|
||
@userge.on_cmd("telegraph", about={ | ||
'header': "Upload file to Telegra.ph's servers", | ||
'types': ['.jpg', '.jpeg', '.png', '.gif', '.mp4'], | ||
'usage': "reply {tr}telegraph to supported media : limit 5MB"}) | ||
async def telegraph_(message: Message): | ||
replied = message.reply_to_message | ||
if not replied: | ||
await message.err("reply to supported media") | ||
return | ||
if not ((replied.photo and replied.photo.file_size <= _T_LIMIT) | ||
or (replied.animation and replied.animation.file_size <= _T_LIMIT) | ||
or (replied.video and replied.video.file_name.endswith('.mp4') | ||
and replied.video.file_size <= _T_LIMIT) | ||
or (replied.document | ||
and replied.document.file_name.endswith( | ||
('.jpg', '.jpeg', '.png', '.gif', '.mp4')) | ||
and replied.document.file_size <= _T_LIMIT)): | ||
await message.err("not supported!") | ||
return | ||
await message.edit("`processing...`") | ||
c_time = time.time() | ||
dl_loc = await userge.download_media( | ||
message=message.reply_to_message, | ||
file_name=Config.DOWN_PATH, | ||
progress=progress, | ||
progress_args=( | ||
"trying to download", userge, message, c_time | ||
) | ||
) | ||
await message.edit("`uploading to telegraph...`") | ||
try: | ||
response = upload_file(dl_loc) | ||
except Exception as t_e: | ||
await message.err(t_e) | ||
else: | ||
await message.edit(f"**[Here Your Telegra.ph Link!](https://telegra.ph{response[0]})**") | ||
finally: | ||
os.remove(dl_loc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters