Bläddra i källkod

* Rename set 'flood-g' to 'flood-callerid', which only takes affect if the server supports CALLERID.

Bryan Drewery 16 år sedan
förälder
incheckning
8dcc12817c
5 ändrade filer med 20 tillägg och 19 borttagningar
  1. 1 0
      doc/UPDATES
  2. 2 1
      doc/help.txt
  3. 1 1
      src/mod/server.mod/server.h
  4. 15 16
      src/mod/server.mod/servmsg.c
  5. 1 1
      src/set.c

+ 1 - 0
doc/UPDATES

@@ -1,5 +1,6 @@
 * 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)
+* Rename set 'flood-g' to 'flood-callerid', which only takes affect if the server supports CALLERID.
 
 1.2.17 - http://wraith.botpack.net/milestone/1.2.17
 * Binary / shell / startup changes

+ 2 - 1
doc/help.txt

@@ -1586,7 +1586,8 @@ See also: reload, backup
                           (Resets PID/CPU)
 [R]  $bflood-msg$b       Msgs:Secs until a host is ignored. (0:0 to disable) 
 [R]  $bflood-ctcp$b      Ctcps:Secs until a host is ignored. (0:0 to disable) 
-[R]  $bflood-g$b         Msgs:Secs until triggering to set +g for 60 seconds (0:0 to disable)
+[R]  $bflood-callerid$b  Msgs:Secs until triggering to set CALLERID for
+                          60 seconds (0:0 to disable)
  
 [D]  $blogin$b           How to handle someone logging in to the shell.
 [D]  $btrace$b           How to handle someone tracing/debugging the bot.

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

@@ -58,7 +58,7 @@ extern char		cursrvname[], botrealname[121], botuserhost[], ctcp_reply[1024],
 			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;
+extern rate_t		flood_msg, flood_ctcp, flood_callerid;
 
 int check_bind_ctcpr(char *, char *, struct userrec *, char *, char *, char *, bind_table_t *);
 

+ 15 - 16
src/mod/server.mod/servmsg.c

@@ -389,15 +389,15 @@ static char lastmsghost[FLOOD_GLOBAL_MAX][128];
 static time_t lastmsgtime[FLOOD_GLOBAL_MAX];
 static int dronemsgs;
 static time_t dronemsgtime;
-static bool set_pls_g;
-static interval_t flood_g_time = 60;
+static bool in_callerid = 0;
+static interval_t flood_callerid_time = 60;
 
-rate_t flood_g = { 6, 2 };
+rate_t flood_callerid = { 6, 2 };
 
-void unset_g(int data)
+void unset_callerid(int data)
 {
-  dprintf(DP_MODE, "MODE %s :-g\n", botname);
-  set_pls_g = 0;
+  dprintf(DP_MODE, "MODE %s :-%c\n", botname, callerid_char);
+  in_callerid = 0;
 }
 
 /* Do on NICK, PRIVMSG, NOTICE and JOIN.
@@ -436,9 +436,7 @@ static bool detect_flood(char *floodnick, char *floodhost, char *from, int which
   if (!strcasecmp(floodhost, botuserhost))
     return 0;			/* My user@host (?) */
 
-  //FIXME: hack for +g 
-
-  if (dronemsgtime < now - flood_g.time) {	//expired, reset counter
+  if (dronemsgtime < now - flood_callerid.time) {	//expired, reset counter
     dronemsgs = 0;
 //    dronemsgtime = now;
   }
@@ -446,17 +444,17 @@ static bool detect_flood(char *floodnick, char *floodhost, char *from, int which
   dronemsgs++;
   dronemsgtime = now;
 
-  if (!set_pls_g && dronemsgs >= flood_g.count) {  //flood from dronenet, let's attempt to set +g
+  if (!in_callerid && dronemsgs >= flood_callerid.count && callerid_char) {  //flood from dronenet, let's attempt to set +g
     egg_timeval_t howlong;
 
-    set_pls_g = 1;
+    in_callerid = 1;
     dronemsgs = 0;
     dronemsgtime = 0;
-    dprintf(DP_DUMP, "MODE %s :+g\n", botname);
-    howlong.sec = flood_g_time;
+    dprintf(DP_DUMP, "MODE %s :+%c\n", botname, callerid_char);
+    howlong.sec = flood_callerid_time;
     howlong.usec = 0;
-    timer_create(&howlong, "Unset umode +g", (Function) unset_g);
-    putlog(LOG_MISC, "*", "Drone flood detected! Setting +g for %d seconds.", flood_g_time);
+    timer_create(&howlong, "Unset CALLERID", (Function) unset_callerid);
+    putlog(LOG_MISC, "*", "Drone flood detected! Setting CALLERID for %d seconds.", flood_callerid_time);
     return 1;	//ignore the current msg
   }
 
@@ -1141,6 +1139,7 @@ static void disconnect_server(int idx, int dolost)
   use_354 = 0;
   deaf_char = 0;
   callerid_char = 0;
+  in_callerid = 0;
   use_exempts = 0;
   use_invites = 0;
   if (dolost) {
@@ -1592,7 +1591,7 @@ static int got718(char *from, char *msg)
   uhost = newsplit(&msg);
   fixcolon(msg);
 
-  putlog(LOG_WALL, "*", "(+g) !%s!%s! %s", nick, uhost, msg);
+  putlog(LOG_WALL, "*", "(CALLERID) !%s!%s! %s", nick, uhost, msg);
 
   return 0;
 }

+ 1 - 1
src/set.c

@@ -84,7 +84,7 @@ static variable_t vars[] = {
  VAR("deaf",		&use_deaf,		VAR_INT|VAR_BOOL|VAR_NOLHUB,			0, 1, "1"),
  VAR("fight-threshold",	&fight_threshold,	VAR_INT|VAR_NOLOC,				0, 0, "0"),
  VAR("flood-ctcp",	&flood_ctcp,		VAR_RATE|VAR_NOLHUB,				0, 0, "3:60"),
- VAR("flood-g",		&flood_g,		VAR_RATE|VAR_NOLHUB,				0, 0, "6:2"),
+ VAR("flood-callerid",	&flood_callerid,	VAR_RATE|VAR_NOLHUB,				0, 0, "6:2"),
  VAR("flood-msg",	&flood_msg,		VAR_RATE|VAR_NOLHUB,				0, 0, "5:60"),
  VAR("fork-interval",	&fork_interval,		VAR_INT,					10, 0, "0"),
  VAR("hijack",		&hijack,		VAR_INT|VAR_DETECTED|VAR_PERM,			0, 4, "die"),