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.217]) by gnuweeb.org (Postfix) with ESMTPSA id 463C57E257; Mon, 3 Oct 2022 23:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664841211; bh=EuBsZjl7AL2KneS7e9pbvH+tVXRMNUjbQ4sQXf0S9+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lUGDmTGNqK+t+nyDjWXea5PhfAOic19T31hHYt2UtmMhqsuu2JMPjwhYC/urZNAok zLMgtX/Z0wcj+zqSl4P11fDJHGFY2Duv4AEiq7ADDCBtqLghg+d1Zck/vCPUKSQehm MAe3QigFIKF08IdvpTsJUvOTV4ybqbV8eARnoboxdbldi4JXCopYaqhW2AuV9OpWOH sPuCKMYxCuIj/e7nKOEzCLb2YroC876VmGx3J8eNwX+MmCwGdkSfqS4SYeZu1uylCv Tcub+3ISdih4Sd48HBqe+jP21vBw9Uru9m3i3KucTvoB3JivrfPvKAGmyX4Jx96/Uz 6ZD6W3dy3bVhA== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 17/28] discord: Add send lore email message functions Date: Tue, 4 Oct 2022 06:52:18 +0700 Message-Id: <20221003235230.1824-18-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221003235230.1824-1-kiizuha@gnuweeb.org> References: <20221003235230.1824-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