a5e0e9911ea3690610c04996a09236a70fb90a79
[srvx.git] / src / mod-memoserv.c
1 /* mod-memoserv.c - MemoServ module for srvx
2  * Copyright 2003-2004 Martijn Smit and srvx Development Team
3  *
4  * This file is part of srvx.
5  *
6  * srvx is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with srvx; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
19  */
20
21 /* Adds new section to srvx.conf:
22  * "modules" {
23  *     "memoserv" {
24  *         "bot" "NickServ";
25  *         "message_expiry" "30d"; // age when messages are deleted; set
26  *                                 // to 0 to disable message expiration
27  *     };
28  *  };
29  *
30  * After that, to make the module active on an existing bot:
31  * /msg opserv bind nickserv * *memoserv.*
32  *
33  * If you want a dedicated MemoServ bot, make sure the service control
34  * commands are bound to OpServ:
35  * /msg opserv bind opserv service *modcmd.joiner
36  * /msg opserv bind opserv service\ add *modcmd.service\ add
37  * /msg opserv bind opserv service\ rename *modcmd.service\ rename
38  * /msg opserv bind opserv service\ trigger *modcmd.service\ trigger
39  * /msg opserv bind opserv service\ remove *modcmd.service\ remove
40  * Add the bot:
41  * /msg opserv service add MemoServ User-to-user Memorandum Service
42  * /msg opserv bind memoserv help *modcmd.help
43  * Restart srvx with the updated conf file (as above, butwith "bot"
44  * "MemoServ"), and bind the commands to it:
45  * /msg opserv bind memoserv * *memoserv.*
46  * /msg opserv bind memoserv set *modcmd.joiner
47  */
48
49 #include "chanserv.h"
50 #include "conf.h"
51 #include "modcmd.h"
52 #include "saxdb.h"
53 #include "timeq.h"
54
55 #define KEY_SENT "sent"
56 #define KEY_RECIPIENT "to"
57 #define KEY_FROM "from"
58 #define KEY_MESSAGE "msg"
59 #undef KEY_READ /* thanks microsoft! */
60 #define KEY_READ "read"
61
62 static const struct message_entry msgtab[] = {
63     { "MSMSG_CANNOT_SEND", "You cannot send to account $b%s$b." },
64     { "MSMSG_MEMO_SENT", "Message sent to $b%s$b." },
65     { "MSMSG_NO_MESSAGES", "You have no messages." },
66     { "MSMSG_MEMOS_FOUND", "Found $b%d$b matches.\nUse /msg $S READ <ID> to read a message." },
67     { "MSMSG_CLEAN_INBOX", "You have $b%d$b or more messages, please clean out your inbox.\nUse /msg $S READ <ID> to read a message." },
68     { "MSMSG_LIST_HEAD", "$bID$b   $bFrom$b       $bTime Sent$b" },
69     { "MSMSG_LIST_FORMAT", "%-2u     %s           %s" },
70     { "MSMSG_MEMO_HEAD", "Memo %u From $b%s$b, received on %s:" },
71     { "MSMSG_BAD_MESSAGE_ID", "$b%s$b is not a valid message ID (it should be a number between 0 and %u)." },
72     { "MSMSG_NO_SUCH_MEMO", "You have no memo with that ID." },
73     { "MSMSG_MEMO_DELETED", "Memo $b%d$b deleted." },
74     { "MSMSG_EXPIRY_OFF", "I am currently not expiring messages. (turned off)" },
75     { "MSMSG_EXPIRY", "Messages will be expired when they are %s old (%d seconds)." },
76     { "MSMSG_MESSAGES_EXPIRED", "$b%lu$b message(s) expired." },
77     { "MSMSG_MEMOS_INBOX", "You have $b%d$b new message(s) in your inbox and %d old messages.  Use /msg $S LIST to list them." },
78     { "MSMSG_NEW_MESSAGE", "You have a new message from $b%s$b." },
79     { "MSMSG_DELETED_ALL", "Deleted all of your messages." },
80     { "MSMSG_USE_CONFIRM", "Please use /msg $S DELETE * $bCONFIRM$b to delete $uall$u of your messages." },
81     { "MSMSG_STATUS_TOTAL", "I have $b%u$b memos in my database." },
82     { "MSMSG_STATUS_EXPIRED", "$b%ld$b memos expired during the time I am awake." },
83     { "MSMSG_STATUS_SENT", "$b%ld$b memos have been sent." },
84     { "MSMSG_SET_NOTIFY",     "$bNotify:       $b %s" },
85     { "MSMSG_SET_AUTHNOTIFY", "$bAuthNotify:   $b %s" },
86     { "MSMSG_SET_PRIVATE",    "$bPrivate:      $b %s" },
87     { NULL, NULL }
88 };
89
90 struct memo {
91     struct memo_account *recipient;
92     struct memo_account *sender;
93     char *message;
94     time_t sent;
95     unsigned int is_read : 1;
96 };
97
98 DECLARE_LIST(memoList, struct memo*);
99 DEFINE_LIST(memoList, struct memo*);
100
101 /* memo_account.flags fields */
102 #define MEMO_NOTIFY_NEW   1
103 #define MEMO_NOTIFY_LOGIN 2
104 #define MEMO_DENY_NONCHANNEL 4
105
106 struct memo_account {
107     struct handle_info *handle;
108     unsigned int flags;
109     struct memoList sent;
110     struct memoList recvd;
111 };
112
113 static struct {
114     struct userNode *bot;
115     int message_expiry;
116 } memoserv_conf;
117
118 const char *memoserv_module_deps[] = { NULL };
119 static struct module *memoserv_module;
120 static struct log_type *MS_LOG;
121 static unsigned long memosSent, memosExpired;
122 static struct dict *memos; /* memo_account->handle->handle -> memo_account */
123
124 static struct memo_account *
125 memoserv_get_account(struct handle_info *hi)
126 {
127     struct memo_account *ma;
128     if (!hi)
129         return NULL;
130     ma = dict_find(memos, hi->handle, NULL);
131     if (ma)
132         return ma;
133     ma = calloc(1, sizeof(*ma));
134     if (!ma)
135         return ma;
136     ma->handle = hi;
137     ma->flags = MEMO_NOTIFY_NEW | MEMO_NOTIFY_LOGIN;
138     dict_insert(memos, ma->handle->handle, ma);
139     return ma;
140 }
141
142 static void
143 delete_memo(struct memo *memo)
144 {
145     memoList_remove(&memo->recipient->recvd, memo);
146     memoList_remove(&memo->sender->sent, memo);
147     free(memo->message);
148     free(memo);
149 }
150
151 static void
152 delete_memo_account(void *data)
153 {
154     struct memo_account *ma = data;
155
156     while (ma->recvd.used)
157         delete_memo(ma->recvd.list[0]);
158     while (ma->sent.used)
159         delete_memo(ma->sent.list[0]);
160     memoList_clean(&ma->recvd);
161     memoList_clean(&ma->sent);
162     free(ma);
163 }
164
165 void
166 do_expire(void)
167 {
168     dict_iterator_t it;
169     for (it = dict_first(memos); it; it = iter_next(it)) {
170         struct memo_account *acct = iter_data(it);
171         unsigned int ii;
172         for (ii = 0; ii < acct->sent.used; ++ii) {
173             struct memo *memo = acct->sent.list[ii];
174             if ((now - memo->sent) > memoserv_conf.message_expiry) {
175                 delete_memo(memo);
176                 memosExpired++;
177                 ii--;
178             }
179         }
180     }
181 }
182
183 static void
184 expire_memos(UNUSED_ARG(void *data))
185 {
186     if (memoserv_conf.message_expiry) {
187         do_expire();
188         timeq_add(now + memoserv_conf.message_expiry, expire_memos, NULL);
189     }
190 }
191
192 static struct memo*
193 add_memo(time_t sent, struct memo_account *recipient, struct memo_account *sender, char *message)
194 {
195     struct memo *memo;
196
197     memo = calloc(1, sizeof(*memo));
198     if (!memo)
199         return NULL;
200
201     memo->recipient = recipient;
202     memoList_append(&recipient->recvd, memo);
203     memo->sender = sender;
204     memoList_append(&sender->sent, memo);
205     memo->sent = sent;
206     memo->message = strdup(message);
207     memosSent++;
208     return memo;
209 }
210
211 static int
212 memoserv_can_send(struct userNode *bot, struct userNode *user, struct memo_account *acct)
213 {
214     extern struct userData *_GetChannelUser(struct chanData *channel, struct handle_info *handle, int override, int allow_suspended);
215     struct userData *dest;
216
217     if (!user->handle_info)
218         return 0;
219     if (!(acct->flags & MEMO_DENY_NONCHANNEL))
220         return 1;
221     for (dest = acct->handle->channels; dest; dest = dest->u_next)
222         if (_GetChannelUser(dest->channel, user->handle_info, 1, 0))
223             return 1;
224     send_message(user, bot, "MSMSG_CANNOT_SEND", acct->handle->handle);
225     return 0;
226 }
227
228 static struct memo *find_memo(struct userNode *user, struct svccmd *cmd, struct memo_account *ma, const char *msgid, unsigned int *id)
229 {
230     unsigned int memoid;
231     if (!isdigit(msgid[0])) {
232         if (ma->recvd.used)
233             reply("MSMSG_BAD_MESSAGE_ID", msgid, ma->recvd.used - 1);
234         else
235             reply("MSMSG_NO_MESSAGES");
236         return NULL;
237     }
238     memoid = atoi(msgid);
239     if (memoid >= ma->recvd.used) {
240         reply("MSMSG_NO_SUCH_MEMO");
241         return NULL;
242     }
243     return ma->recvd.list[*id = memoid];
244 }
245
246 static MODCMD_FUNC(cmd_send)
247 {
248     char *message;
249     struct handle_info *hi;
250     struct memo_account *ma, *sender;
251
252     if (!(hi = modcmd_get_handle_info(user, argv[1])))
253         return 0;
254     if (!(sender = memoserv_get_account(user->handle_info))
255         || !(ma = memoserv_get_account(hi))) {
256         reply("MSG_INTERNAL_FAILURE");
257         return 0;
258     }
259     if (!(memoserv_can_send(cmd->parent->bot, user, ma)))
260         return 0;
261     message = unsplit_string(argv + 2, argc - 2, NULL);
262     add_memo(now, ma, sender, message);
263     if (ma->flags & MEMO_NOTIFY_NEW) {
264         struct userNode *other;
265         for (other = ma->handle->users; other; other = other->next_authed)
266             send_message(other, cmd->parent->bot, "MSMSG_NEW_MESSAGE", user->nick);
267     }
268     reply("MSMSG_MEMO_SENT", ma->handle->handle);
269     return 1;
270 }
271
272 static MODCMD_FUNC(cmd_list)
273 {
274     struct memo_account *ma;
275     struct memo *memo;
276     unsigned int ii;
277     char posted[24];
278     struct tm tm;
279
280     if (!(ma = memoserv_get_account(user->handle_info)))
281         return 0;
282     reply("MSMSG_LIST_HEAD");
283     for (ii = 0; (ii < ma->recvd.used) && (ii < 15); ++ii) {
284         memo = ma->recvd.list[ii];
285         localtime_r(&memo->sent, &tm);
286         strftime(posted, sizeof(posted), "%I:%M %p, %m/%d/%Y", &tm);
287         reply("MSMSG_LIST_FORMAT", ii, memo->sender->handle->handle, posted);
288     }
289     if (ii == 0)
290         reply("MSG_NONE");
291     else if (ii == 15)
292         reply("MSMSG_CLEAN_INBOX", ii);
293     else
294         reply("MSMSG_MEMOS_FOUND", ii);
295     return 1;
296 }
297
298 static MODCMD_FUNC(cmd_read)
299 {
300     struct memo_account *ma;
301     unsigned int memoid;
302     struct memo *memo;
303     char posted[24];
304     struct tm tm;
305
306     if (!(ma = memoserv_get_account(user->handle_info)))
307         return 0;
308     if (!(memo = find_memo(user, cmd, ma, argv[1], &memoid)))
309         return 0;
310     localtime_r(&memo->sent, &tm);
311     strftime(posted, sizeof(posted), "%I:%M %p, %m/%d/%Y", &tm);
312     reply("MSMSG_MEMO_HEAD", memoid, memo->sender->handle->handle, posted);
313     send_message_type(4, user, cmd->parent->bot, "%s", memo->message);
314     memo->is_read = 1;
315     return 1;
316 }
317
318 static MODCMD_FUNC(cmd_delete)
319 {
320     struct memo_account *ma;
321     struct memo *memo;
322     unsigned int memoid;
323
324     if (!(ma = memoserv_get_account(user->handle_info)))
325         return 0;
326     if (!irccasecmp(argv[1], "*") || !irccasecmp(argv[1], "all")) {
327         if ((argc < 3) || irccasecmp(argv[2], "confirm")) {
328             reply("MSMSG_USE_CONFIRM");
329             return 0;
330         }
331         while (ma->recvd.used)
332             delete_memo(ma->recvd.list[0]);
333         reply("MSMSG_DELETED_ALL");
334         return 1;
335     }
336
337     if (!(memo = find_memo(user, cmd, ma, argv[1], &memoid)))
338         return 0;
339     delete_memo(memo);
340     reply("MSMSG_MEMO_DELETED", memoid);
341     return 1;
342 }
343
344 static MODCMD_FUNC(cmd_expire)
345 {
346     unsigned long old_expired = memosExpired;
347     do_expire();
348     reply("MSMSG_MESSAGES_EXPIRED", memosExpired - old_expired);
349     return 1;
350 }
351
352 static MODCMD_FUNC(cmd_expiry)
353 {
354     char interval[INTERVALLEN];
355
356     if (!memoserv_conf.message_expiry) {
357         reply("MSMSG_EXPIRY_OFF");
358         return 1;
359     }
360
361     intervalString(interval, memoserv_conf.message_expiry, user->handle_info);
362     reply("MSMSG_EXPIRY", interval, memoserv_conf.message_expiry);
363     return 1;
364 }
365
366 static MODCMD_FUNC(cmd_set_notify)
367 {
368     struct memo_account *ma;
369     char *choice;
370
371     if (!(ma = memoserv_get_account(user->handle_info)))
372         return 0;
373     if (argc > 1) {
374         choice = argv[1];
375         if (enabled_string(choice)) {
376             ma->flags |= MEMO_NOTIFY_NEW;
377         } else if (disabled_string(choice)) {
378             ma->flags &= ~MEMO_NOTIFY_NEW;
379         } else {
380             reply("MSG_INVALID_BINARY", choice);
381             return 0;
382         }
383     }
384
385     choice = (ma->flags & MEMO_NOTIFY_NEW) ? "on" : "off";
386     reply("MSMSG_SET_NOTIFY", choice);
387     return 1;
388 }
389
390 static MODCMD_FUNC(cmd_set_authnotify)
391 {
392     struct memo_account *ma;
393     char *choice;
394
395     if (!(ma = memoserv_get_account(user->handle_info)))
396         return 0;
397     if (argc > 1) {
398         choice = argv[1];
399         if (enabled_string(choice)) {
400             ma->flags |= MEMO_NOTIFY_LOGIN;
401         } else if (disabled_string(choice)) {
402             ma->flags &= ~MEMO_NOTIFY_LOGIN;
403         } else {
404             reply("MSG_INVALID_BINARY", choice);
405             return 0;
406         }
407     }
408
409     choice = (ma->flags & MEMO_NOTIFY_LOGIN) ? "on" : "off";
410     reply("MSMSG_SET_AUTHNOTIFY", choice);
411     return 1;
412 }
413
414 static MODCMD_FUNC(cmd_set_private)
415 {
416     struct memo_account *ma;
417     char *choice;
418
419     if (!(ma = memoserv_get_account(user->handle_info)))
420         return 0;
421     if (argc > 1) {
422         choice = argv[1];
423         if (enabled_string(choice)) {
424             ma->flags |= MEMO_DENY_NONCHANNEL;
425         } else if (disabled_string(choice)) {
426             ma->flags &= ~MEMO_DENY_NONCHANNEL;
427         } else {
428             reply("MSG_INVALID_BINARY", choice);
429             return 0;
430         }
431     }
432
433     choice = (ma->flags & MEMO_DENY_NONCHANNEL) ? "on" : "off";
434     reply("MSMSG_SET_PRIVATE", choice);
435     return 1;
436 }
437
438 static MODCMD_FUNC(cmd_status)
439 {
440     reply("MSMSG_STATUS_TOTAL", dict_size(memos));
441     reply("MSMSG_STATUS_EXPIRED", memosExpired);
442     reply("MSMSG_STATUS_SENT", memosSent);
443     return 1;
444 }
445
446 static void
447 memoserv_conf_read(void)
448 {
449     dict_t conf_node;
450     const char *str;
451
452     str = "modules/memoserv";
453     if (!(conf_node = conf_get_data(str, RECDB_OBJECT))) {
454         log_module(MS_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", str);
455         return;
456     }
457
458     str = database_get_data(conf_node, "message_expiry", RECDB_QSTRING);
459     memoserv_conf.message_expiry = str ? ParseInterval(str) : 60*24*30;
460 }
461
462 static int
463 memoserv_saxdb_read(struct dict *db)
464 {
465     char *str;
466     struct handle_info *sender, *recipient;
467     struct record_data *hir;
468     struct memo *memo;
469     dict_iterator_t it;
470     time_t sent;
471
472     for (it = dict_first(db); it; it = iter_next(it)) {
473         hir = iter_data(it);
474         if (hir->type != RECDB_OBJECT) {
475             log_module(MS_LOG, LOG_WARNING, "Unexpected rectype %d for %s.", hir->type, iter_key(it));
476             continue;
477         }
478
479         if (!(str = database_get_data(hir->d.object, KEY_SENT, RECDB_QSTRING))) {
480             log_module(MS_LOG, LOG_ERROR, "Date sent not present in memo %s; skipping", iter_key(it));
481             continue;
482         }
483         sent = atoi(str);
484
485         if (!(str = database_get_data(hir->d.object, KEY_RECIPIENT, RECDB_QSTRING))) {
486             log_module(MS_LOG, LOG_ERROR, "Recipient not present in memo %s; skipping", iter_key(it));
487             continue;
488         } else if (!(recipient = get_handle_info(str))) {
489             log_module(MS_LOG, LOG_ERROR, "Invalid recipient %s in memo %s; skipping", str, iter_key(it));
490             continue;
491         }
492
493         if (!(str = database_get_data(hir->d.object, KEY_FROM, RECDB_QSTRING))) {
494             log_module(MS_LOG, LOG_ERROR, "Sender not present in memo %s; skipping", iter_key(it));
495             continue;
496         } else if (!(sender = get_handle_info(str))) {
497             log_module(MS_LOG, LOG_ERROR, "Invalid sender %s in memo %s; skipping", str, iter_key(it));
498             continue;
499         }
500
501         if (!(str = database_get_data(hir->d.object, KEY_MESSAGE, RECDB_QSTRING))) {
502             log_module(MS_LOG, LOG_ERROR, "Message not present in memo %s; skipping", iter_key(it));
503             continue;
504         }
505
506         memo = add_memo(sent, memoserv_get_account(recipient), memoserv_get_account(sender), str);
507         if ((str = database_get_data(hir->d.object, KEY_READ, RECDB_QSTRING)))
508             memo->is_read = 1;
509     }
510     return 0;
511 }
512
513 static int
514 memoserv_saxdb_write(struct saxdb_context *ctx)
515 {
516     dict_iterator_t it;
517     struct memo_account *ma;
518     struct memo *memo;
519     char str[7];
520     unsigned int id = 0, ii;
521
522     for (it = dict_first(memos); it; it = iter_next(it)) {
523         ma = iter_data(it);
524         for (ii = 0; ii < ma->recvd.used; ++ii) {
525             memo = ma->recvd.list[ii];
526             saxdb_start_record(ctx, inttobase64(str, id++, sizeof(str)), 0);
527             saxdb_write_int(ctx, KEY_SENT, memo->sent);
528             saxdb_write_string(ctx, KEY_RECIPIENT, memo->recipient->handle->handle);
529             saxdb_write_string(ctx, KEY_FROM, memo->sender->handle->handle);
530             saxdb_write_string(ctx, KEY_MESSAGE, memo->message);
531             if (memo->is_read)
532                 saxdb_write_int(ctx, KEY_READ, 1);
533             saxdb_end_record(ctx);
534         }
535     }
536     return 0;
537 }
538
539 static void
540 memoserv_cleanup(void)
541 {
542     dict_delete(memos);
543 }
544
545 static void
546 memoserv_check_messages(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle))
547 {
548     unsigned int ii, unseen;
549     struct memo_account *ma;
550     struct memo *memo;
551
552     if (!(ma = memoserv_get_account(user->handle_info))
553         || !(ma->flags & MEMO_NOTIFY_LOGIN))
554         return;
555     for (ii = unseen = 0; ii < ma->recvd.used; ++ii) {
556         memo = ma->recvd.list[ii];
557         if (!memo->is_read)
558             unseen++;
559     }
560     if (ma->recvd.used && memoserv_conf.bot)
561         send_message(user, memoserv_conf.bot, "MSMSG_MEMOS_INBOX", unseen, ma->recvd.used - unseen);
562 }
563
564 static void
565 memoserv_rename_account(struct handle_info *hi, const char *old_handle)
566 {
567     struct memo_account *ma;
568     if (!(ma = dict_find(memos, old_handle, NULL)))
569         return;
570     dict_remove2(memos, old_handle, 1);
571     dict_insert(memos, hi->handle, ma);
572 }
573
574 static void
575 memoserv_unreg_account(UNUSED_ARG(struct userNode *user), struct handle_info *handle)
576 {
577     dict_remove(memos, handle->handle);
578 }
579
580 int
581 memoserv_init(void)
582 {
583     MS_LOG = log_register_type("MemoServ", "file:memoserv.log");
584     memos = dict_new();
585     dict_set_free_data(memos, delete_memo_account);
586     reg_auth_func(memoserv_check_messages);
587     reg_handle_rename_func(memoserv_rename_account);
588     reg_unreg_func(memoserv_unreg_account);
589     conf_register_reload(memoserv_conf_read);
590     reg_exit_func(memoserv_cleanup);
591     saxdb_register("MemoServ", memoserv_saxdb_read, memoserv_saxdb_write);
592
593     memoserv_module = module_register("MemoServ", MS_LOG, "mod-memoserv.help", NULL);
594     modcmd_register(memoserv_module, "send", cmd_send, 3, MODCMD_REQUIRE_AUTHED, NULL);
595     modcmd_register(memoserv_module, "list", cmd_list, 1, MODCMD_REQUIRE_AUTHED, NULL);
596     modcmd_register(memoserv_module, "read", cmd_read, 2, MODCMD_REQUIRE_AUTHED, NULL);
597     modcmd_register(memoserv_module, "delete", cmd_delete, 2, MODCMD_REQUIRE_AUTHED, NULL);
598     modcmd_register(memoserv_module, "expire", cmd_expire, 1, MODCMD_REQUIRE_AUTHED, "flags", "+oper", NULL);
599     modcmd_register(memoserv_module, "expiry", cmd_expiry, 1, 0, NULL);
600     modcmd_register(memoserv_module, "status", cmd_status, 1, 0, NULL);
601     modcmd_register(memoserv_module, "set notify", cmd_set_notify, 1, 0, NULL);
602     modcmd_register(memoserv_module, "set authnotify", cmd_set_authnotify, 1, 0, NULL);
603     modcmd_register(memoserv_module, "set private", cmd_set_private, 1, 0, NULL);
604     message_register_table(msgtab);
605
606     if (memoserv_conf.message_expiry)
607         timeq_add(now + memoserv_conf.message_expiry, expire_memos, NULL);
608     return 1;
609 }
610
611 int
612 memoserv_finalize(void) {
613     dict_t conf_node;
614     const char *str;
615
616     str = "modules/memoserv";
617     if (!(conf_node = conf_get_data(str, RECDB_OBJECT))) {
618         log_module(MS_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", str);
619         return 0;
620     }
621
622     str = database_get_data(conf_node, "bot", RECDB_QSTRING);
623     if (str)
624         memoserv_conf.bot = GetUserH(str);
625     return 1;
626 }