jackbox.py

An asynchronous Python framework for interacting with Jackbox Games services.

Classes

class jackbox.Client(*, loop=None, **kwargs)

The base client for connection to a Jackbox Party Pack game.

Parameters
  • loop (asyncio.Loop) – The loop to run the client in.

  • client_attrs (dict) – A map of attr: value to add to the jackbox.Client class.

  • context_attrs (dict) – A map of attr: value to add to all jackbox.helpers.Context classes.

logger

The client’s internal logger.

Type

logging.Logger

loop

The loop the client is running in.

Type

asyncio.Loop

add_listener(func, *, name=None)

A non-decorator alternative to listen().

Parameters
  • func – The coroutine function to register.

  • name (Optional[str]) – The name of the event. By default this is the function name.

Example

async def on_customer_blob_changed(ctx, before, after):
    pass

client.add_listener(on_customer_blob_changed)
await cancel_countdown()

This function is a coroutine.

Cancels the game countdown.

await close()

This function is a coroutine.

Closes the websocket connection to the Jackbox Games services server.

await connect(code, name)

This function is a coroutine.

Opens a websocket connection to the Jackbox Games services server and joins a Jackbox Party Pack game room.

Parameters
  • code (str) – The room code.

  • name (str) – The name of your player.

listen(*, name=None)

A decorator that registers a function as an event handler.

The function must be a coroutine function.

Parameters

name (Optional[str]) – The name of the event. By default this is the function name.

Example

@client.listen()
async def on_customer_blob_changed(ctx, before, after):
    print(after.state)

# with a custom function name
@client.listen(name="on_customer_blob_changed")
async def foo(ctx, before, after):
    ...
remove_listener(func, *, name=None)

Removes a specific listener from this client.

Parameters
  • func – The coroutine function to unregister.

  • name (Optional[str]) – The name of the event. By default this is the function name.

await start_countdown()

This function is a coroutine.

Starts the game countdown.

await wait_for(event, *, timeout=None)

This function is a coroutine.

Waits for a specific event. This works as a one-time listener that can be waited upon in other callbacks.

Note

The result of a wait_for() will not contain the context parameter.

Example

before, after = await client.wait_for("room_join")

Other

Still can’t find what you’re looking for?