ns_saset.c

Go to the documentation of this file.
00001 /* NickServ core functions
00002  *
00003  * (C) 2003-2013 Anope Team
00004  * Contact us at team@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  *
00012  */
00013 /*************************************************************************/
00014 
00015 #include "module.h"
00016 #include "encrypt.h"
00017 
00018 static int do_saset(User * u);
00019 static int do_saset_display(User * u, NickCore * nc, char *param);
00020 static int do_saset_password(User * u, NickCore * nc, char *param);
00021 static int do_saset_url(User * u, NickCore * nc, char *param);
00022 static int do_saset_email(User * u, NickCore * nc, char *param);
00023 static int do_saset_greet(User * u, NickCore * nc, char *param);
00024 static int do_saset_icq(User * u, NickCore * nc, char *param);
00025 static int do_saset_kill(User * u, NickCore * nc, char *param);
00026 static int do_saset_secure(User * u, NickCore * nc, char *param);
00027 static int do_saset_private(User * u, NickCore * nc, char *param);
00028 static int do_saset_msg(User * u, NickCore * nc, char *param);
00029 static int do_saset_hide(User * u, NickCore * nc, char *param);
00030 static int do_saset_noexpire(User * u, NickAlias * nc, char *param);
00031 static int do_saset_autoop(User * u, NickCore * nc, char *param);
00032 static int do_saset_language(User * u, NickCore * nc, char *param);
00033 static void myNickServHelp(User * u);
00034 
00041 int AnopeInit(int argc, char **argv)
00042 {
00043     Command *c;
00044 
00045     moduleAddAuthor("Anope");
00046     moduleAddVersion(VERSION_STRING);
00047     moduleSetType(CORE);
00048 
00049     c = createCommand("SASET", do_saset, is_services_oper, -1, -1,
00050                       NICK_HELP_SASET, NICK_HELP_SASET, NICK_HELP_SASET);
00051     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00052     c = createCommand("SASET DISPLAY", NULL, is_services_oper,
00053                       -1, -1, NICK_HELP_SASET_DISPLAY, NICK_HELP_SASET_DISPLAY, NICK_HELP_SASET_DISPLAY);
00054     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00055     c = createCommand("SASET PASSWORD", NULL, is_services_oper,
00056                       -1, -1, NICK_HELP_SASET_PASSWORD, NICK_HELP_SASET_PASSWORD, NICK_HELP_SASET_PASSWORD);
00057     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00058     c = createCommand("SASET URL", NULL, is_services_oper,
00059                       -1, -1, NICK_HELP_SASET_URL, NICK_HELP_SASET_URL, NICK_HELP_SASET_URL);
00060     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00061     c = createCommand("SASET EMAIL", NULL, is_services_oper,
00062                       -1, -1, NICK_HELP_SASET_EMAIL, NICK_HELP_SASET_EMAIL, NICK_HELP_SASET_EMAIL);
00063     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00064     c = createCommand("SASET ICQ", NULL, is_services_oper,
00065                       -1, -1, NICK_HELP_SASET_ICQ, NICK_HELP_SASET_ICQ, NICK_HELP_SASET_ICQ);
00066     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00067     c = createCommand("SASET GREET", NULL, is_services_oper,
00068                       -1, -1, NICK_HELP_SASET_GREET, NICK_HELP_SASET_GREET, NICK_HELP_SASET_GREET);
00069     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00070     c = createCommand("SASET KILL", NULL, is_services_oper,
00071                       -1, -1, NICK_HELP_SASET_KILL, NICK_HELP_SASET_KILL, NICK_HELP_SASET_KILL);
00072     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00073     c = createCommand("SASET SECURE", NULL, is_services_oper,
00074                       -1, -1, NICK_HELP_SASET_SECURE, NICK_HELP_SASET_SECURE, NICK_HELP_SASET_SECURE);
00075     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00076     c = createCommand("SASET PRIVATE", NULL, is_services_oper,
00077                       -1, -1, NICK_HELP_SASET_PRIVATE, NICK_HELP_SASET_PRIVATE, NICK_HELP_SASET_PRIVATE);
00078     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00079     c = createCommand("SASET MSG", NULL, is_services_oper,
00080                       -1, -1, NICK_HELP_SASET_MSG, NICK_HELP_SASET_MSG, NICK_HELP_SASET_MSG);
00081     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00082     c = createCommand("SASET HIDE", NULL, is_services_oper,
00083                       -1, -1, NICK_HELP_SASET_HIDE, NICK_HELP_SASET_HIDE, NICK_HELP_SASET_HIDE);
00084     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00085     c = createCommand("SASET NOEXPIRE", NULL, is_services_oper, -1, -1,
00086                       NICK_HELP_SASET_NOEXPIRE, NICK_HELP_SASET_NOEXPIRE,
00087                       NICK_HELP_SASET_NOEXPIRE);
00088     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00089     c = createCommand("SASET AUTOOP", NULL, is_services_oper, -1, -1,
00090                       NICK_HELP_SASET_AUTOOP, NICK_HELP_SASET_AUTOOP, NICK_HELP_SASET_AUTOOP);
00091     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00092     c = createCommand("SASET LANGUAGE", NULL, is_services_oper,
00093                       -1, -1, NICK_HELP_SASET_LANGUAGE, NICK_HELP_SASET_LANGUAGE, NICK_HELP_SASET_LANGUAGE);
00094     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00095 
00096     moduleSetNickHelp(myNickServHelp);
00097 
00098     return MOD_CONT;
00099 }
00100 
00104 void AnopeFini(void)
00105 {
00106 
00107 }
00108 
00109 
00110 
00115 static void myNickServHelp(User * u)
00116 {
00117     if (is_services_oper(u))
00118         notice_lang(s_NickServ, u, NICK_HELP_CMD_SASET);
00119 }
00120 
00126 static int do_saset(User * u)
00127 {
00128     char *nick = strtok(NULL, " ");
00129     char *cmd = strtok(NULL, " ");
00130     char *param = strtok(NULL, " ");
00131 
00132     NickAlias *na;
00133 
00134     if (readonly) {
00135         notice_lang(s_NickServ, u, NICK_SASET_DISABLED);
00136         return MOD_CONT;
00137     }
00138         if (!nick) {
00139                 syntax_error(s_NickServ, u, "SASET", NICK_SASET_SYNTAX);
00140                 return MOD_CONT;
00141         }
00142     if (!(na = findnick(nick))) {
00143         notice_lang(s_NickServ, u, NICK_SASET_BAD_NICK, nick);
00144         return MOD_CONT;
00145     }
00146 
00147     if (!param
00148         && (!cmd
00149             || (stricmp(cmd, "URL") != 0 && stricmp(cmd, "EMAIL") != 0
00150                 && stricmp(cmd, "GREET") != 0
00151                 && stricmp(cmd, "ICQ") != 0))) {
00152         syntax_error(s_NickServ, u, "SASET", NICK_SASET_SYNTAX);
00153     } else if (!na) {
00154         notice_lang(s_NickServ, u, NICK_NOT_REGISTERED, nick);
00155     } else if (na->status & NS_VERBOTEN) {
00156         notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
00157     } else if (na->nc->flags & NI_SUSPENDED) {
00158         notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);
00159     } else if (stricmp(cmd, "DISPLAY") == 0) {
00160         do_saset_display(u, na->nc, param);
00161     } else if (stricmp(cmd, "PASSWORD") == 0) {
00162         do_saset_password(u, na->nc, param);
00163     } else if (stricmp(cmd, "URL") == 0) {
00164         do_saset_url(u, na->nc, param);
00165     } else if (stricmp(cmd, "EMAIL") == 0) {
00166         do_saset_email(u, na->nc, param);
00167     } else if (stricmp(cmd, "ICQ") == 0) {
00168         do_saset_icq(u, na->nc, param);
00169     } else if (stricmp(cmd, "GREET") == 0) {
00170         do_saset_greet(u, na->nc, param);
00171     } else if (stricmp(cmd, "KILL") == 0) {
00172         do_saset_kill(u, na->nc, param);
00173     } else if (stricmp(cmd, "SECURE") == 0) {
00174         do_saset_secure(u, na->nc, param);
00175     } else if (stricmp(cmd, "PRIVATE") == 0) {
00176         do_saset_private(u, na->nc, param);
00177     } else if (stricmp(cmd, "MSG") == 0) {
00178         do_saset_msg(u, na->nc, param);
00179     } else if (stricmp(cmd, "HIDE") == 0) {
00180         do_saset_hide(u, na->nc, param);
00181     } else if (stricmp(cmd, "NOEXPIRE") == 0) {
00182         do_saset_noexpire(u, na, param);
00183     } else if (stricmp(cmd, "AUTOOP") == 0) {
00184         do_saset_autoop(u, na->nc, param); 
00185     } else if (stricmp(cmd, "LANGUAGE") == 0) {
00186         do_saset_language(u, na->nc, param);
00187     } else {
00188         notice_lang(s_NickServ, u, NICK_SASET_UNKNOWN_OPTION, cmd);
00189     }
00190     return MOD_CONT;
00191 }
00192 
00193 static int do_saset_display(User * u, NickCore * nc, char *param)
00194 {
00195     int i;
00196     NickAlias *na;
00197 
00198     /* First check whether param is a valid nick of the group */
00199     for (i = 0; i < nc->aliases.count; i++) {
00200         na = nc->aliases.list[i];
00201         if (stricmp(na->nick, param) == 0) {
00202             param = na->nick;   /* Because case may differ */
00203             break;
00204         }
00205     }
00206 
00207     if (i == nc->aliases.count) {
00208         notice_lang(s_NickServ, u, NICK_SASET_DISPLAY_INVALID,
00209                     nc->display);
00210         return MOD_CONT;
00211     }
00212 
00213     alog("%s: %s!%s@%s set the display of %s to: %s",
00214          s_NickServ, u->nick, u->username, u->host, nc->display, param);
00215     change_core_display(nc, param);
00216     notice_lang(s_NickServ, u, NICK_SASET_DISPLAY_CHANGED, nc->display);
00217 
00218     if (NSNickTracking) {
00219         for (i = 0; i < nc->aliases.count; ++i) {
00220             na = nc->aliases.list[i];
00221             if (na->u && nick_identified(na->u))
00222                 nsStartNickTracking(na->u);
00223         }
00224     }
00225 
00226     return MOD_CONT;
00227 }
00228 
00229 static int do_saset_password(User * u, NickCore * nc, char *param)
00230 {
00231     int len = strlen(param);
00232     char tmp_pass[PASSMAX];
00233 
00234     if (NSSecureAdmins && u->na->nc != nc && nick_is_services_admin(nc)
00235         && !is_services_root(u)) {
00236         notice_lang(s_NickServ, u, PERMISSION_DENIED);
00237         return MOD_CONT;
00238     } else if (stricmp(nc->display, param) == 0
00239                || (StrictPasswords && len < 5)) {
00240         notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD);
00241         return MOD_CONT;
00242     } else if (enc_encrypt_check_len(len ,PASSMAX - 1)) {
00243         notice_lang(s_NickServ, u, PASSWORD_TOO_LONG);
00244         return MOD_CONT;
00245     }
00246 
00247     if (enc_encrypt(param, len, nc->pass, PASSMAX - 1) < 0) {
00248         memset(param, 0, len);
00249         alog("%s: Failed to encrypt password for %s (set)", s_NickServ,
00250              nc->display);
00251         notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_FAILED,
00252                     nc->display);
00253         return MOD_CONT;
00254     }
00255     memset(param, 0, len);
00256 
00257     if(enc_decrypt(nc->pass,tmp_pass,PASSMAX - 1)==1) {
00258         notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_CHANGED_TO, nc->display,
00259                     tmp_pass);
00260     } else {
00261         notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_CHANGED, nc->display);
00262     }
00263 
00264     alog("%s: %s!%s@%s used SASET PASSWORD on %s (e-mail: %s)", s_NickServ,
00265          u->nick, u->username, u->host, nc->display,
00266          (nc->email ? nc->email : "none"));
00267     if (WallSetpass)
00268         anope_cmd_global(s_NickServ,
00269                          "\2%s\2 used SASET PASSWORD on \2%s\2",
00270                          u->nick, nc->display);
00271     return MOD_CONT;
00272 }
00273 
00274 static int do_saset_url(User * u, NickCore * nc, char *param)
00275 {
00276     if (nc->url)
00277         free(nc->url);
00278 
00279     if (param) {
00280         nc->url = sstrdup(param);
00281         alog("%s: %s!%s@%s set the url of %s to: %s",
00282              s_NickServ, u->nick, u->username, u->host, nc->display, nc->url);
00283         notice_lang(s_NickServ, u, NICK_SASET_URL_CHANGED, nc->display,
00284                     param);
00285     } else {
00286         nc->url = NULL;
00287         alog("%s: %s!%s@%s unset the url of %s",
00288              s_NickServ, u->nick, u->username, u->host, nc->display);
00289         notice_lang(s_NickServ, u, NICK_SASET_URL_UNSET, nc->display);
00290     }
00291     return MOD_CONT;
00292 }
00293 
00294 static int do_saset_email(User * u, NickCore * nc, char *param)
00295 {
00296     if (!param && NSForceEmail) {
00297         notice_lang(s_NickServ, u, NICK_SASET_EMAIL_UNSET_IMPOSSIBLE);
00298         return MOD_CONT;
00299     } else if (NSSecureAdmins && u->na->nc != nc
00300                && nick_is_services_admin(nc)
00301                && !is_services_root(u)) {
00302         notice_lang(s_NickServ, u, PERMISSION_DENIED);
00303         return MOD_CONT;
00304     } else if (param && !MailValidate(param)) {
00305         notice_lang(s_NickServ, u, MAIL_X_INVALID, param);
00306         return MOD_CONT;
00307     }
00308 
00309     alog("%s: %s!%s@%s used SASET EMAIL on %s (e-mail: %s)", s_NickServ,
00310          u->nick, u->username, u->host, nc->display,
00311          (nc->email ? nc->email : "none"));
00312 
00313     if (nc->email)
00314         free(nc->email);
00315 
00316     if (param) {
00317         nc->email = sstrdup(param);
00318         notice_lang(s_NickServ, u, NICK_SASET_EMAIL_CHANGED, nc->display,
00319                     param);
00320     } else {
00321         nc->email = NULL;
00322         notice_lang(s_NickServ, u, NICK_SASET_EMAIL_UNSET, nc->display);
00323     }
00324     return MOD_CONT;
00325 }
00326 
00327 static int do_saset_icq(User * u, NickCore * nc, char *param)
00328 {
00329     if (param) {
00330         int32 tmp = atol(param);
00331         if (tmp == 0) {
00332             notice_lang(s_NickServ, u, NICK_SASET_ICQ_INVALID, param);
00333         } else {
00334             nc->icq = tmp;
00335             alog("%s: %s!%s@%s set the icq of %s to: %d",
00336                  s_NickServ, u->nick, u->username, u->host, nc->display, nc->icq);
00337             notice_lang(s_NickServ, u, NICK_SASET_ICQ_CHANGED, nc->display,
00338                         param);
00339         }
00340     } else {
00341         nc->icq = 0;
00342         alog("%s: %s!%s@%s unset the icq of %s",
00343              s_NickServ, u->nick, u->username, u->host, nc->display);
00344         notice_lang(s_NickServ, u, NICK_SASET_ICQ_UNSET, nc->display);
00345     }
00346     return MOD_CONT;
00347 }
00348 
00349 static int do_saset_greet(User * u, NickCore * nc, char *param)
00350 {
00351     if (nc->greet)
00352         free(nc->greet);
00353 
00354     if (param) {
00355         char buf[BUFSIZE];
00356         char *end = strtok(NULL, "");
00357 
00358         snprintf(buf, sizeof(buf), "%s%s%s", param, (end ? " " : ""),
00359                  (end ? end : ""));
00360 
00361         nc->greet = sstrdup(buf);
00362         alog("%s: %s!%s@%s set the greet of %s to: %s",
00363              s_NickServ, u->nick, u->username, u->host, nc->display, nc->greet);
00364         notice_lang(s_NickServ, u, NICK_SASET_GREET_CHANGED, nc->display,
00365                     buf);
00366     } else {
00367         nc->greet = NULL;
00368         alog("%s: %s!%s@%s unset the greet of %s",
00369              s_NickServ, u->nick, u->username, u->host, nc->display);
00370         notice_lang(s_NickServ, u, NICK_SASET_GREET_UNSET, nc->display);
00371     }
00372     return MOD_CONT;
00373 }
00374 
00375 static int do_saset_kill(User * u, NickCore * nc, char *param)
00376 {
00377     if (stricmp(param, "ON") == 0) {
00378         nc->flags |= NI_KILLPROTECT;
00379         nc->flags &= ~(NI_KILL_QUICK | NI_KILL_IMMED);
00380         alog("%s: %s!%s@%s set kill ON for %s",
00381              s_NickServ, u->nick, u->username, u->host, nc->display);
00382         notice_lang(s_NickServ, u, NICK_SASET_KILL_ON, nc->display);
00383     } else if (stricmp(param, "QUICK") == 0) {
00384         nc->flags |= NI_KILLPROTECT | NI_KILL_QUICK;
00385         nc->flags &= ~NI_KILL_IMMED;
00386         alog("%s: %s!%s@%s set kill QUICK for %s",
00387              s_NickServ, u->nick, u->username, u->host, nc->display);
00388         notice_lang(s_NickServ, u, NICK_SASET_KILL_QUICK, nc->display);
00389     } else if (stricmp(param, "IMMED") == 0) {
00390         if (NSAllowKillImmed) {
00391             nc->flags |= NI_KILLPROTECT | NI_KILL_IMMED;
00392             nc->flags &= ~NI_KILL_QUICK;
00393             alog("%s: %s!%s@%s set kill IMMED for %s",
00394                  s_NickServ, u->nick, u->username, u->host, nc->display);
00395             notice_lang(s_NickServ, u, NICK_SASET_KILL_IMMED, nc->display);
00396         } else {
00397             notice_lang(s_NickServ, u, NICK_SASET_KILL_IMMED_DISABLED);
00398         }
00399     } else if (stricmp(param, "OFF") == 0) {
00400         nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED);
00401         alog("%s: %s!%s@%s set kill OFF for %s",
00402              s_NickServ, u->nick, u->username, u->host, nc->display);
00403         notice_lang(s_NickServ, u, NICK_SASET_KILL_OFF, nc->display);
00404     } else {
00405         syntax_error(s_NickServ, u, "SASET KILL",
00406                      NSAllowKillImmed ? NICK_SASET_KILL_IMMED_SYNTAX :
00407                      NICK_SASET_KILL_SYNTAX);
00408     }
00409     return MOD_CONT;
00410 }
00411 
00412 static int do_saset_secure(User * u, NickCore * nc, char *param)
00413 {
00414     if (stricmp(param, "ON") == 0) {
00415         nc->flags |= NI_SECURE;
00416         alog("%s: %s!%s@%s set secure ON for %s",
00417              s_NickServ, u->nick, u->username, u->host, nc->display);
00418         notice_lang(s_NickServ, u, NICK_SASET_SECURE_ON, nc->display);
00419     } else if (stricmp(param, "OFF") == 0) {
00420         nc->flags &= ~NI_SECURE;
00421         alog("%s: %s!%s@%s set secure OFF for %s",
00422              s_NickServ, u->nick, u->username, u->host, nc->display);
00423         notice_lang(s_NickServ, u, NICK_SASET_SECURE_OFF, nc->display);
00424     } else {
00425         syntax_error(s_NickServ, u, "SASET SECURE",
00426                      NICK_SASET_SECURE_SYNTAX);
00427     }
00428     return MOD_CONT;
00429 }
00430 
00431 static int do_saset_private(User * u, NickCore * nc, char *param)
00432 {
00433     if (stricmp(param, "ON") == 0) {
00434         nc->flags |= NI_PRIVATE;
00435         alog("%s: %s!%s@%s set private ON for %s",
00436              s_NickServ, u->nick, u->username, u->host, nc->display);
00437         notice_lang(s_NickServ, u, NICK_SASET_PRIVATE_ON, nc->display);
00438     } else if (stricmp(param, "OFF") == 0) {
00439         nc->flags &= ~NI_PRIVATE;
00440         alog("%s: %s!%s@%s set private OFF for %s",
00441              s_NickServ, u->nick, u->username, u->host, nc->display);
00442         notice_lang(s_NickServ, u, NICK_SASET_PRIVATE_OFF, nc->display);
00443     } else {
00444         syntax_error(s_NickServ, u, "SASET PRIVATE",
00445                      NICK_SASET_PRIVATE_SYNTAX);
00446     }
00447     return MOD_CONT;
00448 }
00449 
00450 static int do_saset_msg(User * u, NickCore * nc, char *param)
00451 {
00452     if (!UsePrivmsg) {
00453         notice_lang(s_NickServ, u, NICK_SASET_OPTION_DISABLED, "MSG");
00454         return MOD_CONT;
00455     }
00456 
00457     if (stricmp(param, "ON") == 0) {
00458         nc->flags |= NI_MSG;
00459         alog("%s: %s!%s@%s set msg ON for %s",
00460              s_NickServ, u->nick, u->username, u->host, nc->display);
00461         notice_lang(s_NickServ, u, NICK_SASET_MSG_ON, nc->display);
00462     } else if (stricmp(param, "OFF") == 0) {
00463         nc->flags &= ~NI_MSG;
00464         alog("%s: %s!%s@%s set msg OFF for %s",
00465              s_NickServ, u->nick, u->username, u->host, nc->display);
00466         notice_lang(s_NickServ, u, NICK_SASET_MSG_OFF, nc->display);
00467     } else {
00468         syntax_error(s_NickServ, u, "SASET MSG", NICK_SASET_MSG_SYNTAX);
00469     }
00470     return MOD_CONT;
00471 }
00472 
00473 static int do_saset_hide(User * u, NickCore * nc, char *param)
00474 {
00475     int flag, onmsg, offmsg;
00476     char *param2;
00477 
00478     if (stricmp(param, "EMAIL") == 0) {
00479         flag = NI_HIDE_EMAIL;
00480         onmsg = NICK_SASET_HIDE_EMAIL_ON;
00481         offmsg = NICK_SASET_HIDE_EMAIL_OFF;
00482     } else if (stricmp(param, "USERMASK") == 0) {
00483         flag = NI_HIDE_MASK;
00484         onmsg = NICK_SASET_HIDE_MASK_ON;
00485         offmsg = NICK_SASET_HIDE_MASK_OFF;
00486     } else if (stricmp(param, "STATUS") == 0) {
00487         flag = NI_HIDE_STATUS;
00488         onmsg = NICK_SASET_HIDE_STATUS_ON;
00489         offmsg = NICK_SASET_HIDE_STATUS_OFF;
00490     } else if (stricmp(param, "QUIT") == 0) {
00491         flag = NI_HIDE_QUIT;
00492         onmsg = NICK_SASET_HIDE_QUIT_ON;
00493         offmsg = NICK_SASET_HIDE_QUIT_OFF;
00494     } else {
00495         syntax_error(s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX);
00496         return MOD_CONT;
00497     }
00498 
00499     param2 = strtok(NULL, " ");
00500     if (!param2) {
00501         syntax_error(s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX);
00502     } else if (stricmp(param2, "ON") == 0) {
00503         nc->flags |= flag;
00504         alog("%s: %s!%s@%s set hide %s ON for %s",
00505              s_NickServ, u->nick, u->username, u->host, param, nc->display);
00506         notice_lang(s_NickServ, u, onmsg, nc->display, s_NickServ);
00507     } else if (stricmp(param2, "OFF") == 0) {
00508         nc->flags &= ~flag;
00509         alog("%s: %s!%s@%s set hide %s OFF for %s",
00510              s_NickServ, u->nick, u->username, u->host, param, nc->display);
00511         notice_lang(s_NickServ, u, offmsg, nc->display, s_NickServ);
00512     } else {
00513         syntax_error(s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX);
00514     }
00515 
00516     return MOD_CONT;
00517 }
00518 
00519 static int do_saset_noexpire(User * u, NickAlias * na, char *param)
00520 {
00521     if (!param) {
00522         syntax_error(s_NickServ, u, "SASET NOEXPIRE",
00523                      NICK_SASET_NOEXPIRE_SYNTAX);
00524         return MOD_CONT;
00525     }
00526     if (stricmp(param, "ON") == 0) {
00527         na->status |= NS_NO_EXPIRE;
00528         alog("%s: %s!%s@%s set noexpire ON for %s",
00529              s_NickServ, u->nick, u->username, u->host, na->nick);
00530         notice_lang(s_NickServ, u, NICK_SASET_NOEXPIRE_ON, na->nick);
00531     } else if (stricmp(param, "OFF") == 0) {
00532         na->status &= ~NS_NO_EXPIRE;
00533         alog("%s: %s!%s@%s set noexpire OFF for %s",
00534              s_NickServ, u->nick, u->username, u->host, na->nick);
00535         notice_lang(s_NickServ, u, NICK_SASET_NOEXPIRE_OFF, na->nick);
00536     } else {
00537         syntax_error(s_NickServ, u, "SASET NOEXPIRE",
00538                      NICK_SASET_NOEXPIRE_SYNTAX);
00539     }
00540     return MOD_CONT;
00541 }
00542 
00543 static int do_saset_autoop(User * u, NickCore * nc, char *param)
00544 {
00545     if (stricmp(param, "ON") == 0) {
00546         nc->flags &= ~NI_AUTOOP;
00547         alog("%s: %s!%s@%s set autoop ON for %s",
00548              s_NickServ, u->nick, u->username, u->host, nc->display);
00549         notice_lang(s_NickServ, u, NICK_SASET_AUTOOP_ON, nc->display);
00550     } else if (stricmp(param, "OFF") == 0) {
00551         nc->flags |= NI_AUTOOP;
00552         alog("%s: %s!%s@%s set autoop OFF for %s",
00553              s_NickServ, u->nick, u->username, u->host, nc->display);
00554         notice_lang(s_NickServ, u, NICK_SASET_AUTOOP_OFF, nc->display);
00555     } else {
00556         syntax_error(s_NickServ, u, "SET AUTOOP", NICK_SASET_AUTOOP_SYNTAX);
00557     }
00558 
00559     return MOD_CONT;
00560 }
00561 
00562 static int do_saset_language(User * u, NickCore * nc, char *param)
00563 {
00564     int langnum;
00565 
00566     if (param[strspn(param, "0123456789")] != 0) {      /* i.e. not a number */
00567         syntax_error(s_NickServ, u, "SASET LANGUAGE",
00568                      NICK_SASET_LANGUAGE_SYNTAX);
00569         return MOD_CONT;
00570     }
00571     langnum = atoi(param) - 1;
00572     if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0) {
00573         notice_lang(s_NickServ, u, NICK_SASET_LANGUAGE_UNKNOWN, langnum + 1,
00574                     s_NickServ);
00575         return MOD_CONT;
00576     }
00577     nc->language = langlist[langnum];
00578     alog("%s: %s!%s@%s set the language of %s to %s",
00579          s_NickServ, u->nick, u->username, u->host, nc->display, getstring2(nc, LANG_NAME));
00580     notice_lang(s_NickServ, u, NICK_SASET_LANGUAGE_CHANGED, nc->display, getstring2(nc, LANG_NAME));
00581 
00582     return MOD_CONT;
00583 }
00584 
00585 /* EOF */