chatServer/modules/-[example modules]/parrot text server/module.py

22 lines
621 B
Python
Raw Normal View History

2021-04-09 13:16:29 +00:00
global textPreRequest
def textPreRequest(event,self,requestLength):
if requestLength <= 128: return
sendResponse(self.connection,"error: too long".encode("utf-8"))
self.closeThread()
return True
addEventHandler("onPreRequest",textPreRequest)
global textRequest
def textRequest(event,self,requestLength):
data = self.connection.recv(requestLength)
sendResponse(self.connection,data)
text = data.decode("utf-8")
print(":".join(map(str,self.address))+ " > " +text)
if text == "exit":
2021-04-09 14:42:52 +00:00
with threadsLock:
global close
close = True
2021-04-09 13:16:29 +00:00
self.closeThread()
return True
addEventHandler("onRequest",textRequest)