]> jfr.im git - irc/quakenet/newserv.git/blobdiff - noperserv/noperserv.c
Merge.
[irc/quakenet/newserv.git] / noperserv / noperserv.c
index 54b1d9333d7754f02e6a53825da09fa6c1eab1be..ae5c3c1062c03079923834e8bbc9753df684e3ca 100644 (file)
@@ -10,6 +10,7 @@
 #include "../lib/irc_string.h"
 #include "../lib/strlfunc.h"
 #include "../lib/version.h"
+#include "../authext/authext.h"
 #include "noperserv.h"
 #include "noperserv_db.h"
 #include "noperserv_hooks.h"
 #include <string.h>
 #include <stdarg.h>
 
-MODULE_VERSION("$Id: noperserv.c 663 2006-05-16 17:27:36Z newserv $")
+MODULE_VERSION("");
 
 #define FLAGBUFLEN 100
 
 #define NO_FOUND_NICKNAME 1
 #define NO_FOUND_AUTHNAME 2
 
+int noperserv_ext;
+
 const flag no_commandflags[] = {
     { 'o', __NO_OPER },
     { 't', __NO_TRUST },
@@ -36,6 +39,7 @@ const flag no_commandflags[] = {
     { 'O', __NO_OPERED },
     { 'r', __NO_AUTHED },
     { 'R', __NO_ACCOUNT },
+    { 'Y', __NO_RELAY },
     { '\0', 0 }
   }; 
 
@@ -45,6 +49,7 @@ const flag no_userflags[] = {
     { 's', __NO_STAFF },
     { 'S', __NO_SEC },
     { 'd', __NO_DEVELOPER },
+    { 'Y', __NO_RELAY },
     { '\0', 0 }
   }; 
 
@@ -54,6 +59,7 @@ const flag no_noticeflags[] = {
     { 'k', NL_KICKKILLS },    /* KICK/KILL commands */
     { 'I', NL_MISC },         /* misc commands */
     { 'g', NL_GLINES },       /* GLINE commands */
+    { 'G', NL_GLINES_AUTO },  /* automated gline messages */
     { 'h', NL_HITS },         /* Where a gline or kill is set automatically by the bot */
     { 'c', NL_CLONING },      /* Clone detection */
     { 'C', NL_CLEARCHAN },    /* When someone clearchans */
@@ -71,7 +77,7 @@ int noperserv_noticeflags(void *sender, int cargc, char **cargv);
 int noperserv_userflags(void *sender, int cargc, char **cargv);
 int noperserv_deluser(void *sender, int cargc, char **cargv);
 void noperserv_oper_detection(int hooknum, void *arg);
-void noperserv_reply(nick *np, char *format, ...);
+void noperserv_reply(nick *np, char *format, ...) __attribute__ ((format (printf, 2, 3)));
 
 int init = 0;
 
@@ -95,6 +101,7 @@ void _init() {
     "  +S: Security team member\n"
     "  +d: NOperserv developer\n"
     "  +t: Trust queue worker\n"
+    "  +Y: Relay\n"
     " Additional flags may show up in SHOWCOMMANDS but are not userflags as such:\n"
     "  +r: Authed user\n"
     "  +R: Registered NOperserv user\n"
@@ -109,7 +116,8 @@ void _init() {
     "  +t: Trusts\n"
     "  +k: KICK/KILL commands\n"
     "  +g: GLINE commands\n"
-    "  +h: Shows when glines are played automatically (hits)\n"
+    "  +G: automated gline messages\n"
+    "  +h: Shows when glines are set by code (hits)\n"
     "  +c: Clone information\n"
     "  +C: CLEARCHAN command\n"
     "  +f: FAKEUSER commands\n"
@@ -140,6 +148,8 @@ void _fini() {
   deregistercontrolcmd("noticeflags", &noperserv_noticeflags);
   deregistercontrolcmd("userflags", &noperserv_userflags);
   deregistercontrolcmd("noticeflags", &noperserv_noticeflags);
+  deregistercontrolcmd("hello", &noperserv_hello);
+  deregistercontrolcmd("deluser", &noperserv_deluser);
 
   noperserv_cleanup_hooks();
 
@@ -159,18 +169,12 @@ int noperserv_hello(void *sender, int cargc, char **cargv) {
     newaccount = np->authname;
   } else {
     if(cargv[0][0] == '#') {
-      nick *np2;
-      for(i=0;i<NICKHASHSIZE;i++)
-        for(np2=nicktable[i];np2;np2=np2->next)
-          if(IsAccount(np2) && !ircd_strcmp(cargv[0] + 1, np2->authname)) {
-            target = np2;
-            newaccount = target->authname;
-            break;
-          }
-      if(!target) {
+      authname *a = getauthbyname(cargv[0] + 1);
+      if(!a) {
         controlreply(np, "Cannot find anyone with that authname on the network.");
         return CMD_ERROR;
       }
+      newaccount = a->name;
     } else {
       target = getnickbynick(cargv[0]);
       if(!target) {
@@ -484,17 +488,15 @@ int noperserv_userflags(void *sender, int cargc, char **cargv) {
 }
 
 void noperserv_oper_detection(int hooknum, void *arg) {
-  void **args = (void **)arg;
-  nick *np = args[0];
-  char *modestr = args[1];
-  flag_t after = np->umodes;
+  nick *np = (nick *)arg;
 
-  setflags(&after, UMODE_ALL, modestr, umodeflags, REJECT_NONE);
   if(np->umodes & UMODE_OPER) {
-    if(!(after & UMODE_OPER))
-      controlwall(NO_OPER, NL_OPERING, "%s!%s@%s%s%s just DEOPERed", np->nick, np->ident, np->host->name->content, IsAccount(np)?"/":"", IsAccount(np)?np->authname:"");
-  } else {
-    if(after & UMODE_OPER)
+    if(np->opername && strcmp(np->opername->content, "-")) {
+      controlwall(NO_OPER, NL_OPERING, "%s!%s@%s%s%s just OPERed as %s", np->nick, np->ident, np->host->name->content, IsAccount(np)?"/":"", IsAccount(np)?np->authname:"", np->opername->content);
+    } else {
       controlwall(NO_OPER, NL_OPERING, "%s!%s@%s%s%s just OPERed", np->nick, np->ident, np->host->name->content, IsAccount(np)?"/":"", IsAccount(np)?np->authname:"");
+    }
+  } else {
+    controlwall(NO_OPER, NL_OPERING, "%s!%s@%s%s%s just DEOPERed", np->nick, np->ident, np->host->name->content, IsAccount(np)?"/":"", IsAccount(np)?np->authname:"");
   }
 }