def add_url(_bot, update, args): if len(args) >= 1: tg_chat_id = str(update.effective_chat.id) tg_feed_link = args[0] link_processed = parse(tg_feed_link) # check if link is a valid RSS Feed link if link_processed.bozo == 0: if len(link_processed.entries[0]) >= 1: tg_old_entry_link = link_processed.entries[0].link else: tg_old_entry_link = "" # gather the row which contains exactly that telegram group ID and # link for later comparison row = sql.check_url_availability(tg_chat_id, tg_feed_link) # check if there's an entry already added to DB by the same user in # the same group with the same link if row: update.effective_message.reply_text( "This URL has already been added") else: sql.add_url(tg_chat_id, tg_feed_link, tg_old_entry_link) update.effective_message.reply_text( "Added URL to subscription") else: update.effective_message.reply_text( "This link is not an RSS Feed link") else: update.effective_message.reply_text("URL missing")
def remove_url(_bot, update, args): if len(args) >= 1: tg_chat_id = str(update.effective_chat.id) tg_feed_link = args[0] link_processed = parse(tg_feed_link) if link_processed.bozo == 0: user_data = sql.check_url_availability(tg_chat_id, tg_feed_link) if user_data: sql.remove_url(tg_chat_id, tg_feed_link) update.effective_message.reply_text( "Removed URL from subscription") else: update.effective_message.reply_text( "You haven't subscribed to this URL yet") else: update.effective_message.reply_text( "This link is not an RSS Feed link") else: update.effective_message.reply_text("URL missing")