A simple Python API for interacting with the Star Sonata game server as a chat client user.
Import and create an instance of the API
from StarSonataAPI import *
from StarSonataAPI.message_types import *
ss = StarSonataAPI()Setup an account instance, provide the username and password you wish to log in as;
account = Account('aUsername', 'aPassword')Setup message handlers for messages you wish to capture, e.g.,;
@ss.on_event(SC_TEXTMESSAGE)
async def text_message(message):
tm = TextMessage()
tm.buf_in(message.payload)
print(f'[{tm.channel_name}] {tm.username}: {tm.message}')message is the raw message sent by the server, generate the correct message object and buf_in to get usable data.
Connect to server and start handling messages by calling run;
ss.run(account)run is async, and can be chucked into an asyncio task list.