-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.py
40 lines (29 loc) · 863 Bytes
/
commands.py
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
30
31
32
33
34
35
36
37
38
39
40
from twisted.protocols import amp
import amptypes
# Exceptions
class LoginError(Exception):
pass
# commands to server side
class Login(amp.Command):
arguments = [("username", amp.String()), ("password", amp.String())]
response = []
errors = {LoginError: "LoginError"}
class SendToAll(amp.Command):
arguments = [("message", amp.String())]
response = []
class SendToUsers(amp.Command):
arguments = [
("message", amp.String()),
("usernames", amptypes.TypedList(amp.String())),
]
response = []
# commands to client side
class Send(amp.Command):
arguments = [("message", amp.String()), ("sender", amp.String())]
response = []
class AddUser(amp.Command):
arguments = [("user", amp.String())]
response = []
class DelUser(amp.Command):
arguments = [("user", amp.String())]
response = []