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 A303B80DA1; Sun, 11 Sep 2022 10:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1662892459; bh=BMcpDmzgAGFjUfS5sNNiTtIVreiCwBHFrxCMT8z01Vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JB+gUK2U6cp+J9lorBkxXF2nbkIlBzqlhFqf882TE0s2HCQia8EuVIf6MOIJn5vxP 5ClFUEmiI296//YIiaAWk2ztJKXyRJcM+efKx6x5FlgxBQR3F06/0JEOalv+cJeK2a XCpi4NlqbL3CalMda5AF4xFT2jcSnM8+SiciMuVMwO0o+5q+rJ7WprtHKPFW/UacFm DVKegNcshGCJHj9B6X49BKiVETlv7+fLE7L2hhF1pbE2Qq7d9DHU7i7hWBdq3TrBW8 fHiEzcxONGc+9XX3lgd734KIO//1appiafDWdkUsOigsau2Sph9B3SmYXZNiZAAwPc O89NKevnAZIHQ== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [RFC PATCH v1 16/17] [discord] Add save_discord_mail() in database insertion Date: Sun, 11 Sep 2022 17:33:22 +0700 Message-Id: <20220911103323.1949-17-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220911103323.1949-1-kiizuha@gnuweeb.org> References: <20220911103323.1949-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