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 1AE1D80E16; Mon, 19 Sep 2022 07:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1663572438; bh=hc6uRwz7U/v/JAKVCIZBaXxr0ABJ3cgy7y6SbYId5Ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E5qiP7WTjiASjb1GyHy8uNizuMP0M4lK2q73fxILVIOd6JloWvVEUPYAGqxIVvqNx EV6ItBtimeXPwjzCWP/TN+t/dfvNo0TIOsUkYSbpZiRwSOxNaEUJ36K4OlYjPh1ReD bpDJMulIJyPY78DCO60l0FCPPTqNh29YqucfSsFkztmlQBZtmsEG75rJT55TPNlP8c LnhUnq14wy8OkezOLaEAW0QquZxKW88Edf6tIG26XPGR4n3LfW6sndPGGBE44ao/cq ihJkV1TJXNAptVrTEGCPoGV+IUFiEGpCnEbmfRzk0LPTrn/kKIlz0qhEpbk0+/b18D nmpZG4HHnlAXQ== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [RFC PATCH v3 08/17] discord: Initial work Discord bot Date: Mon, 19 Sep 2022 14:26:32 +0700 Message-Id: <20220919072641.996-9-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220919072641.996-1-kiizuha@gnuweeb.org> References: <20220919072641.996-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Just initialize Discord bot, the feature is not available yet, only running the bot and has game activity. Signed-off-by: Muhammad Rizki --- .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 +# + +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 +# + +# 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 +# + +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 +# + +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 +# + + +from discord.ext import commands + + +async def setup(bot: "commands.Bot"): + pass -- Muhammad Rizki