Skip to content

Commit

Permalink
replace custom emoji with their name
Browse files Browse the repository at this point in the history
  • Loading branch information
mralext20 committed Sep 11, 2023
1 parent 64b20cb commit 59e426e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion alexBot/cogs/voiceTTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from discord import app_commands

from alexBot.classes import googleVoices
from alexBot.database import UserConfig, async_session, select
from alexBot.database import UserConfig, async_session, select, ServerTTSOverride
from alexBot.tools import Cog

log = logging.getLogger(__name__)
Expand All @@ -30,6 +30,8 @@

# regex to remove spoilers
SPOILERREGEX = re.compile(r"\|\|(.*?)\|\|")
# regex to capture custom emojis (<a?:name:id>)
EMOJIREGEX = re.compile(r"<a?:([a-zA-Z0-9_]+):(\d+)>")


@dataclasses.dataclass
Expand Down Expand Up @@ -81,6 +83,7 @@ async def on_message(self, message: discord.Message):
return
content = message.clean_content
content = SPOILERREGEX.sub("", content)
content = EMOJIREGEX.sub(r"\1", content)
if content == "":
return
await self.sendTTS(
Expand Down

0 comments on commit 59e426e

Please sign in to comment.