mirror of
https://github.com/nova-r/fediplug.git
synced 2025-03-10 07:39:00 +01:00
add cli websocket parameter (#27)
Co-authored-by: Mæve Rey <42996147M-rey@users.noreply.github.com>
This commit is contained in:
parent
d2910785ed
commit
72f424e9b8
2 changed files with 7 additions and 4 deletions
|
@ -11,10 +11,10 @@ from fediplug.cli import options
|
|||
from typing import Tuple
|
||||
|
||||
|
||||
async def connect_plug_client() -> Client:
|
||||
async def connect_plug_client(websocket_url: str = "127.0.0.1:12345") -> Client:
|
||||
"""create Client object and connect plug client to Intiface Central or similar"""
|
||||
plug_client = Client("fediplug", ProtocolSpec.v3)
|
||||
connector = WebsocketConnector("ws://127.0.0.1:12345", logger=plug_client.logger)
|
||||
connector = WebsocketConnector(f"ws://{websocket_url}", logger=plug_client.logger)
|
||||
|
||||
try:
|
||||
await plug_client.connect(connector)
|
||||
|
|
|
@ -88,13 +88,16 @@ def login(instance: str) -> None:
|
|||
|
||||
|
||||
@cli.command()
|
||||
@click.option("-w", "--websocket", help="Pass an alternative websocket.")
|
||||
@click.argument("instance")
|
||||
@click.argument("users", nargs=-1)
|
||||
def stream(instance: str, users: Tuple[str]):
|
||||
def stream(instance: str, users: Tuple[str], websocket: str):
|
||||
"""Control buttplug.io device from your timeline."""
|
||||
|
||||
event_loop = asyncio.get_event_loop()
|
||||
plug_client = event_loop.run_until_complete(buttplugio.connect_plug_client())
|
||||
plug_client = event_loop.run_until_complete(
|
||||
buttplugio.connect_plug_client(websocket)
|
||||
)
|
||||
plug_client = event_loop.run_until_complete(buttplugio.scan_devices(plug_client))
|
||||
|
||||
client_id, client_secret = get_client_credentials(instance)
|
||||
|
|
Loading…
Reference in a new issue