def remove_url(update: Update, context: CallbackContext):
    bot = context.bot
    args = context.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")
Exemplo n.º 2
0
def add_url(bot, update, args):
    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("Bu URL zaten eklenmiş")
            else:
                sql.add_url(tg_chat_id, tg_feed_link, tg_old_entry_link)

                update.effective_message.reply_text("Aboneliğe URL eklendi")
        else:
            update.effective_message.reply_text(
                "Bu bağlantı bir RSS Yayını bağlantısı değil")
    else:
        update.effective_message.reply_text("URL eksik")
def add_url(update: Update, context: CallbackContext):
    bot = context.bot
    args = context.args
    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(
                    "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")
Exemplo n.º 4
0
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(
                    "URL abonelikten kaldırıldı")
            else:
                update.effective_message.reply_text(
                    "Bu URL'ye henüz abone olmadınız")
        else:
            update.effective_message.reply_text(
                "Bu bağlantı bir RSS Yayını bağlantısı değil")
    else:
        update.effective_message.reply_text("URL eksik")