def size_handle(update, context): tmp_share_name_list = "" share_id_list = [] share_name_list = [] share_id = update.effective_message.text share_id_list = _func.cook_to_id(share_id) for item in share_id_list: size_msg = update.effective_message.reply_text( _text[_lang]["ready_to_size"]) size_chat_id = size_msg.chat_id size_message_id = size_msg.message_id share_name_list += _func.get_src_name_from_id( update, item, list_name=tmp_share_name_list) tmp_share_name_list = "" progress = _mp(target=_s_payload.simple_size, args=(update, context, item, size_chat_id, size_message_id, share_name_list)) progress.start() context.bot.edit_message_text(chat_id=size_chat_id, message_id=size_message_id, text=_text[_lang]["sizing"]) return ConversationHandler.END
def pre_to_purge(update, context): get_callback = update.callback_query.data purge_msg = bot.edit_message_text( chat_id=update.callback_query.message.chat_id, message_id=update.callback_query.message.message_id, text=_text[_lang]["ready_to_purge"], reply_markup=None, ) purge_chat_id = purge_msg.chat_id purge_message_id = purge_msg.message_id fav_info_list = get_callback.split("id+name") fav_id = fav_info_list[0] fav_name = fav_info_list[1] if len(fav_id) < 28: progress = _mp( target=_p_payload.purge_fav, args=( ns, purge_chat_id, purge_message_id, fav_id, fav_name, ), ) progress.start() bot.edit_message_text( chat_id=purge_chat_id, message_id=purge_message_id, text=_text[_lang]["purging"], ) return ConversationHandler.END else: bot.edit_message_text( chat_id=purge_chat_id, message_id=purge_message_id, text=_text[_lang]["is_folder_not_drive"], ) return ConversationHandler.END
def pre_cook_fav_to_size(update, context): get_callback = update.callback_query.data size_msg = bot.edit_message_text( chat_id=update.callback_query.message.chat_id, message_id=update.callback_query.message.message_id, text=_text[_lang]["ready_to_size"], reply_markup=None, ) size_chat_id = size_msg.chat_id size_message_id = size_msg.message_id fav_info_list = get_callback.split("id+name") fav_id = fav_info_list[0] fav_name = fav_info_list[1] task_id = 0 task_link = r"https://drive.google.com/open?id={}".format(fav_id) endpoint_id = fav_id endpoint_name = fav_name progress = _mp( target=_s_payload.owner_size, args=( ns, size_chat_id, size_message_id, task_id, task_link, endpoint_id, endpoint_name, ), ) progress.start() context.bot.edit_message_text( chat_id=size_chat_id, message_id=size_message_id, text=_text[_lang]["sizing"], ) return ConversationHandler.END
def pre_favdedu_info(update, context): dedu_mode = update.callback_query.data dedu_msg = update.callback_query.edit_message_text( text=_text[_lang]["ready_to_dedupe"], reply_markup=None, ) dedu_chat_id = dedu_msg.chat_id dedu_message_id = dedu_msg.message_id dedu_task_id = 0 dedufav_info = dedufav_callback.split("id+name") dedu_id = dedufav_info[0] dedu_name = dedufav_info[1] dedu_link = r"https://drive.google.com/open?id={}".format( dedufav_info[0] ) progress = _mp( target=_d_payload.dedupe_task, args=( ns, dedu_mode, dedu_chat_id, dedu_message_id, dedu_task_id, dedu_link, dedu_id, dedu_name, ), ) progress.start() bot.edit_message_text( chat_id=dedu_chat_id, message_id=dedu_message_id, text=_text[_lang]["deduping"], ) return ConversationHandler.END
) Thread(target=stop_and_restart).start() dp.add_handler(conv_handler) dp.add_handler(CommandHandler("start", _start.start)) dp.add_handler(CommandHandler("reset", _box.task_reset)) dp.add_handler(CommandHandler("kill", _func.taskill)) dp.add_handler(CommandHandler("ver", _func._version)) dp.add_handler( CommandHandler( "restart", restart, filters=Filters.user(user_id=int(load.cfg["tg"]["usr_id"])), )) dp.add_error_handler(_func.error) updater.start_polling() logger.info("Fxxkr LAB iCopy " + __version__.__version__ + " Start") updater.idle() if __name__ == "__main__": ns.x = 0 progress = _mp(target=_payload.task_buffer, args=(ns, )) progress.start() #web = _mp(target=dash.dashboard) #web.start() main()
def dedupe_mode(update, context): get_callback = update.callback_query.data dedu_msg = bot.edit_message_text( chat_id=update.callback_query.message.chat_id, message_id=update.callback_query.message.message_id, text=_text[_lang]["ready_to_dedupe"], reply_markup=None, ) dedu_chat_id = dedu_msg.chat_id dedu_message_id = dedu_msg.message_id dedu_mode = get_callback if "dst_endpoint_id" and "dst_endpoint_link" in check_task: dedu_task_id = check_task["_id"] dedu_name = check_task["src_name"] dedu_id = check_task["dst_endpoint_id"] dedu_link = check_task["dst_endpoint_link"] else: dst_endpoint_id = _gd.get_dst_endpoint_id( _gd(), check_task["dst_id"], check_task["src_name"] ) if dst_endpoint_id: dst_endpoint_link = r"https://drive.google.com/open?id={}".format( dst_endpoint_id["id"] ) load.task_list.update_one( {"_id": int(check_task["_id"])}, { "$set": { "dst_endpoint_id": dst_endpoint_id["id"], "dst_endpoint_link": dst_endpoint_link, }, }, ) dedu_task_id = check_task["_id"] dedu_name = check_task["src_name"] dedu_id = dst_endpoint_id dedu_link = dst_endpoint_link progress = _mp( target=_d_payload.dedupe_task, args=( ns, dedu_mode, dedu_chat_id, dedu_message_id, dedu_task_id, dedu_link, dedu_id, dedu_name, ), ) progress.start() bot.edit_message_text( chat_id=dedu_chat_id, message_id=dedu_message_id, text=_text[_lang]["deduping"], ) return ConversationHandler.END
def size(update, context): entry_cmd = update.effective_message.text match_cmd = re.search(r"^\/size ([1-9]\d*)$", entry_cmd, flags=re.I) if "/size" == entry_cmd: update.effective_message.reply_text(_text[_lang]["request_share_link"]) return _stage.COOK_ID elif match_cmd: limit_query = load.db_counters.find_one({"_id": "task_list_id"}) check_query = match_cmd.group(1) size_msg = update.effective_message.reply_text(_text[_lang]["ready_to_size"]) size_chat_id = size_msg.chat_id size_message_id = size_msg.message_id if int(check_query) <= limit_query["future_id"]: check_task = load.task_list.find_one({"_id": int(check_query)}) if check_task["status"] == 1: if "dst_endpoint_link" and "dst_endpoint_id" in check_task: task_id = str(check_query) task_link = check_task["dst_endpoint_link"] endpoint_id = check_task["dst_endpoint_id"] endpoint_name = check_task["src_name"] progress = _mp( target=_s_payload.owner_size, args=( ns, size_chat_id, size_message_id, task_id, task_link, endpoint_id, endpoint_name, ), ) progress.start() context.bot.edit_message_text( chat_id=size_chat_id, message_id=size_message_id, text=_text[_lang]["sizing"], ) return ConversationHandler.END else: dst_endpoint_id = _gd.get_dst_endpoint_id( _gd(), check_task["dst_id"], check_task["src_name"] ) if dst_endpoint_id: dst_endpoint_link = r"https://drive.google.com/open?id={}".format( dst_endpoint_id["id"] ) load.task_list.update_one( {"_id": int(check_query)}, { "$set": { "dst_endpoint_id": dst_endpoint_id["id"], "dst_endpoint_link": dst_endpoint_link, }, }, ) task_id = str(check_query) task_link = dst_endpoint_link endpoint_id = dst_endpoint_id["id"] endpoint_name = check_task["src_name"] progress = _mp( target=_s_payload.owner_size, args=( ns, size_chat_id, size_message_id, task_id, task_link, endpoint_id, endpoint_name, ), ) progress.start() context.bot.edit_message_text( chat_id=size_chat_id, message_id=size_message_id, text=_text[_lang]["sizing"], ) return ConversationHandler.END else: bot.edit_message_text( chat_id=size_chat_id, message_id=size_message_id, text=_text[_lang]["support_error"], ) return ConversationHandler.END elif check_task["status"] == 0: bot.edit_message_text( chat_id=size_chat_id, message_id=size_message_id, text=_text[_lang]["task_is_in_queue"] + "\n" + _text[_lang]["finished_could_be_check"], ) return ConversationHandler.END elif check_task["status"] == 2: bot.edit_message_text( chat_id=size_chat_id, message_id=size_message_id, text=_text[_lang]["doing"] + "\n" + _text[_lang]["finished_could_be_check"], ) return ConversationHandler.END else: bot.edit_message_text( chat_id=size_chat_id, message_id=size_message_id, text=_text[_lang]["over_limit_to_check"], ) return ConversationHandler.END elif entry_cmd.split(" ")[1].strip() == "fav": update.effective_message.reply_text( _text[_lang]["request_target_folder"], reply_markup=_KB.dst_keyboard(update, context), ) return _stage.COOK_FAV_TO_SIZE
def regex_callback(update, context): if "quick" == update.callback_query.data: regex_in_chat_id = regex_in_update.effective_message.chat_id regex_in_message_id = regex_in_update.effective_message.message_id tmp_task_list = [] mode = "quick" is_quick = {"_id": "fav_quick"} is_quick_cur = load.fav_col.find(is_quick) if is_quick_cur is not None: for doc in is_quick_cur: dst_id = doc["G_id"] dst_name = doc["G_name"] for item in src_name_list: src_id = item["G_id"] src_name = item["G_name"] tmp_task_list.append({ "mode_type": mode, "src_id": src_id, "src_name": src_name, "dst_id": dst_id, "dst_name": dst_name, "chat_id": regex_in_chat_id, "raw_message_id": regex_in_message_id, }) Thread(target=_box.cook_task_to_db, args=(regex_in_update, regex_in_context, tmp_task_list)).start() return ConversationHandler.END if "copy" == update.callback_query.data: update.callback_query.edit_message_text( _text[_lang]["mode_select_msg"].replace( "replace", _text[_lang]["copy_mode"]) + "\n" + _text[_lang]["request_dst_target"], reply_markup=_KB.dst_keyboard(update, context), ) return REGEX_GET_DST if "size" == update.callback_query.data: for item in src_id_list: size_msg = update.effective_message.reply_text( _text[_lang]["ready_to_size"]) size_chat_id = size_msg.chat_id size_message_id = size_msg.message_id # to payload progress = _mp(target=_s_payload.simple_size, args=(update, context, item, size_chat_id, size_message_id, src_name_list)) progress.start() context.bot.edit_message_text(chat_id=size_chat_id, message_id=size_message_id, text=_text[_lang]["sizing"]) return ConversationHandler.END
dp.add_handler(conv_handler) dp.add_handler(CommandHandler("start", _start.start)) dp.add_handler(CommandHandler("reset", _box.task_reset)) dp.add_handler(CommandHandler("kill", _func.taskill)) dp.add_handler(CommandHandler("ver", _func._version)) dp.add_handler( CommandHandler( "restart", restart, filters=Filters.user(user_id=int(load.cfg["tg"]["usr_id"])), ) ) dp.add_error_handler(_func.error) updater.start_polling() logger.info("Fxxkr LAB iCopy " + __version__.__version__ + " Start") updater.idle() if __name__ == "__main__": ns.x = 0 progress = _mp(target=_payload.task_buffer, args=(ns,)) progress.start() if load.cfg['web']['dashboard']: web = _mp(target=dash.dashboard) web.start() main()
#!/usr/bin/python3 # -*- coding: utf-8 -*- import os, sys, logging from multiprocessing import Process as _mp, Manager from web import dash webdash = int(os.environ.get("DASHBOARD")) if webdash: web = _mp(target=dash.dashboard) web.start()