Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
79fb14b1bc | |||
0379d99e69 | |||
462f4c7a09 | |||
078eac1446 | |||
6334002068 | |||
ffa3babb45 | |||
fba819ce29 | |||
7ccb674b9f | |||
b6e9f5089c | |||
85480c7658 | |||
|
78a845a99b |
10
README.md
10
README.md
@@ -1,13 +1,14 @@
|
||||
# YusarinBot
|
||||
[](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) [](https://crowdin.com/project/yusarinbot) 
|
||||
|
||||
Simple, easy to set up, yet reliable.
|
||||
A specially designed bot for creating private voice channels on your Discord servers.
|
||||
Installation instructions are listed below. Please, make sure you have installed dependencies before opening issue here.
|
||||
|
||||
> Since version 1.5 only slash commands are supported. If you'd like to use old-fashioned commands and commands prefix feature – consider installing [1.4 version](https://github.com/profitrollgame/YusarinBot/releases/tag/v1.4) which is the last one compatible with those.
|
||||
> Since version 1.5 only slash commands are supported. If you'd like to use old-fashioned commands and commands prefix feature – consider installing [1.4 version](https://git.end-play.xyz/profitroll/YusarinBot/releases/tag/v1.4) which is the last one compatible with those.
|
||||
|
||||
## Installation (Short)
|
||||
1. `git clone https://github.com/profitrollgame/YusarinBot`
|
||||
1. `git clone https://git.end-play.xyz/profitroll/YusarinBot`
|
||||
2. `cd YusarinBot`
|
||||
3. `pip install -r requirements.txt`
|
||||
4. `nano config.json`
|
||||
@@ -15,7 +16,7 @@ Installation instructions are listed below. Please, make sure you have installed
|
||||
|
||||
## Installation (Detailed)
|
||||
1. Download and install Python 3 (3.6+ should be fine)
|
||||
2. Download bot's release: https://github.com/profitrollgame/YusarinBot/releases/latest
|
||||
2. Download bot's release: https://git.end-play.xyz/profitroll/YusarinBot/releases/latest
|
||||
3. Unpack your archive to folder. Name it YusarinBot for example
|
||||
4. Change working directory using `cd YusarinBot` or `cd FolderYouHaveCreated`
|
||||
5. Run `pip install -r requirements.txt` to install dependencies
|
||||
@@ -28,7 +29,7 @@ Installation instructions are listed below. Please, make sure you have installed
|
||||
12. Bot is ready! Run it using `python yusarin.py`
|
||||
|
||||
## Config explanation
|
||||
Default configuration file is [available here](https://github.com/profitrollgame/YusarinBot/blob/main/config.json)
|
||||
Default configuration file is [available here](https://git.end-play.xyz/profitroll/YusarinBot/blob/main/config.json)
|
||||
- "debug" - Option that enables more detailed log messages [Boolean]
|
||||
- "owner" - Discord ID of user who will be able to execute admin commands (`$shutdown` for example) [Integer]
|
||||
- "bot_name" - Name of your bot. Is not used anywhere yet [String]
|
||||
@@ -40,6 +41,7 @@ Default configuration file is [available here](https://github.com/profitrollgame
|
||||
- "color_ok" - HTML color used on command success embed [String]
|
||||
- "color_warn" - HTML color used in all warning embeds [String]
|
||||
- "color_error" - HTML color used on command error embed [String]
|
||||
- "enable_nomic" - Option that allows you to create additional text channel for "nomic" purposes [Boolean]
|
||||
- "bot_site" - http or https link that will be used in help message header [String]
|
||||
- "bot_icon" - http or https link that will be used in help message header's icon [String]
|
||||
- "check_for_updates" - Option that defines whether bot should check for a new version available [Boolean]
|
||||
|
@@ -10,6 +10,7 @@
|
||||
"color_ok": "#226699",
|
||||
"color_warn": "#FFCC4D",
|
||||
"color_error": "#DD2E44",
|
||||
"enable_nomic": false,
|
||||
"bot_site": "https://www.end-play.xyz/yusarin",
|
||||
"bot_icon": "https://www.end-play.xyz/yusarin/logo",
|
||||
"check_for_updates": true,
|
||||
|
43
functions.py
43
functions.py
@@ -61,7 +61,7 @@ def appendLog(message, guild=None, announce=True):
|
||||
message_formatted = f'[{datetime.now().strftime("%d.%m.%Y")}] [{datetime.now().strftime("%H:%M:%S")}] [{guild}] {message}'
|
||||
|
||||
if announce:
|
||||
print(message_formatted)
|
||||
print(message_formatted, flush=True)
|
||||
|
||||
checkSize()
|
||||
|
||||
@@ -216,7 +216,8 @@ async def removeUserVoice(vc):
|
||||
vc_conf = loadJson(vc_file)
|
||||
|
||||
needed_channel = discord.utils.get(vc.guild.channels, id=vc.id)
|
||||
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
|
||||
if loadJson("config.json")["enable_nomic"]:
|
||||
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
|
||||
|
||||
os.remove(vc_file)
|
||||
|
||||
@@ -225,11 +226,13 @@ async def removeUserVoice(vc):
|
||||
appendLog(f"Removed voice channel '{needed_channel}' ({str(needed_channel.id)}) of user with id {str(vc_conf['ownerid'])}", guild=vc.guild)
|
||||
else:
|
||||
appendLog(f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}", guild=vc.guild)
|
||||
await nomic_channel.delete()
|
||||
if debug:
|
||||
appendLog(f"Removed nomic channel {nomic_channel} ({str(nomic_channel.id)}) of channel with id {str(needed_channel.id)}", guild=vc.guild)
|
||||
else:
|
||||
appendLog(f"Removed nomic channel '{nomic_channel}' of channel with id {str(needed_channel.id)}", guild=vc.guild)
|
||||
|
||||
if loadJson("config.json")["enable_nomic"]:
|
||||
await nomic_channel.delete()
|
||||
if debug:
|
||||
appendLog(f"Removed nomic channel {nomic_channel} ({str(nomic_channel.id)}) of channel with id {str(needed_channel.id)}", guild=vc.guild)
|
||||
else:
|
||||
appendLog(f"Removed nomic channel '{nomic_channel}' of channel with id {str(needed_channel.id)}", guild=vc.guild)
|
||||
else:
|
||||
return
|
||||
|
||||
@@ -257,13 +260,14 @@ async def createUserVoice(vc, category, member):
|
||||
vc_file = f"{path}/guilds/{str(created_channel.guild.id)}/channels/{str(created_channel.id)}.json"
|
||||
chan["ownerid"] = member.id
|
||||
saveJson(chan, vc_file)
|
||||
nomic_channel = await vc.guild.create_text_channel(getMsg("name_nomic", vc.guild).format(created_channel.id), category=category, overwrites=overwrites_nomic, topic=getMsg("description_nomic", vc.guild).format(str(created_channel.id)))
|
||||
if debug:
|
||||
appendLog(f"Created nomic channel '{nomic_channel}' ({str(nomic_channel.id)}) for channel '{created_channel}' ({str(created_channel.id)})", guild=vc.guild)
|
||||
else:
|
||||
appendLog(f"Created nomic channel '{nomic_channel}' for channel '{created_channel}'", guild=vc.guild)
|
||||
chan["nomic"] = nomic_channel.id
|
||||
saveJson(chan, vc_file)
|
||||
if loadJson("config.json")["enable_nomic"]:
|
||||
nomic_channel = await vc.guild.create_text_channel(getMsg("name_nomic", vc.guild).format(created_channel.id), category=category, overwrites=overwrites_nomic, topic=getMsg("description_nomic", vc.guild).format(str(created_channel.id)))
|
||||
if debug:
|
||||
appendLog(f"Created nomic channel '{nomic_channel}' ({str(nomic_channel.id)}) for channel '{created_channel}' ({str(created_channel.id)})", guild=vc.guild)
|
||||
else:
|
||||
appendLog(f"Created nomic channel '{nomic_channel}' for channel '{created_channel}'", guild=vc.guild)
|
||||
chan["nomic"] = nomic_channel.id
|
||||
saveJson(chan, vc_file)
|
||||
return created_channel
|
||||
|
||||
def isVoiceOfUser(vc, member):
|
||||
@@ -279,11 +283,12 @@ async def changeNomicPerms(mode, vc, member):
|
||||
global path
|
||||
vc_file = f"{path}/guilds/{str(vc.guild.id)}/channels/{str(vc.id)}.json"
|
||||
vc_conf = loadJson(vc_file)
|
||||
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
|
||||
if mode == "deny":
|
||||
await nomic_channel.set_permissions(member, view_channel=False)
|
||||
else:
|
||||
await nomic_channel.set_permissions(member, view_channel=True)
|
||||
if loadJson("config.json")["enable_nomic"]:
|
||||
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
|
||||
if mode == "deny":
|
||||
await nomic_channel.set_permissions(member, view_channel=False)
|
||||
else:
|
||||
await nomic_channel.set_permissions(member, view_channel=True)
|
||||
|
||||
async def clearTrash(client):
|
||||
global path
|
||||
|
@@ -4,52 +4,52 @@
|
||||
"locale_name": "Українська",
|
||||
"name_voice": "Канал {0}",
|
||||
"name_nomic": "без-мікро-{0}",
|
||||
"description_nomic": "Текстовий канал для комунікації без мікрофона\nID голосової кімнати: {0}",
|
||||
"description_nomic": "Текстовий канал для комунікації без мікрофона\\nID голосової кімнати: {0}",
|
||||
"set_channel_title": "☑ Твірний канал встановлено",
|
||||
"set_channel_description": "Голосовий канал `{0}` був встановлений як твірний.",
|
||||
"set_category_title": "☑ Твірну категорію встановлено",
|
||||
"set_category_description": "Категорія `{0}` була встановлена як твірна.",
|
||||
"set_category_description": "Категорія `{0}` була встановлена як твірна.",
|
||||
"set_locale_title": "☑ Мова бота встановлена",
|
||||
"set_locale_description": "На цьому сервері тепер використовується `{0}`",
|
||||
"reset_channel_title": "☑ Твірний канал скинутий",
|
||||
"reset_channel_description": "Для вибору нового каналу використовуйте `/channel set`",
|
||||
"reset_category_title": "☑ Твірна категорія скинута",
|
||||
"reset_category_description": "Для вибору нової категорії використовуйте `/category set`",
|
||||
"reset_category_title": "☑ Твірну категорію скинуто",
|
||||
"reset_category_description": "Використовуйте `/category set` для вибору нової категорії",
|
||||
"reset_locale_title": "☑ Мова бота скинута",
|
||||
"reset_locale_description": "Тепер використовується стандартна мова `{0}`.\nДля вибору іншого використовуйте `/locale set`",
|
||||
"error_channel_title": "🚫 Помилка установки каналу",
|
||||
"reset_locale_description": "Тепер використовується стандартна мова `{0}`.\\nДля вибору іншого використовуйте `/locale set`",
|
||||
"error_channel_title": "🚫 Помилка встановлення каналу",
|
||||
"error_channel_description": "Правильне використання: `/channel set`",
|
||||
"error_category_title": "🚫 Помилка установки категорії",
|
||||
"error_category_title": "🚫 Помилка налаштування категорії",
|
||||
"error_category_description": "Правильне використання: `/category set`",
|
||||
"error_locale_title": "🚫 Помилка встановлення мови",
|
||||
"error_locale_description": "Правильне використання: `/locale set`\nДоступні мови: {1}",
|
||||
"error_locale_description": "Правильне використання: `/locale set`\\nДоступні мови: {1}",
|
||||
"hint_none_channel_title": "⚠ Твірний канал не заданий",
|
||||
"hint_none_channel_description": "Для правильної роботи робота необхідно задати твірний канал, входячи в який користувач зможе створити свій приватний голосовий канал. Встановіть твірний канал командою `/channel set`",
|
||||
"hint_none_category_title": "⚠ Твірна категорія не задана",
|
||||
"hint_none_category_title": "⚠ Твірна категорія не встановлена",
|
||||
"hint_none_category_description": "Для правильної роботи робота необхідно задати твірну категорію, всередині якої для користувача буде створено його приватний канал. Встановіть твірну категорію командою `/category set`",
|
||||
"hint_none_locale_title": "⚠ Мова бота не задана",
|
||||
"hint_none_locale_description": "На цьому сервері використовується стандартний `{0}`.\nЩоб змінити його використовуйте `/locale set`",
|
||||
"error_text_channel_title": "🚫 Помилка установки каналу",
|
||||
"error_text_channel_description": "Вибраний канал повинен бути голосовим.",
|
||||
"hint_none_locale_title": "⚠ Мова бота не встановлена",
|
||||
"hint_none_locale_description": "На цьому сервері використовується стандартний `{0}`.\\nЩоб змінити його використовуйте `/locale set`",
|
||||
"error_text_channel_title": "🚫 Помилка встановлення каналу",
|
||||
"error_text_channel_description": "Обраний канал має бути голосовим каналом.",
|
||||
"help_title": "Інформація про сервер",
|
||||
"help_title_dm": "Команда бота",
|
||||
"help_server": "Команди повинні виконуватись на сервері",
|
||||
"help_server": "Команди слід запускати на сервері",
|
||||
"help_locale": "ℹ Мова бота на сервері: `{0}`",
|
||||
"help_channel_set": "☑ Твірний канал: `{0}`",
|
||||
"help_channel_none": "⚠ Твірний канал не встановлено",
|
||||
"help_category_set": "☑ Твірна категорія: `{0}`",
|
||||
"help_category_none": "⚠ Твірна категорія не встановлена",
|
||||
"help_cmd_shutdown": "Вимкнути бота",
|
||||
"help_cmd_channel": "Встановити твірний канал\nКанал повинен бути голосовим",
|
||||
"help_cmd_channel": "Встановити твірний канал\\nКанал повинен бути голосовим",
|
||||
"help_cmd_category": "Встановити твірну категорію",
|
||||
"help_cmd_locale": "Змінити мову бота на сервері",
|
||||
"help_notice_id": "Зверніть увагу, що ім'я каналу ≠ ID каналу",
|
||||
"help_notice_id_category": "Зверніть увагу, що ім'я категорії ≠ ID категорії",
|
||||
"forbidden_title": "🚫 Відмовлено у доступі",
|
||||
"forbidden_title": "🚫 Немає прав доступу",
|
||||
"forbidden_description": "Для налаштування приватних каналів потрібно мати право **Адміністратор**",
|
||||
"dm_title": "🚫 Помилка виконання",
|
||||
"dm_description": "Команди можна виконувати лише перебуваючи на сервері",
|
||||
"admin_title": "🚫 Відмовлено в доступі",
|
||||
"admin_title": "🚫 Немає прав доступу",
|
||||
"admin_description": "Треба бути адміністратором бота щоб зробити це"
|
||||
}
|
||||
}
|
21
yusarin.py
21
yusarin.py
@@ -2,29 +2,29 @@ import os
|
||||
import sys
|
||||
import json
|
||||
import shutil
|
||||
import requests
|
||||
import requests # type: ignore
|
||||
import threading
|
||||
|
||||
try:
|
||||
import discord # type: ignore
|
||||
from discord import ApplicationContext, Option, Intents # type: ignore
|
||||
from discord import ApplicationContext, Option, Intents # type: ignore
|
||||
except Exception as exp:
|
||||
print(f"Module py-cord is not installed. Make sure to run 'pip install -r requirements.txt' before first start")
|
||||
sys.exit()
|
||||
|
||||
from functions import *
|
||||
pid = os.getpid()
|
||||
version = 1.5
|
||||
version = 1.6
|
||||
|
||||
if loadJson("config.json")["owner"] == "SET-OWNER-ID" or loadJson("config.json")["bot_token"] == "SET-BOT-TOKEN":
|
||||
print(f"Bot is not correctly configured.\nMake sure you've set up owner id and bot token in {path}/config.json\nLearn more here: https://github.com/profitrollgame/YusarinBot")
|
||||
print(f"Bot is not correctly configured.\nMake sure you've set up owner id and bot token in {path}/config.json\nLearn more here: https://git.end-play.xyz/profitroll/YusarinBot")
|
||||
sys.exit()
|
||||
|
||||
if loadJson("config.json")["check_for_updates"]:
|
||||
try:
|
||||
serv_ver = json.loads(requests.get("https://api.end-play.xyz/version&apikey=publickey&app=yusarinbot").text)["version"]
|
||||
serv_ver = json.loads(requests.get("https://api.end-play.xyz/version?app=yusarinbot&apikey=publickey").text)["version"]
|
||||
if float(serv_ver) > version:
|
||||
appendLog(f"YusarinBot version {serv_ver} is available. Download new version here: https://github.com/profitrollgame/YusarinBot/releases/latest")
|
||||
appendLog(f"YusarinBot version {serv_ver} is available. Download new version here: https://git.end-play.xyz/profitroll/YusarinBot/releases/latest")
|
||||
appendLog(f"Currently using YusarinBot v{str(version)}")
|
||||
except Exception as exp:
|
||||
appendLog(f"Could not get YusarinBot cloud version due to {exp}. Currently using {str(version)}")
|
||||
@@ -83,7 +83,8 @@ async def on_voice_state_update(member, before, after):
|
||||
await removeUserVoice(vc_from)
|
||||
return
|
||||
else:
|
||||
await changeNomicPerms("deny", vc_from, member)
|
||||
if loadJson("config.json")["enable_nomic"]:
|
||||
await changeNomicPerms("deny", vc_from, member)
|
||||
|
||||
# If user joined vc
|
||||
else:
|
||||
@@ -91,9 +92,11 @@ async def on_voice_state_update(member, before, after):
|
||||
if isVoiceOfUser(vc_from, member):
|
||||
await removeUserVoice(vc_from)
|
||||
else:
|
||||
await changeNomicPerms("deny", vc_from, member)
|
||||
if loadJson("config.json")["enable_nomic"]:
|
||||
await changeNomicPerms("deny", vc_from, member)
|
||||
if isUserVoice(vc_to):
|
||||
await changeNomicPerms("allow", vc_to, member)
|
||||
if loadJson("config.json")["enable_nomic"]:
|
||||
await changeNomicPerms("allow", vc_to, member)
|
||||
if vc_to.id == guildConfGet(vc_to.guild, "channel"):
|
||||
if guildConfGet(vc_to.guild, "category") is not None:
|
||||
voice_chan = await createUserVoice(vc_to, discord.utils.get(vc_to.guild.categories, id=guildConfGet(vc_to.guild, "category")), member)
|
||||
|
Reference in New Issue
Block a user