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 package com.levelonelabs.aimbot.modules;
35
36
37 import java.util.ArrayList;
38 import java.util.StringTokenizer;
39
40 import com.levelonelabs.aim.AIMBuddy;
41 import com.levelonelabs.aimbot.AIMBot;
42 import com.levelonelabs.aimbot.BotModule;
43
44
45 /***
46 * Default module to give non AI responses to non-commands
47 *
48 * @author (matty501 AT yahoo.com)
49 */
50 public class DefaultModule extends BotModule {
51 private static ArrayList services;
52
53 /***
54 * Initialize the service commands.
55 */
56 static {
57
58 services=new ArrayList();
59 services.add("addTerm");
60 }
61
62 /***
63 * Constructor for the Default module
64 *
65 * @param bot
66 */
67 public DefaultModule(AIMBot bot) {
68 super(bot);
69 }
70
71 /***
72 * Gets the services
73 *
74 * @return The services
75 */
76 public ArrayList getServices() {
77 return services;
78 }
79
80
81 /***
82 * Gets the name of the module
83 *
84 * @return The name value
85 */
86 public String getName() {
87 return "Default Module";
88 }
89
90
91 /***
92 * Describes the usage of the module
93 *
94 * @return the usage of the module
95 */
96 public String help() {
97 StringBuffer sb=new StringBuffer();
98 sb.append("Default Module\nThis will output default text if the input \n");
99 sb.append("is not recognized\n");
100 sb.append("<B>addTerm <i>TEXT</i></B> "+
101 "(add possible lines for the module to output) *Admin only*");
102 return sb.toString();
103 }
104
105
106 /***
107 * Responds to an unknown command, or adds a term to respond with
108 *
109 * @param buddy requesting buddy
110 * @param query the message
111 */
112 public void performService(AIMBuddy buddy, String query) {
113 StringTokenizer st=new StringTokenizer(query);
114 String output="";
115
116
117 if(query.toLowerCase().startsWith("addTerm")) {
118 if(!buddy.hasRole(AIMBot.ROLE_ADMINISTRATOR)) {
119 super.sendMessage(buddy, "Sorry, only admins can add terms");
120 return;
121 }
122 if(st.countTokens() < 2) {
123 super.sendMessage(buddy, "ERROR:\n"+help());
124 return;
125 }
126
127 String imcommand=st.nextToken();
128 String term=st.nextToken();
129 while(st.hasMoreTokens()) {
130 term=term+" "+st.nextToken();
131 }
132 super.sendMessage(buddy, "Sorry, this feature hasn't been implemented yet");
133
134 } else {
135 output="Sorry, I don't understand that\n type \"help\" to see available commands";
136 super.sendMessage(buddy, output);
137 }
138 }
139 }