Skip to content

Commit

Permalink
enhacements to upload.py module
Browse files Browse the repository at this point in the history
    *force upload as a document
    *New flag -d

Signed-off-by: Udith <[email protected]>
  • Loading branch information
uaudith committed Apr 17, 2020
1 parent eb924b1 commit c8b9bc9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
22 changes: 13 additions & 9 deletions userge/plugins/misc/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
**Usage:**
`.upload [file or folder path]`""")
`.upload [file or folder path] -<Flags>`
Available flags ::
-d upload as document""",
del_pre=True)
async def uploadtotg(message: Message):
path_ = message.input_str
flags = message.flags
path_ = message.filtered_input_str
if not path_:
await message.edit("invalid input!, check `.help .upload`", del_in=5)
return
Expand All @@ -44,24 +48,24 @@ async def uploadtotg(message: Message):

else:
await message.delete()
await explorer(string, message.chat.id)
await explorer(string, message.chat.id, flags)


async def explorer(path: Path, chatid):
async def explorer(path: Path, chatid, flags):
if path.is_file():
try:
await upload(path, chatid)
await upload(path, chatid, flags)

except FloodWait as x:
time.sleep(x.x) # asyncio sleep ?

elif path.is_dir():
for i in path.iterdir():
await explorer(i, chatid)
await explorer(i, chatid, flags)


async def upload(path: Path, chat_id: int):
if path.name.endswith((".mkv", ".mp4", ".webm")):
async def upload(path: Path, chat_id: int, flags):
if path.name.endswith((".mkv", ".mp4", ".webm")) and ('d' not in flags):
await vid_upload(chat_id, path)

else:
Expand Down Expand Up @@ -155,6 +159,6 @@ async def get_thumb(path: str = '') -> str:

async def remove_thumb(thumb: str) -> None:
if os.path.exists(thumb) and \
thumb != LOGO_PATH and \
thumb != LOGO_PATH and \
thumb != THUMB_PATH:
os.remove(thumb)
1 change: 1 addition & 0 deletions userge/plugins/utils/pmpermit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
else:
noPmMessage = "Hello {fname} this is an automated message\nPlease wait untill you get approved to direct message " \
"And please dont spam untill then "
del _pm, _pmMsg


@userge.on_cmd("allow", about="""\
Expand Down
2 changes: 1 addition & 1 deletion userge/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
__version_mjaor__ = 0
__version_minor__ = 1
__version_micro__ = 2
__version_beta__ = 1
__version_beta__ = 2


__version__ = "{}.{}.{}".format(__version_mjaor__,
Expand Down

0 comments on commit c8b9bc9

Please sign in to comment.