Messenger_back_database / send_to_testuser.py
Nrighton233j
Add stateless JOY endpoint for search summaries — https://huggingface.co/spaces/Brighton233j/Messenger_back_database
f71fc0d
Raw
History Blame Contribute Delete
907 Bytes
import socketio
import time
TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjIsInVzZXJuYW1lIjoia2JqIiwiaWF0IjoxNzgzMTg1Nzk2LCJleHAiOjE3ODU3Nzc3OTZ9.3-Zn7DXTnyrR37sJOjXZig_gQihqAwgH0o-Rwtd0HN0"
BASE_URL = "https://Brighton233j-Messenger-back-database.hf.space"
sio = socketio.Client()
@sio.event
def connect():
print("Connected as kbj! Sending message to testuser...")
sio.emit("send_message", {
"token": TOKEN,
"recipient_id": 1,
"content": "Hey testuser, this is kbj — friend request test message!"
})
@sio.on("new_message")
def on_message(data):
print(f"[msg] sender_id={data['sender_id']} -> recipient_id={data['recipient_id']}: {data['content']}")
@sio.event
def connect_error(data):
print("Connection failed:", data)
sio.connect(f"{BASE_URL}?token={TOKEN}", socketio_path="/socket.io", transports=["websocket"])
time.sleep(4)
sio.disconnect()