Kaynağa Gözat

* Add cmd_netmsg back in. It may only be used to message channels the bots are opped in.

Bryan Drewery 16 yıl önce
ebeveyn
işleme
a40e176881
4 değiştirilmiş dosya ile 30 ekleme ve 6 silme
  1. 1 0
      doc/UPDATES
  2. 8 3
      doc/help.txt
  3. 0 1
      src/binds.c
  4. 21 2
      src/cmds.c

+ 1 - 0
doc/UPDATES

@@ -110,6 +110,7 @@
   * Add cmd_hash which returns the MD5, SHA1 and SHA256 of the given string.
   * Credits/cmd_about updates.
   * Add chanset '+/-voicebitch' for a +bitch style enforcement over voices.
+  * Add cmd_netmsg back in. It may only be used to message channels the bots are opped in.
 
 1.2.16.1
 * Fix linux compile errors

+ 8 - 3
doc/help.txt

@@ -282,10 +282,10 @@ See also: botpart, +chan, -chan, chanset, chaninfo
 See also: jump, servers, botserver
 :hub:botmsg:
 ###  $bbotmsg$b <bot> <nickname|#chan> <text>
-   sends a private message to someone from the bot, just as if the
+   Sends a private message to someone from the bot, just as if the
    bot had typed /msg.
  
-See also: msg%{+n}
+See also: netmsg, msg%{+n}
 :hub:botnick:
 ###  $bbotnick$b <bot>
    The specified bot will display its current nick over DCC.
@@ -1367,7 +1367,7 @@ See also: whois
    Sends a private message to someone from the bot, just as if the
    bot had typed /msg.
  
-See also: botmsg%{+n}
+See also: netmsg, botmsg%{+n}
 :hub:netcrontab:
 ###  $bnetcrontab$b <status|delete|show|new> [interval]
    Runs the specified command on all linked bots.
@@ -1383,6 +1383,11 @@ See also: lagged
    the user that they are currently running as.
  
 See also: last
+:hub:netmsg:
+###  $bnetmsg$b <bot> <#chan> <text>
+   Sends a message to the specified channel from all opped bots.
+ 
+See also: botmsg, msg%{+n}
 :hub:netnick:
 ###  $bnetnick$b 
    All bots on the botnet will display their nick over DCC.

+ 0 - 1
src/binds.c

@@ -427,7 +427,6 @@ void add_builtins(const char *table_name, cmd_t *cmds)
 
 	for (; cmds->name; cmds++) {
           if (have_cmd(cmds->name, cmds->type)) {
-                if (!strncasecmp(cmds->name, "netm", 4) && !HAVE_F2) continue;
                 /* add BT_dcc cmds to cmdlist[] :: add to the help system.. */
                 if (!strcmp(table->name, "dcc") && (findhelp(cmds->name) != NULL)) {
                   cmdlist[cmdi].name = cmds->name;

+ 21 - 2
src/cmds.c

@@ -3989,13 +3989,18 @@ static void cmd_netmsg(int idx, char * par) {
   putlog(LOG_CMDS, "*", "#%s# netmsg %s", dcc[idx].nick, par);
   tnick = newsplit(&par);
   if (!par[0]) {
-    dprintf(idx, "Usage: netmsg <nick|#channel> <message>\n");
+    dprintf(idx, "Usage: netmsg <#channel> <message>\n");
+    return;
+  }
+
+  if (!strchr(CHANMETA, tnick[0])) {
+    dprintf(idx, "You may only netmsg channels the bots are opped in.\n");
     return;
   }
 
   char tmp[1024] = "";
 
-  simple_snprintf(tmp, sizeof tmp, "msg %s %s", tnick, par);
+  simple_snprintf(tmp, sizeof tmp, "nmsg %s %s", tnick, par);
   botnet_send_cmd_broad(-1, conf.bot->nick, dcc[idx].nick, idx, tmp);
 }
 
@@ -4013,6 +4018,18 @@ static void rcmd_msg(char * tobot, char * frombot, char * fromhand, char * fromi
   }
 }
 
+static void rcmd_nmsg(char * tobot, char * frombot, char * fromhand, char * fromidx, char * par) {
+  if (!conf.bot->hub) {
+    char *nick = newsplit(&par);
+
+    if (!strchr(CHANMETA, nick[0])) return;
+    if (!me_op(findchan_by_dname(nick))) return;
+
+    rcmd_msg(tobot, frombot, fromhand, fromidx, par);
+  }
+}
+
+
 /* netlag */
 static void cmd_netlag(int idx, char * par) {
   egg_timeval_t tv;
@@ -4357,6 +4374,8 @@ void gotremotecmd (char *forbot, char *frombot, char *fromhand, char *fromidx, c
     rcmd_jump(frombot, fromhand, fromidx, par);
   } else if (!strcmp(cmd, "msg")) {
     rcmd_msg(forbot, frombot, fromhand, fromidx, par);
+  } else if (!strcmp(cmd, "nmsg")) {
+    rcmd_nmsg(forbot, frombot, fromhand, fromidx, par);
   } else if (!strcmp(cmd, "ver")) {
     rcmd_ver(frombot, fromhand, fromidx);
   } else if (!strcmp(cmd, "ping")) {