11 Commits
v1.5 ... v1.7

Author SHA1 Message Date
79fb14b1bc Update 1.7 2022-08-03 10:19:17 +02:00
0379d99e69 Update 1.7 2022-08-03 10:11:40 +02:00
462f4c7a09 Update 1.7 2022-08-03 10:11:04 +02:00
078eac1446 Updated version check path 2022-07-22 10:54:57 +03:00
6334002068 Updated repo badges 2022-07-20 22:29:39 +03:00
ffa3babb45 Some minor locale changes 2022-07-20 14:14:58 +03:00
fba819ce29 Update 'locale/uk.json' 2022-07-20 14:14:04 +03:00
7ccb674b9f Update 'locale/uk.json' 2022-07-20 14:06:53 +03:00
b6e9f5089c Changed some small things 2022-07-20 14:06:36 +03:00
85480c7658 Added "localized" badge 2022-07-20 00:25:10 +03:00
Profitroll
78a845a99b Update 1.6 2022-07-15 22:28:01 +02:00
5 changed files with 60 additions and 49 deletions

View File

@@ -1,13 +1,14 @@
# YusarinBot # YusarinBot
[![License: GPL v2](https://img.shields.io/badge/License-GPL_v2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) [![Crowdin](https://badges.crowdin.net/yusarinbot/localized.svg)](https://crowdin.com/project/yusarinbot) ![Discord](https://img.shields.io/discord/940760922346123284)
Simple, easy to set up, yet reliable. Simple, easy to set up, yet reliable.
A specially designed bot for creating private voice channels on your Discord servers. 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. 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) ## Installation (Short)
1. `git clone https://github.com/profitrollgame/YusarinBot` 1. `git clone https://git.end-play.xyz/profitroll/YusarinBot`
2. `cd YusarinBot` 2. `cd YusarinBot`
3. `pip install -r requirements.txt` 3. `pip install -r requirements.txt`
4. `nano config.json` 4. `nano config.json`
@@ -15,7 +16,7 @@ Installation instructions are listed below. Please, make sure you have installed
## Installation (Detailed) ## Installation (Detailed)
1. Download and install Python 3 (3.6+ should be fine) 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 3. Unpack your archive to folder. Name it YusarinBot for example
4. Change working directory using `cd YusarinBot` or `cd FolderYouHaveCreated` 4. Change working directory using `cd YusarinBot` or `cd FolderYouHaveCreated`
5. Run `pip install -r requirements.txt` to install dependencies 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` 12. Bot is ready! Run it using `python yusarin.py`
## Config explanation ## 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] - "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] - "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] - "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_ok" - HTML color used on command success embed [String]
- "color_warn" - HTML color used in all warning embeds [String] - "color_warn" - HTML color used in all warning embeds [String]
- "color_error" - HTML color used on command error embed [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_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] - "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] - "check_for_updates" - Option that defines whether bot should check for a new version available [Boolean]

View File

@@ -10,6 +10,7 @@
"color_ok": "#226699", "color_ok": "#226699",
"color_warn": "#FFCC4D", "color_warn": "#FFCC4D",
"color_error": "#DD2E44", "color_error": "#DD2E44",
"enable_nomic": false,
"bot_site": "https://www.end-play.xyz/yusarin", "bot_site": "https://www.end-play.xyz/yusarin",
"bot_icon": "https://www.end-play.xyz/yusarin/logo", "bot_icon": "https://www.end-play.xyz/yusarin/logo",
"check_for_updates": true, "check_for_updates": true,

View File

@@ -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}' message_formatted = f'[{datetime.now().strftime("%d.%m.%Y")}] [{datetime.now().strftime("%H:%M:%S")}] [{guild}] {message}'
if announce: if announce:
print(message_formatted) print(message_formatted, flush=True)
checkSize() checkSize()
@@ -216,7 +216,8 @@ async def removeUserVoice(vc):
vc_conf = loadJson(vc_file) vc_conf = loadJson(vc_file)
needed_channel = discord.utils.get(vc.guild.channels, id=vc.id) 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) 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) appendLog(f"Removed voice channel '{needed_channel}' ({str(needed_channel.id)}) of user with id {str(vc_conf['ownerid'])}", guild=vc.guild)
else: else:
appendLog(f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}", guild=vc.guild) appendLog(f"Removed voice channel '{needed_channel}' of user with id {str(vc_conf['ownerid'])}", guild=vc.guild)
await nomic_channel.delete()
if debug: if loadJson("config.json")["enable_nomic"]:
appendLog(f"Removed nomic channel {nomic_channel} ({str(nomic_channel.id)}) of channel with id {str(needed_channel.id)}", guild=vc.guild) await nomic_channel.delete()
else: if debug:
appendLog(f"Removed nomic channel '{nomic_channel}' of channel with id {str(needed_channel.id)}", guild=vc.guild) 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: else:
return 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" vc_file = f"{path}/guilds/{str(created_channel.guild.id)}/channels/{str(created_channel.id)}.json"
chan["ownerid"] = member.id chan["ownerid"] = member.id
saveJson(chan, vc_file) 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 loadJson("config.json")["enable_nomic"]:
if debug: 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)))
appendLog(f"Created nomic channel '{nomic_channel}' ({str(nomic_channel.id)}) for channel '{created_channel}' ({str(created_channel.id)})", guild=vc.guild) if debug:
else: appendLog(f"Created nomic channel '{nomic_channel}' ({str(nomic_channel.id)}) for channel '{created_channel}' ({str(created_channel.id)})", guild=vc.guild)
appendLog(f"Created nomic channel '{nomic_channel}' for channel '{created_channel}'", guild=vc.guild) else:
chan["nomic"] = nomic_channel.id appendLog(f"Created nomic channel '{nomic_channel}' for channel '{created_channel}'", guild=vc.guild)
saveJson(chan, vc_file) chan["nomic"] = nomic_channel.id
saveJson(chan, vc_file)
return created_channel return created_channel
def isVoiceOfUser(vc, member): def isVoiceOfUser(vc, member):
@@ -279,11 +283,12 @@ async def changeNomicPerms(mode, vc, member):
global path global path
vc_file = f"{path}/guilds/{str(vc.guild.id)}/channels/{str(vc.id)}.json" vc_file = f"{path}/guilds/{str(vc.guild.id)}/channels/{str(vc.id)}.json"
vc_conf = loadJson(vc_file) vc_conf = loadJson(vc_file)
nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"]) if loadJson("config.json")["enable_nomic"]:
if mode == "deny": nomic_channel = discord.utils.get(vc.guild.channels, id=vc_conf["nomic"])
await nomic_channel.set_permissions(member, view_channel=False) if mode == "deny":
else: await nomic_channel.set_permissions(member, view_channel=False)
await nomic_channel.set_permissions(member, view_channel=True) else:
await nomic_channel.set_permissions(member, view_channel=True)
async def clearTrash(client): async def clearTrash(client):
global path global path

View File

@@ -4,52 +4,52 @@
"locale_name": "Українська", "locale_name": "Українська",
"name_voice": "Канал {0}", "name_voice": "Канал {0}",
"name_nomic": "без-мікро-{0}", "name_nomic": "без-мікро-{0}",
"description_nomic": "Текстовий канал для комунікації без мікрофона\nID голосової кімнати: {0}", "description_nomic": "Текстовий канал для комунікації без мікрофона\\nID голосової кімнати: {0}",
"set_channel_title": "☑ Твірний канал встановлено", "set_channel_title": "☑ Твірний канал встановлено",
"set_channel_description": "Голосовий канал `{0}` був встановлений як твірний.", "set_channel_description": "Голосовий канал `{0}` був встановлений як твірний.",
"set_category_title": "☑ Твірну категорію встановлено", "set_category_title": "☑ Твірну категорію встановлено",
"set_category_description": "Категорія `{0}` була встановлена як твірна.", "set_category_description": "Категорія `{0}` була встановлена як твірна.",
"set_locale_title": "☑ Мова бота встановлена", "set_locale_title": "☑ Мова бота встановлена",
"set_locale_description": "На цьому сервері тепер використовується `{0}`", "set_locale_description": "На цьому сервері тепер використовується `{0}`",
"reset_channel_title": "☑ Твірний канал скинутий", "reset_channel_title": "☑ Твірний канал скинутий",
"reset_channel_description": "Для вибору нового каналу використовуйте `/channel set`", "reset_channel_description": "Для вибору нового каналу використовуйте `/channel set`",
"reset_category_title": "☑ Твірна категорія скинута", "reset_category_title": "☑ Твірну категорію скинуто",
"reset_category_description": "Для вибору нової категорії використовуйте `/category set`", "reset_category_description": "Використовуйте `/category set` для вибору нової категорії",
"reset_locale_title": "☑ Мова бота скинута", "reset_locale_title": "☑ Мова бота скинута",
"reset_locale_description": "Тепер використовується стандартна мова `{0}`.\nДля вибору іншого використовуйте `/locale set`", "reset_locale_description": "Тепер використовується стандартна мова `{0}`.\\nДля вибору іншого використовуйте `/locale set`",
"error_channel_title": "🚫 Помилка установки каналу", "error_channel_title": "🚫 Помилка встановлення каналу",
"error_channel_description": "Правильне використання: `/channel set`", "error_channel_description": "Правильне використання: `/channel set`",
"error_category_title": "🚫 Помилка установки категорії", "error_category_title": "🚫 Помилка налаштування категорії",
"error_category_description": "Правильне використання: `/category set`", "error_category_description": "Правильне використання: `/category set`",
"error_locale_title": "🚫 Помилка встановлення мови", "error_locale_title": "🚫 Помилка встановлення мови",
"error_locale_description": "Правильне використання: `/locale set`\nДоступні мови: {1}", "error_locale_description": "Правильне використання: `/locale set`\\оступні мови: {1}",
"hint_none_channel_title": "⚠ Твірний канал не заданий", "hint_none_channel_title": "⚠ Твірний канал не заданий",
"hint_none_channel_description": "Для правильної роботи робота необхідно задати твірний канал, входячи в який користувач зможе створити свій приватний голосовий канал. Встановіть твірний канал командою `/channel set`", "hint_none_channel_description": "Для правильної роботи робота необхідно задати твірний канал, входячи в який користувач зможе створити свій приватний голосовий канал. Встановіть твірний канал командою `/channel set`",
"hint_none_category_title": "⚠ Твірна категорія не задана", "hint_none_category_title": "⚠ Твірна категорія не встановлена",
"hint_none_category_description": "Для правильної роботи робота необхідно задати твірну категорію, всередині якої для користувача буде створено його приватний канал. Встановіть твірну категорію командою `/category set`", "hint_none_category_description": "Для правильної роботи робота необхідно задати твірну категорію, всередині якої для користувача буде створено його приватний канал. Встановіть твірну категорію командою `/category set`",
"hint_none_locale_title": "⚠ Мова бота не задана", "hint_none_locale_title": "⚠ Мова бота не встановлена",
"hint_none_locale_description": "На цьому сервері використовується стандартний `{0}`.\nЩоб змінити його використовуйте `/locale set`", "hint_none_locale_description": "На цьому сервері використовується стандартний `{0}`.\\об змінити його використовуйте `/locale set`",
"error_text_channel_title": "🚫 Помилка установки каналу", "error_text_channel_title": "🚫 Помилка встановлення каналу",
"error_text_channel_description": "Вибраний канал повинен бути голосовим.", "error_text_channel_description": "Обраний канал має бути голосовим каналом.",
"help_title": "Інформація про сервер", "help_title": "Інформація про сервер",
"help_title_dm": "Команда бота", "help_title_dm": "Команда бота",
"help_server": "Команди повинні виконуватись на сервері", "help_server": "Команди слід запускати на сервері",
"help_locale": " Мова бота на сервері: `{0}`", "help_locale": " Мова бота на сервері: `{0}`",
"help_channel_set": "☑ Твірний канал: `{0}`", "help_channel_set": "☑ Твірний канал: `{0}`",
"help_channel_none": "⚠ Твірний канал не встановлено", "help_channel_none": "⚠ Твірний канал не встановлено",
"help_category_set": "☑ Твірна категорія: `{0}`", "help_category_set": "☑ Твірна категорія: `{0}`",
"help_category_none": "⚠ Твірна категорія не встановлена", "help_category_none": "⚠ Твірна категорія не встановлена",
"help_cmd_shutdown": "Вимкнути бота", "help_cmd_shutdown": "Вимкнути бота",
"help_cmd_channel": "Встановити твірний канал\nКанал повинен бути голосовим", "help_cmd_channel": "Встановити твірний канал\\nКанал повинен бути голосовим",
"help_cmd_category": "Встановити твірну категорію", "help_cmd_category": "Встановити твірну категорію",
"help_cmd_locale": "Змінити мову бота на сервері", "help_cmd_locale": "Змінити мову бота на сервері",
"help_notice_id": "Зверніть увагу, що ім'я каналу ≠ ID каналу", "help_notice_id": "Зверніть увагу, що ім'я каналу ≠ ID каналу",
"help_notice_id_category": "Зверніть увагу, що ім'я категорії ≠ ID категорії", "help_notice_id_category": "Зверніть увагу, що ім'я категорії ≠ ID категорії",
"forbidden_title": "🚫 Відмовлено у доступі", "forbidden_title": "🚫 Немає прав доступу",
"forbidden_description": "Для налаштування приватних каналів потрібно мати право **Адміністратор**", "forbidden_description": "Для налаштування приватних каналів потрібно мати право **Адміністратор**",
"dm_title": "🚫 Помилка виконання", "dm_title": "🚫 Помилка виконання",
"dm_description": "Команди можна виконувати лише перебуваючи на сервері", "dm_description": "Команди можна виконувати лише перебуваючи на сервері",
"admin_title": "🚫 Відмовлено в доступі", "admin_title": "🚫 Немає прав доступу",
"admin_description": "Треба бути адміністратором бота щоб зробити це" "admin_description": "Треба бути адміністратором бота щоб зробити це"
} }
} }

View File

@@ -2,29 +2,29 @@ import os
import sys import sys
import json import json
import shutil import shutil
import requests import requests # type: ignore
import threading import threading
try: try:
import discord # type: ignore import discord # type: ignore
from discord import ApplicationContext, Option, Intents # type: ignore from discord import ApplicationContext, Option, Intents # type: ignore
except Exception as exp: except Exception as exp:
print(f"Module py-cord is not installed. Make sure to run 'pip install -r requirements.txt' before first start") print(f"Module py-cord is not installed. Make sure to run 'pip install -r requirements.txt' before first start")
sys.exit() sys.exit()
from functions import * from functions import *
pid = os.getpid() 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": 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() sys.exit()
if loadJson("config.json")["check_for_updates"]: if loadJson("config.json")["check_for_updates"]:
try: 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: 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)}") appendLog(f"Currently using YusarinBot v{str(version)}")
except Exception as exp: except Exception as exp:
appendLog(f"Could not get YusarinBot cloud version due to {exp}. Currently using {str(version)}") 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) await removeUserVoice(vc_from)
return return
else: else:
await changeNomicPerms("deny", vc_from, member) if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("deny", vc_from, member)
# If user joined vc # If user joined vc
else: else:
@@ -91,9 +92,11 @@ async def on_voice_state_update(member, before, after):
if isVoiceOfUser(vc_from, member): if isVoiceOfUser(vc_from, member):
await removeUserVoice(vc_from) await removeUserVoice(vc_from)
else: else:
await changeNomicPerms("deny", vc_from, member) if loadJson("config.json")["enable_nomic"]:
await changeNomicPerms("deny", vc_from, member)
if isUserVoice(vc_to): 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 vc_to.id == guildConfGet(vc_to.guild, "channel"):
if guildConfGet(vc_to.guild, "category") is not None: 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) voice_chan = await createUserVoice(vc_to, discord.utils.get(vc_to.guild.categories, id=guildConfGet(vc_to.guild, "category")), member)