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.149]) by gnuweeb.org (Postfix) with ESMTPSA id 748CB80E1F; Sun, 25 Sep 2022 21:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664140520; bh=BqORDhYtuKELCMb4AtDS+zMmI11uWfjdog3w4Ha80EA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V3vEM2hGsrSmPph/IVNHABR8aNGXmqmT2ZXpigMieOq8FOqBMwiKY6YeWOcVUPJW+ IZc19kukVjV2J+sSWjejzicjfLhhp7A2I6FgUah1nOY0vrdTLfT0EUkQ4xCROJe5T/ GMXIEQjXVT6Efvm4c+wtvNpf9kJjurzsWJcdIA5R5a4CycMS4YUvS67x0OZfRxeBo/ YEfa/CkRdSd887gnCCmrdVhGsbXp9Pv+ZoaZ7KZer7kjmUImjKteEyarQqAt7nsv7a G/a7ZssD3JxNKmDGSKuWd4ByimtgUgj+OjfSL3vhl14WLFBGJA4cL5dGnpwiAZSRJs eVAKF28zrvfRw== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [RFC PATCH v5 16/18] discord: Add save_discord_mail() in database insertion Date: Mon, 26 Sep 2022 04:14:25 +0700 Message-Id: <20220925211427.412-17-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220925211427.412-1-kiizuha@gnuweeb.org> References: <20220925211427.412-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Add save_discord_mail() to save lore email that has been sent in the Discord guild channel for checking if this email has already been sent to the channel and has a reply to the header then the bot replies to that message if the reply id exists in the database. Signed-off-by: Muhammad Rizki --- .../dscord/database/methods/insertion/__init__.py | 4 +++- .../database/methods/insertion/insert_discord.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 daemon/dscord/database/methods/insertion/insert_discord.py diff --git a/daemon/dscord/database/methods/insertion/__init__.py b/daemon/dscord/database/methods/insertion/__init__.py index 4192735..dd3ecf4 100644 --- a/daemon/dscord/database/methods/insertion/__init__.py +++ b/daemon/dscord/database/methods/insertion/__init__.py @@ -6,9 +6,11 @@ from .insert_atom import InsertAtom from .insert_broadcast import InsertBroadcast +from .insert_discord import InsertDiscord class Insertion( InsertAtom, - InsertBroadcast + InsertBroadcast, + InsertDiscord ): pass diff --git a/daemon/dscord/database/methods/insertion/insert_discord.py b/daemon/dscord/database/methods/insertion/insert_discord.py new file mode 100644 index 0000000..0623188 --- /dev/null +++ b/daemon/dscord/database/methods/insertion/insert_discord.py @@ -0,0 +1,14 @@ +from datetime import datetime + + +class InsertDiscord: + + def save_discord_mail(self, email_id, channel_id, dc_msg_id): + q = """ + INSERT INTO dc_mail_msg + (email_id, channel_id, dc_msg_id, created_at) + VALUES (%s, %s, %s, %s); + """ + self.cur.execute(q, (email_id, channel_id, dc_msg_id, + datetime.utcnow())) + return self.cur.lastrowid -- Muhammad Rizki