19
19
import ongaku
20
20
from ongaku .ext import checker
21
21
22
- if not os .path .isfile ('dectalk/Lavalink.jar' ):
22
+ if not os .path .isfile ('dectalk/Lavalink.jar' ) or \
23
+ not os .path .isfile ('dectalk/dectalk/say' ):
23
24
raise Exception ('Unable to find required dectalk files' )
24
25
25
26
plugin = crescent .Plugin [hikari .GatewayBot , BotData ]()
@@ -42,6 +43,14 @@ def start_lavalink():
42
43
)
43
44
44
45
46
+ def run_dectalk (text : str , guild_id : hikari .Snowflake ) -> str :
47
+ name = f'{ guild_id } .wav'
48
+ subprocess .run (
49
+ ['dectalk/dectalk/say' , '-a' , text , '-fo' , f'dectalk/{ name } ' ]
50
+ )
51
+ return name
52
+
53
+
45
54
async def fetch_player (guild_id : hikari .Snowflake ) -> ongaku .Player | None :
46
55
"""Return a functional ongaku player object."""
47
56
# TODO: Figure out why player.connect fails with SessionStartException
@@ -88,7 +97,7 @@ class DecTalkCommand:
88
97
Implemented by something sensible(somethingsensible).
89
98
"""
90
99
91
- # text = crescent.option(str, 'Text to speak')
100
+ text = crescent .option (str , 'Text to speak' )
92
101
channel = crescent .option (
93
102
hikari .GuildVoiceChannel , 'Channel to speak in' , default = None
94
103
)
@@ -97,6 +106,8 @@ async def callback(self, ctx: crescent.Context) -> None:
97
106
"""Handle dectalk command being run."""
98
107
sent_message = False
99
108
109
+ wav_name = run_dectalk (self .text , ctx .guild_id )
110
+
100
111
if self .channel is None :
101
112
voice_state = ctx .client .app .cache .get_voice_state (
102
113
ctx .guild_id , ctx .user .id
@@ -153,7 +164,7 @@ async def callback(self, ctx: crescent.Context) -> None:
153
164
first_call = False
154
165
155
166
# TODO: Check if this is needed?
156
- checked_query = await checker .check ('test.wav' )
167
+ checked_query = await checker .check (wav_name )
157
168
if checked_query .type != checker .CheckedType .QUERY :
158
169
await ctx .respond (
159
170
'Failed to look for dectalk matches' , ephemeral = True
0 commit comments