From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.125.94]) by gnuweeb.org (Postfix) with ESMTPSA id DB7907FA25; Wed, 27 Jul 2022 02:47:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1658890043; bh=DFPehYbN/yr5oRWnePXG8hVXb/O2QE4m7IirMsVzEAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=La/1nlfTxy8pNlkkC9s3ozeIz6Z/t+3K7yotne9PCyPncI+EWjQk4BJfkNth/LbAX QPSJCIcCECqlUX4LSQSd/UOgAZ92rPdg2YwGMkB1ePElI48L3xefpF//JOmmj/v2Q1 pWm/WnpCDhprF2wsaBlCLYGkoImnM+GRgN8oDZV9rIyiMl6nLdpGJn0wXbs1z3rP+C BeUUuqda0hL4U0zVGSZy9RP9BmEy26Pf0Tf1C/pzio+bU7ooHvAlDFbfJNi+yL43tB jVgIEnPPqDe6lEmSi2MYDMvcIXkgJnEjpA5kg7hIKF1THGv2kJ4U7ap4ql/YG0cpB/ FcYnfZRHeXz9g== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , GNU/Weeb Mailing List Subject: [PATCH v1 14/18] Add delete_broadcast() in scraper/db.py Date: Wed, 27 Jul 2022 09:46:30 +0700 Message-Id: <20220727024634.1995-15-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220727024634.1995-1-kiizuha@gnuweeb.org> References: <20220727024634.1995-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Add delete_broadcast() for delete a chat in the database from receiving email messages. Signed-off-by: Muhammad Rizki --- daemon/scraper/db.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/daemon/scraper/db.py b/daemon/scraper/db.py index 805b591..6faedb6 100644 --- a/daemon/scraper/db.py +++ b/daemon/scraper/db.py @@ -199,6 +199,24 @@ class Db(): return self.cur.lastrowid + def delete_broadcast(self, chat_id: Union[int, str]): + get_query = """ + SELECT id FROM broadcast_chats + WHERE chat_id = %(chat_id)s + """ + delete_query = """ + DELETE FROM broadcast_chats + WHERE chat_id = %(chat_id)s + """ + self.cur.execute(get_query, {"chat_id": chat_id}) + exist = self.cur.fetchone() + if bool(exist): + self.cur.execute(delete_query, {"chat_id": chat_id}) + return True + + return False + + def get_broadcast_chats(self): q = """ SELECT * -- Muhammad Rizki