Ver código fonte

* Change all PRIVMSG/NOTICE cmds into privmsg()/notice() to prepare for CPRIVMSG/CNOTICE and later use of FiSH

Bryan Drewery 16 anos atrás
pai
commit
2e1d5b1e7b

+ 8 - 0
src/chanprog.c

@@ -943,3 +943,11 @@ samechans(const char *nick, const char *delim)
 
   return ret;
 }
+
+void privmsg(const char* target, const char* msg, int idx) {
+  dprintf(idx, "PRIVMSG %s :%s\n", target, msg);
+}
+
+void notice(const char* target, const char* msg, int idx) {
+  dprintf(idx, "NOTICE %s :%s\n", target, msg);
+}

+ 2 - 0
src/chanprog.h

@@ -32,6 +32,8 @@ void add_child_bots();
 bool is_hub(const char*);
 void load_internal_users();
 void setup_HQ(int);
+void privmsg(const char* target, const char* msg, int idx);
+void notice(const char* target, const char* msg, int idx);
 
 extern struct chanset_t		*chanset, *chanset_default;
 extern char			admin[], origbotnick[NICKLEN + 1], origbotname[NICKLEN + 1], jupenick[NICKLEN], botname[NICKLEN + 1], *def_chanset;

+ 1 - 1
src/cmds.c

@@ -3905,7 +3905,7 @@ static void rcmd_msg(char * tobot, char * frombot, char * fromhand, char * fromi
   if (!conf.bot->hub) {
     char *nick = newsplit(&par);
 
-    dprintf(DP_SERVER, "PRIVMSG %s :%s\n", nick, par);
+    privmsg(nick, par, DP_SERVER);
     if (!strcasecmp(tobot, conf.bot->nick)) {
       char buf[1024] = "";
 

+ 1 - 1
src/dccutil.c

@@ -336,7 +336,7 @@ dprintf(int idx, const char *format, ...)
 
 //      simple_snprintf(ircbuf, size, "PRIVMSG %s :%s", dcc[idx].simulbot, buf);
 //      tputs(dcc[idx].sock, ircbuf, strlen(ircbuf));
-      dprintf(DP_HELP, "PRIVMSG %s :%s\n", dcc[idx].simulbot, buf);
+      privmsg(dcc[idx].simulbot, buf, DP_HELP);
 //      free(ircbuf);
     } else {
       if (dcc[idx].type && ((long) (dcc[idx].type->output) == 1)) {

+ 5 - 2
src/log.c

@@ -342,8 +342,11 @@ irc_log(struct chanset_t *chan, const char *format, ...)
   egg_vsnprintf(va_out, sizeof(va_out), format, va);
   va_end(va);
 
-  if ((chan && strcasecmp(chan->dname, "#!obs")) || !chan)
-    dprintf(DP_HELP, "PRIVMSG %s :[%s] %s\n", relay_chan, chan ? chan->dname : "*" , va_out);
+  if ((chan && strcasecmp(chan->dname, "#...")) || !chan) {
+    bd::String msg;
+    msg.printf("[%s] %s", chan ? chan->dname : "*" , va_out);
+    privmsg(relay_chan, msg.c_str(), DP_HELP);
+  }
 /*
   chanout_but(-1, 1, "[%s] %s\n", chan->dname, va_out);
   botnet_send_chan(-1, conf.bot->nick, chan->dname, 1, va_out);

+ 1 - 1
src/misc.c

@@ -1057,7 +1057,7 @@ int goodpass(char *pass, int idx, char *nick)
     if (idx)
       dprintf(idx, "%s\n", tell);
     else if (nick[0])
-      dprintf(DP_HELP, "NOTICE %s :%s\n", nick, tell);
+      notice(nick, tell, DP_HELP);
     return 0;
   }
   return 1;

+ 46 - 17
src/mod/ctcp.mod/ctcp.c

@@ -43,6 +43,7 @@
 #include <arpa/inet.h>
 #include <sys/utsname.h>
 #include <ctype.h>
+#include <bdlib/src/String.h>
 
 #define AVGAWAYTIME             60
 #define AVGHERETIME             5
@@ -409,8 +410,10 @@ static int ctcp_FINGER(char *nick, char *uhost, struct userrec *u, char *object,
     idletime = now - cloak_awaytime;
   else if (cloak_heretime)
     idletime = now - cloak_heretime;
-  dprintf(DP_HELP, "NOTICE %s :\001%s %s (%s) Idle %d second%s\001\n", nick, keyword, "",
+  bd::String msg;
+  msg.printf("\001%s %s (%s) Idle %d second%s\001", keyword, "",
                    botuserhost, (int) idletime, idletime == 1 ? "" : "s");
+  notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
 
@@ -419,13 +422,18 @@ static int ctcp_ECHO(char *nick, char *uhost, struct userrec *u, char *object, c
   char reply[60] = "";
 
   strlcpy(reply, text, sizeof(reply));
-  dprintf(DP_HELP, "NOTICE %s :\001%s %s\001\n", nick, keyword, reply);
+  bd::String msg;
+  msg.printf("\001%s %s\001", keyword, reply);
+  notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
 static int ctcp_PING(char *nick, char *uhost, struct userrec *u, char *object, char *keyword, char *text)
 {
-  if (strlen(text) <= 80)       /* bitchx ignores > 80 */
-    dprintf(DP_HELP, "NOTICE %s :\001%s %s\001\n", nick, keyword, text);
+  if (strlen(text) <= 80) {       /* bitchx ignores > 80 */
+    bd::String msg;
+    msg.printf("\001%s %s\001", keyword, text);
+    notice(nick, msg.c_str(), DP_HELP);
+  }
   return BIND_RET_BREAK;
 }
 
@@ -472,17 +480,24 @@ static int ctcp_VERSION(char *nick, char *uhost, struct userrec *u, char *object
     ++first_ctcp_check;
   }
 
-  dprintf(queue, "NOTICE %s :\001%s %s%s\001\n", nick, keyword, ctcpversion, s);
+  bd::String msg;
+  msg.printf("\001%s %s%s\001", keyword, ctcpversion, s);
+  notice(nick, msg.c_str(), queue);
 
-  if (ctcpversion2[0])
-    dprintf(DP_HELP, "NOTICE %s :\001%s %s\001\n", nick, keyword, ctcpversion2);
+  if (ctcpversion2[0]) {
+    msg.printf("\001%s %s\001", keyword, ctcpversion2);
+    notice(nick, msg.c_str(), DP_HELP);
+  }
   return BIND_RET_BREAK;
 }
 
 static int ctcp_WHOAMI(char *nick, char *uhost, struct userrec *u, char *object, char *keyword, char *text)
 {
-  if (cloak_script > 0 && cloak_script < 9)
-    dprintf(DP_HELP, "NOTICE %s :\002BitchX\002: Access Denied\n", nick);
+  if (cloak_script > 0 && cloak_script < 9) {
+    bd::String msg;
+    msg.printf("\002BitchX\002: Access Denied");
+    notice(nick, msg.c_str(), DP_HELP);
+  }
   return BIND_RET_BREAK;
 }
 
@@ -495,7 +510,9 @@ static int ctcp_OP(char *nick, char *uhost, struct userrec *u, char *object, cha
     p = strchr(chan, ' ');
     if (p)
       *p = 0;
-    dprintf(DP_HELP, "NOTICE %s :\002BitchX\002: I'm not on %s or I'm not opped\n", nick, chan);
+    bd::String msg;
+    msg.printf("\002BitchX\002: I'm not on %s or I'm not opped", chan);
+    notice(nick, msg.c_str(), DP_HELP);
   }
   return BIND_RET_BREAK;
 }
@@ -505,6 +522,7 @@ static int ctcp_INVITE_UNBAN(char *nick, char *uhost, struct userrec *u, char *o
   if (text[0] == '#' && cloak_script > 0 && cloak_script < 9) {
     struct chanset_t *chan = chanset;
     char chname[256] = "", *p = NULL;
+    bd::String msg;
 
     strlcpy(chname, text, sizeof(chname));
     p = strchr(chname, ' ');
@@ -513,13 +531,15 @@ static int ctcp_INVITE_UNBAN(char *nick, char *uhost, struct userrec *u, char *o
     while (chan) {
       if (chan->status & CHAN_ACTIVE) {
         if (!strcasecmp(chan->name, chname)) {
-          dprintf(DP_HELP, "NOTICE %s :\002BitchX\002: Access Denied\n", nick);
+          msg.printf("\002BitchX\002: Access Denied");
+          notice(nick, msg.c_str(), DP_HELP);
           return BIND_RET_LOG;
         }
       }
       chan = chan->next;
     }
-    dprintf(DP_HELP, "NOTICE %s :\002BitchX\002: I'm not on that channel\n", nick);
+    msg.printf("\002BitchX\002: I'm not on that channel");
+    notice(nick, msg.c_str(), DP_HELP);
   }
   return BIND_RET_BREAK;
 }
@@ -532,7 +552,9 @@ static int ctcp_USERINFO(char *nick, char *uhost, struct userrec *u, char *objec
     strlcpy(ctcpuserinfo, botname, sizeof(ctcpuserinfo));
     strlcat(ctcpuserinfo, " ?", sizeof(ctcpuserinfo));
   }
-  dprintf(DP_HELP, "NOTICE %s :\001%s %s\001\n", nick, keyword, ctcpuserinfo);
+  bd::String msg;
+  msg.printf("\001%s %s\001", keyword, ctcpuserinfo);
+  notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
 
@@ -542,6 +564,7 @@ static int ctcp_CLIENTINFO(char *nick, char *uhost, struct userrec *u, char *obj
     return BIND_RET_BREAK;
 
   char buf[256] = "";
+  bd::String msg;
 
   if (!text[0]) {
     strlcpy(buf, "SED UTC ACTION DCC CDCC BDCC XDCC VERSION CLIENTINFO USERINFO ERRMSG FINGER TIME PING ECHO INVITE WHOAMI OP OPS UNBAN IDENT XLINK UPTIME :Use CLIENTINFO <COMMAND> to get more specific information", sizeof(buf));
@@ -592,10 +615,12 @@ static int ctcp_CLIENTINFO(char *nick, char *uhost, struct userrec *u, char *obj
   else if (!strcasecmp(text, "UPTIME"))
     strlcpy(buf, "UPTIME my uptime", sizeof(buf));
   else {
-    dprintf(DP_HELP, "NOTICE %s :\001ERRMSG %s is not a valid function\001\n", nick, text);
+    msg.printf("\001ERRMSG %s is not a valid function\001", text);
+    notice(nick, msg.c_str(), DP_HELP);
     return BIND_RET_LOG;
   }
-  dprintf(DP_HELP, "NOTICE %s :\001%s %s\001\n", nick, keyword, buf);
+  msg.printf("\001%s %s\001", keyword, buf);
+  notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
 
@@ -604,7 +629,9 @@ static int ctcp_TIME(char *nick, char *uhost, struct userrec *u, char *object, c
   char tms[81] = "";
 
   strlcpy(tms, ctime(&now), sizeof(tms));
-  dprintf(DP_HELP, "NOTICE %s :\001%s %s\001\n", nick, keyword, tms);
+  bd::String msg;
+  msg.printf("\001%s %s\001", keyword, tms);
+  notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
 
@@ -634,7 +661,9 @@ static int ctcp_CHAT(char *nick, char *uhost, struct userrec *u, char *object, c
       /* do me a favour and don't change this back to a CTCP reply,
        * CTCP replies are NOTICE's this has to be a PRIVMSG
        * -poptix 5/1/1997 */
-      dprintf(DP_SERVER, "PRIVMSG %s :\001DCC CHAT chat %lu %u\001\n", nick, iptolong(getmyip()), dcc[ix].port);
+      bd::String msg;
+      msg.printf("\001DCC CHAT chat %lu %u\001", iptolong(getmyip()), dcc[ix].port);
+      privmsg(nick, msg.c_str(), DP_SERVER);
     }
     return BIND_RET_BREAK;
 }

+ 7 - 5
src/mod/irc.mod/chan.c

@@ -1624,7 +1624,9 @@ static int got341(char *from, char *msg)
     dprintf(DP_MODE_NEXT, "MODE %s +b *!*%s\n", chan->name, cache->uhost);
   }
   putlog(LOG_MISC, "*", "HIJACKED invite detected: %s to %s", nick, chan->dname);
-  dprintf(DP_MODE_NEXT, "PRIVMSG %s :ALERT! \002%s was invited via a hijacked connection/process.\002\n", chan->name, nick);
+  bd::String msg;
+  msg.printf("ALERT! \002%s was invited via a hijacked connection/process.\002", nick);
+  privmsg(chan->name, msg.c_str(), DP_MODE_NEXT);
   return 0;
 }
 #endif /* CACHE */
@@ -2433,7 +2435,7 @@ static int gotinvite(char *from, char *msg)
     chan = findchan_by_dname(msg);
   else {
     if (channel_pending(chan) || channel_active(chan))
-      dprintf(DP_HELP, "NOTICE %s :I'm already here.\n", nick);
+      notice(nick, "I'm already here.", DP_HELP);
     else if (shouldjoin(chan))
       dprintf(DP_MODE, "JOIN %s %s\n", (chan->name[0]) ? chan->name : chan->dname,
               chan->channel.key[0] ? chan->channel.key : chan->key_prot);
@@ -3214,13 +3216,13 @@ static int gotmsg(char *from, char *msg)
   /* Send out possible ctcp responses */
   if (ctcp_reply[0]) {
     if (ctcp_mode != 2) {
-      dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
+      notice(nick, ctcp_reply, DP_HELP);
     } else {
       if (now - last_ctcp > flood_ctcp.time) {
-	dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
+        notice(nick, ctcp_reply, DP_HELP);
 	count_ctcp = 1;
       } else if (count_ctcp < flood_ctcp.count) {
-	dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
+        notice(nick, ctcp_reply, DP_HELP);
 	count_ctcp++;
       }
       last_ctcp = now;

+ 9 - 6
src/mod/irc.mod/cmdsirc.c

@@ -116,8 +116,9 @@ static void cmd_act(int idx, char *par)
   }
   putlog(LOG_CMDS, "*", "#%s# (%s) act %s", dcc[idx].nick,
 	 chan->dname, par);
-  dprintf(DP_HELP, "PRIVMSG %s :\001ACTION %s\001\n",
-	  chan->name, par);
+  bd::String msg;
+  msg.printf("\001ACTION %s\001", par);
+  privmsg(chan->name, msg.c_str(), DP_HELP);
   dprintf(idx, "Action to %s: %s\n", chan->dname, par);
 }
 
@@ -137,7 +138,7 @@ static void cmd_msg(int idx, char *par)
   char *nick = newsplit(&par);
 
   putlog(LOG_CMDS, "*", "#%s# msg %s %s", dcc[idx].nick, nick, par);
-  dprintf(DP_HELP, "PRIVMSG %s :%s\n", nick, par);
+  privmsg(nick, par, DP_HELP);
   dprintf(idx, "Msg to %s: %s\n", nick, par);
 }
 
@@ -185,7 +186,7 @@ static void cmd_say(int idx, char *par)
     return;
   }
   putlog(LOG_CMDS, "*", "#%s# (%s) say %s", dcc[idx].nick, chan->dname, par);
-  dprintf(DP_HELP, "PRIVMSG %s :%s\n", chan->name, par);
+  privmsg(chan->name, par, DP_HELP);
   dprintf(idx, "Said to %s: %s\n", chan->dname, par);
 }
 
@@ -1805,7 +1806,9 @@ static void cmd_adduser(int idx, char *par)
     dprintf(idx, "%s's initial password set to \002%s\002\n", hand, s2);
     dprintf(idx, "%s's initial secpass set to \002%s\002\n", hand, s3);
 
-    dprintf(DP_HELP, "PRIVMSG %s :*** You've been add to this botnet as '%s' with the host '%s'. Ask a botnet admin for the msg cmds. Your initial password is: %s\n", nick, hand, p1, s2);
+    bd::String msg;
+    msg.printf("*** You've been add to this botnet as '%s' with the host '%s'. Ask a botnet admin for the msg cmds. Your initial password is: %s", hand, p1, s2);
+    privmsg(nick, msg.c_str(), DP_HELP);
   } else {
     dprintf(idx, "Added hostmask %s to %s.\n", p1, u->handle);
     addhost_by_handle(hand, p1);
@@ -1969,7 +1972,7 @@ static void cmd_play(int idx, char *par)
   while (stream.tell() < stream.length()) {
     str = stream.getline().chomp();
     if (str.length())
-      dprintf(DP_PLAY, "PRIVMSG %s :%s\n", chan->name, str.c_str());
+      privmsg(chan->name, str.c_str(), DP_PLAY);
   }
 }
 

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

@@ -193,8 +193,10 @@ void notice_invite(struct chanset_t *chan, char *handle, char *nick, char *uhost
   if (handle)
     simple_snprintf(fhandle, sizeof(fhandle), "\002%s\002 ", handle);
   putlog(LOG_MISC, "*", "Invited %s%s(%s%s%s) to %s.", handle ? handle : "", handle ? " " : "", nick, uhost ? "!" : "", uhost ? uhost : "", chan->dname);
-  dprintf(DP_MODE, "PRIVMSG %s :\001ACTION has invited %s(%s%s%s) to %s.%s\001\n",
-    chan->name, fhandle, nick, uhost ? "!" : "", uhost ? uhost : "", chan->dname, op ? ops : "");
+  bd::String msg;
+  msg.printf("\001ACTION has invited %s(%s%s%s) to %s.%s\001",
+    fhandle, nick, uhost ? "!" : "", uhost ? uhost : "", chan->dname, op ? ops : "");
+  privmsg(chan->name, msg.c_str(), DP_MODE);
 }
 
 #ifdef CACHE

+ 62 - 35
src/mod/irc.mod/msgcmds.c

@@ -39,9 +39,12 @@ static int msg_bewm(char *nick, char *host, struct userrec *u, char *par)
 
   if (match_my_nick(nick))
     return BIND_RET_BREAK;
+
+  bd::String msg;
+
   if (!u) {
-    dprintf(DP_SERVER, STR("PRIVMSG %s :---- (%s!%s) attempted to gain secure invite, but is not a recognized user.\n"), 
-          chan->dname, nick, host);
+    msg.printf(STR("---- (%s!%s) attempted to gain secure invite, but is not a recognized user."), nick, host);
+    privmsg(chan->name, msg.c_str(), DP_SERVER);
 
     putlog(LOG_CMDS, "*", STR("(%s!%s) !*! BEWM"), nick, host);
     return BIND_RET_BREAK;
@@ -55,13 +58,13 @@ static int msg_bewm(char *nick, char *host, struct userrec *u, char *par)
 
   if (!chk_op(fr, chan))  {
     putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! !BEWM"), nick, host, u->handle);
-    dprintf(DP_SERVER, STR("PRIVMSG %s :---- %s (%s!%s) attempted to gain secure invite, but is missing a flag.\n"), 
-            chan->dname, u->handle, nick, host);
+    msg.printf(STR("---- %s (%s!%s) attempted to gain secure invite, but is missing a flag."), u->handle, nick, host);
+    privmsg(chan->name, msg.c_str(), DP_SERVER);
     return BIND_RET_BREAK;
   }
 
-  dprintf(DP_SERVER, "PRIVMSG %s :\001ACTION has invited \002%s\002 (%s!%s) to %s.\001\n"
-           , chan->dname, u->handle, nick, host, chan->dname);
+  msg.printf("\001ACTION has invited \002%s\002 (%s!%s) to %s.\001", u->handle, nick, host, chan->dname);
+  privmsg(chan->name, msg.c_str(), DP_SERVER);
 
   cache_invite(chan, nick, host, u->handle, 0, 0);
   putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! BEWM"), nick, host, u->handle);
@@ -82,20 +85,20 @@ static int msg_pass(char *nick, char *host, struct userrec *u, char *par)
   if (u->bot)
     return BIND_RET_BREAK;
   if (!par[0]) {
-    dprintf(DP_HELP, "NOTICE %s :%s\n", nick, u_pass_match(u, "-") ? "You don't have a password set." : "You have a password set.");
+    notice(nick, u_pass_match(u, "-") ? "You don't have a password set." : "You have a password set.", DP_HELP);
     putlog(LOG_CMDS, "*", "(%s!%s) !%s! PASS?", nick, host, u->handle);
     return BIND_RET_BREAK;
   }
   old = newsplit(&par);
   if (!u_pass_match(u, "-") && !par[0]) {
     putlog(LOG_CMDS, "*", "(%s!%s) !%s! $b!$bPASS...", nick, host, u->handle);
-    dprintf(DP_HELP, "NOTICE %s :You already have a password set.\n", nick);
+    notice(nick, "You already have a password set.", DP_HELP);
     return BIND_RET_BREAK;
   }
   if (par[0]) {
     if (!u_pass_match(u, old)) {
       putlog(LOG_CMDS, "*", "(%s!%s) !%s! $b!$bPASS...", nick, host, u->handle);
-      dprintf(DP_HELP, "NOTICE %s :Incorrect password.\n", nick);
+      notice(nick, "Incorrect password.", DP_HELP);
       return BIND_RET_BREAK;
     }
     mynew = newsplit(&par);
@@ -113,8 +116,9 @@ static int msg_pass(char *nick, char *host, struct userrec *u, char *par)
   putlog(LOG_CMDS, "*", "(%s!%s) !%s! PASS", nick, host, u->handle);
 
   set_user(&USERENTRY_PASS, u, mynew);
-  dprintf(DP_HELP, "NOTICE %s :%s '%s'.\n", nick,
-	  mynew == old ? "Password set to:" : "Password changed to:", mynew);
+  bd::String msg;
+  msg.printf("%s '%s'.", mynew == old ? "Password set to:" : "Password changed to:", mynew);
+  notice(nick, msg.c_str(), DP_HELP);
   return BIND_RET_BREAK;
 }
 
@@ -128,6 +132,8 @@ static int msg_op(char *nick, char *host, struct userrec *u, char *par)
     return BIND_RET_BREAK;
   pass = newsplit(&par);
 
+  bd::String msg;
+
   if (homechan[0]) {
     struct chanset_t *hchan = NULL;
 
@@ -136,11 +142,10 @@ static int msg_op(char *nick, char *host, struct userrec *u, char *par)
     if (hchan && channel_active(hchan) && !ismember(hchan, nick)) {
       putlog(LOG_CMDS, "*", "(%s!%s) !*! failed OP %s (not in %s)", nick, host, par, homechan);
       if (par[0]) 
-        dprintf(DP_SERVER, "PRIVMSG %s :---- (%s!%s) attempted to OP for %s but is not currently in %s.\n", 
-              homechan, nick, host, par, homechan);
+        msg.printf("---- (%s!%s) attempted to OP for %s but is not currently in %s.", nick, host, par, homechan);
       else
-        dprintf(DP_SERVER, "PRIVMSG %s :---- (%s!%s) attempted to OP but is not currently in %s.\n", 
-              homechan, nick, host, homechan);
+        msg.printf("---- (%s!%s) attempted to OP but is not currently in %s.", nick, host, homechan);
+      privmsg(homechan, msg.c_str(), DP_SERVER);
       return BIND_RET_BREAK;
     }
   }
@@ -155,8 +160,10 @@ static int msg_op(char *nick, char *host, struct userrec *u, char *par)
             if (do_op(nick, chan, 0, 1)) {
               stats_add(u, 0, 1);
               putlog(LOG_CMDS, "*", "(%s!%s) !%s! OP %s", nick, host, u->handle, par);
-              if (manop_warn && chan->manop)
-                dprintf(DP_HELP, "NOTICE %s :%s is currently set to punish for manual op.\n", nick, chan->dname);
+              if (manop_warn && chan->manop) {
+                msg.printf("%s is currently set to punish for manual op.", chan->dname);
+                notice(nick, msg.c_str(), DP_HELP);
+              }
             }
           }
           return BIND_RET_BREAK;
@@ -168,8 +175,10 @@ static int msg_op(char *nick, char *host, struct userrec *u, char *par)
           if (chk_op(fr, chan)) {
             if (do_op(nick, chan, 0, 1)) {
               stats++;
-              if (manop_warn && chan->manop)
-                dprintf(DP_HELP, "NOTICE %s :%s is currently set to punish for manual op.\n", nick, chan->dname);
+              if (manop_warn && chan->manop) {
+                msg.printf("%s is currently set to punish for manual op.", chan->dname);
+                notice(nick, msg.c_str(), DP_HELP);
+              }
             }
           }
         }
@@ -199,6 +208,7 @@ static int msg_ident(char *nick, char *host, struct userrec *u, char *par)
     strlcpy(who, par, sizeof(who));
     who[NICKMAX] = 0;
   }
+  bd::String msg;
   u2 = get_user_by_handle(userlist, who);
   if (u2 && rfc_casecmp(who, origbotname) && !u2->bot) {
     /* This could be used as detection... */
@@ -208,16 +218,18 @@ static int msg_ident(char *nick, char *host, struct userrec *u, char *par)
       putlog(LOG_CMDS, "*", "(%s!%s) !*! failed IDENT %s", nick, host, who);
       return BIND_RET_BREAK;
     } else if (u == u2) {
-      dprintf(DP_HELP, "NOTICE %s :I recognize you there.\n", nick);
+      notice(nick, "I recognize you there.", DP_HELP);
       return BIND_RET_BREAK;
     } else if (u) {
-      dprintf(DP_HELP, "NOTICE %s :You're not %s, you're %s.\n", nick, who, u->handle);
+      msg.printf("You're not %s, you're %s.", who, u->handle);
+      notice(nick, msg.c_str(), DP_HELP);
       return BIND_RET_BREAK;
     } else {
       putlog(LOG_CMDS, "*", "(%s!%s) !*! IDENT %s", nick, host, who);
       simple_snprintf(s, sizeof s, "%s!%s", nick, host);
       maskaddr(s, s1, 0); /* *!user@host */
-      dprintf(DP_HELP, "NOTICE %s :Added hostmask: %s\n", nick, s1);
+      msg.printf("Added hostmask: %s", s1);
+      notice(nick, msg.c_str(), DP_HELP);
       addhost_by_handle(who, s1);
       check_this_user(who, 0, NULL);
       return BIND_RET_BREAK;
@@ -248,12 +260,15 @@ static int msg_invite(char *nick, char *host, struct userrec *u, char *par)
       putlog(LOG_CMDS, "*", "(%s!%s) !%s! INVITE ALL", nick, host, u->handle);
       return BIND_RET_BREAK;
     }
+    bd::String msg;
     if (!(chan = findchan_by_dname(par))) {
-      dprintf(DP_HELP, "NOTICE %s :Usage: /MSG %s %s <pass> <channel>\n", nick, botname, msginvite);
+      msg.printf("Usage: /MSG %s %s <pass> <channel>", botname, msginvite);
+      notice(nick, msg.c_str(), DP_HELP);
       return BIND_RET_BREAK;
     }
     if (!channel_active(chan)) {
-      dprintf(DP_HELP, "NOTICE %s :%s: Not on that channel right now.\n", nick, par);
+      msg.printf("%s: Not on that channel right now.", par);
+      notice(nick, msg.c_str(), DP_HELP);
       return BIND_RET_BREAK;
     }
     /* We need to check access here also (dw 991002) */
@@ -280,9 +295,9 @@ static void reply(char *nick, struct chanset_t *chan, const char *format, ...)
   va_end(va);
 
   if (chan)
-    dprintf(DP_HELP, "PRIVMSG %s :%s", chan->name, buf);
+    privmsg(chan->name, buf, DP_HELP);
   else
-    dprintf(DP_HELP, "NOTICE %s :%s", nick, buf);
+    notice(nick, buf, DP_HELP);
 }
 
 static void logc(const char *cmd, Auth *a, char *chname, char *par)
@@ -314,7 +329,7 @@ static int msg_authstart(char *nick, char *host, struct userrec *u, char *par)
 
   if (auth) {
     if (auth->Authed()) {
-      dprintf(DP_HELP, STR("NOTICE %s :You are already authed.\n"), nick);
+      notice(nick, "You are already authed.", DP_HELP);
       return 0;
     }
   } else
@@ -322,7 +337,9 @@ static int msg_authstart(char *nick, char *host, struct userrec *u, char *par)
 
   /* Send "auth." if they are recognized, otherwise "auth!" */
   auth->Status(AUTH_PASS);
-  dprintf(DP_HELP, STR("PRIVMSG %s :auth%s %s\n"), nick, u ? "." : "!", conf.bot->nick);
+  bd::String msg;
+  msg.printf(STR("auth%s %s"), u ? "." : "!", conf.bot->nick);
+  privmsg(nick, msg.c_str(), DP_HELP);
 
   return BIND_RET_BREAK;
 }
@@ -332,7 +349,9 @@ AuthFinish(Auth *auth)
 {
   putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! +AUTH"), auth->nick, auth->host, auth->handle);
   auth->Done();
-  dprintf(DP_HELP, STR("NOTICE %s :You are now authorized for cmds, see %chelp\n"), auth->nick, auth_prefix[0]);
+  bd::String msg;
+  msg.printf(STR("You are now authorized for cmds, see %chelp"), auth_prefix[0]);
+  notice(auth->nick, msg.c_str(), DP_HELP);
 }
 
 static int msg_auth(char *nick, char *host, struct userrec *u, char *par)
@@ -357,7 +376,9 @@ static int msg_auth(char *nick, char *host, struct userrec *u, char *par)
       putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! AUTH"), nick, host, u->handle);
       auth->Status(AUTH_HASH);
       auth->MakeHash();
-      dprintf(DP_HELP, STR("PRIVMSG %s :-Auth %s %s\n"), nick, auth->rand, conf.bot->nick);
+      bd::String msg;
+      msg.printf(STR("-Auth %s %s"), auth->rand, conf.bot->nick);
+      privmsg(nick, msg.c_str(), DP_HELP);
     } else {
       /* no auth_key and/or no SECPASS for the user, don't require a hash auth */
       AuthFinish(auth);
@@ -389,7 +410,7 @@ static int msg_pls_auth(char *nick, char *host, struct userrec *u, char *par)
       char s[300] = "";
 
       putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! failed +AUTH"), nick, host, u->handle);
-      dprintf(DP_HELP, STR("NOTICE %s :Invalid hash.\n"), nick);
+      notice(nick, STR("Invalid hash."), DP_HELP);
       simple_snprintf(s, sizeof(s), "*!%s", host);
       addignore(s, origbotname, STR("Invalid auth hash."), now + (60 * ignore_time));
       delete auth;
@@ -412,7 +433,7 @@ static int msg_unauth(char *nick, char *host, struct userrec *u, char *par)
     return BIND_RET_BREAK;
 
   delete auth;
-  dprintf(DP_HELP, STR("NOTICE %s :You are now unauthorized.\n"), nick);
+  notice(nick, STR("You are now unauthorized."), DP_HELP);
   putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! UNAUTH"), nick, host, u->handle);
 
   return BIND_RET_BREAK;
@@ -479,7 +500,9 @@ static int msgc_op(Auth *a, char *chname, char *par)
     if (!strcasecmp(tmp, "force") || !strcasecmp(tmp, "f")) 
       force = 1;
     else {
-      dprintf(DP_HELP, "NOTICE %s :Invalid option: %s\n", a->nick, tmp);
+      bd::String msg;
+      msg.printf("Invalid option: %s", tmp);
+      notice(a->nick, msg.c_str(), DP_HELP);
       return 0;
     }
   }
@@ -528,7 +551,9 @@ static int msgc_voice(Auth *a, char *chname, char *par)
     if (!strcasecmp(tmp, "force") || !strcasecmp(tmp, "f")) 
       force = 1;
     else {
-      dprintf(DP_HELP, "NOTICE %s :Invalid option: %s\n", a->nick, tmp);
+      bd::String msg;
+      msg.printf("Invalid option: %s", tmp);
+      notice(a->nick, msg.c_str(), DP_HELP);
       return 0;
     }
   }
@@ -672,7 +697,9 @@ static int msgc_invite(Auth *a, char *chname, char *par)
     if (!strcasecmp(tmp, "force") || !strcasecmp(tmp, "f")) 
       force = 1;
     else {
-      dprintf(DP_HELP, "NOTICE %s :Invalid option: %s\n", a->nick, tmp);
+      bd::String msg;
+      msg.printf("Invalid option: %s", tmp);
+      notice(a->nick, msg.c_str(), DP_HELP);
       return 0;
     }
   }

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

@@ -636,13 +636,13 @@ static int gotmsg(char *from, char *msg)
   /* Send out possible ctcp responses */
   if (ctcp_reply[0]) {
     if (ctcp_mode != 2) {
-      dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
+      notice(nick, ctcp_reply, DP_HELP);
     } else {
       if (now - last_ctcp > flood_ctcp.time) {
-        dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
+        notice(nick, ctcp_reply, DP_HELP);
 	count_ctcp = 1;
       } else if (count_ctcp < flood_ctcp.count) {
-        dprintf(DP_HELP, "NOTICE %s :%s\n", nick, ctcp_reply);
+        notice(nick, ctcp_reply, DP_HELP);
 	count_ctcp++;
       }
       last_ctcp = now;

+ 7 - 2
src/mod/transfer.mod/transfer.c

@@ -45,6 +45,9 @@
 #include "src/mod/share.mod/share.h"
 #include "src/mod/update.mod/update.h"
 
+#include "src/chanprog.h"
+#include <bdlib/src/String.h>
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <netinet/in.h>
@@ -491,7 +494,7 @@ void dcc_send(int idx, char *buf, int len)
   dcc[idx].timeval = now;
   if (dcc[idx].status > dcc[idx].u.xfer->length &&
       dcc[idx].u.xfer->length > 0) {
-    dprintf(DP_HELP,"NOTICE %s :Bogus file length.\n", dcc[idx].nick);
+    notice(dcc[idx].nick, "Bogus file length.", DP_HELP);
     putlog(LOG_FILES, "*",
 	   "File too long: dropping dcc send %s from %s!%s",
 	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host);
@@ -747,7 +750,9 @@ static void dcc_get_pending(int idx, char *buf, int len)
   dcc[idx].addr = ip;
   dcc[idx].port = (int) port;
   if (dcc[idx].sock == -1) {
-    dprintf(DP_HELP, "NOTICE %s :Bad connection (%s)\n", dcc[idx].nick, strerror(errno));
+    bd::String msg;
+    msg.printf("Bad connection (%s)", strerror(errno));
+    notice(dcc[idx].nick, msg.c_str(), DP_HELP);
     putlog(LOG_FILES, "*", "DCC bad connection: GET %s (%s!%s)",
 	   dcc[idx].u.xfer->origname, dcc[idx].nick, dcc[idx].host);
     fclose(dcc[idx].u.xfer->f);