author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Sat, 13 Dec 2008 15:40:28 +0100 | |
changeset 15 | f19c1f9b4cd3 |
parent 14 | fe8adc56b109 |
child 16 | 33245bf7873a |
permissions | -rw-r--r-- |
0 | 1 |
/** |
2 |
* $Id: parse.c 153 2008-04-27 07:26:15Z mbroeker $ |
|
3 |
* $URL: http://localhost/svn/c/mcbot/trunk/src/parse.c $ |
|
4 |
* |
|
5 |
*/ |
|
6 |
||
7 |
#include <stdio.h> |
|
8 |
#include <stdlib.h> |
|
9 |
#include <string.h> |
|
10 |
#include <time.h> |
|
11 |
||
12 |
#include <mcbot.h> |
|
13 |
#include <database.h> |
|
14 |
||
15 |
#include <locale.h> |
|
16 |
#include <libintl.h> |
|
17 |
||
18 |
#ifndef DATABASE_FILE |
|
19 |
#define DATABASE_FILE "/var/lib/nobody/data/mcbot.dat" |
|
20 |
#endif |
|
21 |
||
14
fe8adc56b109
mcbot shows the proper git location for the source...
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
13
diff
changeset
|
22 |
#ifndef SOURCE_URL |
fe8adc56b109
mcbot shows the proper git location for the source...
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
13
diff
changeset
|
23 |
#define SOURCE_URL "http://largo.homelinux.org/cgi-bin/gitweb.cgi?p=net/mcbot.git" |
fe8adc56b109
mcbot shows the proper git location for the source...
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
13
diff
changeset
|
24 |
#endif |
fe8adc56b109
mcbot shows the proper git location for the source...
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
13
diff
changeset
|
25 |
|
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
26 |
#define HELP 0 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
27 |
#define JOIN 1 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
28 |
#define LEAVE 2 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
29 |
#define ADD 3 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
30 |
#define REPLACE 4 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
31 |
#define DELETE 5 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
32 |
#define LIST 6 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
33 |
#define SEARCH 7 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
34 |
#define INFO 8 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
35 |
#define PING 9 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
36 |
#define ON 10 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
37 |
#define OFF 11 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
38 |
#define DEBUG 12 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
39 |
#define VACCUUM 13 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
40 |
#define LOGOUT 14 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
41 |
#define WHO 15 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
42 |
#define WHOIS 16 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
43 |
#define TIME 17 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
44 |
#define TELL 18 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
45 |
#define OP 19 |
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
46 |
|
0 | 47 |
const |
48 |
char *COMMAND_LIST[] = { |
|
49 |
"!help Known Commands: join(1), leave(2), add(3), replace(4), delete(5), list(6), search(7), info(8)\r\n", |
|
50 |
"!join: Joins a new channel\r\n", |
|
51 |
"!leave: Parts from the current channel\r\n", |
|
52 |
"!add: adds an entry\r\n", |
|
53 |
"!replace: replaces an entry\r\n", |
|
54 |
"!delete: deletes an entry\r\n", |
|
55 |
"!list: lists the number of stored values\r\n", |
|
56 |
"!search: searches an entry up\r\n", |
|
57 |
"!info: Prints the current Bot-Version\r\n", |
|
58 |
"!ping: pings an host\r\n", |
|
59 |
"!on: enables autolearning mode\r\n", |
|
60 |
"!off: disables autolearning\r\n", |
|
61 |
"!debug: prints some debug infos\r\n", |
|
62 |
"!vaccuum: reorganizes the database\r\n", |
|
63 |
"!logout: Protected logout function\r\n", |
|
64 |
}; |
|
65 |
||
66 |
const |
|
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
67 |
char VISIBLE_ITEMS = 14; |
0 | 68 |
|
69 |
const |
|
70 |
char *Bot_Commands[] = { |
|
71 |
"!help", "!join", "!leave", |
|
72 |
"!add", "!replace", "!delete", |
|
73 |
"!list", "!search", "!info", |
|
74 |
"!ping", "!on", "!off", |
|
75 |
"!debug", "!vaccuum", "!logout", |
|
76 |
"!who", "!whois", "!time", "!tell", |
|
11
a769385a59c6
Many Memory Leaks in config.c
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
10
diff
changeset
|
77 |
"!op", NULL |
0 | 78 |
}; |
79 |
||
8
3152de03758e
A critical change was introduced here...
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
3
diff
changeset
|
80 |
char *parse (MSG * message) |
0 | 81 |
{ |
82 |
static char msg[513]; |
|
83 |
int cmd = -1; |
|
84 |
int i; |
|
85 |
char *token; |
|
86 |
char *parameters; |
|
87 |
||
88 |
time_t t; |
|
89 |
struct tm *timeptr; |
|
90 |
static int counter = 0; |
|
91 |
||
92 |
/* |
|
93 |
* default message |
|
94 |
*/ |
|
95 |
snprintf (msg, 512, "PRIVMSG %s :%s.\r\n", message->channel, gettext ("Request cannot be performed")); |
|
96 |
||
97 |
/* |
|
98 |
* PRIVATE MESSAGES |
|
99 |
*/ |
|
100 |
if (!strcmp (message->channel, message->nick)) |
|
101 |
message->channel = message->user; |
|
102 |
||
103 |
if (strstr (message->line, message->nick)) { |
|
104 |
if (*message->line != '!') { |
|
105 |
/* |
|
106 |
* DEAD - LOCK - CHECK |
|
107 |
*/ |
|
108 |
if (strcmp (message->user, message->nick)) { |
|
109 |
snprintf (msg, 512, "PRIVMSG %s :%s, %s?\r\n", message->channel, gettext ("What's up"), message->user); |
|
110 |
if (counter++ > 3) |
|
111 |
return NULL; |
|
112 |
return msg; |
|
113 |
} |
|
114 |
/* |
|
115 |
* DEAD - LOCK - CHECK ENDS |
|
116 |
*/ |
|
117 |
} |
|
118 |
return NULL; |
|
119 |
} |
|
120 |
||
121 |
counter = 0; |
|
122 |
||
123 |
/* |
|
124 |
* NO BOT Commands |
|
125 |
*/ |
|
126 |
if (*message->line != '!') { |
|
127 |
return NULL; |
|
128 |
} |
|
129 |
||
130 |
i = 0; |
|
131 |
token = strtok (message->line, " "); |
|
132 |
while (Bot_Commands[i]) { |
|
133 |
if (!strcmp (token, Bot_Commands[i])) { |
|
134 |
switch (i) { |
|
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
135 |
case HELP: |
0 | 136 |
if ((token = strtok (NULL, "\r\n"))) |
137 |
cmd = atoi (token); |
|
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
138 |
if ((cmd > 0) && (cmd < VISIBLE_ITEMS)) |
0 | 139 |
snprintf (msg, 512, "PRIVMSG %s :%s\r\n", message->channel, COMMAND_LIST[cmd]); |
140 |
else |
|
141 |
snprintf (msg, 512, "PRIVMSG %s :%s\r\n", message->channel, COMMAND_LIST[0]); |
|
142 |
return msg; |
|
143 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
144 |
case JOIN: |
0 | 145 |
if ((token = strtok (NULL, "\r\n"))) |
146 |
snprintf (msg, 512, "JOIN %s\r\n", token); |
|
147 |
return msg; |
|
148 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
149 |
case LEAVE: |
0 | 150 |
if (*message->channel != '#') |
151 |
return NULL; |
|
152 |
snprintf (msg, 512, "PART %s :Leaving.\r\n", message->channel); |
|
153 |
return msg; |
|
154 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
155 |
case ADD: |
0 | 156 |
if ((token = strtok (NULL, " "))) { |
157 |
if ((parameters = strtok (NULL, "\r\n"))) { |
|
158 |
snprintf (msg, 512, "PRIVMSG %s :%s, %s\r\n", |
|
159 |
message->channel, message->user, db_insert (DATABASE_FILE, token, parameters, 0)); |
|
160 |
} else { |
|
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
161 |
snprintf (msg, 512, "PRIVMSG %s :%s, %s!\r\n", message->channel, |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
162 |
gettext ("I need more parameters to add"), message->user); |
0 | 163 |
} |
164 |
} |
|
165 |
return msg; |
|
166 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
167 |
case REPLACE: |
0 | 168 |
if ((token = strtok (NULL, " "))) { |
169 |
if ((parameters = strtok (NULL, "\r\n"))) { |
|
170 |
snprintf (msg, 512, "PRIVMSG %s :%s, %s\r\n", |
|
171 |
message->channel, message->user, db_insert (DATABASE_FILE, token, parameters, 1)); |
|
172 |
} else { |
|
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
173 |
snprintf (msg, 512, "PRIVMSG %s :%s, %s!\r\n", message->channel, |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
174 |
gettext ("I need more parameters to replace"), message->user); |
0 | 175 |
} |
176 |
} |
|
177 |
return msg; |
|
178 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
179 |
case DELETE: |
0 | 180 |
if ((token = strtok (NULL, "\r\n"))) { |
181 |
snprintf (msg, 512, "PRIVMSG %s :%s, %s\r\n", |
|
182 |
message->channel, message->user, db_remove (DATABASE_FILE, token)); |
|
183 |
} else { |
|
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
184 |
snprintf (msg, 512, "PRIVMSG %s :%s, %s!\r\n", message->channel, gettext ("I need a key to delete"), |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
185 |
message->user); |
0 | 186 |
} |
187 |
return msg; |
|
188 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
189 |
case LIST: |
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
190 |
snprintf (msg, 512, "PRIVMSG %s :%s %s\r\n", message->channel, db_elements (DATABASE_FILE), |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
191 |
db_lookup (DATABASE_FILE, "mcbot.cgi")); |
0 | 192 |
return msg; |
193 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
194 |
case SEARCH: |
0 | 195 |
if ((token = strtok (NULL, "\r\n"))) { |
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
196 |
snprintf (msg, 512, "PRIVMSG %s :%s, %s\r\n", message->channel, message->user, |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
197 |
db_lookup (DATABASE_FILE, token)); |
0 | 198 |
} else { |
199 |
snprintf (msg, 512, |
|
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
200 |
"PRIVMSG %s :%s, %s!\r\n", message->channel, gettext ("I need a key to lookup"), |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
201 |
message->user); |
0 | 202 |
} |
203 |
return msg; |
|
204 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
205 |
case INFO: |
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
206 |
snprintf (msg, 512, "PRIVMSG %s :I am MCBot-%1.2f and my source code can be found on %s\r\n", |
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
207 |
message->channel, BOT_VERSION, SOURCE_URL); |
0 | 208 |
return msg; |
209 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
210 |
case PING: |
0 | 211 |
if ((token = strtok (NULL, "\r\n"))) |
212 |
snprintf (msg, 512, "PRIVMSG %s :PING 0815\r\n", token); |
|
213 |
return msg; |
|
214 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
215 |
case ON: |
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
216 |
snprintf (msg, 512, "PRIVMSG %s :%s %s.\r\n", message->user, gettext ("Autolearn enabled for channel"), |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
217 |
message->channel); |
0 | 218 |
return msg; |
219 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
220 |
case OFF: |
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
221 |
snprintf (msg, 512, "PRIVMSG %s :%s %s.\r\n", message->user, gettext ("Autolearn disabled for channel"), |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
222 |
message->channel); |
0 | 223 |
return msg; |
224 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
225 |
case DEBUG: |
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
226 |
snprintf (msg, 512, "PRIVMSG %s :USER: %s EMAIL: %s CHANNEL: %s LINE: %s\r\n", message->channel, |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
227 |
message->user, message->email, message->channel, message->line); |
0 | 228 |
return msg; |
229 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
230 |
case VACCUUM: |
0 | 231 |
snprintf (msg, 512, "PRIVMSG %s :%s\r\n", message->channel, db_vaccuum (DATABASE_FILE)); |
232 |
return msg; |
|
233 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
234 |
case LOGOUT: |
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
235 |
if (strstr (message->user, db_lookup (DATABASE_FILE, "mcbot.user"))) { |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
236 |
if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email"))) { |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
237 |
snprintf (msg, 512, "PRIVMSG %s :%s!\r\nQUIT\r\n", message->channel, |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
238 |
gettext ("Bye, have a nice day!")); |
0 | 239 |
} |
240 |
} |
|
241 |
/* |
|
242 |
* the returned message is either the default one or the generated one |
|
243 |
*/ |
|
244 |
return msg; |
|
245 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
246 |
case WHO: |
0 | 247 |
if ((token = strtok (NULL, "\r\n")) != NULL) { |
248 |
snprintf (msg, 512, "WHO %s\r\n", token); |
|
249 |
} |
|
250 |
return msg; |
|
251 |
||
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
252 |
case WHOIS: |
0 | 253 |
if ((token = strtok (NULL, "\r\n")) != NULL) { |
254 |
snprintf (msg, 512, "WHOIS %s\r\n", token); |
|
255 |
} |
|
256 |
return msg; |
|
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
257 |
|
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
258 |
case TIME: |
0 | 259 |
t = time (NULL); |
260 |
timeptr = localtime (&t); |
|
261 |
if ((token = malloc (81))) { |
|
262 |
strftime (token, 80, "%I:%M:%S %p", timeptr); |
|
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
263 |
snprintf (msg, 512, "PRIVMSG %s :%s %s, %s!\r\n", message->channel, gettext ("It is"), token, |
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
264 |
message->user); |
0 | 265 |
free (token); |
266 |
} |
|
267 |
return msg; |
|
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
268 |
|
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
269 |
case TELL: |
0 | 270 |
if ((token = strtok (NULL, " "))) { |
271 |
if ((parameters = strtok (NULL, "\r\n"))) { |
|
13
d3554afaa768
mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
11
diff
changeset
|
272 |
if (*token == '*') |
d3554afaa768
mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
11
diff
changeset
|
273 |
message->channel = ++token; |
d3554afaa768
mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
11
diff
changeset
|
274 |
snprintf (msg, 512, "PRIVMSG %s :%s, %s\r\n", message->channel, token, |
d3554afaa768
mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
11
diff
changeset
|
275 |
db_lookup (DATABASE_FILE, parameters)); |
0 | 276 |
} |
277 |
} |
|
278 |
return msg; |
|
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
279 |
|
15
f19c1f9b4cd3
ChangeLog mcbot-0.95-1
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
14
diff
changeset
|
280 |
case OP: |
0 | 281 |
if ((token = strtok (NULL, "\r\n")) != NULL) { |
3
a82a978f23f7
unreachable code removed and gitignore added
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
282 |
if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email"))) |
0 | 283 |
snprintf (msg, 512, "MODE %s +o %s\r\n", message->channel, token); |
284 |
} |
|
285 |
return msg; |
|
286 |
} |
|
287 |
} |
|
288 |
i++; |
|
289 |
} |
|
290 |
||
291 |
return NULL; |
|
292 |
} |