2024-02-19 18:35:44 -05:00
# _____ _
# / ____| (_)
# | (___ ___ __ _ _____ ___ _ __ ___ _ __ ___ ___ _ __
# \___ \ / _ \/ _` / __\ \ /\ / / | '_ ` _ \| '_ ` _ \ / _ \ '__|
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
import logging
from discord import Message
from redbot . core import Config , commands
from redbot . core . bot import Red
class TTS ( commands . Cog ) :
""" Text to Speech through Pylav """
def __init__ ( self , bot : Red ) :
self . bot = bot
self . logger = logging . getLogger ( " red.sea.tts " )
self . config = Config . get_conf ( self , 69737245070283 , force_registration = True )
self . config . register_global (
use_google_tts = False ,
)
self . config . register_guild (
enabled_channels = [ ] ,
announce = False ,
voice_channels = True
)
async def on_message ( self , message : Message ) :
2024-02-19 18:51:59 -05:00
await self . bot . wait_until_red_ready ( )
2024-02-19 18:35:44 -05:00
if message . author . bot :
return
if message . guild is None :
return
valid_prefixes = await self . bot . get_valid_prefixes ( message . guild )
valid_prefixes . append ( " \\ " )
if any ( message . content . startswith ( prefix ) for prefix in valid_prefixes ) :
return
if message . channel . id in await self . config . guild ( message . guild ) . enabled_channels ( ) :
2024-02-19 18:51:59 -05:00
pylav = self . bot . get_cog ( " PyLavPlayer " )
if pylav is None :
self . logger . error ( " PyLav is not loaded, so TTS is not available. " )
await message . reply ( " PyLav is not loaded, so TTS is not available. \n Please report this to the bot owner. \n If you are the bot owner, see [https://github.com/PyLav/Red-Cogs](PyLav/RedCogs) for more information. " )
return
2024-02-19 18:35:44 -05:00
#TODO - add PyLav integration
return
2024-02-19 18:37:34 -05:00
#TODO - add commands for enabling/disabling channels, setting voice channel settings, and setting global settings