]> jfr.im git - irc/quakenet/newserv.git/commitdiff
G 2.14
authorstrutsi <redacted>
Sat, 26 Nov 2005 22:28:00 +0000 (22:28 +0000)
committerstrutsi <redacted>
Sat, 26 Nov 2005 22:28:00 +0000 (22:28 +0000)
helpmod2/changelist
helpmod2/hchannel.c
helpmod2/hchannel.h
helpmod2/hcommands.c
helpmod2/hed.h
helpmod2/helpmod.c
helpmod2/helpmod.h
helpmod2/hversions.h

index 9216156e7eae3494463a53ab3f10822e7733cd82..b781e90d1d48d3e03eb36bead1a19ec50a0b1c05 100644 (file)
@@ -350,3 +350,11 @@ Added missing command help for ?+ and ?-
 2.13
 Fixed the account expiration problem
 Fixed the empty censor pattern bug
+
+2.14
+Text output changed a bit
+Text list is now sorted
+Added ?? term support for out reason
+Added channel option to kick users for highlighting chanops
+
+
index e503a66aa478039e965ff33acb7359c616e3c004..2a868b8183aa607853d54b38dc3e930206436363 100644 (file)
@@ -1,12 +1,16 @@
 
 #include <stdlib.h>
 #include <assert.h>
+#include <string.h>
+#include <ctype.h>
 
 #include "../lib/sstring.h"
 #include "../lib/irc_string.h"
 #include "../channel/channel.h"
 #include "../localuser/localuserchannel.h"
 #include "../core/schedule.h"
+#include "../nick/nick.h"
+
 
 #include "hchannel.h"
 #include "haccount.h"
@@ -463,6 +467,50 @@ const char *hchannel_get_state(hchannel* hchan, int mask)
         return "No";
 }
 
+int hchannel_highlight_detection(hchannel *hchan, const char *message)
+{
+    char buffer[512], *buffer_ptr = buffer, *ptr = buffer;
+    int i = 0, matches = 0;
+
+    strcpy(buffer, message);
+
+    do
+    {
+       nick *tmp;
+       huser *tmp_huser;
+       huser_channel *tmp_huserchan;
+
+       if (i++ > 6)
+            break;
+
+       while (*buffer_ptr && isspace(*buffer))
+           buffer_ptr++;
+
+       if (*buffer_ptr)
+       {
+           ptr = strchr(buffer_ptr, ' ');
+           if (ptr)
+           {
+                *ptr = '\0';
+               ptr++;
+           }
+           if ((tmp = getnickbynick(buffer_ptr)))
+               if ((tmp_huser = huser_get(tmp)))
+                   if ((tmp_huserchan = huser_on_channel(tmp_huser, hchan)))
+                       if ((tmp_huserchan->flags & HCUMODE_OP) && strlen(huser_get_nick(tmp_huser)) > 1)
+                           matches++;
+       }
+       if (ptr == NULL)
+           break;
+       else
+           buffer_ptr = ptr;
+    } while (*ptr);
+
+    if (matches > 2)
+       return 1;
+    else
+       return 0;
+}
 
 const char *hchannel_get_sname(int flag)
 {
@@ -512,7 +560,9 @@ const char *hchannel_get_sname(int flag)
     case 19:
        return "Require a ticket to join";
     case 20:
-        return "Send a message on ticket issue";
+       return "Send a message on ticket issue";
+    case 21:
+        return "Excessive highlight prevention";
     default:
         return "Error, please contact strutsi";
     }
index f71cd775c6945db70bd92f07f07e96ee9877a08e..9e6ffdcce276322d2ef2bd18e3301752f21c626a 100644 (file)
@@ -40,7 +40,9 @@ enum
     H_DISALLOW_LAME_TEXT   = 1 << 17,
     H_QUEUE_TIMEOUT        = 1 << 18,
     H_REQUIRE_TICKET       = 1 << 19,
+
     H_TICKET_MESSAGE       = 1 << 20,
+    H_HIGHLIGHT_PREVENTION = 1 << 21,
 
     /* the following are not real channel flags, they're used only internally */
     H_UNUSED_1             = 1 << 28,
@@ -51,7 +53,7 @@ enum
 
 #define H_CHANFLAGS_DEFAULT (H_CHANNEL_COMMANDS)
 
-#define HCHANNEL_CONF_COUNT 20
+#define HCHANNEL_CONF_COUNT 21
 
 typedef struct hchannel_struct
 {
@@ -132,6 +134,8 @@ void hchannels_match_accounts(void);
 
 int hchannel_count(void);
 
+int hchannel_highlight_detection(hchannel *, const char *);
+
 void hchannel_activate_join_flood(hchannel*);
 /* goes to schedule */
 void hchannel_deactivate_join_flood();
index afa3e481b424a01307d96a9f386b70a2be91cfec..8bd239da6f245efecc9b4ad577b33b7aa4535fe5 100644 (file)
@@ -1580,6 +1580,16 @@ static void helpmod_cmd_out (huser *sender, channel* returntype, char* ostr, int
                SKIP_WORD;
            }
            reason = ostr + 1;
+
+           if (!strncmp(reason, "?? ", 3))
+           { /* obtain reason from hterms */
+               hchannel *hchan = NULL;
+               if (returntype != NULL)
+                   hchan = hchannel_get_by_channel(returntype);
+               hterm *new_reason = hterm_get_and_find(hchan->channel_hterms, reason + 3);
+               if (new_reason != NULL)
+                   reason = new_reason->description->content;
+           }
            break;
        }
 
@@ -3122,36 +3132,74 @@ static void helpmod_cmd_text (huser *sender, channel* returntype, char* ostr, in
     {
        DIR *dir;
        struct dirent *dent;
-       char buffer[384];
-        int nwritten, bufpos = 0;
+       char buffer[384], **lines, *start;
+        int nwritten, bufpos = 0, nlines = 0,i;
 
        dir = opendir(HELPMOD_TEXT_DIR);
        assert(dir != NULL);
 
-       helpmod_reply(sender, returntype, "Following texts are available:");
-
+        /* First pass, count */
        for (dent = readdir(dir);dent != NULL;dent = readdir(dir))
        {
             /* Skip stuff like . and .. */
            if (!strncmp(dent->d_name, ".", 1))
                continue;
+            nlines++;
+       }
+
+       if (nlines == 0)
+       {
+           helpmod_reply(sender, returntype, "No texts are available.");
+            return;
+       }
 
+       helpmod_reply(sender, returntype, "Following texts are available:");
+
+       {
+           lines = (char **)malloc(sizeof(char*) * nlines);
+            *lines = (char *)malloc(sizeof(char) * (HED_FILENAME_LENGTH+1) * nlines);
+            /* We need the start to free this array */
+           start = *lines;
+           for(i=0;i < nlines;i++)
+               lines[i] = &lines[0][(HED_FILENAME_LENGTH+1) * i];
+       }
+        
+       /* Second pass, create array */
+        rewinddir(dir);
+       for (dent = readdir(dir), i = 0;dent != NULL && i < nlines;dent = readdir(dir))
+       {
+           /* Skip stuff like . and .. */
+           if (!strncmp(dent->d_name, ".", 1))
+               continue;
+           strncpy(lines[i], dent->d_name, 64);
+            i++;
+       }
+       /* Sort */
+       qsort(*lines, nlines, sizeof(char)*(HED_FILENAME_LENGTH+1), (int (*)(const void*, const void*))&strcmp);
+
+       for (i = 0;i < nlines;i++)
+       {
            if (bufpos)
            {
                buffer[bufpos] = ' ';
                bufpos++;
            }
-           sprintf(buffer + bufpos, "%s%n", dent->d_name, &nwritten);
+           sprintf(buffer + bufpos, "%s%n", lines[i], &nwritten);
            bufpos+=nwritten;
 
-           if (bufpos > 256)
+           if (bufpos > (384 - (HED_FILENAME_LENGTH+1)))
            {
                helpmod_reply(sender, returntype, buffer);
                bufpos = 0;
            }
        }
-        if (bufpos)
+
+       if (bufpos)
            helpmod_reply(sender, returntype, buffer);
+
+       free(start);
+        free(lines);
+
        return;
     }
     else if (!ci_strcmp(argv[0], "show"))
@@ -3179,9 +3227,9 @@ static void helpmod_cmd_text (huser *sender, channel* returntype, char* ostr, in
            if (!fgets(buffer, 512, in))
                 break;
            if (returntype != NULL && huser_get_level(sender) > H_PEON)
-               helpmod_message_channel(hchannel_get_by_channel(returntype), "%s", buffer);
+               helpmod_message_channel(hchannel_get_by_channel(returntype), "%s: %s", argv[1], buffer);
            else
-                helpmod_reply(sender, returntype, "%s", buffer);
+               helpmod_reply(sender, returntype, "%s: %s", argv[1], buffer);
        }
        fclose (in);
         return;
index 68fd4769b587a33f613bc58c23315a46b593224a..e23a9e3e08b97ab2bc1e55a81ddf70d4ec427416 100644 (file)
@@ -6,6 +6,7 @@
 #define HED_BUFFER_LINES 16
 
 #define HELPMOD_TEXT_DIR "./helpmod2/text"
+#define HED_FILENAME_LENGTH 64
 
 /* Forward declarations */
 struct hchannel_struct;
@@ -48,7 +49,7 @@ typedef struct helpmod_editor_line_struct
 
 typedef struct helpmod_editor_struct
 {
-    char filename[64];
+    char filename[HED_FILENAME_LENGTH];
     hed_line buffers[HED_BUFFER_LINES];
 
     hed_line *start;
index 7956dc3b788619a12eaff6b8e49fbe20eb6a5b37..f1d9eeb5ba0cb32e6a4875f4cda319ccb3b76b32 100644 (file)
@@ -333,7 +333,12 @@ void helpmod_chan_privmsg(void **args)
         {
             helpmod_kick(hchan, sender_huser, "Please only use normal text on %s", hchannel_get_name(hchan));
             return;
-        }
+       }
+       if ((hchan->flags & H_HIGHLIGHT_PREVENTION) && hchannel_highlight_detection(hchan, (char*)message))
+       {
+           helpmod_kick(hchan, sender_huser, "Please do not abuse the highlight feature of IRC clients");
+            return;
+       }
     }
 
     if (hcommand_is_command((char*)message) && (hchan->flags & H_CHANNEL_COMMANDS))
index 028d65fd1d425b22302980e3f4bea8b91f7d02d7..19e972c6157045658f70f459c48b8069d63a9e0d 100644 (file)
@@ -12,8 +12,8 @@
 /* configuration */
 
 /* These should always be equal */
-#define HELPMOD_VERSION_INTERNAL HELPMOD_VERSION_2_13
-#define HELPMOD_VERSION "2.13"
+#define HELPMOD_VERSION_INTERNAL HELPMOD_VERSION_2_14
+#define HELPMOD_VERSION "2.14"
 
 #define HELPMOD_USER_TIMEOUT 1200
 
index 8499d3cb66a840d8daa8397abc75d0a5ffa6b483..32cc9f3bcfca960ab2ec47fd2c8904b2d30870f4 100644 (file)
@@ -10,6 +10,8 @@
 
 #define HELPMOD_VERSION_2_12 12 /* */
 
-#define HELPMOD_VERSION_2_13 13 /* */
+#define HELPMOD_VERSION_2_13 13 /* October 2005*/
+
+#define HELPMOD_VERSION_2_14 14 /* November 2005*/
 
 #endif