Esempio n. 1
0
def yandere_view(update, context):
    message = update.message
    try:
        post_id = int(context.args[0])
        if post_id < 0:
            message.reply_text('Invalid post id!')
            return
        imgs, details = moebooru.site('yande.re').view(post_id)
        sendPhotos(update, context, imgs, details)
    except (IndexError, ValueError):
        message.reply_text('Usage: /yandere <post_id>')
    except BadRequest as error:
        handleBadRequest(update, context, error)
    except NazurinError as error:
        message.reply_text(error.msg)
Esempio n. 2
0
def pixiv_view(update, context):
    message = update.message
    try:
        # args[0] should contain the queried artwork id
        artwork_id = int(context.args[0])
        if artwork_id < 0:
            message.reply_text('Invalid artwork id!')
            return
        imgs, details = pixiv.view_illust(artwork_id)
        sendPhotos(update, context, imgs, details)
    except (IndexError, ValueError):
        message.reply_text('Usage: /pixiv <artwork_id>')
    except NazurinError as error:
        message.reply_text(error.msg)
    except BadRequest as error:
        handleBadRequest(update, context, error)
Esempio n. 3
0
def pixiv_view(update, context):
    message = update.message
    try:
        # args[0] should contain the queried artwork id
        artwork_id = int(context.args[0])
        if artwork_id < 0:
            message.reply_text('Invalid artwork id!')
            return
        imgs, details = pixiv.view_illust(artwork_id)
        # use reverse proxy to avoid strange problems
        for img in imgs:
            img['url'] = img['url'].replace('i.pximg.net', IMG_PROXY)
            img['url'] += '?' + str(random.random())
            img['thumbnail'] = img['thumbnail'].replace(
                'i.pximg.net', IMG_PROXY)
            img['thumbnail'] += '?' + str(random.random())
        sendPhotos(update, context, imgs, details)
    except (IndexError, ValueError):
        message.reply_text('Usage: /pixiv <artwork_id>')
    except NazurinError as error:
        message.reply_text(error.msg)
    except BadRequest as error:
        handleBadRequest(update, context, error)