# На модуль распространяется лицензия "GNU General Public License v3.0"
# https://github.com/all-licenses/GNU-General-Public-License-v3.0
# meta developer: @PyModule
# requires: lyricsgenius===3.7.0
from lyricsgenius import Genius
from .. import loader, utils
@loader.tds
class LyricsMod(loader.Module):
"""Модуль для поиска текста песни через Genius API"""
strings = {"name": "Lyrics"}
def __init__(self):
self.config = loader.ModuleConfig(
"GENIUS_TOKEN",
None,
lambda: "Токен для доступа к Genius API. Получите его на https://genius.com/api-clients",
)
def get_genius(self):
token = self.config["GENIUS_TOKEN"]
if not token:
return None
return Genius(token, timeout=10)
@loader.command()
async def lyrics(self, message):
"""[запрос] - Найти текст песни по запросу"""
genius = self.get_genius()
if not genius:
return await message.edit(
".cfg Lyrics, чтобы добавить токен."
)
args = utils.get_args_raw(message)
if not args:
return await message.edit("
{lyrics}" ) except Exception as e: await message.edit(f"Ошибка: {str(e)}")