planetcasio.shout – Shoutbox interactions

planetcasio.shout.Source

Type representing a shoutbox message source.

alias of Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]

pydantic model planetcasio.shout.MessagePosted

Bases: BaseModel

A message was posted by a user.

field at: AwareDatetime [Required]

Date and time at which the message was posted.

field content: str [Required]

Content of the posted message.

field id: int [Required]

Identifier of the posted message.

field source: Source [Required]

Message source, e.g. SHOUTBOX or IRC.

Constraints:
  • min_length = 1

field username: str [Required]

Username of the posted message.

pydantic model planetcasio.shout.MessageDeleted

Bases: BaseModel

A message was deleted by a user.

field at: AwareDatetime [Required]

Date and time at which the message was deleted.

field id: int [Required]

Identifier of the message that has been deleted.

planetcasio.shout.Event

Event emitted on a shoutbox channel.

See Channel for more information.

alias of MessagePosted | MessageDeleted

class planetcasio.shout.Channel(client: BaseClient, name: str, /, *, format: str, default_source: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)])

Bases: Feature

Shoutbox channel.

Iterating over this class yields events occuring in the channel. For example, in order to read messages from the hs channel:

from planetcasio.client import Client
from planetcasio.shout import MessagePosted

async with Client(auth=("myusername", "mypassword")) as client:
    channel = await client.get_channel("hs")
    async for event in channel:
        if isinstance(event, MessagePosted):
            print(f"{event.username}: {event.content}")
async post(message: str, /, *, source: Source | None = None) None

Post a message in the channel.

Parameters:
  • message – Message to post, in BBCode.

  • source – Source to add to the message.

async post_as(message: str, /, *, author: str, source: Source | None = None) None

Post a message as another user in the channel.

This requires elevated privileges, which usually come when logging in as a bot or admin.

Parameters:
  • message – Message to post, in BBCode.

  • author – Username of the author as which to post.

  • source – Source to add to the message.

class planetcasio.shout.Shout(client: BaseClient, /)

Bases: Feature

Shoutbox client.

async get_channel(name: str, /, *, format: Literal['html', 'text', 'bbcode', 'irc'] = 'html', default_source: Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] = 'SHOUTBOX') Channel

Get a channel with a given name.

Parameters:
  • name – Name of the channel to get.

  • format – Format to request for the messages.

  • default_source – Default source to use when posting messages.

Returns:

Channel with the provided name.