Explorar el Código

* Add set 'callerid' to run bot in CALLERID mode (+g). +c bots will automatically accept messages from known users. (fixes #45)

Bryan Drewery hace 16 años
padre
commit
5966564b06
Se han modificado 7 ficheros con 20 adiciones y 7 borrados
  1. 1 0
      doc/UPDATES
  2. 3 0
      doc/help.txt
  3. 1 0
      src/mod/server.mod/server.c
  4. 1 1
      src/mod/server.mod/server.h
  5. 5 0
      src/mod/server.mod/servmsg.c
  6. 8 5
      src/set.c
  7. 1 1
      src/set.h

+ 1 - 0
doc/UPDATES

@@ -1,4 +1,5 @@
 * Add set 'deaf' to run bot in DEAF mode on supporting IRCDs. This prevents channel conversations coming to the bot. On by default.
+* Add set 'callerid' to run bot in CALLERID mode (+g). +c bots will automatically accept messages from known users. (fixes #45)
 
 1.2.17 - http://wraith.botpack.net/milestone/1.2.17
 * Binary / shell / startup changes

+ 3 - 0
doc/help.txt

@@ -1604,6 +1604,9 @@ See also: reload, backup
                            the IRCD from sending any channel conversations to the bot.
                            This will decrease bandwidth/CPU used, as well as prevent
                            sniffing of channels.
+[B]  $bcallerid$b        Run bot in CALLERID mode. This is commonly known as +g on most
+                           servers. +c bots will automatically accept messages from
+                           known users. Note that this will break msg-ident.
  
 [S]  $baltchars$b        Define string of characters to cycle when generating alternative
                           nicks when nick is taken. Ie: _-`[].

+ 1 - 0
src/mod/server.mod/server.c

@@ -96,6 +96,7 @@ static bool use_penalties = 0;
 static int use_fastdeq;
 size_t nick_len = 9;			/* Maximal nick length allowed on the network. */
 char deaf_char = 0;
+char callerid_char = 0;
 
 static bool double_mode = 0;		/* allow a msgs to be twice in a queue? */
 static bool double_server = 0;

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

@@ -55,7 +55,7 @@ extern port_t		default_port, newserverport, curservport;
 extern time_t		server_online;
 extern interval_t	cycle_time;
 extern char		cursrvname[], botrealname[121], botuserhost[], ctcp_reply[1024],
-			newserver[], newserverpass[], curnetwork[], botuserip[], altnick_char, deaf_char;
+			newserver[], newserverpass[], curnetwork[], botuserip[], altnick_char, deaf_char, callerid_char;
 extern struct server_list *serverlist;
 extern struct dcc_table SERVER_SOCKET;
 extern rate_t		flood_msg, flood_ctcp, flood_g;

+ 5 - 0
src/mod/server.mod/servmsg.c

@@ -298,6 +298,10 @@ got005(char *from, char *msg)
       deaf_char = p[0];
       if (use_deaf)
         dprintf(DP_SERVER, "MODE %s +%c\n", botname, deaf_char);
+    } else if (!strcasecmp(tmp, "CALLERID")) {
+      callerid_char = p[0];
+      if (use_callerid)
+        dprintf(DP_SERVER, "MODE %s +%c\n", botname, callerid_char);
     } else if (!strcasecmp(tmp, "EXCEPTS"))
       use_exempts = 1;
     else if (!strcasecmp(tmp, "INVEX"))
@@ -1136,6 +1140,7 @@ static void disconnect_server(int idx, int dolost)
   use_penalties = 0;
   use_354 = 0;
   deaf_char = 0;
+  callerid_char = 0;
   use_exempts = 0;
   use_invites = 0;
   if (dolost) {

+ 8 - 5
src/set.c

@@ -41,6 +41,7 @@ bool irc_autoaway;
 bool link_cleartext;
 bool dccauth = 0;
 bool use_deaf = 0;
+bool use_callerid = 0;
 int cloak_script = 0;
 rate_t close_threshold;
 int fight_threshold;
@@ -75,6 +76,7 @@ static variable_t vars[] = {
  VAR("auth-key",	auth_key,		VAR_STRING|VAR_PERM,				0, 0, NULL),
  VAR("auth-obscure",	&auth_obscure,		VAR_INT|VAR_BOOL,				0, 1, "0"),
  VAR("auth-prefix",	auth_prefix,		VAR_WORD|VAR_NOLHUB|VAR_PERM,			0, 0, "+"),
+ VAR("callerid",	&use_callerid,		VAR_INT|VAR_BOOL|VAR_NOLHUB,			0, 1, "1"),
  VAR("cloak-script",	&cloak_script,		VAR_INT|VAR_CLOAK|VAR_NOLHUB,			0, 10, "0"),
  VAR("close-threshold",	&close_threshold,	VAR_RATE|VAR_NOLOC,				0, 0, "0:0"),
  VAR("dcc-autoaway",	&dcc_autoaway,		VAR_INT|VAR_NOLOC,				0, (5*60*60), "1800"),
@@ -274,16 +276,17 @@ sdprintf("var (mem): %s -> %s", var->name, datain ? datain : "(NULL)");
 
     if (!strcmp(var->name, "ident-botnick"))
       strlcpy(botuser, conf.username && !num ? conf.username : origbotname, 21);
-    else if (!strcmp(var->name, "deaf")) {
-      if (server_online && deaf_char) {
+    else if ((!strcmp(var->name, "deaf") && deaf_char) || (!strcmp(var->name, "callerid") && callerid_char)) {
+      if (server_online) {
         char which = 0;
         if (num == 1 && olddata == 0)
           which = '+';
         else if (num == 0 && olddata == 1)
           which = '-';
-        if (which)
-          dprintf(DP_SERVER, "MODE %s %c%c\n", botname, which, deaf_char);
-
+        if (which) {
+          char mode_char = strcmp(var->name, "deaf") == 0 ? deaf_char : callerid_char;
+          dprintf(DP_SERVER, "MODE %s %c%c\n", botname, which, mode_char);
+        }
       }
     }
   } else if (var->flags & (VAR_STRING|VAR_WORD)) {

+ 1 - 1
src/set.h

@@ -70,7 +70,7 @@ typedef struct rate_b {
 extern char		auth_key[], auth_prefix[2], motd[], alias[], rbl_servers[1024],
 			msgident[], msginvite[], msgop[], msgpass[],
                         homechan[], altchars[];
-extern bool		dccauth, auth_obscure, manop_warn, auth_chan, oidentd, ident_botnick, irc_autoaway, link_cleartext, use_deaf;
+extern bool		dccauth, auth_obscure, manop_warn, auth_chan, oidentd, ident_botnick, irc_autoaway, link_cleartext, use_deaf, use_callerid;
 extern int		cloak_script, fight_threshold, fork_interval, in_bots, set_noshare, dcc_autoaway,
 			kill_threshold, lag_threshold, op_bots, hijack, login, promisc, trace,
                         ison_time;