Add "dnrsearch count" action.
[srvx.git] / src / chanserv.c
index 8bc2a6100de4be82242795aeb47400c3fe1aacf8..d9cfea21e92d79900ee38f7c9fb4cde86fb65945 100644 (file)
@@ -1610,7 +1610,7 @@ chanserv_is_dnr(const char *chan_name, struct handle_info *handle)
     struct dnrList list;
     struct do_not_register *dnr;
 
-    list = chanserv_find_dnrs(chan_name, handle->handle, 1);
+    list = chanserv_find_dnrs(chan_name, handle ? handle->handle : NULL, 1);
     dnr = list.used ? list.list[0] : NULL;
     free(list.list);
     return dnr;
@@ -1918,6 +1918,12 @@ dnr_remove_func(struct do_not_register *match, void *extra)
     return 0;
 }
 
+static int
+dnr_count_func(struct do_not_register *match, void *extra)
+{
+    return 0; (void)match; (void)extra;
+}
+
 static MODCMD_FUNC(cmd_dnrsearch)
 {
     struct dnr_search *discrim;
@@ -1939,6 +1945,8 @@ static MODCMD_FUNC(cmd_dnrsearch)
         action = dnr_print_func;
     else if(!irccasecmp(argv[1], "remove"))
         action = dnr_remove_func;
+    else if(!irccasecmp(argv[1], "count"))
+        action = dnr_count_func;
     else
     {
         reply("CSMSG_DNR_BAD_ACTION", argv[1]);
@@ -5949,7 +5957,7 @@ static CHANSERV_FUNC(cmd_giveownership)
     {
         if(force)
         {
-            new_owner = add_channel_user(cData, new_owner_hi, UL_COOWNER, 0, NULL);
+            new_owner = add_channel_user(cData, new_owner_hi, UL_OWNER - 1, 0, NULL);
         }
         else
         {
@@ -7669,6 +7677,7 @@ init_chanserv(const char *nick)
     DEFINE_COMMAND(dnrsearch, 3, 0, "template", "noregister", NULL);
     modcmd_register(chanserv_module, "dnrsearch print", NULL, 0, 0, NULL);
     modcmd_register(chanserv_module, "dnrsearch remove", NULL, 0, 0, NULL);
+    modcmd_register(chanserv_module, "dnrsearch count", NULL, 0, 0, NULL);
     DEFINE_COMMAND(move, 1, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "template", "register", NULL);
     DEFINE_COMMAND(csuspend, 2, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "flags", "+helping", NULL);
     DEFINE_COMMAND(cunsuspend, 1, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "flags", "+helping", NULL);
@@ -7785,8 +7794,8 @@ init_chanserv(const char *nick)
     DEFINE_CHANNEL_OPTION(ctcpreaction);
     DEFINE_CHANNEL_OPTION(inviteme);
     DEFINE_CHANNEL_OPTION(unreviewed);
-    modcmd_register(chanserv_module, "set unreviewed on", NULL, 0, 0, NULL);
-    modcmd_register(chanserv_module, "set unreviewed off", NULL, 0, 0, NULL);
+    modcmd_register(chanserv_module, "set unreviewed on", NULL, 0, 0, "flags", "+helping", NULL);
+    modcmd_register(chanserv_module, "set unreviewed off", NULL, 0, 0, "flags", "+oper", NULL);
     if(off_channel > 1)
         DEFINE_CHANNEL_OPTION(offchannel);
     modcmd_register(chanserv_module, "set defaults", chan_opt_defaults, 1, 0, "access", "owner", NULL);