Skip to content

Commit

Permalink
GoogleDrive: fix parent_id always None if input not url
Browse files Browse the repository at this point in the history
Change-Id: I8532f357b4770a15f09033d185a073db16b2a695
  • Loading branch information
adekmaulana committed Sep 9, 2021
1 parent 4097aff commit 11602d7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bot/plugins/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@
r"([a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9])\.[^\s]{2,}")


def getIdFromUrl(url: str) -> Optional[str]:
def getIdFromUrl(url: Optional[str]) -> Optional[str]:
if not url:
return None

match = PATTERN.search(url)
return match[0] if match else None
return match[0] if match else url


class GoogleDrive(plugin.Plugin):
Expand Down Expand Up @@ -652,9 +655,7 @@ async def cmd_gdsearch(self, ctx: command.Context) -> Optional[str]:
return "__Invalid parameters of input.__"

name = options.get("name")
parent = options.get("parent")
if parent:
parent = getIdFromUrl(parent)
parent = getIdFromUrl(options.get("parent"))

limit = int(options.get("limit", 15))
if limit > 1000:
Expand Down

0 comments on commit 11602d7

Please sign in to comment.