Another year is about to end... So we have to update these damn copyright information :P
[NeonServV5.git] / src / cmd_global_setbot.c
1 /* cmd_global_setbot.c - NeonServ v5.3
2  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
3  * 
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.
8  * 
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.
13  * 
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/>. 
16  */
17
18 #include "cmd_global.h"
19
20 /*
21 * argv[0]  botid
22 * argv[1]  setting
23 * argv[2]  value
24 */
25
26 static int global_cmd_setbot_active(struct UserNode *user, MYSQL_ROW bot, char *value);
27 static int global_cmd_setbot_nick(struct UserNode *user, MYSQL_ROW bot, char *value);
28 static int global_cmd_setbot_ident(struct UserNode *user, MYSQL_ROW bot, char *value);
29 static int global_cmd_setbot_realname(struct UserNode *user, MYSQL_ROW bot, char *value);
30 static int global_cmd_setbot_server(struct UserNode *user, MYSQL_ROW bot, char *value);
31 static int global_cmd_setbot_port(struct UserNode *user, MYSQL_ROW bot, char *value);
32 static int global_cmd_setbot_bind(struct UserNode *user, MYSQL_ROW bot, char *value);
33 static int global_cmd_setbot_ssl(struct UserNode *user, MYSQL_ROW bot, char *value);
34 static int global_cmd_setbot_serverpass(struct UserNode *user, MYSQL_ROW bot, char *value);
35 static int global_cmd_setbot_class(struct UserNode *user, MYSQL_ROW bot, char *value);
36 static int global_cmd_setbot_queue(struct UserNode *user, MYSQL_ROW bot, char *value);
37 static int global_cmd_setbot_prefered(struct UserNode *user, MYSQL_ROW bot, char *value);
38 static int global_cmd_setbot_maxchan(struct UserNode *user, MYSQL_ROW bot, char *value);
39 static int global_cmd_setbot_priority(struct UserNode *user, MYSQL_ROW bot, char *value);
40 static int global_cmd_setbot_trigger(struct UserNode *user, MYSQL_ROW bot, char *value);
41
42 CMD_BIND(global_cmd_setbot) {
43     MYSQL_RES *res;
44     MYSQL_ROW row;
45     int botid = atoi(argv[0]);
46     printf_mysql_query("SELECT `active`, `nick`, `server`, `port`, `pass`, `botclass`, `textbot`, `queue`, `defaulttrigger`, `max_channels`, `register_priority`, `bind`, `ident`, `realname`, `ssl`, `id` FROM `bots` WHERE `id` = '%d'", botid);
47     res = mysql_use();
48     if(!(row = mysql_fetch_row(res))) {
49         reply(getTextBot(), user, "NS_SETBOT_UNKNOWN", botid);
50         return;
51     }
52     if(argc > 1) {
53         char *value;
54         if(argc > 2) {
55             value = merge_argv(argv, 2, argc);
56         } else
57             value = NULL;
58         int log_event = 0;
59         if(!stricmp(argv[1], "active")) log_event = global_cmd_setbot_active(user, row, value);
60         else if(!stricmp(argv[1], "nick")) log_event = global_cmd_setbot_nick(user, row, value);
61         else if(!stricmp(argv[1], "ident")) log_event = global_cmd_setbot_ident(user, row, value);
62         else if(!stricmp(argv[1], "realname")) log_event = global_cmd_setbot_realname(user, row, value);
63         else if(!stricmp(argv[1], "server")) log_event = global_cmd_setbot_server(user, row, value);
64         else if(!stricmp(argv[1], "port")) log_event = global_cmd_setbot_port(user, row, value);
65         else if(!stricmp(argv[1], "bind")) log_event = global_cmd_setbot_bind(user, row, value);
66         else if(!stricmp(argv[1], "ssl")) log_event = global_cmd_setbot_ssl(user, row, value);
67         else if(!stricmp(argv[1], "serverpass")) log_event = global_cmd_setbot_serverpass(user, row, value);
68         else if(!stricmp(argv[1], "botclass")) log_event = global_cmd_setbot_class(user, row, value);
69         else if(!stricmp(argv[1], "queue")) log_event = global_cmd_setbot_queue(user, row, value);
70         else if(!stricmp(argv[1], "prefered")) log_event = global_cmd_setbot_prefered(user, row, value);
71         else if(!stricmp(argv[1], "maxchan")) log_event = global_cmd_setbot_maxchan(user, row, value);
72         else if(!stricmp(argv[1], "priority")) log_event = global_cmd_setbot_priority(user, row, value);
73         else if(!stricmp(argv[1], "trigger")) log_event = global_cmd_setbot_trigger(user, row, value);
74         else {
75             reply(getTextBot(), user, "NS_SETBOT_SETTING", argv[1]);
76         }
77         if(log_event) {
78             if(!stricmp(argv[1], "serverpass") && value) { //censor server password 
79                 char cmd_args[MAXLEN];
80                 sprintf(cmd_args, "%d SERVERPASS ***", botid);
81                 free(event->arguments);
82                 event->arguments = strdup(cmd_args);
83             }
84             logEvent(event);
85         }
86     } else {
87         reply(getTextBot(), user, "NS_SETBOT_HEADER", botid);
88         global_cmd_setbot_active(user, row, NULL);
89         global_cmd_setbot_nick(user, row, NULL);
90         global_cmd_setbot_ident(user, row, NULL);
91         global_cmd_setbot_realname(user, row, NULL);
92         global_cmd_setbot_server(user, row, NULL);
93         global_cmd_setbot_port(user, row, NULL);
94         global_cmd_setbot_bind(user, row, NULL);
95         global_cmd_setbot_ssl(user, row, NULL);
96         global_cmd_setbot_serverpass(user, row, NULL);
97         global_cmd_setbot_class(user, row, NULL);
98         global_cmd_setbot_queue(user, row, NULL);
99         global_cmd_setbot_prefered(user, row, NULL);
100         global_cmd_setbot_maxchan(user, row, NULL);
101         global_cmd_setbot_priority(user, row, NULL);
102         global_cmd_setbot_trigger(user, row, NULL);
103     }
104 }
105
106 static int global_cmd_setbot_active(struct UserNode *user, MYSQL_ROW bot, char *value) {
107     int val = ((bot[0] && !strcmp(bot[0], "1")) ? 1 : 0);
108     int ret = 0;
109     if(value) {
110         if(!strcmp(value, "0") || !stricmp(value, "off") || !stricmp(value, get_language_string(user, "NS_SET_OFF"))) {
111             val = 0;
112         } else if(!strcmp(value, "1") || !stricmp(value, "on") || !stricmp(value, get_language_string(user, "NS_SET_ON"))) {
113             val = 1;
114         } else {
115             reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", value);
116             return 0;
117         }
118         if(val != ((bot[0] && !strcmp(bot[0], "1")) ? 1 : 0)) {
119             if(val) {
120                 //add the bot
121                 struct ClientSocket *client;
122                 client = create_socket(bot[2], atoi(bot[3]), bot[11], bot[4], bot[1], bot[12], bot[13]);
123                 client->flags |= (strcmp(bot[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
124                 client->flags |= (strcmp(bot[7], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
125                 client->flags |= (strcmp(bot[14], "0") ? SOCKET_FLAG_SSL : 0);
126                 client->botid = atoi(bot[5]);
127                 client->clientid = atoi(bot[15]);
128                 connect_socket(client);
129                 if(client->botid == 0) {
130                     MYSQL_RES *res;
131                     MYSQL_ROW row;
132                     printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '0' AND `botid` = '%d'", client->clientid);
133                     res = mysql_use();
134                     while ((row = mysql_fetch_row(res)) != NULL) {
135                         if(bind_botwise_cmd_to_command(0, client->clientid, row[0], row[1])) {
136                             if(row[2] && strcmp(row[2], "")) {
137                                 bind_botwise_set_parameters(0, client->clientid, row[0], row[2]);
138                             }
139                             if(row[3]) {
140                                 bind_botwise_set_global_access(0, client->clientid, row[0], atoi(row[3]));
141                             }
142                             if(row[4]) {
143                                 bind_botwise_set_channel_access(0, client->clientid, row[0], row[4]);
144                             }
145                         }
146                     }
147                     bind_botwise_unbound_required_functions(0, client->clientid);
148                 }
149             } else {
150                 //remove the bot
151                 struct ClientSocket *client;
152                 for(client = getBots(0, NULL); client; client = getBots(0, client)) {
153                     if(client->clientid == atoi(bot[15])) {
154                         unbind_botwise_allcmd(client->clientid);
155                         close_socket(client);
156                         break;
157                     }
158                 }
159             }
160             printf_mysql_query("UPDATE `bots` SET `active` = '%d' WHERE `id` = '%s'", val, bot[15]);
161             ret = 1;
162         }
163     }
164     reply(getTextBot(), user, "\002ACTIVE     \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
165     return ret;
166 }
167
168 static int global_cmd_setbot_nick(struct UserNode *user, MYSQL_ROW bot, char *value) {
169     char *val = bot[1];
170     int ret = 0;
171     if(value) {
172         if(!is_valid_nick(value)) {
173             reply(getTextBot(), user, "NS_SETBOT_NICK_INVALID", value);
174             return 0;
175         }
176         //rename the bot
177         struct ClientSocket *client;
178         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
179             if(client->clientid == atoi(bot[15])) {
180                 if(client->nick)
181                     free(client->nick);
182                 client->nick = strdup(value);
183                 if(client->flags & SOCKET_FLAG_READY)
184                     putsock(client, "NICK %s", value);
185                 break;
186             }
187         }
188         printf_mysql_query("UPDATE `bots` SET `nick` = '%s' WHERE `id` = '%s'", escape_string(value), bot[15]);
189         val = value;
190         ret = 1;
191     }
192     reply(getTextBot(), user, "\002NICK       \002 %s", val);
193     return ret;
194 }
195
196 static int global_cmd_setbot_ident(struct UserNode *user, MYSQL_ROW bot, char *value) {
197     char *val = bot[12];
198     int ret = 0;
199     if(value) {
200         if(strlen(value) > 12)
201             value[12] = '\0';
202         //rename the bot
203         struct ClientSocket *client;
204         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
205             if(client->clientid == atoi(bot[15])) {
206                 if(client->ident)
207                     free(client->ident);
208                 client->ident = strdup(value);
209                 break;
210             }
211         }
212         printf_mysql_query("UPDATE `bots` SET `ident` = '%s' WHERE `id` = '%s'", escape_string(value), bot[15]);
213         val = value;
214         ret = 1;
215     }
216     reply(getTextBot(), user, "\002IDENT      \002 %s", val);
217     return ret;
218 }
219
220 static int global_cmd_setbot_realname(struct UserNode *user, MYSQL_ROW bot, char *value) {
221     char *val = bot[13];
222     int ret = 0;
223     if(value) {
224         if(strlen(value) > 255)
225             value[255] = '\0';
226         //rename the bot
227         struct ClientSocket *client;
228         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
229             if(client->clientid == atoi(bot[15])) {
230                 if(client->ident)
231                     free(client->ident);
232                 client->ident = strdup(value);
233                 break;
234             }
235         }
236         printf_mysql_query("UPDATE `bots` SET `realname` = '%s' WHERE `id` = '%s'", escape_string(value), bot[15]);
237         val = value;
238         ret = 1;
239     }
240     reply(getTextBot(), user, "\002REALNAME   \002 %s", val);
241     return ret;
242 }
243
244 static int global_cmd_setbot_server(struct UserNode *user, MYSQL_ROW bot, char *value) {
245     char *val = bot[2];
246     int ret = 0;
247     if(value) {
248         struct ClientSocket *client;
249         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
250             if(client->clientid == atoi(bot[15])) {
251                 if(client->host)
252                     free(client->host);
253                 client->host = strdup(value);
254                 if(client->flags & SOCKET_FLAG_READY)
255                     reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
256                 break;
257             }
258         }
259         printf_mysql_query("UPDATE `bots` SET `server` = '%s' WHERE `id` = '%s'", escape_string(value), bot[15]);
260         val = value;
261         ret = 1;
262     }
263     reply(getTextBot(), user, "\002SERVER     \002 %s", val);
264     return ret;
265 }
266
267 static int global_cmd_setbot_port(struct UserNode *user, MYSQL_ROW bot, char *value) {
268     int val = atoi(bot[3]);
269     int ret = 0;
270     if(value) {
271         val = atoi(value);
272         if(val <= 0 || val > 65534) {
273             reply(getTextBot(), user, "NS_SETBOT_PORT_INVALID", value);
274             return 0;
275         }
276         struct ClientSocket *client;
277         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
278             if(client->clientid == atoi(bot[15])) {
279                 client->port = val;
280                 if(client->flags & SOCKET_FLAG_READY)
281                     reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
282                 break;
283             }
284         }
285         printf_mysql_query("UPDATE `bots` SET `port` = '%d' WHERE `id` = '%s'", val, bot[15]);
286         ret = 1;
287     }
288     reply(getTextBot(), user, "\002PORT       \002 %d", val);
289     return ret;
290 }
291
292 static int global_cmd_setbot_bind(struct UserNode *user, MYSQL_ROW bot, char *value) {
293     char *val = bot[11];
294     int ret = 0;
295     if(value) {
296         if(!strcmp(value, "*")) 
297             value = NULL;
298         struct ClientSocket *client;
299         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
300             if(client->clientid == atoi(bot[15])) {
301                 if(client->bind)
302                     free(client->bind);
303                 client->bind = (value ? strdup(value) : NULL);
304                 if(client->flags & SOCKET_FLAG_READY)
305                     reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
306                 break;
307             }
308         }
309         if(value)
310             printf_mysql_query("UPDATE `bots` SET `bind` = '%s' WHERE `id` = '%s'", escape_string(value), bot[15]);
311         else
312             printf_mysql_query("UPDATE `bots` SET `bind` = NULL WHERE `id` = '%s'", bot[15]);
313         val = value;
314         ret = 1;
315     }
316     reply(getTextBot(), user, "\002BIND       \002 %s", val);
317     return ret;
318 }
319
320 static int global_cmd_setbot_ssl(struct UserNode *user, MYSQL_ROW bot, char *value) {
321     int val = (strcmp(bot[14], "0") ? 1 : 0);
322     int ret = 0;
323     if(value) {
324         if(!strcmp(value, "0") || !stricmp(value, "off") || !stricmp(value, get_language_string(user, "NS_SET_OFF"))) {
325             val = 0;
326         } else if(!strcmp(value, "1") || !stricmp(value, "on") || !stricmp(value, get_language_string(user, "NS_SET_ON"))) {
327             val = 1;
328         } else {
329             reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", value);
330             return 0;
331         }
332         struct ClientSocket *client;
333         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
334             if(client->clientid == atoi(bot[15])) {
335                 if(val)
336                     client->flags |= SOCKET_FLAG_SSL;
337                 else
338                     client->flags &= ~SOCKET_FLAG_SSL;
339                 if(client->flags & SOCKET_FLAG_READY)
340                     reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
341                 break;
342             }
343         }
344         printf_mysql_query("UPDATE `bots` SET `ssl` = '%d' WHERE `id` = '%s'", val, bot[15]);
345         ret = 1;
346     }
347     reply(getTextBot(), user, "\002SSL        \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
348     return ret;
349 }
350
351 static int global_cmd_setbot_serverpass(struct UserNode *user, MYSQL_ROW bot, char *value) {
352     char *val = bot[4];
353     int ret = 0;
354     if(value) {
355         if(!strcmp(value, "*")) 
356             value = "";
357         struct ClientSocket *client;
358         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
359             if(client->clientid == atoi(bot[15])) {
360                 if(client->pass)
361                     free(client->pass);
362                 client->pass = (value ? strdup(value) : NULL);
363                 if(client->flags & SOCKET_FLAG_READY)
364                     reply(getTextBot(), user, "NS_SETBOT_NEED_RESTART");
365                 break;
366             }
367         }
368         printf_mysql_query("UPDATE `bots` SET `pass` = '%s' WHERE `id` = '%s'", escape_string(value), bot[15]);
369         val = value;
370         ret = 1;
371     }
372     reply(getTextBot(), user, "\002SERVERPASS \002 %s", val);
373     return ret;
374 }
375
376 static int global_cmd_setbot_class(struct UserNode *user, MYSQL_ROW bot, char *value) {
377     int val = atoi(bot[5]);
378     int ret = 0;
379     if(value) {
380         if((val = resolve_botalias(value)) == -1) {
381             reply(getTextBot(), user, "NS_SETBOT_INVALID_CLASS", value);
382             return 0;
383         }
384         if(val != atoi(bot[5])) {
385             struct ClientSocket *client;
386             for(client = getBots(0, NULL); client; client = getBots(0, client)) {
387                 if(client->clientid == atoi(bot[15])) {
388                     unbind_botwise_allcmd(client->clientid);
389                     client->botid = val;
390                     if(client->botid == 0) {
391                         MYSQL_RES *res;
392                         MYSQL_ROW row;
393                         printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '0' AND `botid` = '%d'", client->clientid);
394                         res = mysql_use();
395                         while ((row = mysql_fetch_row(res)) != NULL) {
396                             if(bind_botwise_cmd_to_command(client->botid, client->clientid, row[0], row[1])) {
397                                 if(row[2] && strcmp(row[2], "")) {
398                                     bind_botwise_set_parameters(client->botid, client->clientid, row[0], row[2]);
399                                 }
400                                 if(row[3]) {
401                                     bind_botwise_set_global_access(client->botid, client->clientid, row[0], atoi(row[3]));
402                                 }
403                                 if(row[4]) {
404                                     bind_botwise_set_channel_access(client->botid, client->clientid, row[0], row[4]);
405                                 }
406                             }
407                         }
408                         bind_botwise_unbound_required_functions(client->botid, client->clientid);
409                     }
410                     break;
411                 }
412             }
413             printf_mysql_query("UPDATE `bots` SET `botclass` = '%d' WHERE `id` = '%s'", val, bot[15]);
414             ret = 1;
415         }
416     }
417     reply(getTextBot(), user, "\002BOTCLASS   \002 %s", resolve_botid(val));
418     return ret;
419 }
420
421 static int global_cmd_setbot_queue(struct UserNode *user, MYSQL_ROW bot, char *value) {
422     int val = (strcmp(bot[7], "0") ? 1 : 0);
423     int ret = 0;
424     if(value) {
425         if(!strcmp(value, "0") || !stricmp(value, "off") || !stricmp(value, get_language_string(user, "NS_SET_OFF"))) {
426             val = 0;
427         } else if(!strcmp(value, "1") || !stricmp(value, "on") || !stricmp(value, get_language_string(user, "NS_SET_ON"))) {
428             val = 1;
429         } else {
430             reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", value);
431             return 0;
432         }
433         struct ClientSocket *client;
434         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
435             if(client->clientid == atoi(bot[15])) {
436                 if(val)
437                     client->flags |= SOCKET_FLAG_USE_QUEUE;
438                 else
439                     client->flags &= ~SOCKET_FLAG_USE_QUEUE;
440                 break;
441             }
442         }
443         printf_mysql_query("UPDATE `bots` SET `queue` = '%d' WHERE `id` = '%s'", val, bot[15]);
444         ret = 1;
445     }
446     reply(getTextBot(), user, "\002QUEUE      \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
447     return ret;
448 }
449
450 static int global_cmd_setbot_prefered(struct UserNode *user, MYSQL_ROW bot, char *value) {
451     int val = (strcmp(bot[6], "0") ? 1 : 0);
452     int ret = 0;
453     if(value) {
454         if(!strcmp(value, "0") || !stricmp(value, "off") || !stricmp(value, get_language_string(user, "NS_SET_OFF"))) {
455             val = 0;
456         } else if(!strcmp(value, "1") || !stricmp(value, "on") || !stricmp(value, get_language_string(user, "NS_SET_ON"))) {
457             val = 1;
458         } else {
459             reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", value);
460             return 0;
461         }
462         struct ClientSocket *client;
463         for(client = getBots(0, NULL); client; client = getBots(0, client)) {
464             if(client->clientid == atoi(bot[15])) {
465                 if(val)
466                     client->flags |= SOCKET_FLAG_PREFERRED;
467                 else
468                     client->flags &= ~SOCKET_FLAG_PREFERRED;
469                 break;
470             }
471         }
472         printf_mysql_query("UPDATE `bots` SET `queue` = '%d' WHERE `id` = '%s'", val, bot[15]);
473         ret = 1;
474     }
475     reply(getTextBot(), user, "\002PREFERED   \002 %s", get_language_string(user, (val ? "NS_SET_ON" : "NS_SET_OFF")));
476     return ret;
477 }
478
479 static int global_cmd_setbot_maxchan(struct UserNode *user, MYSQL_ROW bot, char *value) {
480     int val = atoi(bot[9]);
481     int ret = 0;
482     if(value) {
483         val = atoi(value);
484         if(val < 0 || val > 99999) {
485             reply(getTextBot(), user, "NS_SETBOT_MAXCHAN_INVALID", value);
486             return 0;
487         }
488         printf_mysql_query("UPDATE `bots` SET `max_channels` = '%d' WHERE `id` = '%s'", val, bot[15]);
489         ret = 1;
490     }
491     reply(getTextBot(), user, "\002MAXCHAN    \002 %d", val);
492     return ret;
493 }
494
495 static int global_cmd_setbot_priority(struct UserNode *user, MYSQL_ROW bot, char *value) {
496     int val = atoi(bot[10]);
497     int ret = 0;
498     if(value) {
499         val = atoi(value);
500         if(val < 0 || val > 99) {
501             reply(getTextBot(), user, "NS_SETBOT_PRIORITY_INVALID", value);
502             return 0;
503         }
504         printf_mysql_query("UPDATE `bots` SET `register_priority` = '%d' WHERE `id` = '%s'", val, bot[15]);
505         ret = 1;
506     }
507     reply(getTextBot(), user, "\002PRIORITY   \002 %d", val);
508     return ret;
509 }
510
511 static int global_cmd_setbot_trigger(struct UserNode *user, MYSQL_ROW bot, char *value) {
512     char *val = bot[8];
513     int ret = 0;
514     if(value) {
515         if(!*value || strlen(value) > 10) {
516             reply(getTextBot(), user, "NS_SETBOT_TRIGGER_INVALID", value);
517             return 0;
518         }
519         printf_mysql_query("UPDATE `bots` SET `defaulttrigger` = '%s' WHERE `id` = '%s'", escape_string(value), bot[15]);
520         flush_trigger_cache(atoi(bot[5]), atoi(bot[15]));
521         reply(getTextBot(), user, "NS_SETBOT_TRIGGER_NOTE");
522         val = value;
523         ret = 1;
524     }
525     reply(getTextBot(), user, "\002TRIGGER    \002 %s", val);
526     return ret;
527 }