1 /* modcmd.c - NeonServ v5.2
2 * Copyright (C) 2011 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "IRCEvents.h"
20 #include "IRCParser.h"
21 #include "ClientSocket.h"
25 #include "WHOHandler.h"
27 #include "mysqlConn.h"
29 #include "EventLogger.h"
31 struct trigger_callback {
33 trigger_callback_t *func;
35 struct trigger_callback *next;
38 struct cmd_bot_alias {
42 struct cmd_bot_alias *next;
45 struct command_check_user_cache {
46 struct ClientSocket *client, *textclient;
47 struct UserNode *user;
48 struct ChanNode *chan, *sent_chan;
51 char *message, *args_buffer;
52 struct cmd_binding *cbind;
55 static struct cmd_binding **cmd_binds;
56 static struct cmd_function *cmd_functions = NULL;
57 static struct trigger_callback *trigger_callbacks = NULL;
58 static struct cmd_bot_alias *bot_aliases = NULL;
59 static struct ClientSocket *tmp_text_client;
61 static const struct default_language_entry msgtab[] = {
62 {"MODCMD_LESS_PARAM_COUNT", "This command requires more parameters."},
63 {"MODCMD_CHAN_REQUIRED", "You must provide the name of a channel that exists and the bot is on."},
64 {"MODCMD_AUTH_REQUIRED", "You need to be authenticated with AuthServ to use this command."},
65 {"MODCMD_CHAN_SUSPENDED", "This channel is currently suspended."},
66 {"MODCMD_PRIVILEGED", "$b%s$b is a privileged command."}, /* {ARGS: "god"} */
67 {"MODCMD_PUBCMD", "Public commands in $b%s$b are restricted."}, /* {ARGS: "#TestChan"} */
68 {"MODCMD_ACCESS_DENIED", "Access denied."},
72 static int get_binds_index(char first_char) {
73 if(tolower(first_char) >= 'a' && tolower(first_char) <= 'z') {
74 return tolower(first_char) - 'a';
79 struct ClientSocket* get_prefered_bot(int botid) {
80 struct ClientSocket *client, *lowbot = NULL;
81 for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
82 if(client->botid == botid) {
83 if((client->flags & SOCKET_FLAG_PREFERRED))
92 static char* get_channel_trigger(int botid, struct ChanNode *chan) {
93 struct trigger_cache *trigger;
94 for(trigger = chan->trigger; trigger; trigger = trigger->next) {
95 if(trigger->botid == botid)
96 return trigger->trigger;
98 struct trigger_callback *cb;
99 for(cb = trigger_callbacks; cb; cb = cb->next) {
100 if(cb->botid == botid)
103 char triggerStr[TRIGGERLEN];
105 cb->func(chan, triggerStr);
107 strcpy(triggerStr, "+");
108 trigger = malloc(sizeof(*trigger));
110 perror("malloc() failed");
113 trigger->botid = botid;
114 trigger->trigger = (triggerStr[0] ? strdup(triggerStr) : NULL);
115 trigger->next = chan->trigger;
116 chan->trigger = trigger;
117 return trigger->trigger;
120 static void handle_command_async(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct ChanNode *sent_chan, struct cmd_binding *cbind, char **argv, int argc);
122 static USERAUTH_CALLBACK(command_checked_auth) {
123 struct command_check_user_cache *cache = data;
124 tmp_text_client = cache->textclient;
125 handle_command_async(cache->client, user, cache->chan, cache->sent_chan, cache->cbind, cache->argv, cache->argc);
126 free(cache->message);
127 if(cache->args_buffer)
128 free(cache->args_buffer);
133 static void handle_command(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char *message) {
134 struct ChanNode *sent_chan = chan;
135 if(message[0] == '#') {
136 char *chanName = message;
137 message = strstr(message, " ");
141 struct ChanNode *chan2 = getChanByName(chanName);
145 message = strdup(message);
146 int bind_index = get_binds_index(message[0]);
147 char *args = strstr(message, " ");
148 char *args_buffer = NULL; //we need this to save a possible pointer to a allocation we need to free
153 struct cmd_binding *cbind;
154 for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
155 if(cbind->botid == client->botid && stricmp(cbind->cmd, message) == 0) {
156 if((cbind->func->flags & CMDFLAG_FUNCMD)) {
162 tmp_text_client = get_prefered_bot(client->botid);
163 //parse the arguments...
164 char *arga[MAXNUMPARAMS];
169 //skip leading spaces
173 if (argc >= MAXNUMPARAMS)
175 while (*args != ' ' && *args)
180 if(argc != 0 && argv[0][0] == '#' && !(cbind->func->flags & CMDFLAG_CHAN_PARAM)) {
181 struct ChanNode *chan2 = getChanByName(argv[0]);
188 if(cbind->paramcount) {
189 //userdefined parameters...
190 args_buffer = malloc(MAXLEN * 2 * sizeof(*args_buffer));
192 char *uargs[MAXNUMPARAMS];
197 for(i = 0; i < cbind->paramcount; i++) {
198 b = cbind->parameters[i];
201 if(b[strlen(b)-1] == '-') {
202 allargs = strlen(b)-1;
207 } else if(b[strlen(b)-1] == '+') {
208 allargs = strlen(b)-1;
219 uargs[uargc++] = args_buffer + args_pos;
221 args_pos += sprintf(args_buffer + args_pos, "%s", argv[argi-1]) + 1;
222 } else if(allargs == 1) {
223 args_pos += sprintf(args_buffer + args_pos, "%s", argv[argi-1]) + 1;
224 for(argi++; argi <= argc; argi++) {
225 uargs[uargc++] = args_buffer + args_pos;
226 args_pos += sprintf(args_buffer + args_pos, "%s", argv[argi-1]) + 1;
228 } else if(allargs == 2) {
229 for(;argi <= argc; argi++) {
230 args_pos += sprintf(args_buffer + args_pos, (allargs ? "%s" : " %s"), argv[argi-1]);
235 } else if((cbind->func->flags & CMDFLAG_EMPTY_ARGS)) {
236 uargs[uargc++] = args_buffer + args_pos;
237 args_buffer[args_pos++] = '\0';
239 } else if(!strcmp(b, "c")) {
240 uargs[uargc++] = args_buffer + args_pos;
241 args_pos += sprintf(args_buffer + args_pos, "%s", (chan ? chan->name : "")) + 1;
242 } else if(!strcmp(b, "n")) {
243 uargs[uargc++] = args_buffer + args_pos;
244 args_pos += sprintf(args_buffer + args_pos, "%s", user->nick) + 1;
247 uargs[uargc++] = args_buffer + args_pos;
248 args_pos += sprintf(args_buffer + args_pos, "%s", b) + 1;
254 if(argc < cbind->func->paramcount) {
255 reply(tmp_text_client, user, "MODCMD_LESS_PARAM_COUNT");
258 if((cbind->func->flags & CMDFLAG_REQUIRE_CHAN) && !chan) {
259 reply(tmp_text_client, user, "MODCMD_CHAN_REQUIRED");
262 if((cbind->func->flags & CMDFLAG_CHECK_AUTH) && !(user->flags & USERFLAG_ISAUTHED)) {
264 struct command_check_user_cache *data = malloc(sizeof(*data));
265 char **temp_argv = malloc(argc*sizeof(*temp_argv));
266 if (!data || !temp_argv) {
267 perror("malloc() failed");
270 memcpy(temp_argv, argv, argc*sizeof(*temp_argv));
271 data->argv = temp_argv;
273 data->client = client;
276 data->sent_chan = sent_chan;
277 data->message = message;
278 data->args_buffer = args_buffer;
280 data->textclient = tmp_text_client;
281 get_userauth(user, command_checked_auth, data);
284 handle_command_async(client, user, chan, sent_chan, cbind, argv, argc);
293 static void handle_command_async(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct ChanNode *sent_chan, struct cmd_binding *cbind, char **argv, int argc) {
297 int eventflags = (cbind->func->flags & (CMDFLAG_LOG | CMDFLAG_OPLOG));
298 if((cbind->func->flags & CMDFLAG_REQUIRE_AUTH) && !(user->flags & USERFLAG_ISAUTHED)) {
299 reply(tmp_text_client, user, "MODCMD_AUTH_REQUIRED");
302 if(sent_chan && sent_chan != chan) {
303 //check pubcmd of this channel
304 printf_mysql_query("SELECT `channel_pubcmd` FROM `channels` WHERE `channel_name` = '%s'", escape_string(sent_chan->name));
306 if ((row = mysql_fetch_row(res)) != NULL) {
307 uaccess = getChannelAccess(user, sent_chan);
308 if(row[0] && uaccess < atoi(row[0]) && !isGodMode(user)) { //NOTE: HARDCODED DEFAULT: pubcmd = 0
309 reply(tmp_text_client, user, "MODCMD_PUBCMD", sent_chan->name);
314 int global_access = ((cbind->flags & CMDFLAG_OVERRIDE_GLOBAL_ACCESS) ? cbind->global_access : cbind->func->global_access);
315 if(global_access > 0) {
316 int user_global_access = 0;
317 printf_mysql_query("SELECT `user_access` FROM `users` WHERE `user_user` = '%s'", escape_string(user->auth));
319 if ((row = mysql_fetch_row(res)) != NULL) {
320 user_global_access = atoi(row[0]);
322 if(user_global_access < global_access) {
323 if(!user_global_access)
324 reply(tmp_text_client, user, "MODCMD_PRIVILEGED", cbind->cmd);
326 reply(tmp_text_client, user, "MODCMD_ACCESS_DENIED");
330 if((cbind->func->flags & CMDFLAG_REGISTERED_CHAN)) {
331 MYSQL_ROW defaults = NULL;
332 char access_list[256];
334 int access_count = 0;
336 char *str_a, *str_b = cbind->func->channel_access, *str_c;
337 if(cbind->flags & CMDFLAG_OVERRIDE_CHANNEL_ACCESS)
338 str_b = cbind->channel_access;
339 access_list[0] = '\0';
341 str_c = strdup(str_b);
343 while((str_a = str_b)) {
344 str_b = strstr(str_a, ",");
351 access_pos += sprintf(access_list+access_pos, ", `%s`", str_a);
354 if(atoi(str_a) > minaccess)
355 minaccess = atoi(str_a);
360 if(!(chan->flags & CHANFLAG_REQUESTED_CHANINFO) || (sent_chan && sent_chan == chan) || access_count || minaccess) {
361 printf_mysql_query("SELECT `channel_id`, `channel_pubcmd` %s FROM `channels` WHERE `channel_name` = '%s'", access_list, escape_string(chan->name));
363 if ((row = mysql_fetch_row(res)) != NULL) {
364 chan->flags |= CHANFLAG_CHAN_REGISTERED;
365 chan->channel_id = atoi(row[0]);
366 if((sent_chan && sent_chan == chan) || access_count || minaccess) {
367 uaccess = getChannelAccess(user, chan);
368 if(uaccess < minaccess && isGodMode(user)) {
369 eventflags |= CMDFLAG_OPLOG;
370 } else if(uaccess < minaccess) {
372 reply(tmp_text_client, user, "MODCMD_ACCESS_DENIED");
375 if(!row[1] && !defaults) {
376 printf_mysql_query("SELECT `channel_id`, `channel_pubcmd` %s FROM `channels` WHERE `channel_name` = 'defaults'", access_list);
377 defaults = mysql_fetch_row(mysql_use());
379 if(sent_chan && (sent_chan == chan) && uaccess < (row[1] ? atoi(row[1]) : atoi(defaults[1]))) {
380 if(isGodMode(user)) {
381 eventflags |= CMDFLAG_OPLOG;
384 reply(tmp_text_client, user, "MODCMD_PUBCMD", chan->name);
389 for(i = 0; i < access_count; i++) {
390 if(!row[2+i] && !defaults) {
391 printf_mysql_query("SELECT `channel_id`, `channel_pubcmd` %s FROM `channels` WHERE `channel_name` = 'defaults'", access_list);
392 defaults = mysql_fetch_row(mysql_use());
394 if(uaccess < (row[2+i] ? atoi(row[2+i]) : atoi(defaults[2+i]))) {
395 if(isGodMode(user)) {
396 eventflags |= CMDFLAG_OPLOG;
398 reply(tmp_text_client, user, "MODCMD_ACCESS_DENIED");
405 chan->flags |= CHANFLAG_REQUESTED_CHANINFO;
407 if(!(chan->flags & CHANFLAG_CHAN_REGISTERED)) {
408 reply(tmp_text_client, user, "MODCMD_CHAN_REQUIRED");
411 printf_mysql_query("SELECT `botid`, `suspended` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chan->channel_id, client->botid);
413 if ((row = mysql_fetch_row(res)) == NULL) {
414 reply(tmp_text_client, user, "MODCMD_CHAN_REQUIRED");
416 } else if(!strcmp(row[1], "1")) {
417 reply(tmp_text_client, user, "MODCMD_CHAN_SUSPENDED");
421 if((cbind->func->flags & CMDFLAG_REQUIRE_GOD) && !isGodMode(user)) {
422 reply(tmp_text_client, user, "MODCMD_PRIVILEGED", cbind->cmd);
425 struct Event *event = createEvent(client, user, chan, cbind->func->name, argv, argc, eventflags);
426 cbind->func->func(client, user, chan, argv, argc, event);
429 static void got_chanmsg(struct UserNode *user, struct ChanNode *chan, char *message) {
432 struct ClientSocket *client;
434 for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
435 if(isUserOnChan(client->user, chan) && (client->flags & SOCKET_FLAG_PREFERRED) && !FD_ISSET(client->botid, &fds)) {
436 FD_SET(client->botid, &fds);
437 trigger = get_channel_trigger(client->botid, chan);
438 if(trigger && stricmplen(message, trigger, strlen(trigger)) == 0) {
439 handle_command(client, user, chan, message + strlen(trigger));
443 for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
444 if(isUserOnChan(client->user, chan) && !FD_ISSET(client->botid, &fds)) {
445 FD_SET(client->botid, &fds);
446 trigger = get_channel_trigger(client->botid, chan);
447 if(trigger && stricmplen(message, trigger, strlen(trigger)) == 0) {
448 handle_command(client, user, chan, message + strlen(trigger));
454 static void got_privmsg(struct UserNode *user, struct UserNode *target, char *message) {
455 struct ClientSocket *client;
456 for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
457 if(client->user == target) {
458 handle_command(client, user, NULL, message);
463 int register_command(int botid, char *name, cmd_bind_t *func, int paramcount, char *channel_access, int global_access, unsigned int flags) {
464 struct cmd_function *cmdfunc;
465 for(cmdfunc = cmd_functions; cmdfunc; cmdfunc = cmdfunc->next) {
466 if((cmdfunc->botid == botid || cmdfunc->botid == 0) && strcmp(cmdfunc->name, name) == 0)
469 cmdfunc = malloc(sizeof(*cmdfunc));
471 perror("malloc() failed");
474 cmdfunc->botid = botid;
475 cmdfunc->name = strdup(name);
476 cmdfunc->func = func;
477 cmdfunc->flags = flags;
478 cmdfunc->paramcount = paramcount;
479 cmdfunc->channel_access = channel_access;
480 cmdfunc->global_access = global_access;
481 cmdfunc->next = cmd_functions;
482 cmd_functions = cmdfunc;
486 int set_trigger_callback(int botid, trigger_callback_t *func) {
487 static struct trigger_callback *cb = NULL;
488 for(cb = trigger_callbacks; cb; cb = cb->next) {
489 if(cb->botid == botid)
493 cb = malloc(sizeof(*cb));
495 perror("malloc() failed");
499 cb->next = trigger_callbacks;
500 trigger_callbacks = cb;
506 int changeChannelTrigger(int botid, struct ChanNode *chan, char *new_trigger) {
507 struct trigger_cache *trigger;
508 for(trigger = chan->trigger; trigger; trigger = trigger->next) {
509 if(trigger->botid == botid) {
510 free(trigger->trigger);
511 trigger->trigger = strdup(new_trigger);
518 int bind_cmd_to_function(int botid, char *cmd, struct cmd_function *func) {
519 int bind_index = get_binds_index(cmd[0]);
520 struct cmd_binding *cbind;
521 for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
522 if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0)
525 cbind = malloc(sizeof(*cbind));
527 perror("malloc() failed");
530 cbind->botid = botid;
531 cbind->cmd = strdup(cmd);
533 cbind->paramcount = 0;
534 cbind->global_access = 0;
535 cbind->channel_access = NULL;
537 cbind->next = cmd_binds[bind_index];
538 cmd_binds[bind_index] = cbind;
542 int bind_cmd_to_command(int botid, char *cmd, char *func) {
543 struct cmd_function *cmdfunc;
546 if((c = strstr(func, "."))) {
548 struct cmd_bot_alias *botalias;
549 for(botalias = bot_aliases; botalias; botalias = botalias->next) {
550 if(!stricmp(botalias->alias, func)) {
551 fbotid = botalias->botid;
558 for(cmdfunc = cmd_functions; cmdfunc; cmdfunc = cmdfunc->next) {
559 if((cmdfunc->botid == fbotid || cmdfunc->botid == 0) && strcmp(cmdfunc->name, func) == 0)
562 if(!cmdfunc) return 0;
563 int bind_index = get_binds_index(cmd[0]);
564 struct cmd_binding *cbind;
565 for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
566 if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0)
569 cbind = malloc(sizeof(*cbind));
571 perror("malloc() failed");
574 cbind->botid = botid;
575 cbind->cmd = strdup(cmd);
576 cbind->func = cmdfunc;
577 cbind->next = cmd_binds[bind_index];
578 cbind->paramcount = 0;
579 cbind->global_access = 0;
580 cbind->channel_access = NULL;
582 cmd_binds[bind_index] = cbind;
586 int unbind_cmd(int botid, char *cmd) {
587 int bind_index = get_binds_index(cmd[0]);
588 struct cmd_binding *cbind, *last = NULL;
589 for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
590 if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) {
592 last->next = cbind->next;
594 cmd_binds[bind_index] = cbind->next;
596 if(cbind->paramcount) {
598 for(i = 0; i < cbind->paramcount; i++)
599 free(cbind->parameters[i]);
609 struct cmd_function *find_cmd_function(int botid, char *name) {
610 struct cmd_function *cmdfunc;
612 if((c = strstr(name, "."))) {
614 struct cmd_bot_alias *botalias;
615 for(botalias = bot_aliases; botalias; botalias = botalias->next) {
616 if(!stricmp(botalias->alias, name)) {
617 botid = botalias->botid;
624 for(cmdfunc = cmd_functions; cmdfunc; cmdfunc = cmdfunc->next) {
625 if((cmdfunc->botid == botid || cmdfunc->botid == 0) && stricmp(cmdfunc->name, name) == 0)
631 struct ClientSocket *getTextBot() {
632 return tmp_text_client;
636 cmd_binds = calloc(27, sizeof(*cmd_binds));
637 bind_chanmsg(got_chanmsg);
638 bind_privmsg(got_privmsg);
639 register_default_language_table(msgtab);
644 for(i = 0; i < 27; i++) {
645 struct cmd_binding *cbind, *next;
646 for(cbind = cmd_binds[i]; cbind; cbind = next) {
649 if(cbind->paramcount) {
651 for(j = 0; j < cbind->paramcount; j++)
652 free(cbind->parameters[j]);
654 if(cbind->channel_access)
655 free(cbind->channel_access);
660 struct cmd_function *cmdfunct, *next;
661 for(cmdfunct = cmd_functions; cmdfunct; cmdfunct = next) {
662 next = cmdfunct->next;
663 free(cmdfunct->name);
666 struct trigger_callback *cb, *next_cb;
667 for(cb = trigger_callbacks; cb; cb = next_cb) {
671 struct cmd_bot_alias *botalias, *next_botalias;
672 for(botalias = bot_aliases; botalias; botalias = next_botalias) {
673 next_botalias = botalias->next;
674 free(botalias->alias);
677 cmd_functions = NULL;
678 trigger_callbacks = NULL;
682 void bind_set_parameters(int botid, char *cmd, char *parameters) {
683 int bind_index = get_binds_index(cmd[0]);
684 struct cmd_binding *cbind;
685 for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
686 if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) {
687 if(cbind->paramcount) {
689 for(i = 0; i < cbind->paramcount; i++)
690 free(cbind->parameters[i]);
691 cbind->paramcount = 0;
693 char *a, *b = parameters;
697 cbind->parameters[cbind->paramcount++] = strdup(b);
705 void bind_set_global_access(int botid, char *cmd, int gaccess) {
706 int bind_index = get_binds_index(cmd[0]);
707 struct cmd_binding *cbind;
708 for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
709 if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) {
711 cbind->global_access = gaccess;
712 cbind->flags |= CMDFLAG_OVERRIDE_GLOBAL_ACCESS;
714 cbind->flags &= ~CMDFLAG_OVERRIDE_GLOBAL_ACCESS;
721 void bind_set_channel_access(int botid, char *cmd, char *chanaccess) {
722 int bind_index = get_binds_index(cmd[0]);
723 struct cmd_binding *cbind;
724 for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
725 if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) {
726 if(cbind->channel_access)
727 free(cbind->channel_access);
729 cbind->channel_access = strdup(chanaccess);
730 cbind->flags |= CMDFLAG_OVERRIDE_CHANNEL_ACCESS;
732 cbind->channel_access = NULL;
733 cbind->flags &= ~CMDFLAG_OVERRIDE_CHANNEL_ACCESS;
740 struct cmd_binding *find_cmd_binding(int botid, char *cmd) {
741 int bind_index = get_binds_index(cmd[0]);
742 struct cmd_binding *cbind;
743 for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
744 if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) {
751 void bind_unbound_required_functions(int botid) {
752 struct cmd_function *cmdfunc;
754 struct cmd_binding *cbind;
755 for(cmdfunc = cmd_functions; cmdfunc; cmdfunc = cmdfunc->next) {
756 if((cmdfunc->flags & CMDFLAG_REQUIRED)) {
758 for(i = 0; i < 27; i++) {
759 for(cbind = cmd_binds[i]; cbind; cbind = cbind->next) {
760 if(cbind->botid == botid && cbind->func == cmdfunc) {
768 if(!found && bind_cmd_to_function(botid, cmdfunc->name, cmdfunc)) {
769 cbind = find_cmd_binding(botid, cmdfunc->name);
770 cbind->flags |= CMDFLAG_TEMPONARY_BIND;
776 void register_command_alias(int botid, char *alias) {
777 struct cmd_bot_alias *botalias;
778 for(botalias = bot_aliases; botalias; botalias = botalias->next) {
779 if(!stricmp(botalias->alias, alias))
782 botalias = malloc(sizeof(*botalias));
784 perror("malloc() failed");
787 botalias->botid = botid;
788 botalias->alias = strdup(alias);
789 botalias->next = bot_aliases;
790 bot_aliases = botalias;
793 struct cmd_binding *getAllBinds(struct cmd_binding *last) {
798 bind_index = get_binds_index(last->cmd[0]) + 1;
804 if(cmd_binds[bind_index])
805 return cmd_binds[bind_index];
807 } while(bind_index < 27);