GNU/Weeb Mailing List <[email protected]>
 help / color / mirror / Atom feed
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: [RFC PATCH v2 08/17] discord: Initial work Discord bot
Date: Tue, 13 Sep 2022 17:24:49 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Just initialize Discord bot, the feature is not available yet, only
running the bot and has game activity.

Signed-off-by: Muhammad Rizki <[email protected]>
---
 .gitignore                                |  1 +
 daemon/dc.py                              | 20 ++++++++++++++++
 daemon/discord.env.example                | 11 +++++++++
 daemon/dscord/config.py.example           | 13 +++++++++++
 daemon/dscord/gnuweeb/__init__.py         |  6 +++++
 daemon/dscord/gnuweeb/client.py           | 28 +++++++++++++++++++++++
 daemon/dscord/gnuweeb/plugins/__init__.py | 11 +++++++++
 7 files changed, 90 insertions(+)
 create mode 100644 daemon/dc.py
 create mode 100644 daemon/discord.env.example
 create mode 100644 daemon/dscord/config.py.example
 create mode 100644 daemon/dscord/gnuweeb/__init__.py
 create mode 100644 daemon/dscord/gnuweeb/client.py
 create mode 100644 daemon/dscord/gnuweeb/plugins/__init__.py

diff --git a/.gitignore b/.gitignore
index e77815f..ad5ade0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -142,3 +142,4 @@ data.json
 # configuration file
 daemon/*.env
 daemon/telegram/config.py
+daemon/dscord/config.py
diff --git a/daemon/dc.py b/daemon/dc.py
new file mode 100644
index 0000000..ff29abe
--- /dev/null
+++ b/daemon/dc.py
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2022  Muhammad Rizki <[email protected]>
+#
+
+import os
+from dotenv import load_dotenv
+
+from dscord.gnuweeb import GWClient
+
+
+def main():
+	load_dotenv("discord.env")
+
+	client = GWClient()
+	client.run(os.getenv("DISCORD_TOKEN"), log_handler=None)
+
+
+if __name__ == "__main__":
+	main()
diff --git a/daemon/discord.env.example b/daemon/discord.env.example
new file mode 100644
index 0000000..60fcfac
--- /dev/null
+++ b/daemon/discord.env.example
@@ -0,0 +1,11 @@
+# Input your Discord bot token below
+DISCORD_TOKEN=
+
+# Input your MySQL connection below
+DB_HOST=
+DB_USER=
+DB_PASS=
+DB_NAME=
+
+# Storage directory to save patch files
+STORAGE_DIR=
diff --git a/daemon/dscord/config.py.example b/daemon/dscord/config.py.example
new file mode 100644
index 0000000..87eca75
--- /dev/null
+++ b/daemon/dscord/config.py.example
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2022  Muhammad Rizki <[email protected]>
+#
+
+# Paste the admin role ID below
+# to filter only admin who can
+# access add/delete lore commands.
+ADMIN_ROLE_ID = 
+
+# The activity name like "Playing Genshin Impact"
+# you set the value as "Genshin Impact"
+ACTIVITY_NAME = 
diff --git a/daemon/dscord/gnuweeb/__init__.py b/daemon/dscord/gnuweeb/__init__.py
new file mode 100644
index 0000000..f3d814a
--- /dev/null
+++ b/daemon/dscord/gnuweeb/__init__.py
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2022  Muhammad Rizki <[email protected]>
+#
+
+from .client import GWClient
diff --git a/daemon/dscord/gnuweeb/client.py b/daemon/dscord/gnuweeb/client.py
new file mode 100644
index 0000000..fa07fb1
--- /dev/null
+++ b/daemon/dscord/gnuweeb/client.py
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2022  Muhammad Rizki <[email protected]>
+#
+
+import discord
+from discord.ext import commands
+from discord import Intents
+from dscord.config import ACTIVITY_NAME
+
+
+class GWClient(commands.Bot):
+	def __init__(self) -> None:
+		intents = Intents.default()
+		intents.message_content = True
+		super().__init__(
+			command_prefix=["$", "."],
+			description="Just a bot for receiving lore emails.",
+			intents=intents,
+			activity=discord.Game(ACTIVITY_NAME)
+		)
+
+
+	async def setup_hook(self):
+		await self.load_extension(
+			name=".gnuweeb.plugins",
+			package="dscord"
+		)
diff --git a/daemon/dscord/gnuweeb/plugins/__init__.py b/daemon/dscord/gnuweeb/plugins/__init__.py
new file mode 100644
index 0000000..b9a7e37
--- /dev/null
+++ b/daemon/dscord/gnuweeb/plugins/__init__.py
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2022  Muhammad Rizki <[email protected]>
+#
+
+
+from discord.ext import commands
+
+
+async def setup(bot: "commands.Bot"):
+	pass
-- 
Muhammad Rizki


  parent reply	other threads:[~2022-09-13 10:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 10:24 [RFC PATCH v2 00/17] Refactor Telegram & initial work Discord Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 01/17] telegram: Move the Telegram bot source code Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 02/17] telegram: Refactor Telegram bot database method Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 03/17] telegram: Renaming some functions in scraper/bot.py Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 04/17] Add ignore file for .env Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 05/17] telegram: Refactor the Telegram bot Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 06/17] telegram: Renames in telegram mailer directory Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 07/17] Move scraper and utility file Muhammad Rizki
2022-09-17 17:14   ` Ammar Faizi
2022-09-17 17:16     ` Muhammad Rizki
2022-09-13 10:24 ` Muhammad Rizki [this message]
2022-09-13 10:24 ` [RFC PATCH v2 09/17] discord: Add success run notice on_ready event Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 10/17] discord: Add error handler on events Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 11/17] Move db.sql to combine database with Discord and Telegram Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 12/17] discord: Add database tables for Discord bot Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 13/17] discord: Add initial Discord bot database instance Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 14/17] discord: Add save_atom() in database insertion Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 15/17] discord: Add save_broadcast() " Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 16/17] discord: Add save_discord_mail() " Muhammad Rizki
2022-09-13 10:24 ` [RFC PATCH v2 17/17] discord: Add save_email() " Muhammad Rizki
2022-09-17 17:08 ` [RFC PATCH v2 00/17] Refactor Telegram & initial work Discord Ammar Faizi
2022-09-17 17:16   ` Muhammad Rizki

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