From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
GNU/Weeb Mailing List <[email protected]>,
Alviro Iskandar Setiawan <[email protected]>
Subject: [PATCH v4 09/18] Add delete_atom() function in scraper/db.py
Date: Sat, 30 Jul 2022 11:40:07 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Add delete_atom() function to remove atom URL in database
Signed-off-by: Muhammad Rizki <[email protected]>
---
daemon/packages/plugins/manage_atom.py | 19 ++++++++++++++++++-
daemon/scraper/db.py | 12 ++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/daemon/packages/plugins/manage_atom.py b/daemon/packages/plugins/manage_atom.py
index 934aba9..0d2166a 100644
--- a/daemon/packages/plugins/manage_atom.py
+++ b/daemon/packages/plugins/manage_atom.py
@@ -3,7 +3,7 @@
# Copyright (C) 2022 Muhammad Rizki <[email protected]>
#
-from pyrogram.types import Message
+from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
from pyrogram import filters
from packages import DaemonClient
from scraper import utils
@@ -28,3 +28,20 @@ async def add_atom_url(c: DaemonClient, m: Message):
return await m.reply(f"This URL already listened for new email.")
await m.reply(f"Success add **{text}** for listening new email")
+
+
[email protected]_message(
+ filters.command("del_atom") &
+ filters.chat(["kiizuah", "nekoha", -1001673279485])
+)
+async def del_atom_url(c: DaemonClient, m: Message):
+ atoms = c.db.get_atom_urls()
+ if len(atoms) == 0:
+ return await m.reply("Currently empty.")
+
+ text = "List of atom URL that currently listened:\n"
+ for u,i in zip(atoms, range(1, len(atoms)+1)):
+ text += f"{i}. {u}\n"
+
+ text += "\nChoose one of the URL above to delete by index below."
+ await m.reply(text)
diff --git a/daemon/scraper/db.py b/daemon/scraper/db.py
index 30ed9a7..24fc2c6 100644
--- a/daemon/scraper/db.py
+++ b/daemon/scraper/db.py
@@ -130,6 +130,18 @@ class Db():
return self.cur.lastrowid
+ def delete_atom(self, atom: str):
+ q = """
+ DELETE FROM atom_urls
+ WHERE url = %(atom)s
+ """
+ try:
+ self.cur.execute(q, {"atom": atom})
+ return True
+ except:
+ return False
+
+
def get_atom_urls(self):
q = """
SELECT atom_urls.url
--
Muhammad Rizki
next prev parent reply other threads:[~2022-07-30 4:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-30 4:39 [PATCH v4 00/18] New feature to handle atom URLs and broadcast Muhammad Rizki
2022-07-30 4:39 ` [PATCH v4 01/18] Add new table for atom URLs and broadcast chats in db.sql Muhammad Rizki
2022-07-31 15:38 ` Alviro Iskandar Setiawan
2022-07-31 15:42 ` Ammar Faizi
2022-07-30 4:40 ` [PATCH v4 02/18] Add ATOM_URLS and BROADCAST_CHAT methods Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 03/18] Fix MySQL InternalError: Unread result found Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 04/18] Create /add_atom command Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 05/18] Add utility functions for /add_atom Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 06/18] Refactor database methods Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 07/18] Add insert_atom() in scraper/db.py Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 08/18] Rename admin.py to debugger.py Muhammad Rizki
2022-07-30 4:40 ` Muhammad Rizki [this message]
2022-07-30 4:40 ` [PATCH v4 10/18] Add utility function buton_numbers() Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 11/18] Move bot commands related files to packages/plugins/commands/ Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 12/18] Add del_atom callback query Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 13/18] Add insert_broadcast() in scraper/db.py Muhammad Rizki
2022-07-31 15:48 ` Alviro Iskandar Setiawan
2022-07-30 4:40 ` [PATCH v4 14/18] Add delete_broadcast() " Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 15/18] Create /add_bc bot command Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 16/18] Add create_chat_link() function Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 17/18] Add /del_bc bot command Muhammad Rizki
2022-07-30 4:40 ` [PATCH v4 18/18] Add del_chat callback query Muhammad Rizki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox