-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsend.py
More file actions
31 lines (16 loc) · 727 Bytes
/
send.py
File metadata and controls
31 lines (16 loc) · 727 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
26
27
28
29
import asyncio
from kademlia.network import Server
def send(port, chatname, username, message):
node = Server()
node.listen(port)
loop = asyncio.get_event_loop()
loop.run_until_complete(node.bootstrap([("0.0.0.0", 8468)]))
chat = loop.run_until_complete(node.get(chatname))
loop.run_until_complete(node.set(chatname, str(chat) + "\n" + username + ": " + message + "\n"))
new_chat = loop.run_until_complete(node.get(chatname))
node.stop()
print("************************************************")
print(chatname)
print("************************************************")
print( "\n"+ new_chat + "\n")
print("************************************************")