Beispiel #1
0
def remove_deadline_by_index(update, context):
    db = DBHelper(CONFIG["db_name"])
    delete_old_listings(update, context)
    text = re.sub(r"/(\d+)(@{})?$".format(re.escape(context.bot.username)),
                  r"\g<1>", update.message.text)
    try:
        index = int(text)
        dl_id, dl = context.user_data["remove_list"][index]
        db.delete_deadline(dl_id)
        update.message.reply_text(str(dl) + " removed!")
        check_deadline(update, context)
    except KeyError as ke:
        update.message.reply_text(str(index) + " not in list!")
    except ValueError as ve:
        update.message.reply_text(text + " is not a valid integer!")
    context.user_data["remove_list"] = None
    return -1