Parcourir la source

* Added some functions for CAP kicking, unfinished.
* Added egg_isupper
* Fixed a modesetting() bug


svn: 286

Bryan Drewery il y a 22 ans
Parent
commit
29a650fed2
4 fichiers modifiés avec 38 ajouts et 1 suppressions
  1. 1 0
      src/eggdrop.h
  2. 1 1
      src/mod/channels.mod/cmdschan.c
  3. 35 0
      src/mod/irc.mod/irc.c
  4. 1 0
      src/mod/irc.mod/irc.h

+ 1 - 0
src/eggdrop.h

@@ -288,6 +288,7 @@ typedef u_32bit_t dword;
 #define egg_isascii(x)  isascii((int)  (unsigned char) (x))
 #define egg_isspace(x)  isspace((int)  (unsigned char) (x))
 #define egg_islower(x)  islower((int)  (unsigned char) (x))
+#define egg_isupper(x)  isupper((int)  (unsigned char) (x))
 
 /***********************************************************************/
 

+ 1 - 1
src/mod/channels.mod/cmdschan.c

@@ -1482,7 +1482,7 @@ static void cmd_mns_chan(struct userrec *u, int idx, char *par)
 void modesetting(int idx, char *work, int *cnt, char *name, int state)
 {
   char tmp[100];
-  if (!name || (name && !name[0])) (*cnt) = 3; 		/* empty buffer if no (char *) name */
+  if (((*cnt) < 3) && (!name || (name && !name[0]))) (*cnt) = 3; 		/* empty buffer if no (char *) name */
   (*cnt)++;
   if (*cnt > 4) {
     *cnt = 1;

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

@@ -83,6 +83,41 @@ static int include_lk = 1;		/* For correct calculation
 #include "msgcmds.c"
 #include "tclirc.c"
 
+static void detect_autokick(char *nick, char *uhost, struct chanset_t *chan, char *msg)
+{
+  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0};
+  struct userrec *u = NULL;
+  int i = 0, tot = 0;
+
+  if (!nick || !nick[0] || !uhost || !uhost[0] || !chan || !msg || !msg[0])
+    return;
+  
+  tot = strlen(msg);
+  u = get_user_by_host(uhost);
+  get_user_flagrec(u, &fr, chan->dname);
+
+  for(; *msg; ++msg) {
+    if (egg_isupper(*msg))
+      i++;
+  }
+
+//  if ((chan->capslimit)) {
+    while (((msg) && *msg)) {
+      if (egg_isupper(*msg))
+        i++;
+      msg++;
+    }
+
+//  if (chan->capslimit && ((i / tot) >= chan->capslimit)) {
+//dprintf(DP_MODE, "PRIVMSG %s :flood stats for %s: %d/%d are CAP, percentage: %d\n", chan->name, nick, i, tot, (i/tot)*100);
+//  if ((((i / tot) * 100) >= 50)) {
+//dprintf(DP_HELP, "PRIVMSG %s :cap flood.\n", chan->dname);
+//  }
+
+}
+
+
+
 void makeopline(struct chanset_t *chan, char *nick, char *buf)
 {
   char plaincookie[20], enccookie[48], *p, nck[20], key[200];

+ 1 - 0
src/mod/irc.mod/irc.h

@@ -31,6 +31,7 @@ static void flush_mode(struct chanset_t *, int);
 #define resetinvites(chan)  resetmasks((chan), (chan)->channel.invite,	\
 				       (chan)->invites, global_invites, 'I')
 
+static void detect_autokick(char *, char *, struct chanset_t *, char *);
 static int target_priority(struct chanset_t *, memberlist *, int);
 static void request_op(struct chanset_t *);
 static void request_in(struct chanset_t *);