10 Commits
v1.6 ... 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
5 changed files with 53 additions and 42 deletions

View File

@@ -1,4 +1,5 @@
# 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.
A specially designed bot for creating private voice channels on your Discord servers.
@@ -40,6 +41,7 @@ Default configuration file is [available here](https://git.end-play.xyz/profitro
- "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]

View File

@@ -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,

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}'
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

View File

@@ -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`\\оступні мови: {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}`.\\об змінити його використовуйте `/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": "Треба бути адміністратором бота щоб зробити це"
}
}

View File

@@ -2,12 +2,12 @@ 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()
@@ -22,7 +22,7 @@ if loadJson("config.json")["owner"] == "SET-OWNER-ID" or loadJson("config.json")
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://git.end-play.xyz/profitroll/YusarinBot/releases/latest")
appendLog(f"Currently using YusarinBot v{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)