Skip to content

Commit

Permalink
some formating fixes and add gshare command
Browse files Browse the repository at this point in the history
  • Loading branch information
rking32 committed Jun 29, 2020
1 parent f79622b commit 4a7c5e3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion userge/core/methods/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async def forward_stored(self,
Time in Seconds for delete that message.
Returns:
message_id on success or None
None
"""
message_ = await self._client.get_messages(chat_id=Config.LOG_CHANNEL_ID,
message_ids=message_id)
Expand Down
24 changes: 23 additions & 1 deletion userge/plugins/misc/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def _refresh_creds() -> None:


def creds_dec(func):
""" decorator for check _CREDS """
""" decorator for check CREDS """
@wraps(func)
async def wrapper(self):
if _CREDS:
Expand Down Expand Up @@ -656,6 +656,20 @@ async def reset_parent(self) -> None:
_PARENT_ID = ""
await self._message.edit("`Parents Reset successfully`", del_in=5)

@creds_dec
async def share(self) -> None:
""" get shareable link """
await self._message.edit("`Loading GDrive Share...`")
file_id, _ = self._get_file_id()
try:
out = await pool.run_in_thread(self._get_output)(file_id)
except HttpError as h_e:
_LOG.exception(h_e)
await self._message.err(h_e._get_reason())
return
await self._message.edit(f"**Shareable Links**\n\n{out}",
disable_web_page_preview=True, log=__name__)

@creds_dec
async def search(self) -> None:
""" Search files in GDrive """
Expand Down Expand Up @@ -1061,6 +1075,14 @@ async def gmake_(message: Message):
await Worker(message).make_folder()


@userge.on_cmd("gshare", about={
'header': "Get Shareable Links for GDrive files",
'usage': "{tr}gshare [file_id | file/folder link]"})
async def gshare_(message: Message):
""" share files """
await Worker(message).share()


@userge.on_cmd("gup", about={
'header': "Upload files to GDrive",
'description': "set destination by setting parent_id, "
Expand Down
2 changes: 1 addition & 1 deletion userge/plugins/utils/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ async def raw_ls(message: Message, name, collection):
if 'mid' not in c_l:
continue
liststr += f"**{(await userge.get_chat(c_l['_id'])).title}**\n"
liststr += f"**Active:** `{c_l['on']}` , **[Preview]({CHANNEL.get_link(c_l['mid'])})**\n\n"
liststr += f"**Active:** `{c_l['on']}` , {CHANNEL.get_link(c_l['mid'])}\n\n"
await message.edit(
text=liststr or f'`NO {name.upper()}S STARTED`', del_in=0)

Expand Down

0 comments on commit 4a7c5e3

Please sign in to comment.