Receiving shoutbox events¶
It is possible to receive events on a shoutbox channel, by:
Initalizing a client with user credentials, see Initializing the client for more information;
Getting the channel from which to receive events using
Shout.get_channel()
;Iterating over the obtained
Channel
instance to obtainEvent
instances.
For example, if we only want to read messages:
from planetcasio.client import Client
from planetcasio.shout import MessagePosted
async with Client(auth=("<username>", "<password>")) as client:
channel = await client.shout.get_channel("hs", format="bbcode")
async for event in channel:
if isinstance(event, MessagePosted):
print(f"{event.username}: {event.content}")