MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / TTSPlugin

Class TTSPlugin

tts/tts.ts:136–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134 cmdHandlers = {
135 tts: async (msg: Api.Message) => {
136 const text = (msg.message || "").trim();
137 const parts = text.split(/\s+/).slice(1);
138 const subCmd = parts[0]?.toLowerCase() || "";
139
140 const db = await getDB();
141
142 // 帮助
143 if (!subCmd && !msg.replyTo) {
144 await msg.edit({ text: getHelpText(), parseMode: "html" });
145 return;
146 }
147
148 // 配置
149 if (subCmd === "config") {
150 if (parts.length < 3) {
151 await msg.edit({ text: `❌ 用法: <code>${mainPrefix}tts config &lt;key&gt; &lt;region&gt;</code>`, parseMode: "html" });
152 return;
153 }
154 const [, key, region] = parts;
155 db.data.key = key;
156 db.data.region = region;
157 await db.write();
158
159 // 遮挡 Key 显示
160 const maskedKey = key.length > 8 ? `${key.substring(0, 4)}...${key.substring(key.length - 4)}` : "***";
161 await msg.edit({ text: `✅ 配置已更新\nKey: ${codeTag(maskedKey)}\nRegion: ${codeTag(region)}`, parseMode: "html" });
162 return;
163 }
164
165 // 设置语音
166 if (subCmd === "voice") {
167 if (parts.length < 2) {
168 await msg.edit({ text: `❌ 用法: <code>${mainPrefix}tts voice &lt;VoiceName&gt;</code>`, parseMode: "html" });
169 return;
170 }
171 const voice = parts[1];
172 db.data.voice = voice;
173 await db.write();
174 await msg.edit({ text: `✅ 语音已设置为: ${codeTag(voice)}`, parseMode: "html" });
175 return;
176 }
177
178 // 查看配置
179 if (subCmd === "list") {
180 const { key, region, voice, style, rate } = db.data;
181 const maskedKey = key ? (key.length > 8 ? `${key.substring(0, 4)}...${key.substring(key.length - 4)}` : "***") : "未设置";
182 await msg.edit({
183 text: `📋 <b>当前配置</b>\n\nKey: ${codeTag(maskedKey)}\nRegion: ${codeTag(region)}\nVoice: ${codeTag(voice)}\nStyle: ${codeTag(style || "默认")}\nRate: ${codeTag(rate || "1.0")}`,
184 parseMode: "html"
185 });
186 return;
187 }
188
189 // 设置风格
190 if (subCmd === "style") {
191 const style = parts[1];
192 if (!style) {
193 await msg.edit({ text: `❌ 用法: <code>${mainPrefix}tts style &lt;style&gt;</code> (使用 clear 清除)`, parseMode: "html" });

Callers

nothing calls this directly

Calls 11

escapeSsmlTextFunction · 0.85
writeMethod · 0.80
errorMethod · 0.80
getHelpTextFunction · 0.70
getDBFunction · 0.70
codeTagFunction · 0.70
htmlEscapeFunction · 0.70
deleteCommandMessageFunction · 0.70
cleanTextForTTSFunction · 0.70
editMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected