File size: 804 Bytes
f71fc0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
import socketio
import time

TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjIsInVzZXJuYW1lIjoia2JqIiwiaWF0IjoxNzgzMTg1Nzk2LCJleHAiOjE3ODU3Nzc3OTZ9.3-Zn7DXTnyrR37sJOjXZig_gQihqAwgH0o-Rwtd0HN0"
BASE_URL = "https://Brighton233j-Messenger-back-database.hf.space"
GROUP_ID = 2

sio = socketio.Client()

@sio.event
def connect():
    print("Connected as kbj! Sending to group...")
    sio.emit("send_group_message", {
        "token": TOKEN,
        "group_id": GROUP_ID,
        "content": "Hey group, testing this out — @joy say hi!"
    })

@sio.on("new_group_message")
def on_group_message(data):
    print(f"[GROUP] sender_id={data['sender_id']}: {data['content']}")

sio.connect(f"{BASE_URL}?token={TOKEN}", socketio_path="/socket.io", transports=["websocket"])
time.sleep(6)
sio.disconnect()