def edit(query, chat_id, lang, refresh_id=0): buttons = group_settings_helpers.group_settings_buttons( get_string(lang, "group_setting_buttons"), chat_id, refresh_id) chat_details = database.get_group_title(chat_id) chat_link = helpers.chat_link(chat_details["title"], chat_details["link"]) text = get_string(lang, "group_setting_text").format(chat_link) query.edit_message_text(text, reply_markup=InlineKeyboardMarkup(buttons), parse_mode=ParseMode.HTML, disable_web_page_preview=True)
def start(update: Update, context: CallbackContext): user_id = update.effective_user.id database.insert_player_pm(user_id, True) user_data = context.user_data if "lang" not in user_data: lang = database.get_language_player(user_id) user_data["lang"] = lang else: lang = user_data["lang"] context.args = context.args[0].split("_") if context.args else None if not context.args or context.args[0] != "settings": return # not necessary, but pycharm won't believe me that... chat_id = 0 try: chat_id = int(context.args[1]) chat = context.bot.get_chat(chat_id) except ValueError: context.bot.send_message(user_id, get_string(lang, "group_not_found")) return except BadRequest: try: new_id = database.get_new_id(chat_id) if new_id: chat = context.bot.get_chat(int(new_id)) else: raise BadRequest except BadRequest: context.bot.send_message(user_id, get_string(lang, "group_not_found")) return database.insert_group_title(chat_id, chat.title, chat.link) if not helpers.is_admin(context.bot, update.effective_user.id, chat): update.effective_message.reply_text( get_string(lang, "no_admin_settings")) return buttons = group_settings_helpers.group_settings_buttons( get_string(lang, "group_setting_buttons"), chat_id) chat_link = helpers.chat_link(chat.title, chat.link) context.bot.send_message(user_id, get_string( lang, "group_setting_text").format(chat_link), reply_markup=InlineKeyboardMarkup(buttons), parse_mode=ParseMode.HTML, disable_web_page_preview=True)
def group_setting(update: Update, context: CallbackContext): chat_id = update.effective_chat.id lang = database.get_language_chat(chat_id) if not helpers.is_admin(context.bot, update.effective_user.id, update.effective_chat): update.effective_message.reply_text( get_string(lang, "no_admin_settings")) return user_id = update.effective_user.id user_lang = database.get_language_player(user_id) pm = database.get_pm_player(user_id) context.user_data["lang"] = user_lang database.insert_group_title(chat_id, update.effective_chat.title, update.effective_chat.link) if pm: try: # yes, its not a string, I don't change the functions name for this you f****r chat_link = helpers.chat_link(update.effective_chat.title, update.effective_chat.link) buttons = group_settings_helpers.group_settings_buttons( get_string(user_lang, "group_setting_buttons"), chat_id) context.bot.send_message( user_id, get_string(user_lang, "group_setting_text").format(chat_link), reply_markup=InlineKeyboardMarkup(buttons), parse_mode=ParseMode.HTML, disable_web_page_preview=True) # this means the bot was blocked wtf except Unauthorized: update.effective_message.reply_text( get_string(lang, "admin_blocked_bot")) database.insert_player_pm(user_id, False) else: button = [[ InlineKeyboardButton( get_string(lang, "no_pm_settings_button"), url=f"https://t.me/thechameleonbot?start=settings_{chat_id}") ]] update.effective_message.reply_text( get_string(lang, "no_pm_settings"), reply_markup=InlineKeyboardMarkup(button))