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 2E15180D2E; Sun, 11 Sep 2022 10:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1662892440; bh=f0/Gmjb7FpYFaA/9TeJ05eWFEUWEzSi1kF0jgZe3JSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ooo6aAiUtM9GGoK/GBdGFYtp5TJ6QFRVrmmgyUyuJEYrV227qYO2bSIaDj3xgSwLN lV+LMUGbObfhpd3pbEu+AwuGj891Px4PM4zfr3kiC+Hm47VycXUbool2dF05Ibkh7q 35mMYWpXFsArvsRFuejrnyzl9LAQM2wDw++JvCCZ6RRLVts0skaJyp8sVqGMtbVKC3 95BHiLpIC9Du5r+ZmM90uhf1ZKD1wPVobURQawbAJUe2py+NwZ18w90ntzmlzYQiar +XaAVwRgsL5JR8CBNuZ8UkegcRzYnYFIdBmFKMMEgloSsE1DHTzf8KuZZKpdIdYAzs ZkwaM6JK2uC0Q== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [RFC PATCH v1 08/17] [discord] Initial work Discord bot Date: Sun, 11 Sep 2022 17:33:14 +0700 Message-Id: <20220911103323.1949-9-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220911103323.1949-1-kiizuha@gnuweeb.org> References: <20220911103323.1949-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 --- daemon/dc.py | 20 ++++++++++++++++ daemon/discord.env.example | 11 +++++++++ daemon/dscord/config.py | 8 +++++++ 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, 97 insertions(+) create mode 100644 daemon/dc.py create mode 100644 daemon/discord.env.example create mode 100644 daemon/dscord/config.py 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/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 b/daemon/dscord/config.py new file mode 100644 index 0000000..86115c2 --- /dev/null +++ b/daemon/dscord/config.py @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2022 Muhammad Rizki +# + +# Role: Lore Admin +ADMIN_ROLE_ID = 1008478246540693526 +ACTIVITY_NAME = "with Columbina Damselette" 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