Exemple #1
0
def choose_link(call):
    bot.send_chat_action(call.message.chat.id, 'typing')
    # call.data is url, http://www.rrys2020.com/resource/36588
    resource_url = re.findall(r"choose(\S*)", call.data)[0]
    markup = types.InlineKeyboardMarkup()

    if OFFLINE:
        worker_page = offline_link(resource_url)
        btn1 = types.InlineKeyboardButton("打开网页", url=worker_page)
        markup.add(btn1)
        bot.send_message(call.message.chat.id, "离线模式,点击按钮打开网页获取结果", reply_markup=markup)
        return

    link = yyets_get_from_cache(resource_url)
    if not link:
        link = get_detail_page(resource_url)
        save_to_cache(resource_url, link)

    btn1 = types.InlineKeyboardButton("分享页面", callback_data="share%s" % resource_url)
    btn2 = types.InlineKeyboardButton("我全都要", callback_data="all%s" % resource_url)
    markup.add(btn1, btn2)
    text = "想要分享页面,还是我全都要?\n\n" \
           "名词解释:“分享页面”会返回给你一个网站,从那里可以看到全部的下载链接。\n" \
           "“我全都要”会给你发送一个txt文件,文件里包含全部下载连接\n"
    bot.send_message(call.message.chat.id, text, reply_markup=markup)
Exemple #2
0
def all_episode(call):
    # just send a file
    bot.send_chat_action(call.message.chat.id, 'typing')
    resource_url = re.findall(r"all(\S*)", call.data)[0]
    result = yyets_get_from_cache(resource_url)

    with tempfile.NamedTemporaryFile(mode='wb+', prefix=result["cnname"], suffix=".txt") as tmp:
        bytes_data = json.dumps(result["all"], ensure_ascii=False, indent=4).encode('u8')
        tmp.write(bytes_data)
        tmp.flush()
        with open(tmp.name, "rb") as f:
            bot.send_chat_action(call.message.chat.id, 'upload_document')
            bot.send_document(call.message.chat.id, f)
Exemple #3
0
def share_page(call):
    bot.send_chat_action(call.message.chat.id, 'typing')
    resource_url = re.findall(r"share(\S*)", call.data)[0]
    result = yyets_get_from_cache(resource_url)
    bot.send_message(call.message.chat.id, result['share'])