24 lines
712 B
Python
24 lines
712 B
Python
from TikTokLive import TikTokLiveClient
|
|
from TikTokLive.events import ConnectEvent, CommentEvent
|
|
|
|
# Create the client
|
|
client: TikTokLiveClient = TikTokLiveClient(unique_id="@isaackogz")
|
|
|
|
|
|
# Listen to an event with a decorator!
|
|
@client.on(ConnectEvent)
|
|
async def on_connect(event: ConnectEvent):
|
|
print(f"Connected to @{event.unique_id} (Room ID: {client.room_id}")
|
|
|
|
|
|
# Or, add it manually via "client.add_listener()"
|
|
async def on_comment(event: CommentEvent) -> None:
|
|
print(f"{event.user.nickname} -> {event.comment}")
|
|
|
|
|
|
client.add_listener(CommentEvent, on_comment)
|
|
|
|
if __name__ == '__main__':
|
|
# Run the client and block the main thread
|
|
# await client.start() to run non-blocking
|
|
client.run() |