def category(client: Client, callback_query: CallbackQuery) -> None: buttons = [] categories = qbittorrent_control.get_categories() if categories is None: if "magnet" in callback_query.data: addmagnet_callback(client, callback_query) else: addtorrent_callback(client, callback_query) return for key, i in enumerate(categories): buttons.append([ InlineKeyboardButton(i, f"{callback_query.data.split('#')[1]}#{i}") ]) buttons.append([ InlineKeyboardButton("None", f"{callback_query.data.split('#')[1]}#None") ]) buttons.append([InlineKeyboardButton("🔙 Menu", "menu")]) try: app.edit_message_text(callback_query.from_user.id, callback_query.message.message_id, "Choose a category:", reply_markup=InlineKeyboardMarkup(buttons)) except MessageIdInvalid: app.send_message(callback_query.from_user.id, "Choose a category:", reply_markup=InlineKeyboardMarkup(buttons))
def category(chat, message, data, query, shared) -> None: btn = botogram.Buttons() categories = qbittorrent_control.get_categories() if categories is None: if "magnet" in data: addmagnet_callback(shared, query, "#None") else: addtorrent_callback(shared, query, "#None") return key = 0 for key, i in enumerate(categories): btn[key].callback(i, data, i) btn[key + 1].callback("None", data, "None") btn[key + 2].callback("🔙 Menu", "menu") try: message.edit("Choice a category:", attach=btn) except Exception: chat.send("Choice a category:", attach=btn)
def remove_category_callback(chat, message, data): btn = botogram.Buttons() if data is not None: qbittorrent_control.remove_category(data=data) btn[0].callback("🔙 Menu", "menu") message.edit(f"The category {data} has been removed", attach=btn) return categories = qbittorrent_control.get_categories() if categories is None: btn[0].callback("🔙 Menu", "menu") message.edit("There are no categories", attach=btn) return key = 0 for key, i in enumerate(categories): btn[key].callback(i, "remove_category", i) btn[key + 1].callback("🔙 Menu", "menu") try: message.edit("Choice a category:", attach=btn) except Exception: chat.send("Choice a category:", attach=btn)
def modify_category_callback(chat, message, data, shared): btn = botogram.Buttons() if data is not None: btn[2].callback("🔙 Menu", "menu") shared['status'] = f"category_dir_modify#{data}" message.edit(f"Send new path for category {data}", attach=btn) return categories = qbittorrent_control.get_categories() if categories is None: btn[0].callback("🔙 Menu", "menu") message.edit("There are no categories", attach=btn) return key = 0 for key, i in enumerate(categories): btn[key].callback(i, "modify_category", i) btn[key + 1].callback("🔙 Menu", "menu") try: message.edit("Choice a category:", attach=btn) except Exception: chat.send("Choice a category:", attach=btn)
def modify_category_callback(chat, message, data): btn = botogram.Buttons() if data is not None: btn[2].callback("🔙 Menu", "menu") db_management.write_support(f"category_dir_modify#{data}", chat.id) message.edit(f"Send new path for category {data}", attach=btn) return categories = qbittorrent_control.get_categories() if categories is None: btn[0].callback("🔙 Menu", "menu") message.edit("There are no categories", attach=btn) return for key, i in enumerate(categories): btn[key].callback(i, "modify_category", i) btn[key + 1].callback("🔙 Menu", "menu") try: message.edit("Choose a category:", attach=btn) except botogram.api.APIError: chat.send("Choose a category:", attach=btn)