def list_urls(update: Update, context: CallbackContext): tg_chat_id = str(update.effective_chat.id) bot = context.bot user_data = sql.get_urls(tg_chat_id) # this loops gets every link from the DB based on the filter above and appends it to the list links_list = [row.feed_link for row in user_data] final_content = "\n\n".join(links_list) # check if the length of the message is too long to be posted in 1 chat bubble if len(final_content) == 0: bot.send_message(chat_id=tg_chat_id, text="This chat is not subscribed to any links") elif len(final_content) <= constants.MAX_MESSAGE_LENGTH: bot.send_message( chat_id=tg_chat_id, text="This chat is subscribed to the following links:\n" + final_content, ) else: bot.send_message( chat_id=tg_chat_id, parse_mode=ParseMode.HTML, text="<b>Warning:</b> The message is too long to be sent", )
def list_urls(bot, update): tg_chat_id = str(update.effective_chat.id) user_data = sql.get_urls(tg_chat_id) # this loops gets every link from the DB based on the filter above and appends it to the list links_list = [row.feed_link for row in user_data] final_content = "\n\n".join(links_list) # check if the length of the message is too long to be posted in 1 chat bubble if len(final_content) == 0: bot.send_message(chat_id=tg_chat_id, text="Bu sohbet herhangi bir bağlantıya abone değil") elif len(final_content) <= constants.MAX_MESSAGE_LENGTH: bot.send_message( chat_id=tg_chat_id, text="Bu sohbet aşağıdaki bağlantılara abone oldu:\n" + final_content) else: bot.send_message( chat_id=tg_chat_id, parse_mode=ParseMode.HTML, text="<b>Uyarı:</b> Mesaj gönderilemeyecek kadar uzun")