Compare commits

..

8 Commits
v0.1 ... main

Author SHA1 Message Date
trueold89 b420578cf5
Update README.md
- Add link to Figma design file
2024-06-07 19:50:38 +03:00
trueold89 5069c7534c
Database bugfix in __bool__ method 2024-06-07 19:19:24 +03:00
trueold89 9e9e508c30
Update /create command
- Deleting and creating a group is now separated into two different functions
- The bot now reports its actions to the chat room
2024-06-07 18:53:50 +03:00
trueold89 d5f378492f
Now before creating a new group, the bot deletes previously created channels 2024-06-07 18:38:24 +03:00
trueold89 a9ce6a60b9
The "/create" commnad is now available in the bot menu 2024-06-07 18:34:11 +03:00
trueold89 9106386211
Remove unused User class 2024-06-04 18:53:02 +03:00
trueold89 51d7b8e505
Update README.md
- Update style
- Fix docker-compose example
- Add GitLab & Discord link
- Add emoji to headers
2024-06-04 18:51:52 +03:00
trueold89 34088a2107
Little bugfix
- Update Dockerfile
- Fix docker-compose.yml
- Fix setup.py
2024-06-03 22:32:41 +03:00
7 changed files with 71 additions and 67 deletions

View File

@ -1,41 +1,37 @@
# HellMBot # HellMBot
### Discord bot that will wake your friends up from full mute by putting them through 9 circles of hell ### Discord bot that will wake your friends up from full mute by putting them through 9 circles of hell 🔥
![](https://cdn.orudo.ru/.work/trueold89/git/hellm/Header.png) ![](https://cdn.orudo.ru/.work/trueold89/git/hellm/Header.svg)
## Source code: ## 🔗 Links:
[<img src="https://cdn.orudo.ru/.work/trueold89/git/hellm/orudo.svg" alt="SVG Image" width="300" height="102" style="padding-right: 10px">](https://git.orudo.ru/trueold89/HellMBot) [<img src="https://cdn.orudo.ru/.work/trueold89/git/hellm/ORUDO.svg" alt="SVG Image" width="300" height="102" style="padding-right: 10px">](https://git.orudo.ru/trueold89/HellMBot)
[<img src="https://cdn.orudo.ru/.work/trueold89/git/hellm/github.svg" alt="SVG Image" width="300" height="102" style="padding-right: 10px">](https://github.com/Trueold89/HellMBot) [<img src="https://cdn.orudo.ru/.work/trueold89/git/hellm/GitHub.svg" alt="SVG Image" width="300" height="102" style="padding-right: 10px">](https://github.com/Trueold89/HellMBot)
[<img src="https://cdn.orudo.ru/.work/trueold89/git/hellm/GitLab.svg" alt="SVG Image" width="300" height="102" style="padding-right: 10px">](https://gitlab.com/Trueold89/hellmbot)
[<img src="https://cdn.orudo.ru/.work/trueold89/git/hellm/Discord.svg" alt="SVG Image" width="300" height="102" style="padding-right: 10px">](https://discord.com/oauth2/authorize?client_id=1247176574969577514)
*** ***
![](https://cdn.orudo.ru/.work/trueold89/git/hellm/example.gif) ## ⁉️ Usage:
*** ![](https://cdn.orudo.ru/.work/trueold89/git/hellm/faq.svg)
## Usage:
![](https://cdn.orudo.ru/.work/trueold89/git/hellm/faq.png)
--- ---
- **Add bot to your server** - **Add bot to your server**
- **Update the bot's permissions to prevent unnecessary people from using its commands (optional)** - **Update the bot's permissions to prevent unnecessary people from using its commands (optional)**
- **Type /create in any text chat you want**
- **Write `/create` in whatever text chat you want** - **Write `/create` in whatever text chat you want**
- **Move any user (or yourself, if you're a masochist) to any of the channels in the group created by bot** - **Move any user (or yourself, if you're a masochist) to any of the channels in the group created by bot**
- **Have fun!** - **Have fun!**
## Deploy: ## 📦 Deploy:
*** ***
### Python venv: ### Python venv:
![](https://cdn.orudo.ru/.work/trueold89/git/hellm/python.png) ![](https://cdn.orudo.ru/.work/trueold89/git/hellm/python.svg)
- **Install python package from [git.orudo.ru](https://git.orudo.ru/trueold89/HellMBot/packages)**: - **Install python package from [git.orudo.ru](https://git.orudo.ru/trueold89/HellMBot/packages)**:
```shell ```shell
@ -83,7 +79,7 @@ heelm
### Docker: ### Docker:
![](https://cdn.orudo.ru/.work/trueold89/git/hellm/docker.png) ![](https://cdn.orudo.ru/.work/trueold89/git/hellm/docker.svg)
- **Pull image from [git.orudo.ru](https://git.orudo.ru/trueold89/HellMBot/packages)**: - **Pull image from [git.orudo.ru](https://git.orudo.ru/trueold89/HellMBot/packages)**:
```shell ```shell
@ -128,7 +124,7 @@ docker run \
```yml ```yml
services: services:
qbitdl_bot: hellm_bot:
image: git.orudo.ru/trueold89/hellmbot:latest image: git.orudo.ru/trueold89/hellmbot:latest
container_name: HellMBot container_name: HellMBot
volumes: volumes:
@ -137,6 +133,8 @@ services:
environment: environment:
BOT_TOKEN: "insertyourbottokenhere" BOT_TOKEN: "insertyourbottokenhere"
CLIENT_ID: "insertyourclientidhere" CLIENT_ID: "insertyourclientidhere"
volumes:
hellm_db:
``` ```
```shell ```shell
@ -145,7 +143,7 @@ docker compose up -d
*** ***
## Available system environment variables ## 📋 Available system environment variables
*** ***
@ -153,3 +151,9 @@ docker compose up -d
- `CLIENT_ID` - **Discord Application ID** *[(How to get)](https://docs.discordadvertising.com/getting-your-application-id)* - `CLIENT_ID` - **Discord Application ID** *[(How to get)](https://docs.discordadvertising.com/getting-your-application-id)*
- `DB_PATH` - **Path to SQLite DataBase file** *(Optional | Highly recommended to change when running bot on Windows systems) (Default Value: "/etc/hellmbot/database.sqlite")* - `DB_PATH` - **Path to SQLite DataBase file** *(Optional | Highly recommended to change when running bot on Windows systems) (Default Value: "/etc/hellmbot/database.sqlite")*
- `CIRCLES_COUNT` - **Number of channels the bot creates when the "/create" command is activated.** *(Optional)* *(Default value: 9)* - `CIRCLES_COUNT` - **Number of channels the bot creates when the "/create" command is activated.** *(Optional)* *(Default value: 9)*
## Other:
**[Design file (Figma Community)](https://www.figma.com/community/file/1380949720890295687/hellm-bot)**
[![](https://i.imgur.com/SFpy2G2.png)](https://www.figma.com/community/file/1380949720890295687/hellm-bot)

View File

@ -1,6 +1,5 @@
FROM alpine:latest FROM python:3.12.3-alpine3.19
RUN apk update && apk add python3 py3-pip
ENV DB_PATH="/etc/hellmbot/database.sqlite" ENV DB_PATH="/etc/hellmbot/database.sqlite"
RUN pip install --extra-index-url https://git.orudo.ru/api/packages/trueold89/pypi/simple/ HellMBot --break-system-packages RUN pip install --extra-index-url https://git.orudo.ru/api/packages/trueold89/pypi/simple/ HellMBot
WORKDIR /etc/hellmbot WORKDIR /etc/hellmbot
ENTRYPOINT ["hellm"] ENTRYPOINT ["hellm"]

View File

@ -1,5 +1,5 @@
services: services:
qbitdl_bot: hellm_bot:
image: git.orudo.ru/trueold89/hellmbot:latest image: git.orudo.ru/trueold89/hellmbot:latest
container_name: HellMBot container_name: HellMBot
volumes: volumes:
@ -8,3 +8,5 @@ services:
environment: environment:
BOT_TOKEN: "insertyourbottokenhere" BOT_TOKEN: "insertyourbottokenhere"
CLIENT_ID: "insertyourclientidhere" CLIENT_ID: "insertyourclientidhere"
volumes:
hellm_db:

View File

@ -2,7 +2,7 @@
from hellmbot.env import ENV from hellmbot.env import ENV
from hellmbot.db import ServersDB from hellmbot.db import ServersDB
from discord import Intents, Member, VoiceState, Permissions from discord import Intents, Member, VoiceState, Permissions, errors
from discord.utils import oauth_url from discord.utils import oauth_url
from discord.ext import commands from discord.ext import commands
@ -39,6 +39,7 @@ async def on_ready() -> None:
""" """
Displays a link to add a bot to the server Displays a link to add a bot to the server
""" """
await bot.tree.sync()
client_id = ENV.CLIENT_ID.fget(None) client_id = ENV.CLIENT_ID.fget(None)
invite = oauth_url(client_id, permissions=Permissions( invite = oauth_url(client_id, permissions=Permissions(
manage_channels=True, manage_channels=True,
@ -47,7 +48,34 @@ async def on_ready() -> None:
print(f"Your bot invite link: {invite}") print(f"Your bot invite link: {invite}")
@bot.command() async def clear_channels(db: ServersDB) -> None:
"""
Clear previously created channels
:param db: Database
"""
channels = db.channels
for channel in channels:
channel = bot.get_channel(channel)
await channel.delete()
db.clear_channels()
async def create_group(server: commands.Context.guild, db: ServersDB) -> None:
"""
Creates a group of voice channels to move the user and adds their id to the database
:param server: Discord server
:param db: Database
"""
circles_count = ENV.CIRCLES_COUNT.fget(None)
group = await server.create_category(f"{circles_count} Circles of Hell")
for circle in range(circles_count):
vc = await server.create_voice_channel(f"{circle + 1} Circle", category=group)
db.add_channel(vc.id, circle + 1)
@bot.hybrid_command(name="create", description="Creates a group of vc to move users")
async def create(ctx: commands.Context) -> None: async def create(ctx: commands.Context) -> None:
""" """
Creates a group of voice channels to move the user and adds their id to the database Creates a group of voice channels to move the user and adds their id to the database
@ -56,13 +84,14 @@ async def create(ctx: commands.Context) -> None:
""" """
server = ctx.guild server = ctx.guild
db = ServersDB(server.id) db = ServersDB(server.id)
circles_count = ENV.CIRCLES_COUNT.fget(None) await ctx.send("Creating group...", ephemeral=True)
group = await server.create_category(f"{circles_count} Circles of Hell") try:
if db: if db:
db.clear_channels() await clear_channels(db)
for circle in range(circles_count): await create_group(server, db)
vc = await server.create_voice_channel(f"{circle + 1} Circle", category=group) await ctx.send("Group was created! HF!", ephemeral=True)
db.add_channel(vc.id, circle + 1) except errors.Any:
await ctx.send("An error occurred!", ephemeral=True)
user_before_channels = {} user_before_channels = {}

View File

@ -140,7 +140,7 @@ class ServersDB(DataBase):
""" """
Checks the existence of the server in the database table Checks the existence of the server in the database table
""" """
lst = self._get(self.TABLE, ["server_id"]) lst = self._get(self.TABLE, ["server_id"], {"server_id": self.server})
if len(lst) > 0: if len(lst) > 0:
return True return True
return False return False

View File

@ -1,29 +0,0 @@
# -*- coding: utf-8 -*-
###################
# Actions on user #
###################
class User(object):
"""
Describes Discord user
Attributes:
- user (int): Discord id
"""
def __init__(self, user_id: int) -> None:
"""
Init Discord user object
:param user_id: user discord id
"""
self.user = user_id
def move_to(self, channel_id: int) -> None: # ToDo
"""
Moves the user to the specified voice channel
:param channel_id: discord id of voice channel
"""
pass

View File

@ -3,15 +3,14 @@ from setuptools import setup
setup( setup(
name="HellMBot", name="HellMBot",
version="0.1", version="0.2",
url="https://git.orudo.ru/trueold89/HellMBot", url="https://git.orudo.ru/trueold89/HellMBot",
author="trueold89", author="trueold89",
author_email="trueold89@orudo.ru", author_email="trueold89@orudo.ru",
description="Discord bot that will wake your friends up from full mute by putting them through 9 circles of hell", description="Discord bot that will wake your friends up from full mute by putting them through 9 circles of hell",
packages=["hellmbot"], packages=["hellmbot"],
long_description=open("README.md").read(),
install_requires=["discord.py"], install_requires=["discord.py"],
entry_points={ entry_points={
"console_scripts": ["hellm = hellmbot.bot:main"] "console_scripts": ["hellm = hellmbot.bot:start"]
} }
) )