add sendtext command, attach it to the root command.

disable the rt listeners if sendtext command is invoked.
This commit is contained in:
onyx-and-iris 2026-03-01 17:25:01 +00:00
parent dd0d150202
commit 28ec67839a

View File

@ -2,7 +2,7 @@ from dataclasses import dataclass
from typing import Annotated
import vban_cmd
from cyclopts import App, Parameter, config
from cyclopts import App, Argument, Parameter, config
from . import __version__ as version
from . import bus, console, strip
@ -37,15 +37,32 @@ def launcher(
if tokens[0] == '--install-completion':
return command(*bound.args, **bound.kwargs)
disable_rt_listeners = False
if command.__name__ == 'sendtext':
disable_rt_listeners = True
with vban_cmd.api(
vban_config.kind,
ip=vban_config.host,
port=vban_config.port,
streamname=vban_config.streamname,
disable_rt_listeners=disable_rt_listeners,
) as client:
return command(*bound.args, **bound.kwargs, ctx=Context(client=client))
@app.command(name='sendtext')
def sendtext(
text: Annotated[str, Argument()],
/,
*,
ctx: Annotated[Context, Parameter(show=False)] = None,
):
"""Send a text command to the current Voicemeeter/Matrix instance."""
if resp := ctx.client.sendtext(text):
console.out.print(resp)
def run():
try:
app.meta()