예제 #1
0
def on_start_deeplink(update: Update, context: CallbackContext):
    logger.info('%d: /start deeplink', update.effective_user.id)

    topic = int(context.matches[0].group(1))

    release = db.get_release(topic, search_by='topic')

    release_string = Strings.RELEASE.format(**release)
    release_string = re.sub('.*(Usa /fatto.*)$', '', release_string)  # remove the last line, shouldn't show with deeplinks

    reply_markup = InlineKeyboard.release_info(release['id'], release['webarchive_url'])
    update.message.reply_html(release_string, disable_web_page_preview=True, reply_markup=reply_markup)
def on_collapse_button(update: Update, context: CallbackContext):
    logger.info('%d: collapse button', update.effective_user.id)

    release_id = context.match[1]
    release = db.get_release(release_id)

    update.callback_query.edit_message_text(
        Strings.RELEASE.format(**release),
        disable_web_page_preview=True,
        reply_markup=InlineKeyboard.release_info(release_id,
                                                 release['webarchive_url']),
        parse_mode=ParseMode.HTML)
    update.callback_query.answer(Strings.CB_ANSWER_COLLAPSED)
예제 #3
0
def on_release_selected(update: Update, _):
    logger.info('%d: user selected the release from the keyboard', update.effective_user.id)

    release_match = re.search(r'^(\d+)\.\s.*', update.message.text)
    if not release_match:
        # user changed his query
        return search_release(update, WAITING_RELEASE)
    
    release_id = release_match.group(1)
    release = db.release_by_id(release_id)
    
    release_string = Strings.RELEASE.format(**release)
    
    reply_markup = InlineKeyboard.release_info(release_id, release['webarchive_url'])
    update.message.reply_html(release_string, disable_web_page_preview=True, reply_markup=reply_markup)

    return WAITING_RELEASE