async def add_url_(event): if event.pattern_match.group(1): chat = await event.get_chat() tg_chat_id = str(event.chat_id) tg_feed_link = event.pattern_match.group(1) 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 = 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: await event.edit("This URL has already been added") else: add_url(tg_chat_id, tg_feed_link, tg_old_entry_link) await event.edit("Added URL to subscription") else: await event.edit("This link is not an RSS Feed link") else: await event.edit("URL missing")
async def remove_url_(event): if event.pattern_match.group(1): tg_chat_id = str(event.chat_id) tg_feed_link = event.pattern_match.group(1) link_processed = parse(tg_feed_link) if link_processed.bozo == 0: user_data = check_url_availability(tg_chat_id, tg_feed_link) if user_data: remove_url(tg_chat_id, tg_feed_link) await event.edit("Removed URL from subscription") else: await event.edit("You haven't subscribed to this URL yet") else: await event.edit("This link is not an RSS Feed link") else: await event.edit("URL missing")