From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
Alviro Iskandar Setiawan <[email protected]>,
GNU/Weeb Mailing List <[email protected]>
Subject: [PATCH v2 3/8] discord: Add get lore mail slash command
Date: Thu, 20 Oct 2022 15:38:40 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Add a `/lore {url}` slash command to get the specific lore email message
from the raw atom URL.
Signed-off-by: Muhammad Rizki <[email protected]>
---
.../plugins/slash_commands/__init__.py | 2 +
.../plugins/slash_commands/get_lore_mail.py | 39 +++++++++++++++++++
2 files changed, 41 insertions(+)
create mode 100644 daemon/dscord/gnuweeb/plugins/slash_commands/get_lore_mail.py
diff --git a/daemon/dscord/gnuweeb/plugins/slash_commands/__init__.py b/daemon/dscord/gnuweeb/plugins/slash_commands/__init__.py
index a6d913c..126af45 100644
--- a/daemon/dscord/gnuweeb/plugins/slash_commands/__init__.py
+++ b/daemon/dscord/gnuweeb/plugins/slash_commands/__init__.py
@@ -5,9 +5,11 @@
from .manage_atom import ManageAtomSC
from .manage_broadcast import ManageBroadcastSC
+from .get_lore_mail import GetLoreSC
class SlashCommands(
+ GetLoreSC,
ManageAtomSC,
ManageBroadcastSC
): pass
diff --git a/daemon/dscord/gnuweeb/plugins/slash_commands/get_lore_mail.py b/daemon/dscord/gnuweeb/plugins/slash_commands/get_lore_mail.py
new file mode 100644
index 0000000..2d55d16
--- /dev/null
+++ b/daemon/dscord/gnuweeb/plugins/slash_commands/get_lore_mail.py
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2022 Muhammad Rizki <[email protected]>
+#
+
+import asyncio
+import discord
+from discord.ext import commands
+from discord import Interaction
+from discord import app_commands
+
+from atom import utils
+from atom import Scraper
+
+
+class GetLoreSC(commands.Cog):
+ def __init__(self, bot) -> None:
+ self.bot = bot
+
+
+ @app_commands.command(
+ name="lore",
+ description="Get lore email from raw email URL."
+ )
+ @app_commands.describe(url="Raw lore email URL")
+ async def get_lore(self, i: "Interaction", url: str):
+ s = Scraper()
+ mail = await s.get_email_from_url(url)
+ text, _, is_patch = utils.create_template(mail, "discord")
+
+ if is_patch:
+ m = await self.bot.send_patch_mail_interaction(
+ mail=mail, i=i, text=text, url=url
+ )
+ else:
+ text = "#ml\n" + text
+ m = await self.bot.send_text_mail_interaction(
+ i=i, text=text, url=url
+ )
--
Muhammad Rizki
next prev parent reply other threads:[~2022-10-20 8:39 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 8:38 [PATCH v2 0/8] Fix some bugs and add some features Muhammad Rizki
2022-10-20 8:38 ` [PATCH v2 1/8] discord: Add send_text_mail_interaction() Muhammad Rizki
2022-10-20 8:38 ` [PATCH v2 2/8] discord: Add send_patch_mail_interaction() Muhammad Rizki
2022-10-20 8:38 ` Muhammad Rizki [this message]
2022-10-20 8:38 ` [PATCH v2 4/8] atom: Small change for fix_utf8_char() Muhammad Rizki
2022-10-21 6:53 ` Ammar Faizi
2022-10-21 7:35 ` Muhammad Rizki
2022-10-21 8:25 ` Muhammad Rizki
2022-10-21 8:27 ` Ammar Faizi
2022-10-21 10:44 ` Muhammad Rizki
2022-10-21 10:50 ` Ammar Faizi
2022-10-21 10:52 ` Muhammad Rizki
2022-10-21 10:54 ` Ammar Faizi
2022-10-21 10:55 ` Muhammad Rizki
2022-10-21 10:57 ` Ammar Faizi
2022-10-21 10:58 ` Muhammad Rizki
2022-10-21 10:57 ` Muhammad Rizki
2022-10-21 11:00 ` Ammar Faizi
2022-10-21 11:12 ` Muhammad Rizki
2022-10-20 8:38 ` [PATCH v2 5/8] atom: Improve remove_patch() Muhammad Rizki
2022-10-20 8:38 ` [PATCH v2 6/8] atom: add manage_payload() Muhammad Rizki
2022-10-20 8:38 ` [PATCH v2 7/8] telegram: Fix get lore command Muhammad Rizki
2022-10-20 8:38 ` [PATCH v2 8/8] atom: Improve extract_body() Muhammad Rizki
2022-10-20 14:23 ` [PATCH v2 0/8] Fix some bugs and add some features Ammar Faizi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox