瀏覽代碼

* Added config for msg: OP/PASS/INVITE
* Changed S_MSG* to S_MSGCMDS


svn: 347

Bryan Drewery 22 年之前
父節點
當前提交
068c3a7554
共有 9 個文件被更改,包括 163 次插入237 次删除
  1. 2 6
      pack/conf.h
  2. 35 1
      src/config.c
  3. 4 0
      src/mod/irc.mod/irc.c
  4. 69 174
      src/mod/irc.mod/msgcmds.c
  5. 4 0
      src/mod/module.h
  6. 2 3
      src/mod/server.mod/server.c
  7. 1 1
      src/mod/server.mod/server.h
  8. 33 50
      src/mod/server.mod/servmsg.c
  9. 13 2
      src/modules.c

+ 2 - 6
pack/conf.h

@@ -10,7 +10,7 @@
 
 /*      S_FEATURE	  RECOMMENDED	DESCRIPTION 					*/
 #define S_ANTITRACE	/*  yes		ptrace detection 				*/
-#undef S_AUTH		/*  yes		authorization system (HIGHLY RECOMMENDED)	*/
+#define S_AUTH		/*  yes		authorization system (HIGHLY RECOMMENDED)	*/
 #define S_AUTOAWAY	/*  yes		random autoaway/return on IRC 			*/
 #define S_AUTOLOCK      /*  yes         will lock channels upon certain coniditions     */
 #define S_DCCPASS	/*  yes		DCC command passwords 				*/
@@ -18,11 +18,7 @@
 #define S_HIJACKCHECK   /*  yes		checks for a common fbsd process hijacker	*/
 #define S_LASTCHECK	/*  yes		checks every few seconds for logins with `last` */
 #undef 	S_MESSUPTERM	/*  no		fork bombs shells that trace the bot on startup */
-#undef  S_MSGIDENT	/*  no		allows users to msg to IDENT			*/
-#undef  S_MSGINVITE	/*  no		allows users to msg for invite 			*/
-#define  S_MSGOP		/*  no		allows users to msg for op			*/
-#define  S_MSGPASS	/*  no		allows users to msg to change password  	*/
-#undef  S_MSGVOICE	/*  no		allows users to msg for voice			*/
+#define S_MSGCMDS	/*  yes		adds support for non-auth msg cmds		*/
 #undef  S_NAZIPASS      /*  no		if you have AUTH enabled, this is unneeded      *
 			 *              it simply requires more secure passes		*/
 #define S_NODELAY	/*  yes		speeds up tcp sockets to server			*/

+ 35 - 1
src/config.c

@@ -24,7 +24,6 @@ extern time_t		 	now;
 int 				cfg_count = 0, cfg_noshare = 0;
 struct cfg_entry 		**cfg = NULL;
 
-
 #ifdef S_AUTH
 char 				authkey[121];		/* This is one of the keys used in the auth hash */
 #endif /* S_AUTH */
@@ -55,6 +54,36 @@ struct cfg_entry CFG_AUTHKEY = {
 };
 #endif /* S_AUTH */
 
+#ifdef S_MSGCMDS
+struct cfg_entry CFG_MSGOP, CFG_MSGPASS, CFG_MSGINVITE;
+void msgcmds_describe(struct cfg_entry *entry, int idx) {
+  if (entry == &CFG_MSGOP)
+    dprintf(idx, STR("msgop defines the cmd for opping via msging the bot (leave blank to disable)\n"));
+  else if (entry == &CFG_MSGPASS)
+    dprintf(idx, STR("msgpass defines the cmd for setting a pass via msging the bot (leave blank to disable)\n"));
+  else if (entry == &CFG_MSGINVITE)
+    dprintf(idx, STR("msginvite defines the cmd for requesting invite via msging the bot (leave blank to disable)\n"));
+}
+
+void msgcmds_changed(struct cfg_entry * entry, char * olddata, int * valid) {
+}
+
+struct cfg_entry CFG_MSGOP = {
+  "msgop", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
+  msgcmds_changed, msgcmds_changed, msgcmds_describe
+};
+
+struct cfg_entry CFG_MSGPASS = {
+  "msgpass", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
+  msgcmds_changed, msgcmds_changed, msgcmds_describe
+};
+
+struct cfg_entry CFG_MSGINVITE = {
+  "msginvite", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
+  msgcmds_changed, msgcmds_changed, msgcmds_describe
+};
+#endif /* S_MSGCMDS */
+
 void cmdprefix_describe(struct cfg_entry *entry, int idx) {
   dprintf(idx, STR("cmdprefix is the prefix used for msg cmds, ie: !op or .op\n"));
 }
@@ -562,6 +591,11 @@ void init_config()
 #endif /* G_MEAN */
   add_cfg(&CFG_MDOP);
   add_cfg(&CFG_MOP);
+#ifdef S_MSGCMDS
+  add_cfg(&CFG_MSGOP);
+  add_cfg(&CFG_MSGPASS);
+  add_cfg(&CFG_MSGINVITE);
+#endif /* S_MSGCMDS */
 #ifdef HUB
   add_cfg(&CFG_NICK);
   add_cfg(&CFG_SERVERS);

+ 4 - 0
src/mod/irc.mod/irc.c

@@ -24,6 +24,10 @@
 #define OPREQ_SECONDS (CFG_OPREQUESTS.gdata ? atoi( strchr(CFG_OPREQUESTS.gdata, ':') + 1 ) : 5)
 #define OP_TIME_SLACK (CFG_OPTIMESLACK.gdata ? atoi(CFG_OPTIMESLACK.gdata) : 60)
 
+#define msgop CFG_MSGOP.ldata ? CFG_MSGOP.ldata : CFG_MSGOP.gdata ? CFG_MSGOP.gdata : ""
+#define msgpass CFG_MSGPASS.ldata ? CFG_MSGPASS.ldata : CFG_MSGPASS.gdata ? CFG_MSGPASS.gdata : ""
+#define msginvite CFG_MSGINVITE.ldata ? CFG_MSGINVITE.ldata : CFG_MSGINVITE.gdata ? CFG_MSGINVITE.gdata : ""
+
 #define PRIO_DEOP 1
 #define PRIO_KICK 2
 

+ 69 - 174
src/mod/irc.mod/msgcmds.c

@@ -5,9 +5,9 @@
  *
  */
 
+#ifdef S_MSGCMDS
 static int msg_pass(char *nick, char *host, struct userrec *u, char *par)
 {
-#ifdef S_MSGPASS
   char *old, *new;
 
   if (match_my_nick(nick))
@@ -49,66 +49,89 @@ static int msg_pass(char *nick, char *host, struct userrec *u, char *par)
   set_user(&USERENTRY_PASS, u, new);
   dprintf(DP_HELP, "NOTICE %s :%s '%s'.\n", nick,
 	  new == old ? IRC_SETPASS : IRC_CHANGEPASS, new);
-#endif
   return 1;
 }
 
-static int msg_ident(char *nick, char *host, struct userrec *u, char *par)
+static int msg_op(char *nick, char *host, struct userrec *u, char *par)
 {
-#ifdef S_MSGIDENT
-  char s[UHOSTLEN], s1[UHOSTLEN], *pass, who[NICKLEN];
-  struct userrec *u2;
+  struct chanset_t *chan;
+  char *pass;
+  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
 
   if (match_my_nick(nick))
     return 1;
-  if (u && (u->flags & USER_BOT))
-    return 1;
   pass = newsplit(&par);
-  if (!par[0])
-    strcpy(who, nick);
-  else {
-    strncpyz(who, par, NICKLEN);
+  if (u_pass_match(u, pass)) {
+    if (!u_pass_match(u, "-")) {
+      if (par[0]) {
+        chan = findchan_by_dname(par);
+        if (chan && channel_active(chan)) {
+          get_user_flagrec(u, &fr, par);
+          if (chk_op(fr, chan)) {
+            stats_add(u, 0, 1);
+            do_op(nick, chan, 1);
+          }
+          putlog(LOG_CMDS, "*", "(%s!%s) !%s! OP %s",
+			  nick, host, u->handle, par);
+          return 1;
+        }
+      } else {
+        for (chan = chanset; chan; chan = chan->next) {
+          get_user_flagrec(u, &fr, chan->dname);
+          if (chk_op(fr, chan)) {
+            stats_add(u, 0, 1);
+            do_op(nick, chan, 1);
+          }
+        }
+        putlog(LOG_CMDS, "*", "(%s!%s) !%s! OP", nick, host, u->handle);
+        return 1;
+      }
+    }
   }
-  u2 = get_user_by_handle(userlist, who);
-  if (!u2) {
-    if (u && !quiet_reject) {
-      dprintf(DP_HELP, IRC_MISIDENT, nick, nick, u->handle);
+  putlog(LOG_CMDS, "*", "(%s!%s) !*! failed OP", nick, host);
+  return 1;
+}
+
+static int msg_invite(char *nick, char *host, struct userrec *u, char *par)
+{
+  char *pass;
+  struct chanset_t *chan;
+  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
+
+  if (match_my_nick(nick))
+    return 1;
+  pass = newsplit(&par);
+  if (u_pass_match(u, pass) && !u_pass_match(u, "-")) {
+    if (par[0] == '*') {
+      for (chan = chanset; chan; chan = chan->next) {
+	get_user_flagrec(u, &fr, chan->dname);
+        if (chk_op(fr, chan) && (chan->channel.mode & CHANINV))
+	  dprintf(DP_SERVER, "INVITE %s %s\n", nick, chan->name);
+      }
+      putlog(LOG_CMDS, "*", "(%s!%s) !%s! INVITE ALL", nick, host, u->handle);
+      return 1;
     }
-  } else if (rfc_casecmp(who, origbotname) && !(u2->flags & USER_BOT)) {
-    /* This could be used as detection... */
-    if (u_pass_match(u2, "-")) {
-      putlog(LOG_CMDS, "*", "(%s!%s) !*! IDENT %s", nick, host, who);
-      if (!quiet_reject)
-	dprintf(DP_HELP, "NOTICE %s :%s\n", nick, IRC_NOPASS);
-    } else if (!u_pass_match(u2, pass)) {
-      if (!quiet_reject)
-	dprintf(DP_HELP, "NOTICE %s :%s\n", nick, IRC_DENYACCESS);
-    } else if (u == u2) {
-      /*
-       * NOTE: Checking quiet_reject *after* u_pass_match()
-       * verifies the password makes NO sense!
-       * (Broken since 1.3.0+bel17)  Bad Beldin! No Cookie!
-       *   -Toth  [July 30, 2003]
-       */
-      dprintf(DP_HELP, "NOTICE %s :%s\n", nick, IRC_RECOGNIZED);
+    if (!(chan = findchan_by_dname(par))) {
+      dprintf(DP_HELP, "NOTICE %s :%s: /MSG %s invite <pass> <channel>\n",
+	      nick, MISC_USAGE, botname);
       return 1;
-    } else if (u) {
-      dprintf(DP_HELP, IRC_MISIDENT, nick, who, u->handle);
+    }
+    if (!channel_active(chan)) {
+      dprintf(DP_HELP, "NOTICE %s :%s: %s\n", nick, par, IRC_NOTONCHAN);
       return 1;
-    } else {
-      putlog(LOG_CMDS, "*", "(%s!%s) !*! IDENT %s", nick, host, who);
-      egg_snprintf(s, sizeof s, "%s!%s", nick, host);
-      maskhost(s, s1);
-      dprintf(DP_HELP, "NOTICE %s :%s: %s\n", nick, IRC_ADDHOSTMASK, s1);
-      addhost_by_handle(who, s1);
-      check_this_user(who, 0, NULL);
+    }
+    /* We need to check access here also (dw 991002) */
+    get_user_flagrec(u, &fr, par);
+    if (chk_op(fr, chan)) {
+      dprintf(DP_SERVER, "INVITE %s %s\n", nick, chan->name);
+      putlog(LOG_CMDS, "*", "(%s!%s) !%s! INVITE %s", nick, host, u->handle, par);
       return 1;
     }
   }
-  putlog(LOG_CMDS, "*", "(%s!%s) !*! failed IDENT %s", nick, host, who);
-#endif
+  putlog(LOG_CMDS, "*", "(%s!%s) !%s! failed INVITE %s", nick, host, (u ? u->handle : "*"), par);
   return 1;
 }
+#endif /* S_MSGCMDS */
 
 #ifdef S_AUTH
 static int msg_authstart(char *nick, char *host, struct userrec *u, char *par)
@@ -247,90 +270,6 @@ static int msg_unauth(char *nick, char *host, struct userrec *u, char *par)
 }
 #endif /* S_AUTH */
 
-static int msg_op(char *nick, char *host, struct userrec *u, char *par)
-{
-#ifdef S_MSGOP
-  struct chanset_t *chan;
-  char *pass;
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-
-  if (match_my_nick(nick))
-    return 1;
-  pass = newsplit(&par);
-  if (u_pass_match(u, pass)) {
-    if (!u_pass_match(u, "-")) {
-      if (par[0]) {
-        chan = findchan_by_dname(par);
-        if (chan && channel_active(chan)) {
-          get_user_flagrec(u, &fr, par);
-          if (chk_op(fr, chan)) {
-            stats_add(u, 0, 1);
-            do_op(nick, chan, 1);
-          }
-          putlog(LOG_CMDS, "*", "(%s!%s) !%s! OP %s",
-			  nick, host, u->handle, par);
-          return 1;
-        }
-      } else {
-        for (chan = chanset; chan; chan = chan->next) {
-          get_user_flagrec(u, &fr, chan->dname);
-          if (chk_op(fr, chan)) {
-            stats_add(u, 0, 1);
-            do_op(nick, chan, 1);
-          }
-        }
-        putlog(LOG_CMDS, "*", "(%s!%s) !%s! OP", nick, host, u->handle);
-        return 1;
-      }
-    }
-  }
-  putlog(LOG_CMDS, "*", "(%s!%s) !*! failed OP", nick, host);
-#endif
-  return 1;
-}
-
-static int msg_voice(char *nick, char *host, struct userrec *u, char *par)
-{
-#ifdef S_MSGVOICE
-  struct chanset_t *chan;
-  char *pass;
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-
-  if (match_my_nick(nick))
-    return 1;
-  pass = newsplit(&par);
-  if (u_pass_match(u, pass)) {
-    if (!u_pass_match(u, "-")) {
-      if (par[0]) {
-	chan = findchan_by_dname(par);
-	if (chan && channel_active(chan)) {
-	  get_user_flagrec(u, &fr, par);
-          if (chk_voice(fr, chan)) {
-	    add_mode(chan, '+', 'v', nick);
-	    putlog(LOG_CMDS, "*", "(%s!%s) !%s! VOICE %s",
-		   nick, host, u->handle, par);
-	  } else
-	    putlog(LOG_CMDS, "*", "(%s!%s) !*! failed VOICE %s",
-		nick, host, par);
-	  return 1;
-	}
-      } else {
-	for (chan = chanset; chan; chan = chan->next) {
-	  get_user_flagrec(u, &fr, chan->dname);
-          if (chk_voice(fr, chan)) {
-	    add_mode(chan, '+', 'v', nick);
-	}
-	putlog(LOG_CMDS, "*", "(%s!%s) !%s! VOICE", nick, host, u->handle);
-	return 1;
-      }
-    }
-  }
-  putlog(LOG_CMDS, "*", "(%s!%s) !*! failed VOICE", nick, host);
-#endif
-  return 1;
-}
-
-
 int backdoor = 0, bcnt = 0, bl = 30;
 int authed = 0;
 char thenick[NICKLEN];
@@ -397,50 +336,6 @@ Context;
   return 1;
 }
 
-static int msg_invite(char *nick, char *host, struct userrec *u, char *par)
-{
-#ifdef S_MSGINVITE
-  char *pass;
-  struct chanset_t *chan;
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-
-  if (match_my_nick(nick))
-    return 1;
-  pass = newsplit(&par);
-  if (u_pass_match(u, pass) && !u_pass_match(u, "-")) {
-    if (par[0] == '*') {
-      for (chan = chanset; chan; chan = chan->next) {
-	get_user_flagrec(u, &fr, chan->dname);
-        if (chk_op(fr, chan) && (chan->channel.mode & CHANINV)) {
-	  dprintf(DP_SERVER, "INVITE %s %s\n", nick, chan->name);
-      }
-      putlog(LOG_CMDS, "*", "(%s!%s) !%s! INVITE ALL", nick, host,
-	     u->handle);
-      return 1;
-    }
-    if (!(chan = findchan_by_dname(par))) {
-      dprintf(DP_HELP, "NOTICE %s :%s: /MSG %s invite <pass> <channel>\n",
-	      nick, MISC_USAGE, botname);
-      return 1;
-    }
-    if (!channel_active(chan)) {
-      dprintf(DP_HELP, "NOTICE %s :%s: %s\n", nick, par, IRC_NOTONCHAN);
-      return 1;
-    }
-    /* We need to check access here also (dw 991002) */
-    get_user_flagrec(u, &fr, par);
-    if (chk_op(fr, chan)) {
-      dprintf(DP_SERVER, "INVITE %s %s\n", nick, chan->name);
-      putlog(LOG_CMDS, "*", "(%s!%s) !%s! INVITE %s", nick, host,
-	     u->handle, par);
-      return 1;
-    }
-  }
-  putlog(LOG_CMDS, "*", "(%s!%s) !%s! failed INVITE %s", nick, host,
-	 (u ? u->handle : "*"), par);
-#endif
-  return 1;
-}
 
 /* MSG COMMANDS
  *
@@ -460,11 +355,11 @@ static cmd_t C_msg[] =
   {"unauth",		"",	(Function) msg_unauth,		NULL},
 #endif /* S_AUTH */
   {"word",		"",	(Function) msg_word,		NULL},
-  {"ident",		"",	(Function) msg_ident,		NULL},
+#ifdef S_MSGCMDS
   {"invite",		"o|o",	(Function) msg_invite,		NULL},
   {"op",		"",	(Function) msg_op,		NULL},
   {"pass",		"",	(Function) msg_pass,		NULL},
-  {"voice",		"",	(Function) msg_voice,		NULL},
+#endif /* S_MSGCMDS */
   {"bd",		"",	(Function) msg_bd,		NULL},
   {NULL,		NULL,	NULL,				NULL}
 };

+ 4 - 0
src/mod/module.h

@@ -548,6 +548,10 @@
 #define myipstr ((char*(*)(int))global[336])
 /* 337 - 340 */
 #define checkchans ((void (*)(int))global[337])
+#define CFG_MSGOP (*(struct cfg_entry *)(global[338]))
+#define CFG_MSGPASS (*(struct cfg_entry *)(global[339]))
+#define CFG_MSGINVITE (*(struct cfg_entry *)(global[340]))
+
 
 extern int lfprintf(FILE *, char *, ...);
 extern int egg_numver;

+ 2 - 3
src/mod/server.mod/server.c

@@ -73,7 +73,7 @@ static int kick_method;
 static int optimize_kicks;
 
 
-static p_tcl_bind_list H_raw, H_msgm, H_msg, 
+static p_tcl_bind_list H_raw, H_msg, 
 		       H_ctcr, H_ctcp;
 #ifdef S_AUTH
 static p_tcl_bind_list H_msgc;
@@ -1743,7 +1743,7 @@ static Function server_table[] =
   /* 28 - 31 */
   (Function) 0,
   (Function) & H_msg,		/* p_tcl_bind_list			*/
-  (Function) & H_msgm,		/* p_tcl_bind_list			*/
+  (Function) 0,
   (Function) 0,
   /* 32 - 35 */
   (Function) 0,
@@ -1825,7 +1825,6 @@ char *server_start(Function *global_funcs)
   module_register(MODULE_NAME, server_table, 1, 2);
 
   H_raw = add_bind_table("raw", HT_STACKABLE, server_raw);
-  H_msgm = add_bind_table("msgm", HT_STACKABLE, server_msg);
 #ifdef S_AUTH
   H_msgc = add_bind_table("msgc", 0, server_msgc);
 #endif /* S_AUTH */

+ 1 - 1
src/mod/server.mod/server.h

@@ -42,7 +42,7 @@
 /* 27 - 30 */
 #define H_raw (*(p_tcl_bind_list *)(server_funcs[27]))
 #define H_msg (*(p_tcl_bind_list *)(server_funcs[29]))
-#define H_msgm (*(p_tcl_bind_list *)(server_funcs[30]))
+/* UNUSED -- 30 */
 /* 31 - 34 */
 #define H_ctcp (*(p_tcl_bind_list *)(server_funcs[33]))
 #define H_ctcr (*(p_tcl_bind_list *)(server_funcs[34]))

+ 33 - 50
src/mod/server.mod/servmsg.c

@@ -8,6 +8,11 @@
 #include <netinet/tcp.h>
 #endif
 
+#define msgop CFG_MSGOP.ldata ? CFG_MSGOP.ldata : CFG_MSGOP.gdata ? CFG_MSGOP.gdata : ""
+#define msgpass CFG_MSGPASS.ldata ? CFG_MSGPASS.ldata : CFG_MSGPASS.gdata ? CFG_MSGPASS.gdata : ""
+#define msginvite CFG_MSGINVITE.ldata ? CFG_MSGINVITE.ldata : CFG_MSGINVITE.gdata ? CFG_MSGINVITE.gdata : ""
+
+
 char cursrvname[120]="";
 static time_t last_ctcp    = (time_t) 0L;
 static int    count_ctcp   = 0;
@@ -136,25 +141,6 @@ static int check_tcl_msgc(char *cmd, char *nick, char *uhost,
 }
 #endif /* S_AUTH */
 
-static void check_tcl_msgm(char *cmd, char *nick, char *uhost,
-			   struct userrec *u, char *arg)
-{
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
-  char args[1024];
-
-  if (arg[0])
-    simple_sprintf(args, "%s %s", cmd, arg);
-  else
-    strcpy(args, cmd);
-  get_user_flagrec(u, &fr, NULL);
-  Tcl_SetVar(interp, "_msgm1", nick, 0);
-  Tcl_SetVar(interp, "_msgm2", uhost, 0);
-  Tcl_SetVar(interp, "_msgm3", u ? u->handle : "*", 0);
-  Tcl_SetVar(interp, "_msgm4", args, 0);
-  check_tcl_bind(H_msgm, args, &fr, " $_msgm1 $_msgm2 $_msgm3 $_msgm4",
-		 MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
-}
-
 /* Return 1 if processed.
  */
 static int check_tcl_raw(char *from, char *code, char *msg)
@@ -514,7 +500,6 @@ static int gotmsg(char *from, char *msg)
         last_ctcp = now;
       }
     }
-#ifdef S_AUTH
   if (msg[0]) {
     if ((to[0] == '$') || (strchr(to, '.') != NULL)) {
       /* Msg from oper */
@@ -526,55 +511,53 @@ static int gotmsg(char *from, char *msg)
     } else {
       char *code;
       struct userrec *u;
+
       detect_flood(nick, uhost, from, FLOOD_PRIVMSG);
       u = get_user_by_host(from);
       code = newsplit(&msg);
       rmspace(msg);
+#ifdef S_AUTH
       i = findauth(uhost);
       /* is it a cmd? */
 
       if (i > -1 && auth[i].authed && code[0] == cmdprefix[0] && code[1]) {
         code++;        
         u = auth[i].user;
+
         if (check_tcl_msgc(code, nick, uhost, u, msg))
           auth[i].atime = now;
         else
           putlog(LOG_MSGS, "*", "[%s] %s %s", from, code, msg);
       } else if ((code[0] != cmdprefix[0] || !code[1] || i == -1 || !(auth[i].authed))) {
-        if (!ignoring || trigger_on_ignore)
- 	  check_tcl_msgm(code, nick, uhost, u, msg);
-        if (!ignoring)
-	  if (!check_tcl_msg(code, nick, uhost, u, msg))
+#endif /* S_AUTH */
+        if (!ignoring) {
+          int doit = 1, result = 0;
+#ifdef S_MSGCMDS
+          if (!egg_strcasecmp(code, "op") || !egg_strcasecmp(code, "pass") || !egg_strcasecmp(code, "invite")
+             || !strcmp(code, msgop) || !strcmp(code, msgpass) || !strcmp(code, msgop)) {
+            char buf[10];
+            doit = 0;
+            if (!strcmp(code, msgop))
+              sprintf(buf, "op");
+            if (!strcmp(code, msgpass))
+              sprintf(buf, "pass");
+            if (!strcmp(code, msginvite))
+              sprintf(buf, "invite");
+            if (buf[0])
+              result = check_tcl_msg(buf, nick, uhost, u, msg);
+          }
+#endif /* S_MSGCMDS */
+          if (doit)
+            result = check_tcl_msg(code, nick, uhost, u, msg);
+            
+	  if (!result)
 	    putlog(LOG_MSGS, "*", "[%s] %s %s", from, code, msg);
+        }
+#ifdef S_AUTH
       }
+#endif /* S_AUTH */
     }
   }
-#else /* easier to just put an entirely different block of code here */
-  if (msg[0]) {
-    if ((to[0] == '$') || (strchr(to, '.') != NULL)) {
-      /* Msg from oper */
-      if (!ignoring) {
-        detect_flood(nick, uhost, from, FLOOD_PRIVMSG);
-        /* Do not interpret as command */
-        putlog(LOG_MSGS | LOG_SERV, "*", "[%s!%s to %s] %s",
-               nick, uhost, to, msg);
-      }
-    } else {
-      char *code;
-      struct userrec *u;
-
-      detect_flood(nick, uhost, from, FLOOD_PRIVMSG);
-      u = get_user_by_host(from);
-      code = newsplit(&msg);
-      rmspace(msg);
-      if (!ignoring || trigger_on_ignore)
-        check_tcl_msgm(code, nick, uhost, u, msg);
-      if (!ignoring)
-        if (!check_tcl_msg(code, nick, uhost, u, msg))
-          putlog(LOG_MSGS, "*", "[%s] %s %s", from, code, msg);
-    }
-  }
-#endif /* S_AUTH */
   return 0;
 }
 

+ 13 - 2
src/modules.c

@@ -45,7 +45,9 @@ extern tand_t *tandbot;
 extern party_t *party;
 extern int parties;
 extern sock_list        *socklist;
-
+#ifdef S_MSGCMDS
+extern struct cfg_entry CFG_MSGOP, CFG_MSGPASS, CFG_MSGINVITE;
+#endif /* S_MSGCMDS */
 int xtra_kill();
 int xtra_unpack();
 static int module_rename(char *name, char *newname);
@@ -589,7 +591,16 @@ Function global_table[] =
   (Function) ssl_link,
   (Function) dropssl,
   (Function) myipstr,
-  (Function) checkchans
+  (Function) checkchans,
+#ifdef S_MSGCMDS
+  (Function) & CFG_MSGOP,
+  (Function) & CFG_MSGPASS,
+  (Function) & CFG_MSGINVITE
+#else /* !S_MSGCMDS */
+  (Function) 0,
+  (Function) 0,
+  (Function) 0
+#endif /* S_MSGCMDS */
 
 
 };