Esempio n. 1
0
def parse_entity_for_drive_id(message):
    if message.photo:
        entities = message.parse_caption_entities()
    else:
        entities = message.parse_entities()

    folder_ids = {}
    k = 0

    for entity in entities:
        if entity.type == 'text_link':
            url = entity.url
            name = entities[entity]
        elif entity.type == 'url':
            url = entities[entity]
            name = 'file{:03d}'.format(k)
        else:
            continue

        logger.debug('Found {0}: {1}.'.format(name, url))
        folder_id = parse_folder_id_from_url(url)
        if not folder_id:
            continue
        folder_ids[folder_id] = name

        logger.debug('Found {0} with folder_id {1}.'.format(name, folder_id))

    if len(folder_ids) == 0:
        logger.debug('Cannot find any legit folder id.')
        return None
    return folder_ids
Esempio n. 2
0
def process_message_from_authorised_user(update, context):
    logger.debug(update.message)
    if update.message.caption:
        text_urled = update.message.caption_html_urled
    else:
        text_urled = update.message.text_html_urled
    if parse_folder_id_from_url(text_urled):
        process_drive_links(update, context)
        return
Esempio n. 3
0
def process_message(update, context):
    if not update.message:
        return
    if update.message.chat_id == config.USER_IDS[0]:
        pass
    else:
        logger.debug(update.message)
        if update.message.caption:
            text_urled = update.message.caption_html_urled
        else:
            text_urled = update.message.text_html_urled
        if parse_folder_id_from_url(text_urled):
            process_drive_links(update, context)
            return