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 E7B2C80DCF; Tue, 13 Sep 2022 10:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1663064774; bh=hc6uRwz7U/v/JAKVCIZBaXxr0ABJ3cgy7y6SbYId5Ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XZUzqF8KCY3tMNF/k43VUafoMOf73OrCsGeQ1jro6ADpL+35hZcYP2EHPC73x2pjg vf1w6qvTUWfNuPcdjRPPz6uRWqKXK3uFPzGxtOQTmcZCL0FFDuwuCxguZUmSIUJexO 3qNuxYmN1pRVFXVJpKI9sS1Ac8RltuS/CfDpv37bv9my4XmIUoiuwKlsoOUEhtqwT7 kjrr/WTxAg6i6HGuqYdt2FRREeiVT9K24Tl5S7avfb+aUSYVkbOCD2/0xHgzWT0+r5 NjQYyo1WFSNbs7hWL4/74tcFaHE6be2sWZ5ifz4ZTqRmwvSV3cFP7AdSSi/GRY31Ph +/oyARNUtp3pA== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [RFC PATCH v2 08/17] discord: Initial work Discord bot Date: Tue, 13 Sep 2022 17:24:49 +0700 Message-Id: <20220913102458.615-9-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220913102458.615-1-kiizuha@gnuweeb.org> References: <20220913102458.615-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