]> nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/commands/Commands.java
Prevent non-admins from sending to announcement groups
[signal-cli] / src / main / java / org / asamk / signal / commands / Commands.java
1 package org.asamk.signal.commands;
2
3 import java.util.HashMap;
4 import java.util.Map;
5 import java.util.TreeMap;
6
7 public class Commands {
8
9 private static final Map<String, Command> commands = new HashMap<>();
10 private static final Map<String, SubparserAttacher> commandSubparserAttacher = new TreeMap<>();
11
12 static {
13 addCommand(new AddDeviceCommand());
14 addCommand(new BlockCommand());
15 addCommand(new DaemonCommand());
16 addCommand(new GetUserStatusCommand());
17 addCommand(new JoinGroupCommand());
18 addCommand(new JsonRpcDispatcherCommand());
19 addCommand(new LinkCommand());
20 addCommand(new ListContactsCommand());
21 addCommand(new ListDevicesCommand());
22 addCommand(new ListGroupsCommand());
23 addCommand(new ListIdentitiesCommand());
24 addCommand(new QuitGroupCommand());
25 addCommand(new ReceiveCommand());
26 addCommand(new RegisterCommand());
27 addCommand(new RemoveDeviceCommand());
28 addCommand(new RemoteDeleteCommand());
29 addCommand(new RemovePinCommand());
30 addCommand(new SendCommand());
31 addCommand(new SendContactsCommand());
32 addCommand(new SendReactionCommand());
33 addCommand(new SendReceiptCommand());
34 addCommand(new SendSyncRequestCommand());
35 addCommand(new SendTypingCommand());
36 addCommand(new SetPinCommand());
37 addCommand(new TrustCommand());
38 addCommand(new UnblockCommand());
39 addCommand(new UnregisterCommand());
40 addCommand(new UpdateAccountCommand());
41 addCommand(new UpdateContactCommand());
42 addCommand(new UpdateGroupCommand());
43 addCommand(new UpdateProfileCommand());
44 addCommand(new UploadStickerPackCommand());
45 addCommand(new VerifyCommand());
46 addCommand(new VersionCommand());
47 }
48
49 public static Map<String, SubparserAttacher> getCommandSubparserAttachers() {
50 return commandSubparserAttacher;
51 }
52
53 public static Command getCommand(String commandKey) {
54 if (!commands.containsKey(commandKey)) {
55 return null;
56 }
57 return commands.get(commandKey);
58 }
59
60 private static void addCommand(Command command) {
61 commands.put(command.getName(), command);
62 if (command instanceof CliCommand) {
63 commandSubparserAttacher.put(command.getName(), ((CliCommand) command)::attachToSubparser);
64 }
65 }
66 }