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.177]) by gnuweeb.org (Postfix) with ESMTPSA id F35ED804FD; Sat, 1 Oct 2022 13:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664629492; bh=EuBsZjl7AL2KneS7e9pbvH+tVXRMNUjbQ4sQXf0S9+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BwC8NHqqCIfhoyQfe56aK3QfNbJiUdRk8FYpD3FPk2sSBcZygAvOtIsbmDICOYsFl 6KTNNx1cstw7oSlpAck52X6/Go1y0+5ud0J8aeeDG08KqpquHbPzQ0564JqZtntGbc 6QfJK+kp9WDPGUU3rRO7RYnFSEfg+WFaqDZVLELCZUGiBg35asoXQt6Q5TujAuwAO4 /vImKrEVmj+vQ1C2a8S8EZnrcHSChpkZlszEAqJ9ckJW84pQD0xGkQC4xptTvCP9pI /rP6hCjYfLARXk4ADRKuimatDLyPJAOKocEYsvE3Dbaf2s3LPc/bPQz7qA4BdgweBB /QAZLrbPEuh9Q== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 15/26] discord: Add send lore email message functions Date: Sat, 1 Oct 2022 20:03:43 +0700 Message-Id: <20221001130355.784-16-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221001130355.784-1-kiizuha@gnuweeb.org> References: <20221001130355.784-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Add send_text_email() and send_patch_email() in the dscord/gnuweeb/client.py to send the lore email message to the Discord channel. Signed-off-by: Muhammad Rizki --- daemon/dscord/gnuweeb/client.py | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/daemon/dscord/gnuweeb/client.py b/daemon/dscord/gnuweeb/client.py index 02a1ac5..2506ec3 100644 --- a/daemon/dscord/gnuweeb/client.py +++ b/daemon/dscord/gnuweeb/client.py @@ -33,3 +33,45 @@ class GWClient(commands.Bot): name=".gnuweeb.plugins", package="dscord" ) + + + @filters.wait_on_limit + async def send_text_email(self, guild_id: int, chat_id: int, text: str, + reply_to: Union[int, None] = None, url: str = None): + print("[send_text_email]") + channel = self.get_channel(chat_id) + + return await channel.send( + content=text, + reference=discord.MessageReference( + guild_id=guild_id, + channel_id=chat_id, + message_id=reply_to + ) if reply_to else None, + view=models.FullMessageBtn(url) + ) + + + @filters.wait_on_limit + async def send_patch_email(self, mail, guild_id: int, chat_id: int, text: str, + reply_to: Union[int, None] = None, url: str = None): + print("[send_patch_email]") + tmp, doc, caption, url = utils.prepare_patch( + mail, text, url, "discord" + ) + channel = self.get_channel(chat_id) + + m = await channel.send( + content=caption, + file=discord.File(doc), + reference=discord.MessageReference( + guild_id=guild_id, + channel_id=chat_id, + message_id=reply_to + ) if reply_to else None, + + view=models.FullMessageBtn(url) + ) + + utils.remove_patch(tmp) + return m -- Muhammad Rizki