def add_url(bot, update, args): spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message) if spam == True: return if len(args) >= 1: chat = update.effective_chat tg_chat_id = str(update.effective_chat.id) tg_feed_link = args[0] is_pinned = False if len(args) >= 2: if args[1] == "pin": is_pinned = True 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: send_message( update.effective_message, tl(update.effective_message, "URL ini sudah ditambahkan")) else: sql.add_url(tg_chat_id, tg_feed_link, tg_old_entry_link, is_pinned) send_message( update.effective_message, tl(update.effective_message, "URL ditambahkan ke langganan")) else: send_message( update.effective_message, tl(update.effective_message, "Tautan ini bukan tautan Umpan RSS")) else: send_message(update.effective_message, tl(update.effective_message, "URL hilang"))
def add_url(bot, update, args): spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id) if spam == True: return update.effective_message.reply_text( "Saya kecewa dengan anda, saya tidak akan mendengar kata-kata anda sekarang!" ) if len(args) >= 1: chat = update.effective_chat 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( "URL ini sudah ditambahkan") else: sql.add_url(tg_chat_id, tg_feed_link, tg_old_entry_link) update.effective_message.reply_text( "URL ditambahkan ke langganan") else: update.effective_message.reply_text( "Tautan ini bukan tautan Umpan RSS") else: update.effective_message.reply_text("URL hilang")