Messenger_back_database / send_group.py
Nrighton233j
Add stateless JOY endpoint for search summaries — https://huggingface.co/spaces/Brighton233j/Messenger_back_database
f71fc0d
Raw
History Blame Contribute Delete
804 Bytes
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()