29 lines
776 B
Python
29 lines
776 B
Python
moduleDepends([
|
|
p("[text server]","[api]","commands"),
|
|
])
|
|
|
|
global textSend
|
|
def textSend(self,command,args):
|
|
if len(args) < 2:
|
|
return ["error","nonfatal","syntax","Correct syntax: " +command+ ",<user>,<command>,[argument 1],[argument 2],..."]
|
|
|
|
user = args[0].lower()
|
|
if len(user) < 1:
|
|
return ["error","nonfatal","name_too_short","Needs to be at least 1 character in length."]
|
|
|
|
me = ""
|
|
with self.lock:
|
|
me = self.user
|
|
|
|
if not me:
|
|
return ["error","nonfatal","not_logged_in"]
|
|
|
|
with threadsLock:
|
|
for threadId in threads:
|
|
thread = threads[threadId]
|
|
with thread.lock:
|
|
if thread.user != user: continue
|
|
thread.sendResponse(textListToCommand(["send",me] + args[1:]).encode("utf-8"),lock = False)
|
|
|
|
return ["ok"]
|
|
textCommandAddHandler("send",textSend) |