forked from wAIfu-DEV/WebsocketCollabClient
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
25 lines (19 loc) · 656 Bytes
/
example.py
File metadata and controls
25 lines (19 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from lib.wcc import WebsocketCollabClient, ProtocolMessage, ProtocolMessageUnknown
WS_URL = "<url>"
USER = "<user>"
PASS = "<pass>"
CHANNEL_ID = "<channel id>"
client = WebsocketCollabClient()
client.connect(
url=WS_URL,
channel_id=CHANNEL_ID,
user=USER,
password=PASS)
def listener_all(msg: ProtocolMessageUnknown):
print("RAW:", msg.to_dict())
def listener_text(msg: ProtocolMessage):
print("RAW:", msg.to_dict())
print(f"From: '{msg.payload.name}' Message: '{msg.payload.content}'")
client.on_all_messages(listener_all)
client.on_text_message(listener_text)
client.send_text("Hilda", "This is a test message", ["all"])