]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/nickserv.c
update memoserv help
[irc/evilnet/x3.git] / src / nickserv.c
index e03e9847703a51d6a38401f890788083088ebd4d..a5f3149f1a8dca2e3ca466070a213d6039dc5242 100644 (file)
@@ -288,6 +288,7 @@ static const struct message_entry msgtab[] = {
     { "NSMSG_SET_PRIVMSG", "$bPRIVMSG:      $b%s" },
     { "NSMSG_SET_STYLE", "$bSTYLE:        $b%s" },
     { "NSMSG_SET_ANNOUNCEMENTS", "$bANNOUNCEMENTS: $b%s" },
+    { "NSMSG_SET_AUTOHIDE", "$bAUTOHIDE: $b%s" },
     { "NSMSG_SET_PASSWORD", "$bPASSWORD:     $b%s" },
     { "NSMSG_SET_FLAGS", "$bFLAGS:        $b%s" },
     { "NSMSG_SET_EMAIL", "$bEMAIL:        $b%s" },
@@ -564,7 +565,7 @@ free_handle_info(void *vhi)
 static void set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp);
 
 static void
-nickserv_unregister_handle(struct handle_info *hi, struct userNode *notify)
+nickserv_unregister_handle(struct handle_info *hi, struct userNode *notify, struct userNode *bot)
 {
     unsigned int n;
 
@@ -574,9 +575,9 @@ nickserv_unregister_handle(struct handle_info *hi, struct userNode *notify)
         set_user_handle_info(hi->users, NULL, 0);
     if (notify) {
         if (nickserv_conf.disable_nicks)
-            send_message(notify, nickserv, "NSMSG_UNREGISTER_SUCCESS", hi->handle);
+            send_message(notify, bot, "NSMSG_UNREGISTER_SUCCESS", hi->handle);
         else
-            send_message(notify, nickserv, "NSMSG_UNREGISTER_NICKS_SUCCESS", hi->handle);
+            send_message(notify, bot, "NSMSG_UNREGISTER_NICKS_SUCCESS", hi->handle);
     }
 
     if (nickserv_conf.sync_log)
@@ -802,6 +803,8 @@ is_secure_password(const char *handle, const char *pass, struct userNode *user)
 {
     unsigned int i, len;
     unsigned int cnt_digits = 0, cnt_upper = 0, cnt_lower = 0;
+    int p;
+
     len = strlen(pass);
     if (len < nickserv_conf.password_min_length) {
         if (user)
@@ -813,8 +816,8 @@ is_secure_password(const char *handle, const char *pass, struct userNode *user)
             send_message(user, nickserv, "NSMSG_PASSWORD_ACCOUNT");
         return 0;
     }
-    dict_find(nickserv_conf.weak_password_dict, pass, &i);
-    if (i) {
+    dict_find(nickserv_conf.weak_password_dict, pass, &p);
+    if (p) {
         if (user)
             send_message(user, nickserv, "NSMSG_PASSWORD_DICTIONARY");
         return 0;
@@ -903,6 +906,17 @@ apply_fakehost(struct handle_info *handle)
         assign_fakehost(target, fake, 1);
 }
 
+void send_func_list(struct userNode *user)
+{
+    unsigned int n;
+    struct handle_info *old_info;
+
+    old_info = user->handle_info;
+
+    for (n=0; n<auth_func_used; n++)
+        auth_func_list[n](user, old_info);
+}
+
 static void
 set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp)
 {
@@ -942,8 +956,13 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp)
     user->handle_info = hi;
     if (hi && !hi->users && !hi->opserv_level)
         HANDLE_CLEAR_FLAG(hi, HELPING);
-    for (n=0; n<auth_func_used; n++)
-        auth_func_list[n](user, old_info);
+
+    if (GetUserH(user->nick)) {
+        for (n=0; n<auth_func_used; n++)
+            auth_func_list[n](user, old_info);
+    } else
+      user->loc = 1;
+
     if (hi) {
         struct nick_info *ni;
 
@@ -953,6 +972,7 @@ set_user_handle_info(struct userNode *user, struct handle_info *hi, int stamp)
             for (other = hi->users; other; other = other->next_authed)
                 send_message(other, nickserv, "NSMSG_CLONE_AUTH", user->nick, user->ident, user->hostname);
         }
+
        user->next_authed = hi->users;
        hi->users = user;
        hi->lastseen = now;
@@ -1808,7 +1828,12 @@ static NICKSERV_FUNC(cmd_auth)
 
     reply("NSMSG_AUTH_SUCCESS");
 
-    if(!IsOper(user))
+    
+    /* Set +x if autohide is on */
+    if(HANDLE_FLAGGED(hi, AUTOHIDE))
+        irc_umode(user, "+x");
+
+    if(!IsOper(user)) /* If they arnt already opered.. */
     {
         /* Auto Oper users with Opserv access -Life4Christ 8-10-2005  */
         if( nickserv_conf.auto_admin[0] && hi->opserv_level >= opserv_conf_admin_level())
@@ -2323,7 +2348,7 @@ set_list(struct userNode *user, struct handle_info *hi, int override)
     unsigned int i;
     char *set_display[] = {
         "INFO", "WIDTH", "TABLEWIDTH", "COLOR", "PRIVMSG", /* "STYLE", */
-        "EMAIL", "ANNOUNCEMENTS", "MAXLOGINS", "LANGUAGE",
+        "EMAIL", "ANNOUNCEMENTS", "AUTOHIDE", "MAXLOGINS", "LANGUAGE",
         "FAKEHOST", "TITLE", "EPITHET"
     };
 
@@ -2456,6 +2481,23 @@ static OPTION_FUNC(opt_privmsg)
     return 1;
 }
 
+static OPTION_FUNC(opt_autohide)
+{
+    if (argc > 1) {
+       if (enabled_string(argv[1]))
+           HANDLE_SET_FLAG(hi, AUTOHIDE);
+        else if (disabled_string(argv[1]))
+           HANDLE_CLEAR_FLAG(hi, AUTOHIDE);
+       else {
+           send_message(user, nickserv, "MSG_INVALID_BINARY", argv[1]);
+           return 0;
+       }
+    }
+
+    send_message(user, nickserv, "NSMSG_SET_AUTOHIDE", user_find_message(user, HANDLE_FLAGGED(hi, AUTOHIDE) ? "MSG_ON" : "MSG_OFF"));
+    return 1;
+}
+
 /*
 static OPTION_FUNC(opt_style)
 {
@@ -2827,7 +2869,7 @@ static NICKSERV_FUNC(cmd_unregister)
     passwd = argv[1];
     argv[1] = "****";
     if (checkpass(passwd, hi->passwd)) {
-        nickserv_unregister_handle(hi, user);
+        nickserv_unregister_handle(hi, user, cmd->parent->bot);
         return 1;
     } else {
        log_module(NS_LOG, LOG_INFO, "Account '%s' tried to unregister with the wrong password.", hi->handle);
@@ -2843,7 +2885,7 @@ static NICKSERV_FUNC(cmd_ounregister)
     NICKSERV_MIN_PARMS(2);
     if (!(hi = get_victim_oper(user, argv[1])))
         return 0;
-    nickserv_unregister_handle(hi, user);
+    nickserv_unregister_handle(hi, user, cmd->parent->bot);
     return 1;
 }
 
@@ -3122,7 +3164,7 @@ static NICKSERV_FUNC(cmd_merge)
     global_message(MESSAGE_RECIPIENT_STAFF, buffer);
 
     /* Unregister the "from" handle. */
-    nickserv_unregister_handle(hi_from, NULL);
+    nickserv_unregister_handle(hi_from, NULL, cmd->parent->bot);
 
     return 1;
 }
@@ -3345,7 +3387,7 @@ static void
 search_unregister_func (struct userNode *source, struct handle_info *match)
 {
     if (oper_has_access(source, nickserv, match->opserv_level, 0))
-        nickserv_unregister_handle(match, source);
+        nickserv_unregister_handle(match, source, nickserv); // XXX nickserv hard coded
 }
 
 static int
@@ -3640,7 +3682,7 @@ expire_handles(UNUSED_ARG(void *data))
         expiry = hi->channels ? nickserv_conf.handle_expire_delay : nickserv_conf.nochan_handle_expire_delay;
         if ((now - hi->lastseen) > expiry) {
             log_module(NS_LOG, LOG_INFO, "Expiring account %s for inactivity.", hi->handle);
-            nickserv_unregister_handle(hi, NULL);
+            nickserv_unregister_handle(hi, NULL, NULL);
         }
     }
 
@@ -4086,6 +4128,7 @@ init_nickserv(const char *nick)
     dict_insert(nickserv_opt_dict, "TABLEWIDTH", opt_tablewidth);
     dict_insert(nickserv_opt_dict, "COLOR", opt_color);
     dict_insert(nickserv_opt_dict, "PRIVMSG", opt_privmsg);
+    dict_insert(nickserv_opt_dict, "AUTOHIDE", opt_autohide);
 /*    dict_insert(nickserv_opt_dict, "STYLE", opt_style); */
     dict_insert(nickserv_opt_dict, "PASS", opt_password);
     dict_insert(nickserv_opt_dict, "PASSWORD", opt_password);