Skip to content

Commit

Permalink
gdrive and alive small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rking32 committed Apr 16, 2020
1 parent bdf2dfd commit eb924b1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
12 changes: 7 additions & 5 deletions userge/plugins/fun/alive.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@


from pyrogram.errors.exceptions import FileIdInvalid, FileReferenceEmpty
from pyrogram.errors.exceptions.bad_request_400 import BadRequest
from userge import userge, Message, Config, versions

LOGO_STICKER_ID, LOGO_STICKER_REF = None, None


class FileIdNotFound(FileIdInvalid, FileReferenceEmpty, BadRequest):
pass


@userge.on_cmd("alive", about="__This command is just for fun XD__")
async def alive(message: Message):
await message.delete()

try:
if LOGO_STICKER_ID:
await sendit(LOGO_STICKER_ID, message)
Expand All @@ -24,11 +30,7 @@ async def alive(message: Message):
await refresh_id()
await sendit(LOGO_STICKER_ID, message)

except FileIdInvalid:
await refresh_id()
await sendit(LOGO_STICKER_ID, message)

except FileReferenceEmpty:
except FileIdNotFound:
await refresh_id()
await sendit(LOGO_STICKER_ID, message)

Expand Down
25 changes: 18 additions & 7 deletions userge/plugins/misc/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
AUTH_FLOW: object = None
PARENT_ID = ""

OAUTH_SCOPE = "https://www.googleapis.com/auth/drive"
OAUTH_SCOPE = ["https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive.metadata"]
REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob"
G_DRIVE_DIR_MIME_TYPE = "application/vnd.google-apps.folder"
G_DRIVE_FILE_LINK = "📄 <a href='https://drive.google.com/open?id={}'>{}</a> __({})__"
Expand Down Expand Up @@ -361,7 +363,7 @@ def _upload(self, file_name: str) -> None:

except HttpError as h_e:
LOG.exception(h_e)
self.__output = h_e._get_reason()
self.__output = h_e

except ProcessCanceled:
self.__output = "`Process Canceled!`"
Expand Down Expand Up @@ -490,7 +492,7 @@ def _download(self, file_id: str) -> None:

except HttpError as h_e:
LOG.exception(h_e)
self.__output = h_e._get_reason()
self.__output = h_e

except ProcessCanceled:
self.__output = "`Process Canceled!`"
Expand Down Expand Up @@ -581,7 +583,7 @@ def _copy(self, file_id: str) -> None:

except HttpError as h_e:
LOG.exception(h_e)
self.__output = h_e._get_reason()
self.__output = h_e

except ProcessCanceled:
self.__output = "`Process Canceled!`"
Expand Down Expand Up @@ -911,7 +913,10 @@ async def upload(self) -> None:
end_t = datetime.now()
m_s = (end_t - start_t).seconds

if self._output is not None and not self._is_canceled:
if isinstance(self._output, HttpError):
out = f"**ERROR** : `{self._output._get_reason()}`"

elif self._output is not None and not self._is_canceled:
out = f"**Uploaded Successfully** __in {m_s} seconds__\n\n{self._output}"

elif self._output is not None and self._is_canceled:
Expand Down Expand Up @@ -950,7 +955,10 @@ async def download(self) -> None:
end_t = datetime.now()
m_s = (end_t - start_t).seconds

if self._output is not None and not self._is_canceled:
if isinstance(self._output, HttpError):
out = f"**ERROR** : `{self._output._get_reason()}`"

elif self._output is not None and not self._is_canceled:
out = f"**Downloaded Successfully** __in {m_s} seconds__\n\n`{self._output}`"

elif self._output is not None and self._is_canceled:
Expand Down Expand Up @@ -993,7 +1001,10 @@ async def copy(self) -> None:
end_t = datetime.now()
m_s = (end_t - start_t).seconds

if self._output is not None and not self._is_canceled:
if isinstance(self._output, HttpError):
out = f"**ERROR** : `{self._output._get_reason()}`"

elif self._output is not None and not self._is_canceled:
out = f"**Copied Successfully** __in {m_s} seconds__\n\n{self._output}"

elif self._output is not None and self._is_canceled:
Expand Down
1 change: 1 addition & 0 deletions userge/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@


logging.getLogger("pyrogram").setLevel(logging.WARNING)
logging.getLogger("pyrogram.client.parser.html").setLevel(logging.ERROR)
logging.getLogger('googleapiclient.discovery').setLevel(logging.WARNING)
4 changes: 2 additions & 2 deletions userge/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

__version_mjaor__ = 0
__version_minor__ = 1
__version_micro__ = 1
__version_beta__ = 0
__version_micro__ = 2
__version_beta__ = 1


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

0 comments on commit eb924b1

Please sign in to comment.