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.100]) by gnuweeb.org (Postfix) with ESMTPSA id BA5468060C; Tue, 20 Sep 2022 13:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1663681745; bh=BMcpDmzgAGFjUfS5sNNiTtIVreiCwBHFrxCMT8z01Vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qQnrH6v25jK6jGZz6OLhErNiEE6aP3zQ99nZ+1St4oV5KEmR5stAW1ByzDmRZYP3h tLTF/VnoU0knhSkZ3HDuEPJyxKEWKWJZiWDSCHt6c6px8j09930VFOUR7aX2RhBPmt /fpwLABlAMoOwCFMH4qHv9KkgY3h4wZDwwezf0AY7ng1kcoyp9N4X5I0FXhdFBG8vL YVmSfv4gMy56/Jc+ICGRfgjgHb49MwsRegyy7PfvGdB6WrYtgmtFfqlcTvkv3S8YQX IcaH4SEULF8vfq6dTGsFjPETWWxSbwbraLIif7vkGMDV8iLfguAzL3Wjkp25NaOqTC lbdwTvf9o89Ew== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [RFC PATCH v4 16/17] discord: Add save_discord_mail() in database insertion Date: Tue, 20 Sep 2022 20:48:11 +0700 Message-Id: <20220920134812.331-17-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220920134812.331-1-kiizuha@gnuweeb.org> References: <20220920134812.331-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 already been sent to the channel and has reply to header then the bot reply to that message if the reply id is exist 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..bb423fd --- /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