From 15fe90bb94b9f4246abb1a5230fd48d74e388627 Mon Sep 17 00:00:00 2001 From: "fixebr@gmail.com" Date: Thu, 21 Dec 2023 00:40:15 +0300 Subject: [PATCH] translate ver 0.1 discord.py req update to actual --- app/bot/cogs/app.py | 144 +++++++++++++++---------------- app/bot/helper/confighelper.py | 28 +++--- app/bot/helper/db.py | 38 ++++---- app/bot/helper/jellyfinhelper.py | 12 +-- app/bot/helper/plexhelper.py | 4 +- requirements.txt | 2 +- run.py | 2 +- 7 files changed, 115 insertions(+), 115 deletions(-) diff --git a/app/bot/cogs/app.py b/app/bot/cogs/app.py index 914c849..a30b992 100644 --- a/app/bot/cogs/app.py +++ b/app/bot/cogs/app.py @@ -28,7 +28,7 @@ try: PLEX_TOKEN = config.get(BOT_SECTION, 'plex_token') PLEX_BASE_URL = config.get(BOT_SECTION, 'plex_base_url') except: - print("No Plex auth token details found") + print("Сведения о токене аутентификации Plex не найдены.") plex_token_configured = False # Get Plex config @@ -37,9 +37,9 @@ try: PLEXPASS = config.get(BOT_SECTION, 'plex_pass') PLEX_SERVER_NAME = config.get(BOT_SECTION, 'plex_server_name') except: - print("No Plex login info found") + print("Информация для входа в Plex не найдена") if not plex_token_configured: - print("Could not load plex config") + print("Не удалось загрузить конфигурацию plex") plex_configured = False # Get Plex roles config @@ -108,32 +108,32 @@ try: JELLYFIN_EXTERNAL_URL = JELLYFIN_SERVER_URL except: JELLYFIN_EXTERNAL_URL = JELLYFIN_SERVER_URL - print("Could not get Jellyfin external url. Defaulting to server url.") + print("Не удалось получить внешний URL-адрес Jellyfin. По умолчанию используется URL-адрес сервера.") if USE_PLEX and plex_configured: try: - print("Connecting to Plex......") + print("Подключение к Plex......") if plex_token_configured and PLEX_TOKEN and PLEX_BASE_URL: - print("Using Plex auth token") + print("Использование токена аутентификации Plex") plex = PlexServer(PLEX_BASE_URL, PLEX_TOKEN) else: - print("Using Plex login info") + print("Использование данных для входа в Plex") account = MyPlexAccount(PLEXUSER, PLEXPASS) plex = account.resource(PLEX_SERVER_NAME).connect() # returns a PlexServer instance - print('Logged into plex!') + print('Зашёл в Plex!') except Exception as e: # probably rate limited. - print('Error with plex login. Please check Plex authentication details. If you have restarted the bot multiple times recently, this is most likely due to being ratelimited on the Plex API. Try again in 10 minutes.') + print('Ошибка при входе в plex. Пожалуйста, проверьте данные аутентификации Plex. Если вы в последнее время перезапускали бота несколько раз, скорее всего, это связано с ограничением скорости в Plex API. Повторите попытку через 10 минут.') print(f'Error: {e}') else: - print(f"Plex {'disabled' if not USE_PLEX else 'not configured'}. Skipping Plex login.") + print(f"Plex {'выключен' if not USE_PLEX else 'не настроен'}. Пропуск входа в Plex.") class app(commands.Cog): # App command groups - plex_commands = app_commands.Group(name="plex", description="Membarr Plex commands") - jellyfin_commands = app_commands.Group(name="jellyfin", description="Membarr Jellyfin commands") - membarr_commands = app_commands.Group(name="membarr", description="Membarr general commands") + plex_commands = app_commands.Group(name="plex", description="Команды Membarr Plex") + jellyfin_commands = app_commands.Group(name="jellyfin", description="Команды Membarr Jellyfin") + membarr_commands = app_commands.Group(name="membarr", description="Membarr общие команды") def __init__(self, bot): self.bot = bot @@ -150,14 +150,14 @@ class app(commands.Cog): # TODO: Make these debug statements work. roles are currently empty arrays if no roles assigned. if plex_roles is None: - print('Configure Plex roles to enable auto invite to Plex after a role is assigned.') + print('Настройте роли Plex, чтобы включить автоматическое приглашение в Plex после назначения роли.') if jellyfin_roles is None: - print('Configure Jellyfin roles to enable auto invite to Jellyfin after a role is assigned.') + print('Настройте роли Jellyfin, чтобы включить автоматическое приглашение в Jellyfin после назначения роли.') async def getemail(self, after): email = None - await embedinfo(after,'Welcome To '+ PLEX_SERVER_NAME +'. Please reply with your email to be added to the Plex server!') - await embedinfo(after,'If you do not respond within 24 hours, the request will be cancelled, and the server admin will need to add you manually.') + await embedinfo(after,'Добро пожаловать в '+ PLEX_SERVER_NAME +'. Пожалуйста, ответьте на свой адрес электронной почты, который будет добавлен на сервер Plex!') + await embedinfo(after,'Если вы не ответите в течение 24 часов, запрос будет отменен, и администратору сервера придется добавить вас вручную.') while(email == None): def check(m): return m.author == after and not m.guild @@ -167,18 +167,18 @@ class app(commands.Cog): return str(email.content) else: email = None - message = "The email you provided is invalid, please respond only with the email you used to sign up for Plex." + message = "Указанный вами адрес электронной почты недействителен. В ответе укажите адрес электронной почты, который вы использовали при регистрации в Plex." await embederror(after, message) continue except asyncio.TimeoutError: - message = "Timed out. Please contact the server admin directly." + message = "Время вышло. Пожалуйста, свяжитесь напрямую с администратором сервера." await embederror(after, message) return None async def getusername(self, after): username = None - await embedinfo(after, f"Welcome To Jellyfin! Please reply with your username to be added to the Jellyfin server!") - await embedinfo(after, f"If you do not respond within 24 hours, the request will be cancelled, and the server admin will need to add you manually.") + await embedinfo(after, f"Добро пожаловать в Jellyfin! Пожалуйста, укажите в ответе свое имя пользователя, которое будет добавлено на сервер Jellyfin!") + await embedinfo(after, f"Если вы не ответите в течение 24 часов, запрос будет отменен, и администратору сервера придется добавить вас вручную.") while (username is None): def check(m): return m.author == after and not m.guild @@ -188,16 +188,16 @@ class app(commands.Cog): return str(username.content) else: username = None - message = "This username is already choosen. Please select another username." + message = "Это имя пользователя уже занято. Пожалуйста, выберите другое имя пользователя." await embederror(after, message) continue except asyncio.TimeoutError: - message = "Timed out. Please contact the server admin directly." - print("Jellyfin user prompt timed out") + message = "Время вышло. Пожалуйста, свяжитесь напрямую с администратором сервера." + print("Время ожидания запроса пользователя Jellyfin истекло") await embederror(after, message) return None except Exception as e: - await embederror(after, "Something went wrong. Please try again with another username.") + await embederror(after, "Что-то пошло не так. Пожалуйста, попробуйте еще раз с другим именем пользователя.") print (e) username = None @@ -205,48 +205,48 @@ class app(commands.Cog): async def addtoplex(self, email, response): if(plexhelper.verifyemail(email)): if plexhelper.plexadd(plex,email,Plex_LIBS): - await embedinfo(response, 'This email address has been added to plex') + await embedinfo(response, 'Этот адрес электронной почты был добавлен в plex') return True else: - await embederror(response, 'There was an error adding this email address. Check logs.') + await embederror(response, 'Произошла ошибка при добавлении этого адреса электронной почты. Проверьте журналы.') return False else: - await embederror(response, 'Invalid email.') + await embederror(response, 'Неверный адрес электронной почты.') return False async def removefromplex(self, email, response): if(plexhelper.verifyemail(email)): if plexhelper.plexremove(plex,email): - await embedinfo(response, 'This email address has been removed from plex.') + await embedinfo(response, 'Этот адрес электронной почты был удален из plex.') return True else: - await embederror(response, 'There was an error removing this email address. Check logs.') + await embederror(response, 'Произошла ошибка при удалении этого адреса электронной почты. Проверьте журналы.') return False else: - await embederror(response, 'Invalid email.') + await embederror(response, 'Неверный адрес электронной почты.') return False async def addtojellyfin(self, username, password, response): if not jelly.verify_username(JELLYFIN_SERVER_URL, JELLYFIN_API_KEY, username): - await embederror(response, f'An account with username {username} already exists.') + await embederror(response, f'Учетная запись с именем пользователя {username} уже существует.') return False if jelly.add_user(JELLYFIN_SERVER_URL, JELLYFIN_API_KEY, username, password, jellyfin_libs): return True else: - await embederror(response, 'There was an error adding this user to Jellyfin. Check logs for more info.') + await embederror(response, 'Произошла ошибка при добавлении этого пользователя в Jellyfin. Проверьте журналы для получения дополнительной информации.') return False async def removefromjellyfin(self, username, response): if jelly.verify_username(JELLYFIN_SERVER_URL, JELLYFIN_API_KEY, username): - await embederror(response, f'Could not find account with username {username}.') + await embederror(response, f'Не удалось найти учетную запись с именем пользователя {username}.') return if jelly.remove_user(JELLYFIN_SERVER_URL, JELLYFIN_API_KEY, username): - await embedinfo(response, f'Successfully removed user {username} from Jellyfin.') + await embedinfo(response, f'Пользователь {username} успешно удален из Jellyfin.') return True else: - await embederror(response, f'There was an error removing this user from Jellyfin. Check logs for more info.') + await embederror(response, f'Произошла ошибка при удалении этого пользователя из Jellyfin. Проверьте журналы для получения дополнительной информации.') return False @commands.Cog.listener() @@ -270,13 +270,13 @@ class app(commands.Cog): if role is not None and (role in after.roles and role not in before.roles): email = await self.getemail(after) if email is not None: - await embedinfo(after, "Got it we will be adding your email to plex shortly!") + await embedinfo(after, "Понятно, в ближайшее время мы добавим ваш адрес электронной почты в plex!") if plexhelper.plexadd(plex,email,Plex_LIBS): db.save_user_email(str(after.id), email) await asyncio.sleep(5) - await embedinfo(after, 'You have Been Added To Plex! Login to plex and accept the invite!') + await embedinfo(after, 'Вас добавили в Plex! Войдите в plex и примите приглашение!') else: - await embedinfo(after, 'There was an error adding this email address. Message Server Admin.') + await embedinfo(after, 'Произошла ошибка при добавлении этого адреса электронной почты. Напишите администраторам сервера.') plex_processed = True break @@ -288,14 +288,14 @@ class app(commands.Cog): plexhelper.plexremove(plex,email) deleted = db.remove_email(user_id) if deleted: - print("Removed Plex email {} from db".format(after.name)) + print("Удален адрес электронной почты Plex {} из базы данных.".format(after.name)) #await secure.send(plexname + ' ' + after.mention + ' was removed from plex') else: - print("Cannot remove Plex from this user.") - await embedinfo(after, "You have been removed from Plex") + print("Невозможно удалить Plex у этого пользователя.") + await embedinfo(after, "Вас удалили из Plex") except Exception as e: print(e) - print("{} Cannot remove this user from plex.".format(email)) + print("{} Невозможно удалить этого пользователя из plex.".format(email)) plex_processed = True break if plex_processed: @@ -311,39 +311,39 @@ class app(commands.Cog): # Jellyfin role was added if role is not None and (role in after.roles and role not in before.roles): - print("Jellyfin role added") + print("Добавлена ​​роль Jellyfin") username = await self.getusername(after) - print("Username retrieved from user") + print("Имя пользователя получено от пользователя") if username is not None: - await embedinfo(after, "Got it we will be creating your Jellyfin account shortly!") + await embedinfo(after, "Поодождите, в ближайшее время мы создадим вашу учетную запись Jellyfin!") password = jelly.generate_password(16) if jelly.add_user(JELLYFIN_SERVER_URL, JELLYFIN_API_KEY, username, password, jellyfin_libs): db.save_user_jellyfin(str(after.id), username) await asyncio.sleep(5) - await embedcustom(after, "You have been added to Jellyfin!", {'Username': username, 'Password': f"||{password}||"}) - await embedinfo(after, f"Go to {JELLYFIN_EXTERNAL_URL} to log in!") + await embedcustom(after, "Вы добавлены в Jellyfin!", {'Username': username, 'Password': f"||{password}||"}) + await embedinfo(after, f"Перейдите по адресу {JELLYFIN_EXTERNAL_URL}, чтобы войти!") else: - await embedinfo(after, 'There was an error adding this user to Jellyfin. Message Server Admin.') + await embedinfo(after, 'Произошла ошибка при добавлении этого пользователя в Jellyfin. Напишите администраторам сервера.') jellyfin_processed = True break # Jellyfin role was removed elif role is not None and (role not in after.roles and role in before.roles): - print("Jellyfin role removed") + print("Роль Jellyfin удалена") try: user_id = after.id username = db.get_jellyfin_username(user_id) jelly.remove_user(JELLYFIN_SERVER_URL, JELLYFIN_API_KEY, username) deleted = db.remove_jellyfin(user_id) if deleted: - print("Removed Jellyfin from {}".format(after.name)) + print("Удален Jellyfin из {}".format(after.name)) #await secure.send(plexname + ' ' + after.mention + ' was removed from plex') else: - print("Cannot remove Jellyfin from this user") - await embedinfo(after, "You have been removed from Jellyfin") + print("Невозможно удалить Jellyfin у этого пользователя.") + await embedinfo(after, "Вас удалили из Jellyfin") except Exception as e: print(e) - print("{} Cannot remove this user from Jellyfin.".format(username)) + print("{} Невозможно удалить этого пользователя из Jellyfin.".format(username)) jellyfin_processed = True break if jellyfin_processed: @@ -361,53 +361,53 @@ class app(commands.Cog): deleted = db.delete_user(member.id) if deleted: - print("Removed {} from db because user left discord server.".format(email)) + print("Удален {} из базы данных, поскольку пользователь покинул сервер Discord.".format(email)) @app_commands.checks.has_permissions(administrator=True) - @plex_commands.command(name="invite", description="Invite a user to Plex") + @plex_commands.command(name="invite", description="Пригласить пользователя в Plex") async def plexinvite(self, interaction: discord.Interaction, email: str): await self.addtoplex(email, interaction.response) @app_commands.checks.has_permissions(administrator=True) - @plex_commands.command(name="remove", description="Remove a user from Plex") + @plex_commands.command(name="remove", description="Удаление пользователя из Plex") async def plexremove(self, interaction: discord.Interaction, email: str): await self.removefromplex(email, interaction.response) @app_commands.checks.has_permissions(administrator=True) - @jellyfin_commands.command(name="invite", description="Invite a user to Jellyfin") + @jellyfin_commands.command(name="invite", description="Пригласить пользователя в Jellyfin") async def jellyfininvite(self, interaction: discord.Interaction, username: str): password = jelly.generate_password(16) if await self.addtojellyfin(username, password, interaction.response): - await embedcustom(interaction.response, "Jellyfin user created!", {'Username': username, 'Password': f"||{password}||"}) + await embedcustom(interaction.response, "Пользователь Jellyfin создан!", {'Username': username, 'Password': f"||{password}||"}) @app_commands.checks.has_permissions(administrator=True) - @jellyfin_commands.command(name="remove", description="Remove a user from Jellyfin") + @jellyfin_commands.command(name="remove", description="Удаление пользователя из Jellyfin") async def jellyfinremove(self, interaction: discord.Interaction, username: str): await self.removefromjellyfin(username, interaction.response) @app_commands.checks.has_permissions(administrator=True) - @membarr_commands.command(name="dbadd", description="Add a user to the Membarr database") + @membarr_commands.command(name="dbadd", description="Добавьте пользователя в базу данных Membarr") async def dbadd(self, interaction: discord.Interaction, member: discord.Member, email: str = "", jellyfin_username: str = ""): email = email.strip() jellyfin_username = jellyfin_username.strip() # Check email if provided if email and not plexhelper.verifyemail(email): - await embederror(interaction.response, "Invalid email.") + await embederror(interaction.response, "Неверный адрес электронной почты.") return try: db.save_user_all(str(member.id), email, jellyfin_username) - await embedinfo(interaction.response,'User was added to the database.') + await embedinfo(interaction.response,'Пользователь добавлен в базу данных.') except Exception as e: - await embedinfo(interaction.response, 'There was an error adding this user to database. Check Membarr logs for more info') + await embedinfo(interaction.response, 'Произошла ошибка при добавлении этого пользователя в базу данных. Проверьте журналы Membarr для получения дополнительной информации.') print(e) @app_commands.checks.has_permissions(administrator=True) - @membarr_commands.command(name="dbls", description="View Membarr database") + @membarr_commands.command(name="dbls", description="Посмотреть базу данных Memarr") async def dbls(self, interaction: discord.Interaction): - embed = discord.Embed(title='Membarr Database.') + embed = discord.Embed(title='База данных Memarr.') all = db.read_all() table = texttable.Texttable() table.set_cols_dtype(["t", "t", "t", "t"]) @@ -432,15 +432,15 @@ class app(commands.Cog): f = open("db.txt", "w") f.write(table.draw()) f.close() - await interaction.response.send_message("Database too large! Total: {total}".format(total = total),file=discord.File('db.txt'), ephemeral=True) + await interaction.response.send_message("База данных слишком велика! Итого: {total}".format(total = total),file=discord.File('db.txt'), ephemeral=True) else: await interaction.response.send_message(embed = embed, ephemeral=True) @app_commands.checks.has_permissions(administrator=True) - @membarr_commands.command(name="dbrm", description="Remove user from Membarr database") + @membarr_commands.command(name="dbrm", description="Удалить пользователя из базы данных Membarr") async def dbrm(self, interaction: discord.Interaction, position: int): - embed = discord.Embed(title='Membarr Database.') + embed = discord.Embed(title='База данных Memarr.') all = db.read_all() for index, peoples in enumerate(all): index = index + 1 @@ -461,10 +461,10 @@ class app(commands.Cog): username = discord_user.name deleted = db.delete_user(id) if deleted: - print("Removed {} from db".format(username)) - await embedinfo(interaction.response,"Removed {} from db".format(username)) + print("{} удален из базы данных.".format(username)) + await embedinfo(interaction.response,"{} удален из базы данных.".format(username)) else: - await embederror(interaction.response,"Cannot remove this user from db.") + await embederror(interaction.response,"Невозможно удалить этого пользователя из базы данных.") except Exception as e: print(e) diff --git a/app/bot/helper/confighelper.py b/app/bot/helper/confighelper.py index a939bc5..c28dc5f 100644 --- a/app/bot/helper/confighelper.py +++ b/app/bot/helper/confighelper.py @@ -64,7 +64,7 @@ try: PLEX_TOKEN = config.get(BOT_SECTION, 'plex_token') PLEX_BASE_URL = config.get(BOT_SECTION, 'plex_base_url') except: - print("No Plex auth token details found") + print("Сведения о токене аутентификации Plex не найдены.") plex_token_configured = False # Get Plex config @@ -73,16 +73,16 @@ try: PLEXUSER = config.get(BOT_SECTION, 'plex_user') PLEXPASS = config.get(BOT_SECTION, 'plex_pass') except: - print("No Plex login info found") + print("Информация для входа в Plex не найдена") if not plex_token_configured: - print("Could not load plex config") + print("Не удалось загрузить конфигурацию plex") plex_configured = False # Get Plex roles config try: plex_roles = config.get(BOT_SECTION, 'plex_roles') except: - print("Could not get Plex roles config") + print("Не удалось получить конфигурацию ролей Plex.") plex_roles = None if plex_roles: plex_roles = list(plex_roles.split(',')) @@ -93,7 +93,7 @@ else: try: Plex_LIBS = config.get(BOT_SECTION, 'plex_libs') except: - print("Could not get Plex libs config. Defaulting to all libraries.") + print("Не удалось получить конфигурацию Plex libs. По умолчанию для всех библиотек.") Plex_LIBS = None if Plex_LIBS is None: Plex_LIBS = ["all"] @@ -105,7 +105,7 @@ try: JELLYFIN_SERVER_URL = config.get(BOT_SECTION, 'jellyfin_server_url') JELLYFIN_API_KEY = config.get(BOT_SECTION, "jellyfin_api_key") except: - print("Could not load Jellyfin config") + print("Не удалось загрузить конфигурацию Jellyfin.") jellyfin_configured = False try: @@ -114,13 +114,13 @@ try: JELLYFIN_EXTERNAL_URL = JELLYFIN_SERVER_URL except: JELLYFIN_EXTERNAL_URL = JELLYFIN_SERVER_URL - print("Could not get Jellyfin external url. Defaulting to server url.") + print("Не удалось получить внешний URL-адрес Jellyfin. По умолчанию используется URL-адрес сервера.") # Get Jellyfin roles config try: jellyfin_roles = config.get(BOT_SECTION, 'jellyfin_roles') except: - print("Could not get Jellyfin roles config") + print("Не удалось получить конфигурацию ролей Jellyfin.") jellyfin_roles = None if jellyfin_roles: jellyfin_roles = list(jellyfin_roles.split(',')) @@ -131,7 +131,7 @@ else: try: jellyfin_libs = config.get(BOT_SECTION, 'jellyfin_libs') except: - print("Could not get Jellyfin libs config. Defaulting to all libraries.") + print("Не удалось получить конфигурацию Jellyfin libs. По умолчанию для всех библиотек.") jellyfin_libs = None if jellyfin_libs is None: jellyfin_libs = ["all"] @@ -143,14 +143,14 @@ try: USE_JELLYFIN = config.get(BOT_SECTION, 'jellyfin_enabled') USE_JELLYFIN = USE_JELLYFIN.lower() == "true" except: - print("Could not get Jellyfin enable config. Defaulting to False") + print("Не удалось получить конфигурацию включения Jellyfin. По умолчанию установлено значение False") USE_JELLYFIN = False try: USE_PLEX = config.get(BOT_SECTION, "plex_enabled") USE_PLEX = USE_PLEX.lower() == "true" except: - print("Could not get Plex enable config. Defaulting to False") + print("Не удалось получить конфигурацию включения Plex. По умолчанию установлено значение False") USE_PLEX = False def get_config(): @@ -162,7 +162,7 @@ def get_config(): return config except Exception as e: print(e) - print('error in reading config') + print('ошибка чтения конфига') return None @@ -175,7 +175,7 @@ def change_config(key, value): config.read(CONFIG_PATH) except Exception as e: print(e) - print("Cannot Read config.") + print("Невозможно прочитать конфигурацию.") try: config.set(BOT_SECTION, key, str(value)) @@ -188,4 +188,4 @@ def change_config(key, value): config.write(configfile) except Exception as e: print(e) - print("Cannot write to config.") + print("Не могу записать в конфиг.") diff --git a/app/bot/helper/db.py b/app/bot/helper/db.py index 6610d58..94cb725 100644 --- a/app/bot/helper/db.py +++ b/app/bot/helper/db.py @@ -50,17 +50,17 @@ def save_user_email(username, email): VALUES('{username}', '{email}') """) conn.commit() - print("User added to db.") + print("Пользователь добавлен в базу.") else: - return "Username and email cannot be empty" + return "Имя пользователя и адрес электронной почты не могут быть пустыми." def save_user(username): if username: conn.execute("INSERT INTO clients (discord_username) VALUES ('"+ username +"')") conn.commit() - print("User added to db.") + print("Пользователь добавлен в БД.") else: - return "Username cannot be empty" + return "Имя пользователя не может быть пустым" def save_user_jellyfin(username, jellyfin_username): if username and jellyfin_username: @@ -69,9 +69,9 @@ def save_user_jellyfin(username, jellyfin_username): VALUES('{username}', '{jellyfin_username}') """) conn.commit() - print("User added to db.") + print("Пользователь добавлен в БД.") else: - return "Discord and Jellyfin usernames cannot be empty" + return "Имена пользователей Discord и Jellyfin не могут быть пустыми." def save_user_all(username, email, jellyfin_username): if username and email and jellyfin_username: @@ -80,7 +80,7 @@ def save_user_all(username, email, jellyfin_username): VALUES('{username}', '{email}', '{jellyfin_username}') """) conn.commit() - print("User added to db.") + print("Пользователь добавлен в БД.") elif username and email: save_user_email(username, email) elif username and jellyfin_username: @@ -88,7 +88,7 @@ def save_user_all(username, email, jellyfin_username): elif username: save_user(username) else: - return "Discord username must all be provided" + return "Необходимо указать имя пользователя Discord." def get_useremail(username): if username: @@ -99,11 +99,11 @@ def get_useremail(username): if email: return email else: - return "No email found" + return "Электронная почта не найдена" except: - return "error in fetching from db" + return "ошибка при извлечении из БД" else: - return "username cannot be empty" + return "имя пользователя не может быть пустым" def get_jellyfin_username(username): """ @@ -121,11 +121,11 @@ def get_jellyfin_username(username): if jellyfin_username: return jellyfin_username else: - return "No users found" + return "Пользователи не найдены" except: - return "error in fetching from db" + return "ошибка при извлечении из БД" else: - return "username cannot be empty" + return "имя пользователя не может быть пустым" def remove_email(username): """ @@ -134,10 +134,10 @@ def remove_email(username): if username: conn.execute(f"UPDATE clients SET email = null WHERE discord_username = '{username}'") conn.commit() - print(f"Email removed from user {username} in database") + print(f"Адрес электронной почты удален от пользователя {username} в базе данных.") return True else: - print(f"Username cannot be empty.") + print(f"Имя пользователя не может быть пустым.") return False def remove_jellyfin(username): @@ -147,10 +147,10 @@ def remove_jellyfin(username): if username: conn.execute(f"UPDATE clients SET jellyfin_username = null WHERE discord_username = '{username}'") conn.commit() - print(f"Jellyfin username removed from user {username} in database") + print(f"Имя пользователя Jellyfin удалено из пользователя {username} в базе данных.") return True else: - print(f"Username cannot be empty.") + print(f"Имя пользователя не может быть пустым.") return False @@ -163,7 +163,7 @@ def delete_user(username): except: return False else: - return "username cannot be empty" + return "Имя пользователя не может быть пустым" def read_all(): cur = conn.cursor() diff --git a/app/bot/helper/jellyfinhelper.py b/app/bot/helper/jellyfinhelper.py index e7f7317..71c6fd9 100644 --- a/app/bot/helper/jellyfinhelper.py +++ b/app/bot/helper/jellyfinhelper.py @@ -16,7 +16,7 @@ def add_user(jellyfin_url, jellyfin_api_key, username, password, jellyfin_libs): userId = response.json()["Id"] if response.status_code != 200: - print(f"Error creating new Jellyfin user: {response.text}") + print(f"Ошибка создания нового пользователя Jellyfin: {response.text}") return False # Grant access to User @@ -35,7 +35,7 @@ def add_user(jellyfin_url, jellyfin_api_key, username, password, jellyfin_libs): enabled_folders.append(server_lib['ItemId']) found = True if not found: - print(f"Couldn't find Jellyfin Library: {lib}") + print(f"Не удалось найти библиотеку Jellyfin: {lib}") payload = { "IsAdministrator": False, @@ -84,7 +84,7 @@ def add_user(jellyfin_url, jellyfin_api_key, username, password, jellyfin_libs): if response.status_code == 200 or response.status_code == 204: return True else: - print(f"Error setting user permissions: {response.text}") + print(f"Ошибка установки прав пользователя: {response.text}") except Exception as e: print(e) @@ -119,7 +119,7 @@ def remove_user(jellyfin_url, jellyfin_api_key, jellyfin_username): if userId is None: # User not found - print(f"Error removing user {jellyfin_username} from Jellyfin: Could not find user.") + print(f"Ошибка удаления пользователя {jellyfin_username} из Jellyfin: не удалось найти пользователя.") return False # Delete User @@ -131,7 +131,7 @@ def remove_user(jellyfin_url, jellyfin_api_key, jellyfin_username): if response.status_code == 204 or response.status_code == 200: return True else: - print(f"Error deleting Jellyfin user: {response.text}") + print(f"Ошибка удаления пользователя Jellyfin: {response.text}") except Exception as e: print(e) return False @@ -147,7 +147,7 @@ def get_users(jellyfin_url, jellyfin_api_key): def generate_password(length, lower=True, upper=True, numbers=True, symbols=True): character_list = [] if not (lower or upper or numbers or symbols): - raise ValueError("At least one character type must be provided") + raise ValueError("Должен быть указан хотя бы один тип символов.") if lower: character_list += string.ascii_lowercase diff --git a/app/bot/helper/plexhelper.py b/app/bot/helper/plexhelper.py index 4af3d07..034a6e2 100644 --- a/app/bot/helper/plexhelper.py +++ b/app/bot/helper/plexhelper.py @@ -8,7 +8,7 @@ def plexadd(plex, plexname, Plex_LIBS): plex.myPlexAccount().inviteFriend(user=plexname, server=plex, sections=Plex_LIBS, allowSync=False, allowCameraUpload=False, allowChannels=False, filterMovies=None, filterTelevision=None, filterMusic=None) - print(plexname +' has been added to plex') + print(plexname +' добавлен в plex') return True except Exception as e: print(e) @@ -18,7 +18,7 @@ def plexadd(plex, plexname, Plex_LIBS): def plexremove(plex, plexname): try: plex.myPlexAccount().removeFriend(user=plexname) - print(plexname +' has been removed from plex') + print(plexname +' удалён из plex') return True except Exception as e: print(e) diff --git a/requirements.txt b/requirements.txt index 3141c4b..e5e371f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ PlexAPI==4.13.0 texttable python-dotenv requests -discord.py==2.0.1 +discord.py diff --git a/run.py b/run.py index 0671633..f437d91 100644 --- a/run.py +++ b/run.py @@ -37,7 +37,7 @@ class Bot(commands.Bot): await self.tree.sync(guild=guild) async def on_guild_join(self, guild): - print(f"Вступил в гильдию {guild.name}") + print(f"Зашёл на сервер {guild.name}") print(f"Синхронизация команд с {guild.name}") self.tree.copy_global_to(guild=guild) await self.tree.sync(guild=guild)