Compare commits

..

No commits in common. "main" and "v0.1" have entirely different histories.
main ... v0.1

7 changed files with 67 additions and 71 deletions

View File

@ -1,37 +1,41 @@
# 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.svg) ![](https://cdn.orudo.ru/.work/trueold89/git/hellm/Header.png)
## 🔗 Links: ## Source code:
[<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)
*** ***
## ⁉️ Usage: ![](https://cdn.orudo.ru/.work/trueold89/git/hellm/example.gif)
![](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.svg) ![](https://cdn.orudo.ru/.work/trueold89/git/hellm/python.png)
- **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
@ -79,7 +83,7 @@ heelm
### Docker: ### Docker:
![](https://cdn.orudo.ru/.work/trueold89/git/hellm/docker.svg) ![](https://cdn.orudo.ru/.work/trueold89/git/hellm/docker.png)
- **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
@ -124,7 +128,7 @@ docker run \
```yml ```yml
services: services:
hellm_bot: qbitdl_bot:
image: git.orudo.ru/trueold89/hellmbot:latest image: git.orudo.ru/trueold89/hellmbot:latest
container_name: HellMBot container_name: HellMBot
volumes: volumes:
@ -133,8 +137,6 @@ services:
environment: environment:
BOT_TOKEN: "insertyourbottokenhere" BOT_TOKEN: "insertyourbottokenhere"
CLIENT_ID: "insertyourclientidhere" CLIENT_ID: "insertyourclientidhere"
volumes:
hellm_db:
``` ```
```shell ```shell
@ -143,7 +145,7 @@ docker compose up -d
*** ***
## 📋 Available system environment variables ## Available system environment variables
*** ***
@ -151,9 +153,3 @@ 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,5 +1,6 @@
FROM python:3.12.3-alpine3.19 FROM alpine:latest
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 RUN pip install --extra-index-url https://git.orudo.ru/api/packages/trueold89/pypi/simple/ HellMBot --break-system-packages
WORKDIR /etc/hellmbot WORKDIR /etc/hellmbot
ENTRYPOINT ["hellm"] ENTRYPOINT ["hellm"]

View File

@ -1,5 +1,5 @@
services: services:
hellm_bot: qbitdl_bot:
image: git.orudo.ru/trueold89/hellmbot:latest image: git.orudo.ru/trueold89/hellmbot:latest
container_name: HellMBot container_name: HellMBot
volumes: volumes:
@ -8,5 +8,3 @@ 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, errors from discord import Intents, Member, VoiceState, Permissions
from discord.utils import oauth_url from discord.utils import oauth_url
from discord.ext import commands from discord.ext import commands
@ -39,7 +39,6 @@ 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,
@ -48,34 +47,7 @@ async def on_ready() -> None:
print(f"Your bot invite link: {invite}") print(f"Your bot invite link: {invite}")
async def clear_channels(db: ServersDB) -> None: @bot.command()
"""
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
@ -84,14 +56,13 @@ async def create(ctx: commands.Context) -> None:
""" """
server = ctx.guild server = ctx.guild
db = ServersDB(server.id) db = ServersDB(server.id)
await ctx.send("Creating group...", ephemeral=True) circles_count = ENV.CIRCLES_COUNT.fget(None)
try: group = await server.create_category(f"{circles_count} Circles of Hell")
if db: if db:
await clear_channels(db) db.clear_channels()
await create_group(server, db) for circle in range(circles_count):
await ctx.send("Group was created! HF!", ephemeral=True) vc = await server.create_voice_channel(f"{circle + 1} Circle", category=group)
except errors.Any: db.add_channel(vc.id, circle + 1)
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"], {"server_id": self.server}) lst = self._get(self.TABLE, ["server_id"])
if len(lst) > 0: if len(lst) > 0:
return True return True
return False return False

29
hellmbot/user.py Normal file
View File

@ -0,0 +1,29 @@
# -*- 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,14 +3,15 @@ from setuptools import setup
setup( setup(
name="HellMBot", name="HellMBot",
version="0.2", version="0.1",
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:start"] "console_scripts": ["hellm = hellmbot.bot:main"]
} }
) )