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 511BA80DD9; Tue, 13 Sep 2022 10:26:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1663064793; bh=BMcpDmzgAGFjUfS5sNNiTtIVreiCwBHFrxCMT8z01Vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YGdX/zDYQ64+UAhdeey2hjHdtJtzOIyAT6jGnpU4d0EexC+kVN7bMXOor5d79sbBr uWyaXgUzfaJTCYJHABCHswu4nNZ2h0i2N6AGa+krAPE9dr3oc91Ty+i2RYzkr8XQMS 7A1RlFwdEmBo0gDDR00+Gk/LEmYWFaf3bq8VyeleYX+DlkojyXgov1nhDNVB11t3i0 42zwIUjJSu65+U/tRUcC2H0AorJF3XhyJiWamwQBdtFdF50ZbQz3my5gW8i/zJZxP7 QzaCPaOjCjQ0wpd59DV4bXPzfzPTxVe5KfsNVrOivV/NA3cMM7Zd8C6r0eEwjlnoY9 gjoE9gYTlpd8g== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [RFC PATCH v2 16/17] discord: Add save_discord_mail() in database insertion Date: Tue, 13 Sep 2022 17:24:57 +0700 Message-Id: <20220913102458.615-17-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220913102458.615-1-kiizuha@gnuweeb.org> References: <20220913102458.615-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