예제 #1
0
def _set_parent(client, message):
    user_id = message.from_user.id
    if len(message.command) > 1:
        link = message.command[1]
        if not 'clear' in link:
            sent_message = message.reply_text(
                '🕵️**Checking Link...[____ACHIYA____]**', quote=True)
            gdrive = GoogleDrive(user_id)
            try:
                result, file_id = gdrive.checkFolderLink(link)
                if result:
                    idsDB._set(user_id, file_id)
                    LOGGER.info(f'SetParent:{user_id}: {file_id}')
                    sent_message.edit(
                        Messages.PARENT_SET_SUCCESS.format(
                            file_id, BotCommands.SetFolder[0]))
                else:
                    sent_message.edit(file_id)
            except IndexError:
                sent_message.edit(Messages.INVALID_GDRIVE_URL)
        else:
            idsDB._clear(user_id)
            message.reply_text(Messages.PARENT_CLEAR_SUCCESS, quote=True)
    else:
        message.reply_text(Messages.CURRENT_PARENT.format(
            idsDB.search_parent(user_id), BotCommands.SetFolder[0]),
                           quote=True)
예제 #2
0
 def __init__(self, user_id):
   self.__G_DRIVE_DIR_MIME_TYPE = "application/vnd.google-apps.folder"
   self.__G_DRIVE_BASE_DOWNLOAD_URL = "https://drive.google.com/uc?id={}&export=download"
   self.__G_DRIVE_DIR_BASE_DOWNLOAD_URL = "https://drive.google.com/drive/folders/{}"
   self.__service = self.authorize(gDriveDB.search(user_id))
   self.__parent_id = idsDB.search_parent(user_id)