]> jfr.im git - irc/quakenet/newserv.git/commitdiff
G 2.11
authorstrutsi <redacted>
Wed, 31 Aug 2005 18:30:00 +0000 (19:30 +0100)
committerstrutsi <redacted>
Wed, 31 Aug 2005 18:30:00 +0000 (19:30 +0100)
30 files changed:
helpmod2/Makefile
helpmod2/changelist
helpmod2/commands/censor
helpmod2/commands/term
helpmod2/commands/ticket
helpmod2/haccount.c
helpmod2/haccount.h
helpmod2/hcensor.c
helpmod2/hcensor.h
helpmod2/hchanban.h
helpmod2/hchannel.c
helpmod2/hchannel.h
helpmod2/hcommands.c
helpmod2/hconf.c
helpmod2/hdef.c
helpmod2/hdef.h
helpmod2/helpmod.c
helpmod2/helpmod.h
helpmod2/helpmod_entries.c
helpmod2/hgen.c
helpmod2/hgen.h
helpmod2/hhooks.c
helpmod2/hhooks.h
helpmod2/hlamer.c
helpmod2/hlamer.h
helpmod2/hqueue.c
helpmod2/hticket.c
helpmod2/huser.c
helpmod2/huser.h
helpmod2/hversions.h

index 7db8b2d82184a7daac0088e993661262179c591f..e199f7ebe36680ea1b8a64c0e24ae41034620b10 100644 (file)
@@ -4,7 +4,7 @@
 CFLAGS=-g -std=c99 -pedantic -Wall
 #-Wno-unused
 
-TARGETS=huser.o hhooks.o hconf.o hgen.o hchannel.o hban.o hchanban.o hlamer.o htopic.o hstat.o hqueue.o hterm.o hcensor.o haccount.o hdef.o hcommand.o hcommands.o helpmod.o helpmod_entries.o helpmod_alias.o hticket.o
+TARGETS=huser.o hhooks.o hconf.o hgen.o hchannel.o hban.o hchanban.o hlamer.o htopic.o hstat.o hqueue.o hterm.o hcensor.o haccount.o hdef.o hcommand.o hcommands.o helpmod.o helpmod_entries.o helpmod_alias.o hticket.o hed.o
 
 all: helpmod2.so
 
index 9acca11b72796afe12cfe08e7895ac9438affb64..74abc1ade496ae9ed2ac98798b965a64c7dc24a9 100644 (file)
@@ -301,3 +301,36 @@ Terms are now in alphabetical order
 Fixed a critical bug with the stats cycle
 hstat_cycle changed to a more sane form
 Two evilhack commands added to fix everything recently broken
+
+2.11
+Fixed a long time bug in hooks
+Removed an unused hook for quit
+Internal flag H_NO_EXPIRE now works
+Account last activity is now stored properly
+Chanban command now defaults to list instead of error on 0 arguments
+Censor listing changed a bit
+Censor now supports a list operation
+?? with target no longer prints a useless space in front of the first nick
+New censor type chanban, all previous bans are now chanbans
+Lamercontrol repeat minimum length only applies to incremential repeat
+Tickets are now in order of expiration
+Channel idlekick time is no longer forgotten
+Added ticket message support and a command ticketmsg
+Added a missing command help for version
+Bug fixed in the invite command involving multiple channels
+Suppressing command errors only suppresses errors from channel commands
+Joinflood protection fixed and limit lowered by 20%
+Added an lc_edit command for editing lamer control profiles
+Trial staff member now separate on queue messages
+lamer control flood tolerance handled in a bit more sane way
+Lamer control warnings are now sent as private messages
+Fixed the term command help to include the pattern for find
+Idlekick and out now default to lazy commit of +b
+Topic's are now refreshed on the end of netsplit
+Added a text command to view and manage stored text files
+Added a ged command to edit stored text files
+Users of level H_LAMER now have access to the commands they should.
+Internal lamer control changes and order of test changed
+Empty old H type helps no longer cause a crash
+Fixed the ticket command help
+Userlevel spacers added to showcommands
index a7b95059271257093d6565ad45e07b55bbff14ae..b2f0992b1693ff0d16652ea83e470111b4b3115a 100644 (file)
@@ -4,5 +4,6 @@ Handles the censor for a channel. Censor allows certain patterns to result in an
 Following operations are supported:
 add [type] [pattern] [reason]   Adds the pattern to censor with the given reason
 del [#pattern]                  Removes the pattern for the index
+list                           Lists all censored patterns
 If no operation or parameters are specified, all censor entries are listed.
-The type for the add command can be either: warn, kick or ban.
+The type for the add command can be either: warn, kick, chanban or ban.
index 0c2bdbb8e731bc16826c7450d2cadf6119bc2fdb..7964a2a25b4eb80e351ba15cf1d042c201ad1f76 100644 (file)
@@ -1,4 +1,4 @@
-Syntax:         term [channel] [operation] [parameters]
+Syntax:  term [channel] [operation] [parameters]
 Example: term #feds add user user is the source of all problems
 Handles terms for channels, if the channel is omitted, global terms are handled.
 Following operations are supported:
@@ -6,6 +6,6 @@ add             [term] [description]     Adds a term
 del             [term]                   Deletes a term, up to 6 terms can be specified
 get             [term]                   Gets a specific term
 find            [pattern]                Returns the first term matching the pattern
-list                                     Lists all term names
+list            [pattern]                Lists all term names
 listfull                                 Lists all terms with their descriptions
 Command '?' is available to all users and is the same as term [channel] find.
index e55a24d2674975efd8deb6c4fb612952b4f4617f..0f5e072fac4eb4d17d80fc635524cdadd0a5008f 100644 (file)
@@ -1,5 +1,5 @@
-Syntax:  ticket channel [nick1] .. [nickn]
+Syntax:  ticket channel [nick1] [expiration]
 Example: ticket #feds user
 Gives the user an invite ticket for the channel.
-With the ticket, the user can use the invite command to get
-to the channel. Up to 6 users can be specified.
+With the ticket, the user can use the invite command to get to the channel.
+Ticket expiration time is optional.
index 5ce4e5537762fd527b3fe064e66c692d316714fc..a8aa62b73c3c940ff9a5ad058b47bbe3dacf0f1e 100644 (file)
@@ -90,9 +90,9 @@ void haccount_clear_inactives(void)
 {
     haccount **ptr = &haccounts;
     while (*ptr)
-        if (time(NULL) - (*ptr)->last_activity > HELPMOD_ACCOUNT_EXPIRATION[(*ptr)->level])
-            haccount_del(*ptr);
-        else
+       if ((time(NULL) - (*ptr)->last_activity > HELPMOD_ACCOUNT_EXPIRATION[(*ptr)->level]) && !(*ptr)->flags & H_NO_EXPIRE)
+           haccount_del(*ptr);
+       else
             ptr = &(*ptr)->next;
 }
 
index c058eb2562c4b881aa07bbcf971a64e15aa96b72..1b3cb82d056774c9389915e9129f7b0e54c22fd4 100644 (file)
@@ -19,10 +19,10 @@ enum
     H_AUTO_OP      = 1 << 3,
     H_AUTO_VOICE   = 1 << 4,
     H_NO_CMD_ERROR = 1 << 5,
-    H_EXPIRES      = 1 << 31
+    H_NO_EXPIRE    = 1 << 31
 };
 
-#define H_ACCFLAGS_DEFAULT 0
+#define H_ACCFLAGS_DEFAULT (0)
 
 #define HACCOUNT_CONF_COUNT 5
 
index 8487b2a70ba0481ee041a56b38b3f8e8f94fae21..7e379161d64dce801b963ddae0805754cc9bedd1 100644 (file)
@@ -99,7 +99,11 @@ int hcensor_match(hchannel *hchan, huser *husr, hcensor *hcens)
        return 0;
     case HCENSOR_KICK:
        helpmod_kick(hchan, husr, hcens->reason?hcens->reason->content:"Improper user");
-        return !0;
+       return !0;
+    case HCENSOR_CHANBAN:
+       helpmod_setban(hchan, hban_ban_string(husr->real_user, HBAN_HOST), HCMD_OUT_DEFAULT + time(NULL), MCB_ADD, HNOW);
+       helpmod_kick(hchan, husr, hcens->reason?hcens->reason->content:"Censor violation");
+       return !0;
     case HCENSOR_BAN:
        hban_add(hban_ban_string(husr->real_user, HBAN_HOST), hcens->reason?hcens->reason->content:"Censor violation", HCMD_OUT_DEFAULT + time(NULL), 1);
        return !0;
@@ -117,6 +121,8 @@ const char *hcensor_get_typename(hcensor_type type)
        return "warn";
     case HCENSOR_KICK:
        return "kick";
+    case HCENSOR_CHANBAN:
+        return "chanban";
     case HCENSOR_BAN:
         return "ban";
     default:
index 753347837edbea49f18a0ff40bcc10f70331c5fe..21d32299ff85b11e5ca939d1d30e8e6e497b774b 100644 (file)
@@ -11,6 +11,7 @@ typedef enum
 {
     HCENSOR_WARN,
     HCENSOR_KICK,
+    HCENSOR_CHANBAN,
     HCENSOR_BAN
 } hcensor_type;
 
index 31c327ddd971773e06c5eb659ef8f62e3dd6d437..4596ef9cbc0bc99bb0a777cd7ed603dfecd1ef12 100644 (file)
@@ -16,6 +16,7 @@ typedef struct hchanban_struct
 
 extern hchanban *hchanbans;
 
+/* This does not really add a chanban, use helpmod_setban instead */
 hchanban *hchanban_add(hchannel*, const char*, time_t);
 hchanban *hchanban_del(hchanban*);
 hchanban *hchanban_del_all(void);
index 5dcebf0f183e3e27c9b35bc57db81b02312649d6..e503a66aa478039e965ff33acb7359c616e3c004 100644 (file)
@@ -50,6 +50,7 @@ hchannel *hchannel_add(const char *cname)
     hchan->censor = NULL;
 
     hchan->htickets = NULL;
+    hchan->ticket_message = NULL;
 
     hchan->last_activity = time(NULL);
     hchan->last_staff_activity = time(NULL);
@@ -220,7 +221,7 @@ void hchannel_remove_inactive_users(void)
                    if (huser_on_channel((*hchanuser)->husr, hchan)->flags & H_IDLE_WARNING)
                     {
                         const char *banmask = hban_ban_string((*hchanuser)->husr->real_user, HBAN_HOST);
-                        helpmod_setban(hchan, banmask, time(NULL) + 10 * HDEF_m, MCB_ADD, HNOW);
+                        helpmod_setban(hchan, banmask, time(NULL) + 10 * HDEF_m, MCB_ADD, HLAZY);
 
                         helpmod_kick(hchan, (*hchanuser)->husr, "Please do not idle in %s", hchannel_get_name(hchan));
                         continue;
@@ -229,8 +230,9 @@ void hchannel_remove_inactive_users(void)
                     {
                         helpmod_reply((*hchanuser)->husr, NULL, "You are currently idle in %s. Please part the channel if you have nothing to do there", hchannel_get_name(hchan));
                         huser_on_channel((*hchanuser)->husr, hchan)->flags |= H_IDLE_WARNING;
-                    }
-                }
+                   }
+               }
+                hcommit_modes();
                 hchanuser = &(*hchanuser)->next;
             }
         }
@@ -508,7 +510,9 @@ const char *hchannel_get_sname(int flag)
     case 18:
         return "Queue inactivity deactivation";
     case 19:
-        return "Require a ticket to join";
+       return "Require a ticket to join";
+    case 20:
+        return "Send a message on ticket issue";
     default:
         return "Error, please contact strutsi";
     }
index d929eb0d3e2081075fa78c4bffd290cd48bbe308..f71cd775c6945db70bd92f07f07e96ee9877a08e 100644 (file)
@@ -40,6 +40,7 @@ enum
     H_DISALLOW_LAME_TEXT   = 1 << 17,
     H_QUEUE_TIMEOUT        = 1 << 18,
     H_REQUIRE_TICKET       = 1 << 19,
+    H_TICKET_MESSAGE       = 1 << 20,
 
     /* the following are not real channel flags, they're used only internally */
     H_UNUSED_1             = 1 << 28,
@@ -50,7 +51,7 @@ enum
 
 #define H_CHANFLAGS_DEFAULT (H_CHANNEL_COMMANDS)
 
-#define HCHANNEL_CONF_COUNT 19
+#define HCHANNEL_CONF_COUNT 20
 
 typedef struct hchannel_struct
 {
@@ -76,6 +77,7 @@ typedef struct hchannel_struct
     hlc_profile *lc_profile;
 
     struct hticket_struct *htickets;
+    sstring *ticket_message;
 
     struct hchannel_struct *next;
 } hchannel;
index 1856fd8beb9e152aac759753f90f839154fef930..208accc703c340190bb7721522ae3612e987ae74 100644 (file)
@@ -2,6 +2,8 @@
 #include <ctype.h>
 #include <stdio.h>
 #include <assert.h>
+#include <sys/types.h>
+#include <dirent.h>
 
 #include "../nick/nick.h"
 #include "../channel/channel.h"
@@ -368,8 +370,14 @@ static void helpmod_cmd_change_userlevel(huser *sender, hlevel target_level, cha
 
             target_huser->account->level = target_level;
 
-            helpmod_reply(sender, returntype, "Userlevel changed: User '%s' now has userlevel %s", argv[i], hlevel_name(target_level));
-            if (huser_get_level(target_huser) != H_LAMER)
+           helpmod_reply(sender, returntype, "Userlevel changed: User '%s' now has userlevel %s", argv[i], hlevel_name(target_level));
+
+           if (huser_get_level(target_huser) == H_LAMER)
+           {
+               const char *banmask = hban_ban_string(target_huser->real_user, HBAN_HOST);
+                hban_add(banmask, "Improper user", time(NULL) + HCMD_OUT_DEFAULT, 1);
+           }
+           else
                helpmod_reply(target_huser, NULL, "Your userlevel has been changed, your current userlevel is %s", hlevel_name(target_level));
         }
     }
@@ -489,7 +497,7 @@ static void helpmod_cmd_censor (huser *sender, channel* returntype, char* ostr,
         return;
     }
 
-    if (argc < 2) /* view */
+    if (argc < 2 || !ci_strcmp(argv[0], "list")) /* view */
     {
         if (hchan->censor == NULL)
             helpmod_reply(sender, returntype, "Nothing is censored on channel %s", hchan->real_channel->index->name->content);
@@ -497,7 +505,7 @@ static void helpmod_cmd_censor (huser *sender, channel* returntype, char* ostr,
         {
             helpmod_reply(sender, returntype, "Censored patterns for channel %s (%s):", hchan->real_channel->index->name->content, (hchan->flags & H_CENSOR)?"active":"inactive");
             for (hcens = hchan->censor;hcens;hcens = hcens->next)
-                helpmod_reply(sender, returntype, "#%d %-8s %s%s%s", i++, hcensor_get_typename(hcens->type), hcens->pattern->content, hcens->reason?" :: ":"", hcens->reason?hcens->reason->content:"");
+                helpmod_reply(sender, returntype, "#%-4d %-8s %s%s%s", i++, hcensor_get_typename(hcens->type), hcens->pattern->content, hcens->reason?" :: ":"", hcens->reason?hcens->reason->content:"");
         }
     }
     else
@@ -528,6 +536,11 @@ static void helpmod_cmd_censor (huser *sender, channel* returntype, char* ostr,
                     type = HCENSOR_KICK;
                     SKIP_WORD;
                }
+               else if (!ci_strcmp(argv[0], "chanban"))
+               {
+                    type = HCENSOR_CHANBAN;
+                    SKIP_WORD;
+               }
                else if (!ci_strcmp(argv[0], "ban"))
                {
                     type = HCENSOR_BAN;
@@ -768,7 +781,7 @@ static void helpmod_cmd_aliases (huser *sender, channel* returntype, char* ostr,
 
 static void helpmod_cmd_showcommands (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
 {
-    int level = H_PEON;
+    int level = H_PEON, previous_level = H_PEON;
     hcommand *tmp;
 
     if (!(argc && (sscanf(argv[0], "%d", &level)) && (level >= 0) && (level <= huser_get_level(sender))))
@@ -779,7 +792,14 @@ static void helpmod_cmd_showcommands (huser *sender, channel* returntype, char*
     hcommand_list(H_NONE);
 
     while ((tmp = hcommand_list(level)) != NULL)
-        helpmod_reply(sender, returntype, "%-16s %s", tmp->name->content, tmp->help->content);
+    {
+       if (tmp->level > previous_level)
+       {
+           helpmod_reply(sender, returntype, "--- Additional commands for userlevel %s ---", hlevel_name(tmp->level));
+           previous_level = tmp->level;
+       }
+       helpmod_reply(sender, returntype, "%-16s %s", tmp->name->content, tmp->help->content);
+    }
 
     return;
 }
@@ -887,8 +907,9 @@ static void helpmod_cmd_term_find_general (huser *sender, channel* returntype, i
             char buffer[256] = "";
             for (i=0;i<ntargets;i++)
             {
-                strcat(buffer, " ");
-                strcat(buffer, huser_get_nick(targets[i]));
+                if (i != 0)
+                   strcat(buffer, " ");
+               strcat(buffer, huser_get_nick(targets[i]));
             }
 
             helpmod_message_channel_long(hchannel_get_by_channel(returntype), "%s: (%s) %s", buffer, htrm->name->content, htrm->description->content);
@@ -958,7 +979,7 @@ static void helpmod_cmd_klingon (huser *sender, channel* returntype, char* ostr,
     }
 }
 
-static void helpmod_cmd_term (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+void helpmod_cmd_term (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
 {
     hterm *htrm;
     hterm **source;
@@ -1319,20 +1340,20 @@ static void helpmod_cmd_chanban (huser *sender, channel* returntype, char* ostr,
     }
 
     HCHANNEL_VERIFY_AUTHORITY(hchan, sender);
-
+/*
     if (argc == 0)
     {
         helpmod_reply(sender, returntype, "Cannot handle channel bans: Operation not defined");
         return;
     }
-
-    if (!ci_strcmp(argv[0], "list"))
+*/
+    if (argc == 0 || !ci_strcmp(argv[0], "list"))
     {
         char *pattern, *cban;
         chanban *ptr = hchan->real_channel->bans;
         int count = 0;
 
-        if (argc ==  1)
+        if (argc <=  1)
             pattern = "*";
         else
             pattern = argv[1];
@@ -1576,10 +1597,11 @@ static void helpmod_cmd_out (huser *sender, channel* returntype, char* ostr, int
     {
        const char *banmask = hban_ban_string(targets[i]->real_user, HBAN_HOST);
 
-       hban_add(banmask, reason, time(NULL) + HCMD_OUT_DEFAULT, 0);
+       hban_add(banmask, reason, time(NULL) + HCMD_OUT_DEFAULT, HLAZY);
 
        helpmod_reply(sender, returntype, "User %s is now gone", huser_get_nick(targets[i]));
     }
+    hcommit_modes();
 }
 
 static void helpmod_cmd_everyoneout (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
@@ -1882,7 +1904,6 @@ static void helpmod_cmd_chanstats (huser *sender, channel* returntype, char* ost
             }
         }
 
-
     channel_stats = hchan->stats;
 
     if (!days && !weeks)
@@ -1940,7 +1961,12 @@ static void helpmod_cmd_activestaff (huser *sender, channel* returntype, char* o
         {
             lvl = H_STAFF;
             SKIP_WORD;
-        }
+       }
+       else if (!ci_strcmp(argv[0], "staff") || !ci_strcmp(argv[0], "s"))
+       {
+            lvl = H_ANY;
+            SKIP_WORD;
+       }
     }
 
     if (argc == 1)
@@ -2240,7 +2266,7 @@ static void helpmod_cmd_invite (huser *sender, channel *returntype, char* arg, i
 
     for (i = 0;i < argc; i++)
     {
-        hchan = hchannel_get_by_name(argv[0]);
+        hchan = hchannel_get_by_name(argv[i]);
         if (hchan == NULL)
         {
             helpmod_reply(sender, returntype, "Cannot invite: Unknown channel %s", argv[i]);
@@ -2307,6 +2333,11 @@ static void helpmod_cmd_ticket (huser *sender, channel* returntype, char* ostr,
         helpmod_reply(sender, returntype, "Cannot issue a ticket: User %s is considered improper and not worthy of a ticket", argv[1]);
         return;
     }
+    if (huser_get_level(husr) > H_PEON)
+    {
+        helpmod_reply(sender, returntype, "Cannot issue a ticket: User %s does not require a ticket", argv[1]);
+        return;
+    }
     if (argc >= 3)
     {
         int tmp;
@@ -2324,8 +2355,10 @@ static void helpmod_cmd_ticket (huser *sender, channel* returntype, char* ostr,
 
     helpmod_reply(sender, returntype, "Issued an invite ticket to user %s for channel %s expiring in %s", huser_get_nick(husr), hchannel_get_name(hchan), helpmod_strtime(expiration));
     helpmod_reply(husr, NULL, "You have been issued an invite ticket for channel %s. This ticket is valid for a period of %s. You can use my invite command to get to the channel now. Type /msg %s invite %s",hchannel_get_name(hchan), helpmod_strtime(HTICKET_EXPIRATION_TIME), helpmodnick->nick, hchannel_get_name(hchan));
-}
+    if (hchan->flags & H_TICKET_MESSAGE && hchan->ticket_message != NULL)
+       helpmod_reply(husr, NULL, "Ticket information for %s: %s", hchannel_get_name(hchan), hchan->ticket_message->content);
 
+}
 static void helpmod_cmd_resolve (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
 {
     int i;
@@ -2477,6 +2510,8 @@ static void helpmod_cmd_termstats(huser *sender, channel* returntype, char* ostr
 
     DEFINE_HCHANNEL;
 
+    HCHANNEL_VERIFY_AUTHORITY(hchan, sender);
+
     if (hchan == NULL)
         origin = hterms;
     else
@@ -2829,6 +2864,394 @@ static void helpmod_cmd_version (huser *sender, channel* returntype, char* ostr,
     helpmod_reply(sender, returntype, "HelpMod version " HELPMOD_VERSION " by strutsi (strutsi@quakenet.org)");
 }
 
+static void helpmod_cmd_ticketmsg (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+{
+    hchannel *hchan;
+
+    DEFINE_HCHANNEL;
+
+    HCHANNEL_VERIFY_AUTHORITY(hchan, sender);
+
+    if (hchan == NULL)
+    {
+       helpmod_reply(sender, returntype, "Can not view or set ticket message: No channel is specified.");
+       return;
+    }
+
+    if (argc == 0)
+    { /* view */
+       if (hchan->ticket_message == NULL)
+           helpmod_reply(sender, returntype, "No ticket message is set for channel %s", hchannel_get_name(hchan));
+       else
+           helpmod_reply(sender, returntype, "Ticket message for channel %s is: %s", hchannel_get_name(hchan), hchan->ticket_message->content);
+       return;
+    }
+
+    /* set */
+    if (hchan->ticket_message != NULL)
+       freesstring(hchan->ticket_message);
+
+    hchan->ticket_message = getsstring(ostr, strlen(ostr));
+    helpmod_reply(sender, returntype, "Ticket message for channel %s set to: %s", hchannel_get_name(hchan), hchan->ticket_message->content);
+}
+
+static void helpmod_cmd_lcedit (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+{
+    hlc_profile *profile;
+
+    if (argc == 0)
+    {
+       helpmod_reply(sender, returntype, "Can not handle lamer control profiles: Operation not defined");
+        return;
+    }
+
+    if (!ci_strcmp(argv[0], "list"))
+    {
+       if (hlc_profiles == NULL)
+       {
+           helpmod_reply(sender, returntype, "Can not list lamer control profiles: No profiles");
+            return;
+       }
+       helpmod_reply(sender, returntype, "Following lamer control profiles are currently available:");
+       for (profile = hlc_profiles;profile != NULL;profile = profile->next)
+           helpmod_reply(sender, returntype, "%s", profile->name->content);
+    }
+    else if (!ci_strcmp(argv[0], "add"))
+    {
+       if (argc < 2)
+       {
+           helpmod_reply(sender, returntype, "Can not add a lamer control profile: Profile name not defined");
+            return;
+       }
+
+       profile = hlc_get(argv[1]);
+
+       if (profile != NULL)
+       {
+           helpmod_reply(sender, returntype, "Can not add a lamer control profile: Profile named %s already exists", argv[1]);
+           return;
+       }
+       profile = hlc_add(argv[1]);
+
+       { /* set the default values */
+           profile->caps_max_percentage = 40;
+           profile->caps_min_count = 20;
+
+           profile->repeats_max_count = 3;
+           profile->repeats_min_length = 7;
+
+           profile->symbol_repeat_max_count = 6;
+           profile->character_repeat_max_count = 7;
+           profile->symbol_max_count = 9;
+
+           profile->tolerance_flood = 5;
+
+           profile->tolerance_spam = 0.008;
+           profile->constant_spam = 10;
+
+           profile->tolerance_warn = 1;
+           profile->tolerance_kick = 3;
+           profile->tolerance_remove = 5;
+       }
+
+       helpmod_reply(sender, returntype, "Lamer control profile %s added", argv[1]);
+    }
+    else if (!ci_strcmp(argv[0], "del"))
+    {
+        hchannel *hchan;
+       if (argc < 2)
+       {
+           helpmod_reply(sender, returntype, "Can not delete a lamer control profile: Profile name not defined");
+            return;
+       }
+
+       profile = hlc_get(argv[1]);
+
+       if (profile == NULL)
+       {
+           helpmod_reply(sender, returntype, "Can not delete a lamer control profile: Profile named %s does not exist", argv[1]);
+           return;
+       }
+       for (hchan = hchannels;hchan != NULL;hchan = hchan->next)
+           if (hchan->lc_profile == profile)
+           {
+               helpmod_reply(sender, returntype, "Can not delete a lamer control profile: Profile %s is in use", argv[1]);
+               return;
+           }
+       hlc_del(profile);
+       helpmod_reply(sender, returntype, "Lamer control profile %s deleted", argv[1]);
+    }
+    else if (!ci_strcmp(argv[0], "view"))
+    {
+       if (argc < 2)
+       {
+           helpmod_reply(sender, returntype, "Can not view a lamer control profile: Profile name not defined");
+           return;
+       }
+
+       profile = hlc_get(argv[1]);
+
+       if (profile == NULL)
+       {
+           helpmod_reply(sender, returntype, "Can not view a lamer control profile: Profile named %s not found", argv[1]);
+           return;
+       }
+
+       helpmod_reply(sender, returntype, "Lamer control profile %s:", profile->name->content);
+       helpmod_reply(sender, returntype, "Maximum caps percentage:    %d", profile->caps_max_percentage);
+       helpmod_reply(sender, returntype, "Caps minimum count:         %d", profile->caps_min_count);
+       helpmod_reply(sender, returntype, "Repeat tolerance:           %d", profile->repeats_max_count);
+        helpmod_reply(sender, returntype, "Repeat minimum length:      %d", profile->repeats_min_length);
+        helpmod_reply(sender, returntype, "Symbol repeat tolerance:    %d", profile->symbol_repeat_max_count);
+       helpmod_reply(sender, returntype, "Character repeat tolerance: %d", profile->character_repeat_max_count);
+       helpmod_reply(sender, returntype, "Continous symbol tolerance: %d", profile->symbol_max_count);
+       helpmod_reply(sender, returntype, "Flood tolerance:            %d", profile->tolerance_flood);
+       helpmod_reply(sender, returntype, "Spam tolerance:             %d", profile->tolerance_spam);
+       helpmod_reply(sender, returntype, "Spam multiplier:            %f", profile->constant_spam);
+       helpmod_reply(sender, returntype, "Warning limit:              %d", profile->tolerance_warn);
+       helpmod_reply(sender, returntype, "Kick limit:                 %d", profile->tolerance_kick);
+       helpmod_reply(sender, returntype, "Ban limit:                  %d", profile->tolerance_remove);
+    }
+    else if (!ci_strcmp(argv[0], "edit"))
+    {
+       int int_val = -1;
+       double dbl_val = -1;
+
+       if (argc != 4)
+       {
+           helpmod_reply(sender, returntype, "Can not edit a lamer control profile: Syntax error");
+            return;
+       }
+
+       profile = hlc_get(argv[1]);
+
+       if (profile == NULL)
+       {
+           helpmod_reply(sender, returntype, "Can not edit a lamer control profile: Profile %s not found", argv[1]);
+           return;
+       }
+
+       sscanf(argv[3], "%d", &int_val);
+        sscanf(argv[3], "%lf", &dbl_val);
+
+       if (dbl_val < 0)
+       {   /* All int values are also valid double values */
+           helpmod_reply(sender, returntype, "Can not edit a lamer control profile: Invalid argument");
+            return;
+       }
+
+       if (!ci_strcmp(argv[2], "caps_percentage"))
+           profile->caps_max_percentage = int_val;
+        else if (!ci_strcmp(argv[2], "caps_count"))
+           profile->caps_min_count = int_val;
+        else if (!ci_strcmp(argv[2], "repeat_tolerance"))
+           profile->repeats_max_count = int_val;
+        else if (!ci_strcmp(argv[2], "repeat_length"))
+           profile->repeats_min_length = int_val;
+        else if (!ci_strcmp(argv[2], "symbol_repeat"))
+           profile->symbol_repeat_max_count = int_val;
+        else if (!ci_strcmp(argv[2], "character_repeat"))
+           profile->character_repeat_max_count = int_val;
+       else if (!ci_strcmp(argv[2], "continuous_symbol"))
+           profile->symbol_max_count = int_val;
+       else if (!ci_strcmp(argv[2], "flood_tolerance"))
+           profile->tolerance_flood = int_val;
+       else if (!ci_strcmp(argv[2], "spam_tolerance"))
+           profile->tolerance_spam = int_val;
+       else if (!ci_strcmp(argv[2], "spam_multiplier"))
+           profile->constant_spam = dbl_val;
+       else if (!ci_strcmp(argv[2], "warn_limit"))
+           profile->tolerance_warn = int_val;
+       else if (!ci_strcmp(argv[2], "kick_limit"))
+           profile->tolerance_kick = int_val;
+       else if (!ci_strcmp(argv[2], "ban_limit"))
+           profile->tolerance_remove = int_val;
+       else
+       {
+           helpmod_reply(sender, returntype, "Can not edit a lamer control profile: No component named %s", argv[2]);
+           return;
+       }
+       helpmod_reply(sender, returntype, "Lamer control profile component value changed succesfully.");
+    }
+}
+
+static void helpmod_cmd_ged (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+{
+    helpmod_editor *editor;
+
+    if (sender->editor == NULL)
+    { /* Start a new editor */
+       if (argc == 0)
+       {
+           helpmod_reply(sender, returntype, "Can not use ged: Filename not specified");
+           return;
+       }
+       editor = hed_open(sender, argv[0]);
+       if (editor == NULL)
+       {
+           helpmod_reply(sender, returntype, "Can not use ged: Invalid filename %s", argv[0]);
+            return;
+       }
+       if (editor->user != sender)
+       {
+           helpmod_reply(sender, returntype, "Can not use ged: File %s is currently being edited by %s", editor->filename, huser_get_nick(editor->user));
+            return;
+       }
+       editor->user = sender;
+       sender->editor = editor;
+
+       helpmod_reply(sender, returntype, "Ged: %d", hed_byte_count(editor));
+    }
+    else
+    {
+       hed_command(sender, returntype, ostr, argc, argv);
+    }
+}
+
+static void helpmod_cmd_text (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+{
+    hchannel *hchan;
+    DEFINE_HCHANNEL;
+    FILE *in;
+/*
+    if (argc == 0)
+    {
+       helpmod_reply(sender, returntype, "Can not handle text: No command specified");
+        return;
+    }
+*/
+    if (argc == 0 || !ci_strcmp(argv[0], "list"))
+    {
+       DIR *dir;
+       struct dirent *dent;
+       char buffer[384];
+        int nwritten, bufpos = 0;
+
+       dir = opendir(HELPMOD_TEXT_DIR);
+       assert(dir != NULL);
+
+       helpmod_reply(sender, returntype, "Following texts are available:");
+
+       for (dent = readdir(dir);dent != NULL;dent = readdir(dir))
+       {
+            /* Skip stuff like . and .. */
+           if (!strncmp(dent->d_name, ".", 1))
+               continue;
+
+           if (bufpos)
+           {
+               buffer[bufpos] = ' ';
+               bufpos++;
+           }
+           sprintf(buffer + bufpos, "%s%n", dent->d_name, &nwritten);
+           bufpos+=nwritten;
+
+           if (bufpos > 256)
+           {
+               helpmod_reply(sender, returntype, buffer);
+               bufpos = 0;
+           }
+       }
+        if (bufpos)
+           helpmod_reply(sender, returntype, buffer);
+       return;
+    }
+    else if (!ci_strcmp(argv[0], "show"))
+    {
+        char fname_buffer[128], buffer[512];
+       if (argc < 2)
+       {
+           helpmod_reply(sender, returntype, "Can not show text: Text not specified");
+            return;
+       }
+       if (!hed_is_valid_filename(argv[1]))
+       {
+           helpmod_reply(sender, returntype, "Can not show text: Invalid filename");
+            return;
+       }
+       sprintf(fname_buffer, HELPMOD_TEXT_DIR"/%s" ,argv[1]);
+       in = fopen(fname_buffer, "rwt");
+       if (in == NULL)
+       {
+           helpmod_reply(sender, returntype, "Can not show text: Text %s not found", argv[1]);
+            return;
+       }
+       while (!feof(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);
+           else
+                helpmod_reply(sender, returntype, "%s", buffer);
+       }
+       fclose (in);
+        return;
+    }
+
+    if (huser_get_level(sender) < H_STAFF)
+    {
+       helpmod_reply(sender, returntype, "Can not handle text: Insufficient user level");
+        return;
+    }
+
+    if (!ci_strcmp(argv[0], "add"))
+    {
+       char fname_buffer[128];
+       if (argc < 2)
+       {
+           helpmod_reply(sender, returntype, "Can not add text: Text not specified");
+            return;
+       }
+       if (!hed_is_valid_filename(argv[1]))
+       {
+           helpmod_reply(sender, returntype, "Can not add text: Invalid filename");
+           return;
+       }
+       sprintf(fname_buffer, HELPMOD_TEXT_DIR"/%s" ,argv[1]);
+       if ((in = fopen(fname_buffer, "rt")) != NULL)
+       {
+           helpmod_reply(sender, returntype, "Can not add text: Text %s already exists", argv[1]);
+            return;
+       }
+       else
+       {
+           if ((in = fopen(fname_buffer, "wt")) == NULL)
+           {
+               helpmod_reply(sender, returntype, "Can not add text: Unexpected error, please contact strutsi");
+                return;
+           }
+           fclose(in);
+       }
+       helpmod_reply(sender, returntype, "Text %s added succesfully", argv[1]);
+    }
+    else if (!ci_strcmp(argv[0], "del"))
+    {
+       char fname_buffer[128];
+       if (argc < 2)
+       {
+           helpmod_reply(sender, returntype, "Can not delete text: Text not specified");
+            return;
+       }
+       if (!hed_is_valid_filename(argv[1]))
+       {
+           helpmod_reply(sender, returntype, "Can not delete text: Invalid filename");
+           return;
+       }
+       sprintf(fname_buffer, HELPMOD_TEXT_DIR"/%s" ,argv[1]);
+
+       if (!remove(fname_buffer))
+           helpmod_reply(sender, returntype, "Text %s removed", argv[1]);
+       else
+           helpmod_reply(sender, returntype, "Can not delete text: Text %s does not exist or can not be deleted", argv[1]);
+    }
+    else
+    {
+       helpmod_reply(sender, returntype, "Can not handle text: Unknown operation %s", argv[0]);
+        return;
+    }
+}
+
 static void helpmod_cmd_evilhack1 (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
 {
     int tmp;
@@ -3104,9 +3527,9 @@ void hcommands_add(void)
     hcommand_add("whois", H_STAFF, helpmod_cmd_whois, "Tells you who someone is");
     hcommand_add("command", H_LAMER, helpmod_cmd_command, "Gives detailed information on a command");
     hcommand_add("addchan", H_ADMIN, helpmod_cmd_addchan, "Joins " HELPMOD_NICK " to a new channel");
-    hcommand_add("delchan", H_ADMIN, helpmod_cmd_delchan, "Removes " HELPMOD_NICK " permanently from a channel");
-    hcommand_add("seen", H_STAFF, helpmod_cmd_seen, "Tells when a specific user/account has had activity");
+    hcommand_add("delchan", H_PEON, helpmod_cmd_delchan, "Removes " HELPMOD_NICK " permanently from a channel");
 
+    hcommand_add("seen", H_STAFF, helpmod_cmd_seen, "Tells when a specific user/account has had activity");
     hcommand_add("op", H_STAFF, helpmod_cmd_op, "Sets mode +o on channels");
     hcommand_add("deop", H_STAFF, helpmod_cmd_deop, "Sets mode -o on channels");
     hcommand_add("voice", H_TRIAL, helpmod_cmd_voice, "Sets mode +v on channels");
@@ -3120,15 +3543,19 @@ void hcommands_add(void)
 
     hcommand_add("termstats", H_OPER, helpmod_cmd_termstats, "Lists usage statistics for terms");
     hcommand_add("checkchannel", H_STAFF, helpmod_cmd_checkchannel, "Shows channel information for any channel");
-    hcommand_add("statsdump", H_ADMIN, helpmod_cmd_statsdump, "Statistics dump command");
-    hcommand_add("statsrepair", H_ADMIN, helpmod_cmd_statsrepair, "Statistics repair command");
-    hcommand_add("statsreset", H_ADMIN, helpmod_cmd_statsreset, "Statistics reset command");
-
     hcommand_add("message", H_TRIAL, helpmod_cmd_message, "Sends a message to a channel");
     hcommand_add("version", H_PEON, helpmod_cmd_version, "G version information");
+    hcommand_add("ticketmsg", H_STAFF, helpmod_cmd_ticketmsg, "Handle the ticket message for a channel");
+
+    hcommand_add("lcedit", H_ADMIN, helpmod_cmd_lcedit, "Lamer control profile manager");
+    hcommand_add("ged", H_STAFF, helpmod_cmd_ged, "Ged IRC text editor");
+    hcommand_add("text", H_PEON, helpmod_cmd_text, "Lists or shows text files");
 
     hcommand_add("evilhack1", H_ADMIN, helpmod_cmd_evilhack1, "An evil hack, don't use");
     hcommand_add("evilhack2", H_ADMIN, helpmod_cmd_evilhack2, "Another evil hack, don't use");
+    hcommand_add("statsdump", H_ADMIN, helpmod_cmd_statsdump, "Statistics dump command");
+    hcommand_add("statsrepair", H_ADMIN, helpmod_cmd_statsrepair, "Statistics repair command");
+    hcommand_add("statsreset", H_ADMIN, helpmod_cmd_statsreset, "Statistics reset command");
 
 
     /*hcommand_add("megod", H_PEON, helpmod_cmd_megod, "Gives you userlevel 4, if you see this in the final version, please kill strutsi");*/
@@ -3142,7 +3569,7 @@ void helpmod_command(huser *sender, channel* returntype, char *args)
     char *parsed_args[H_CMD_MAX_ARGS + 3], *ptr = args_copy;
 
     /* only accept commands from valid sources */
-    if (huser_get_level(sender) < H_PEON || huser_get_level(sender) > H_ADMIN)
+    if (huser_get_level(sender) > H_ADMIN)
         return;
 
     if (returntype && !strncmp(args, helpmodnick->nick, strlen(helpmodnick->nick)))
@@ -3209,7 +3636,8 @@ void helpmod_command(huser *sender, channel* returntype, char *args)
 
        if (hcom == NULL)
        {
-           if ((sender->account == NULL && returntype == NULL) || (sender->account != NULL && !(sender->account->flags & H_NO_CMD_ERROR)))
+           if ((sender->account == NULL && returntype == NULL) ||
+               (sender->account != NULL && !(sender->account->flags & H_NO_CMD_ERROR) && returntype == NULL))
                helpmod_reply(sender, returntype, "Unknown command '%s', please see showcommands for a list of all commands available to you", parsed_args[0]);
        }
         else
index 50ab25495652267e4cb1ac6dcb069cd46404b67d..028e0c4a7e7ca1007a9c4f82daf50d12c6902a9a 100644 (file)
@@ -1,4 +1,3 @@
-
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
@@ -174,7 +173,7 @@ int helpmod_config_write(const char *fname)
 
         fprintf(out,"\n%% account structure:\n");
         fprintf(out,"%%  name (string):\n");
-        fprintf(out,"%%  level (integer):\n");
+        fprintf(out,"%%  level (integer) flags (integer) last_activity (integer):\n");
 
         for(;ptr;ptr=ptr->next)
         {
@@ -258,7 +257,7 @@ int helpmod_config_read_channel(FILE *in)
     hchannel *hchan;
 
     char buf[256],*ptr=(char*)buf;
-    int flags, entries, i;
+    int flags, entries, idlekick, i;
     /* name */
     fgets(buf, 256, in);
     if (feof(in))
@@ -292,6 +291,26 @@ int helpmod_config_read_channel(FILE *in)
 
     hchan->lc_profile = hlc_get(ptr);
 
+    if (hconf_version >= HELPMOD_VERSION_2_11)
+    {
+       fgets((ptr = buf), 256, in);
+       if (feof(in))
+           return -1;
+       helpmod_line_fix(&ptr);
+
+       if (sscanf(ptr, "%d", &idlekick) != 1)
+           return -1;
+
+        hchan->max_idle = idlekick;
+
+       fgets((ptr = buf), 256, in);
+       if (feof(in))
+           return -1;
+       helpmod_line_fix(&ptr);
+
+        hchan->ticket_message = getsstring(ptr,strlen(ptr));
+    }
+
     /* censor entries for channel, a bit complex */
     fgets((ptr = buf), 256, in);
     if (feof(in))
@@ -362,7 +381,14 @@ int helpmod_config_write_channel(FILE *out, hchannel *target)
     if (target->lc_profile == NULL)
         fprintf(out, "\t(null)\n");
     else
-        fprintf(out, "\t%s\n", target->lc_profile->name->content);
+       fprintf(out, "\t%s\n", target->lc_profile->name->content);
+
+    fprintf(out, "\t%d\n", target->max_idle);
+
+    if (target->ticket_message == NULL)
+       fprintf(out, "\t(null)\n");
+    else
+       fprintf(out, "\t%s\n", target->ticket_message->content);
 
     fprintf(out, "\t%d %% censor\n", hcensor_count(target->censor));
     {
@@ -396,7 +422,7 @@ int helpmod_config_read_account(FILE *in)
     int nstats;
 
     char buf[256],*ptr=(char*)buf;
-    int flags, level;
+    int flags, level, last_activity = time(NULL);
 
     fgets(ptr = buf, 256, in);
     if (feof(in))
@@ -409,12 +435,18 @@ int helpmod_config_read_account(FILE *in)
     if (feof(in))
         return -1;
     helpmod_line_fix(&ptr);
-
-    if (sscanf(ptr, "%x %x", (unsigned int*)&level, (unsigned int*)&flags) != 2)
-        return -1;
+    if (hconf_version < HELPMOD_VERSION_2_11)
+    {
+       if (sscanf(ptr, "%x %x", (unsigned int*)&level, (unsigned int*)&flags) != 2)
+           return -1;
+    }
+    else
+       if (sscanf(ptr, "%x %x %x", (unsigned int*)&level, (unsigned int*)&flags, (unsigned int *)&last_activity) != 3)
+           return -1;
 
     hack->level = level;
     hack->flags = flags;
+    hack->last_activity = last_activity;
 
     fgets(ptr = buf, 256, in);
     if (feof(in))
@@ -441,7 +473,7 @@ int helpmod_config_write_account(FILE *out, haccount *target)
 {
     hstat_account *tmp;
     fprintf(out, "\t%s\n", target->name->content);
-    fprintf(out, "\t%x\t%x\n", target->level, target->flags);
+    fprintf(out, "\t%x\t%x\t%x\n", target->level, target->flags, (unsigned int)target->last_activity);
 
     fprintf(out, "\t%d %% statistics for this channel\n", hstat_account_count(target->stats));
     for (tmp = target->stats;tmp;tmp = tmp->next)
@@ -500,7 +532,7 @@ int helpmod_config_read_hlc_profile(FILE *in)
     helpmod_line_fix(&ptr);
 
     if ((hlc_prof = hlc_add(ptr)) == NULL)
-        return -1;
+       return -1;
 
     /*  caps */
     fgets(ptr = buf, 256, in);
index 3137e4576aa0fc94a3ef7cc3df36a89b26ff3688..825fb8fe1035b23a681c77cc8f794669581f61b9 100644 (file)
@@ -24,3 +24,24 @@ const char *hlevel_name(hlevel lvl)
         return "error, please contact strutsi";
     }
 }
+
+const char *hlevel_title(hlevel lvl)
+{
+    switch (lvl)
+    {
+    case H_LAMER:
+    case H_PEON:
+        return "user";
+    case H_TRIAL:
+        return "trial staff member";
+    case H_STAFF:
+        return "staff member";
+    case H_OPER:
+    case H_ADMIN:
+        return "operator";
+    case H_SERVICE:
+    case H_ANY:
+    default:
+        return "error, please contact strutsi";
+    }
+}
index e9eec722afb23e06e0c07aa60ead77e99b8017dc..dbf0358f7c398266853e424ca2e1242c8f7cf546 100644 (file)
@@ -45,4 +45,6 @@ typedef enum
 
 const char *hlevel_name(hlevel);
 
+const char *hlevel_title(hlevel);
+
 #endif
index 00d888d5bfe6f34c3bd08023cf230a25b0f8876e..7956dc3b788619a12eaff6b8e49fbe20eb6a5b37 100644 (file)
@@ -30,6 +30,7 @@
 #include "hgen.h"
 #include "hdef.h"
 #include "hticket.h"
+#include "hed.h"
 
 int HELPMOD_ACCOUNT_EXPIRATION[] =
 {
@@ -50,6 +51,7 @@ hlc_profile *hlc_profiles;
 hban *hbans;
 huser *husers;
 hchanban *hchanbans;
+helpmod_editor *helpmod_editors;
 
 modechanges hmodechanges;
 time_t helpmod_startup_time;
@@ -96,6 +98,9 @@ void helpmod_reply(huser *target, channel* returntype, const char *message, ...
     vsnprintf(buf,512,message,va);
     va_end(va);
 
+    if (buf[0] == '\0' || buf[0] == '\n')
+        return;
+
     if (returntype) /* channel */
         reply_type = H_REPLY_NOTICE;
     else            /* private */
index 15972059da710e985accdc69f698c710ac201271..045198a88765f87f5366ac5e9029d950d01446af 100644 (file)
@@ -12,8 +12,8 @@
 /* configuration */
 
 /* These should always be equal */
-#define HELPMOD_VERSION_INTERNAL HELPMOD_VERSION_2_10
-#define HELPMOD_VERSION "2.10"
+#define HELPMOD_VERSION_INTERNAL HELPMOD_VERSION_2_11
+#define HELPMOD_VERSION "2.11"
 
 #define HELPMOD_USER_TIMEOUT 1200
 
index 2d27e54beb9ed1d70245715a00fa0a4d3b62755f..b8b7b443f012094daa1cc6099d9e15837fe625ba 100644 (file)
@@ -119,8 +119,6 @@ void helpmod_load_entries(char* setting_file)
            return;
        if (*buffer == '$')
        {
-           helpmod_base->options = (helpmod_entry*)realloc(helpmod_base->options, sizeof(helpmod_entry) * ++helpmod_base->option_count);
-            helpmod_base->options[helpmod_base->option_count-1] = NULL;
            /* remove the \n, it's not wanted */
            for (i=0;i<strlen(buffer+1);i++)
                if ((buffer+1)[i] == '\n')
@@ -134,6 +132,9 @@ void helpmod_load_entries(char* setting_file)
                Error("helpmod", ERR_ERROR, "File %s specified in %s not found",buffer+1, setting_file);
                return;
            }
+           helpmod_base->options = (helpmod_entry*)realloc(helpmod_base->options, sizeof(helpmod_entry) * ++helpmod_base->option_count);
+            helpmod_base->options[helpmod_base->option_count-1] = NULL;
+
             helpmod_parse_line(tmp_input);
            helpmod_load_entry(&helpmod_base->options[helpmod_base->option_count-1], tmp_input, 0, helpmod_base);
             fclose(tmp_input);
index 443e261b7d6125914f9936c0adec72d37e890383..5071008a5218eb962c5fa00bda1a6cfede9dc184 100644 (file)
@@ -134,10 +134,7 @@ const char *helpmod_strtime(int total_seconds)
 
 int helpmod_read_strtime(const char *str)
 {
-    int sum = 0;
-    int tmp_sum;
-    int tmp;
-
+    int sum = 0, tmp_sum, tmp;
 
     while (*str)
     {
@@ -248,3 +245,17 @@ float helpmod_percentage(int larger, int smaller)
 
     return 100.0 * ((float)smaller / (float)larger);
 }
+
+int helpmod_select(const char *str, const char **strs, int *enums, int count)
+{
+    int i;
+
+    if (count == 0)
+       return -1;
+
+    for (i = 0;i < count;i++)
+       if (!ci_strcmp(strs[i], str))
+            return enums[i];
+
+    return -1;
+}
index f4d29db44eca00e0b5aece5c179115139d2fbdf1..eb1c2bf8e3b18e22b39e77cee8b9722cfea8f8d2 100644 (file)
@@ -26,4 +26,9 @@ int strnumcount(const char*);
 
 float helpmod_percentage(int, int);
 
+/* A select for strings, case insensitive
+ * String to match, strings, corresponding int values (enums) and amount of both
+ * In case of no match, -1 is returned */
+int helpmod_select(const char*, const char**, int*, int);
+
 #endif
index ab8edda0d64cc7b9b69fa1d80737cf91dec5e80f..8b10fe67c06b792bfa18392b31c423e31302d30d 100644 (file)
 #include "hqueue.h"
 #include "hgen.h"
 #include "hstat.h"
-
+/*
 void helpmod_hook_quit(int unused, void *args)
 {
     nick *nck = ((nick**)args)[0];
     huser *husr = huser_get(nck);
-    /* it was someone we didn't even know */
+    / * it was someone we didn't even know * /
     if (husr == NULL)
         return;
 }
+*/
+
 /*
 void helpmod_hook_part(int unused, void *args)
 {
@@ -29,7 +31,6 @@ void helpmod_hook_part(int unused, void *args)
     nick *nck = ((nick**)args)[1];
     huser *husr;
 
-
 }
 */
 void helpmod_hook_join(int unused, void *args)
@@ -47,19 +48,19 @@ void helpmod_hook_join(int unused, void *args)
 
     assert(husr != NULL); /* hook_channel_newnick should fix this */
 
-    if (hchan->flags & H_JOINFLOOD_PROTECTION & !(hchan->flags & H_PASSIVE))
+    if ((hchan->flags & H_JOINFLOOD_PROTECTION) && !(hchan->flags & H_PASSIVE))
     {
        if (hchan->jf_control < time(NULL))
            hchan->jf_control = time(NULL);
        else
            hchan->jf_control++;
 
-       if (hchan->jf_control - time(NULL) > 25 && !IsRegOnly(hchan))
+       if (hchan->jf_control - time(NULL) > 20 && !IsRegOnly(hchan))
        {
            if (hchan->flags & H_REPORT && hchannel_is_valid(hchan->report_to))
-                helpmod_message_channel(hchan->report_to, "Warning: Possible join flood on %s, setting +r", hchannel_get_name(hchan));
-            hchannel_activate_join_flood(hchan);
-        }
+               helpmod_message_channel(hchan->report_to, "Warning: Possible join flood on %s, setting +r", hchannel_get_name(hchan));
+           hchannel_activate_join_flood(hchan);
+       }
     }
 
     if (hchan->flags & H_PASSIVE)
@@ -192,7 +193,7 @@ void helpmod_hook_channel_lostnick(int unused, void *args)
 
 void helpmod_hook_nick_lostnick(int unused, void *args)
 {
-    nick *nck = ((nick**)args)[0];
+    nick *nck = (nick*)args;
     huser *husr = huser_get(nck);
 
     /* it was someone we didn't even know */
@@ -344,9 +345,24 @@ void helpmod_hook_nick_account(int unused, void *args)
         husr->account = haccount_get_by_name(nck->authname);
 }
 
+void helpmod_hook_server_newserver(int unused, void *args)
+{
+    hchannel *hchan;
+    int numeric = (int)args;
+    server srv = serverlist[numeric];
+
+    /* check linkstate to prevent spam */
+    if (srv.linkstate == LS_LINKING)
+    {
+       for (hchan = hchannels;hchan != NULL;hchan = hchan->next)
+           if ((hchan->flags & H_HANDLE_TOPIC) && (hchan->topic != NULL))
+               hchannel_set_topic(hchan);
+    }
+}
+
 void helpmod_registerhooks(void)
 {
-    registerhook(HOOK_NICK_QUIT, &helpmod_hook_quit);
+/*    registerhook(HOOK_NICK_QUIT, &helpmod_hook_quit); */
     /*if (registerhook(HOOK_CHANNEL_PART, &helpmod_hook_part));*/
     registerhook(HOOK_CHANNEL_JOIN, &helpmod_hook_join);
     registerhook(HOOK_NICK_LOSTNICK, &helpmod_hook_nick_lostnick);
@@ -358,11 +374,12 @@ void helpmod_registerhooks(void)
     registerhook(HOOK_CHANNEL_DEVOICED, &helpmod_hook_channel_devoiced);
     registerhook(HOOK_CHANNEL_TOPIC, &helpmod_hook_channel_topic);
     registerhook(HOOK_NICK_ACCOUNT, &helpmod_hook_nick_account);
+    registerhook(HOOK_SERVER_NEWSERVER, &helpmod_hook_server_newserver);
 }
 
 void helpmod_deregisterhooks(void)
 {
-    deregisterhook(HOOK_NICK_QUIT, &helpmod_hook_quit);
+/*    deregisterhook(HOOK_NICK_QUIT, &helpmod_hook_quit); */
     /*if (deregisterhook(HOOK_CHANNEL_PART, &helpmod_hook_part));*/
     deregisterhook(HOOK_CHANNEL_JOIN, &helpmod_hook_join);
     deregisterhook(HOOK_NICK_LOSTNICK, &helpmod_hook_nick_lostnick);
@@ -374,4 +391,5 @@ void helpmod_deregisterhooks(void)
     deregisterhook(HOOK_CHANNEL_DEVOICED, &helpmod_hook_channel_devoiced);
     deregisterhook(HOOK_CHANNEL_TOPIC, &helpmod_hook_channel_topic);
     deregisterhook(HOOK_NICK_ACCOUNT, &helpmod_hook_nick_account);
+    deregisterhook(HOOK_SERVER_NEWSERVER, &helpmod_hook_server_newserver);
 }
index 7ccf572758b753abde25e79e4121f789d34039b6..ddd54ab8da52386f76d5dd96f7bd47406e66910c 100644 (file)
@@ -2,21 +2,6 @@
 #ifndef HHOOKS_H
 #define HHOOKS_H
 
-void helpmod_hook_quit(int, void*);
-void helpmod_hook_part(int, void*);
-void helpmod_hook_join(int, void*);
-void helpmod_hook_channel_newnick(int, void*);
-void helpmod_hook_channel_lostnick(int, void*);
-void helpmod_hook_nick_lostnick(int, void*);
-void helpmod_hook_nick_account(int, void*);
-
-void helpmod_hook_channel_opped(int, void*);
-void helpmod_hook_channel_deopped(int, void*);
-void helpmod_hook_channel_voiced(int, void*);
-void helpmod_hook_channel_devoiced(int, void*);
-
-void helpmod_hook_channel_topic(int, void*);
-
 void helpmod_registerhooks(void);
 void helpmod_deregisterhooks(void);
 
index 5f4746584500b65ff803167f21ebdd1130bd9764..abf8303cb2126963b6ea95cebb300d46b1881c76 100644 (file)
@@ -62,81 +62,98 @@ hlc_profile *hlc_get(const char *str)
     return NULL;
 }
 
+const char *hlc_get_cname(hlc_component comp)
+{
+    switch (comp)
+    {
+    default:
+        return "Error, contact strutsi";
+    }
+}
+
 /* static functions, used internally */
 
 static int hlc_violation_handle(hchannel *hchan, huser* husr, int violation)
 {
-        if (husr->lc[violation] >= hchan->lc_profile->tolerance_remove) /* get rid of the thing */
-        {
-            const char *banmask = hban_ban_string(husr->real_user, HBAN_HOST);
-
-            switch (violation)
-            {
-            case HLC_CAPS:
-                hban_add(banmask, "Excessive use of capital letters", time(NULL) + HLC_DEFAULT_BANTIME, 0);
-                break;
-            case HLC_REPEAT:
-                hban_add(banmask, "Excessive repeating", time(NULL) + HLC_DEFAULT_BANTIME, 0);
-                break;
-            case HLC_CHARACTER_REPEAT:
-                hban_add(banmask, "Excessive improper use of language", time(NULL) + HLC_DEFAULT_BANTIME, 0);
-                break;
-            case HLC_FLOOD:
-                hban_add(banmask, "Excessive flooding", time(NULL) + HLC_DEFAULT_BANTIME, 0);
-                break;
-            case HLC_SPAM:
-                hban_add(banmask, "Excessive spamming", time(NULL) + HLC_DEFAULT_BANTIME, 0);
-                break;
-            }
-
-            if (IsAccount(husr->real_user))
-                haccount_add(huser_get_auth(husr), H_LAMER);
-
-            return !0;
-        }
-        if (husr->lc[violation] >= hchan->lc_profile->tolerance_kick) /* get rid of the thing */
-        {
-            switch (violation)
-            {
-            case HLC_CAPS:
-                helpmod_kick(hchan, husr, "Channel rule violation: Excessive use of capital letters");
-                break;
-            case HLC_REPEAT:
-                helpmod_kick(hchan, husr, "Channel rule violation: Repeating");
-                break;
-            case HLC_CHARACTER_REPEAT:
-                helpmod_kick(hchan, husr, "Channel rule violation: Improper use of language");
-                break;
-            case HLC_FLOOD:
-                helpmod_kick(hchan, husr, "Channel rule violation: Flooding");
-                break;
-            case HLC_SPAM:
-                helpmod_kick(hchan, husr, "Channel rule violation: Spamming");
-                break;
-            }
-            return !0;
-        }
-        if (husr->lc[violation] >= hchan->lc_profile->tolerance_warn) /* get rid of the thing */
-        {
-            switch (violation)
-            {
-            case HLC_CAPS:
-                helpmod_reply(husr, hchan->real_channel, "You are violating the channel rule of %s : Excessive use of capital letters", hchannel_get_name(hchan));
-                break;
-            case HLC_REPEAT:
-                helpmod_reply(husr, hchan->real_channel, "You are violating the channel rule of %s : Repeating", hchannel_get_name(hchan));
-                break;
-            case HLC_CHARACTER_REPEAT:
-                helpmod_reply(husr, hchan->real_channel, "You are violating the channel rule of %s : Improper use of language", hchannel_get_name(hchan));
-                break;
-            case HLC_FLOOD:
-                helpmod_reply(husr, hchan->real_channel, "You are violating the channel rule of %s : Flooding", hchannel_get_name(hchan));
-                break;
-            case HLC_SPAM:
-                helpmod_reply(husr, hchan->real_channel, "You are violating the channel rule of %s : Spamming", hchannel_get_name(hchan));
-                break;
-            }
-        }
+    if (husr->lc[violation] >= hchan->lc_profile->tolerance_remove) /* get rid of the thing */
+    {
+       const char *banmask = hban_ban_string(husr->real_user, HBAN_HOST);
+       char reason_buffer[128];
+        /*
+       switch (violation)
+       {
+       case HLC_CAPS:
+           hban_add(banmask, "Excessive use of capital letters", time(NULL) + HLC_DEFAULT_BANTIME, 0);
+           break;
+       case HLC_REPEAT:
+           hban_add(banmask, "Excessive repeating", time(NULL) + HLC_DEFAULT_BANTIME, 0);
+           break;
+       case HLC_CHARACTER_REPEAT:
+           hban_add(banmask, "Excessive improper use of language", time(NULL) + HLC_DEFAULT_BANTIME, 0);
+           break;
+       case HLC_FLOOD:
+           hban_add(banmask, "Excessive flooding", time(NULL) + HLC_DEFAULT_BANTIME, 0);
+           break;
+       case HLC_SPAM:
+           hban_add(banmask, "Excessive spamming", time(NULL) + HLC_DEFAULT_BANTIME, 0);
+           break;
+       }
+       */
+       sprintf(reason_buffer, "Excessive violations: %s", hlc_get_violation_name(violation));
+       hban_add(banmask, reason_buffer, time(NULL) + HLC_DEFAULT_BANTIME, 0);
+
+       if (IsAccount(husr->real_user))
+           haccount_add(huser_get_auth(husr), H_LAMER);
+
+       return !0;
+    }
+    if (husr->lc[violation] >= hchan->lc_profile->tolerance_kick) /* get rid of the thing */
+    {
+   /*     switch (violation)
+       {
+       case HLC_CAPS:
+           helpmod_kick(hchan, husr, "Channel rule violation: Excessive use of capital letters");
+           break;
+       case HLC_REPEAT:
+           helpmod_kick(hchan, husr, "Channel rule violation: Repeating");
+           break;
+       case HLC_CHARACTER_REPEAT:
+           helpmod_kick(hchan, husr, "Channel rule violation: Improper use of language");
+           break;
+       case HLC_FLOOD:
+           helpmod_kick(hchan, husr, "Channel rule violation: Flooding");
+           break;
+       case HLC_SPAM:
+           helpmod_kick(hchan, husr, "Channel rule violation: Spamming");
+           break;
+           }
+           */
+       helpmod_kick(hchan, husr, "Channel rule violation: %s", hlc_get_violation_name(violation));
+       return !0;
+    }
+    if (husr->lc[violation] >= hchan->lc_profile->tolerance_warn) /* get rid of the thing */
+    {
+/*     switch (violation)
+       {
+       case HLC_CAPS:
+           helpmod_reply(husr, NULL, "You are violating the channel rule of %s : Excessive use of capital letters", hchannel_get_name(hchan));
+           break;
+       case HLC_REPEAT:
+           helpmod_reply(husr, NULL, "You are violating the channel rule of %s : Repeating", hchannel_get_name(hchan));
+           break;
+       case HLC_CHARACTER_REPEAT:
+           helpmod_reply(husr, NULL, "You are violating the channel rule of %s : Improper use of language", hchannel_get_name(hchan));
+           break;
+       case HLC_FLOOD:
+           helpmod_reply(husr, NULL, "You are violating the channel rule of %s : Flooding", hchannel_get_name(hchan));
+           break;
+       case HLC_SPAM:
+           helpmod_reply(husr, NULL, "You are violating the channel rule of %s : Spamming", hchannel_get_name(hchan));
+           break;
+           }
+           */
+       helpmod_reply(husr, NULL, "You are violating the channel rule of %s : %s. Continuos violation of this rule will result in you being removed from %s", hchannel_get_name(hchan), hlc_get_violation_name(violation), hchannel_get_name(hchan));
+    }
     return 0;
 
 }
@@ -173,6 +190,8 @@ static int hlc_check_repeat(hlc_profile *hlc_prof, huser *husr, const char *line
 {
     if (!strncmp(husr->last_line, line, strlen(husr->last_line)) && (strlen(husr->last_line) >= hlc_prof->repeats_min_length))
         husr->last_line_repeats++;
+    else if (!strcmp(husr->last_line, line))
+        husr->last_line_repeats++;
     else
         husr->last_line_repeats = 0;
 
@@ -224,7 +243,7 @@ static int hlc_check_flood(hlc_profile *hlc_prof, huser *husr, const char *line)
     else
         husr->flood_val++;
 
-    if ((husr->flood_val - time(NULL)) >= (hlc_prof->tolerance_flood))
+    if ((husr->flood_val - time(NULL)) > (hlc_prof->tolerance_flood))
     {
         husr->flood_val = time(NULL);
         return ++husr->lc[HLC_FLOOD];
@@ -254,6 +273,12 @@ int hlc_check(hchannel *hchan, huser* husr, const char *line)
     if (hchan == NULL || hchan->lc_profile == NULL)
         return 0;
 
+    if (hlc_check_flood(hchan->lc_profile, husr, line))
+        if (hlc_violation_handle(hchan, husr, HLC_FLOOD))
+            return -1;
+    if (hlc_check_spam(hchan->lc_profile, husr, line))
+        if (hlc_violation_handle(hchan, husr, HLC_SPAM))
+           return -1;
     if (hlc_check_caps(hchan->lc_profile, husr, line))
         if (hlc_violation_handle(hchan, husr, HLC_CAPS))
             return -1;
@@ -263,13 +288,26 @@ int hlc_check(hchannel *hchan, huser* husr, const char *line)
     if (hlc_check_character_repeats(hchan->lc_profile, husr, line))
         if (hlc_violation_handle(hchan, husr, HLC_CHARACTER_REPEAT))
             return -1;
-    if (hlc_check_flood(hchan->lc_profile, husr, line))
-        if (hlc_violation_handle(hchan, husr, HLC_FLOOD))
-            return -1;
-    if (hlc_check_spam(hchan->lc_profile, husr, line))
-        if (hlc_violation_handle(hchan, husr, HLC_SPAM))
-            return -1;
 
     return 0;
 }
 
+const char *hlc_get_violation_name(hlc_violation violation)
+{
+    switch (violation)
+    {
+    case HLC_CAPS:
+       return "Excessive use of capital letters";
+    case HLC_REPEAT:
+       return "Repeating";
+    case HLC_CHARACTER_REPEAT:
+       return "Improper use of language";
+    case HLC_FLOOD:
+       return "Flooding";
+    case HLC_SPAM:
+       return "Spamming";
+    default:
+        return "Error, please contact strutsi";
+    }
+}
+
index 7d830f82216d41c32a96493d4d69fc53f63eae55..948ba907cd9134102815322f8bb511084f9a7be0 100644 (file)
@@ -19,6 +19,15 @@ typedef enum
     HLC_SPAM
 } hlc_violation;
 
+/* under construction */
+typedef enum
+{
+    HLC_X,
+    HLC_Y
+} hlc_component;
+
+#define HLC_COMPONENT_COUNT 0
+
 typedef struct hlamercontrol_profile_struct
 {
     sstring *name;
@@ -55,4 +64,8 @@ hlc_profile *hlc_get(const char *);
 /* checks a string for lameness, returns non-zero if lameness is present and the user is kicked */
 int hlc_check(struct hchannel_struct*, struct huser_struct*, const char *);
 
+/* Returns the component name for the given component */
+const char *hlc_get_cname(hlc_component);
+const char *hlc_get_violation_name(hlc_violation);
+
 #endif
index c0b8fd6acdfb0ccc4c6a9e61b1cc50a70b9c51a8..82d971c1062c2edea89fa8c274bccb796140d86c 100644 (file)
@@ -151,7 +151,7 @@ void hqueue_advance(hchannel *hchan, huser *oper, int nadv)
 
         if ((hchan->flags & H_QUEUE_SPAMMY) && (oper != NULL))
         {
-           helpmod_reply(hchanuser->husr, hchan->real_channel, "It is now your time to state your problem. Please do so on channel %s and direct your questions to %s %s", (huser_get_level(oper) < H_OPER)?hlevel_name(H_STAFF):hlevel_name(H_OPER), hchannel_get_name(hchan), huser_get_nick(oper));
+           helpmod_reply(hchanuser->husr, hchan->real_channel, "It is now your time to state your problem. Please do so on channel %s and direct your questions to %s %s", hlevel_title(huser_get_level(oper)), hchannel_get_name(hchan), huser_get_nick(oper));
             if (!(huser_get_account_flags(oper) & H_NOSPAM))
                 helpmod_reply(oper, hchan->real_channel, "User %s (%s@%s) is yours, he has been in queue for %s", huser_get_nick(hchanuser->husr), huser_get_ident(hchanuser->husr), huser_get_host(hchanuser->husr), helpmod_strtime(time(NULL) - hchanuser->time_joined));
         }
@@ -162,7 +162,7 @@ void hqueue_advance(hchannel *hchan, huser *oper, int nadv)
         hchanuser = hchanuser->next;
     }
     if (oper != NULL)
-        helpmod_message_channel(hchan, "user%s %s: Please state your questions on this channel and direct them to %s %s", (nadv - counter == 1)?"":"s", buffer, (huser_get_level(oper) < H_OPER)?hlevel_name(H_STAFF):hlevel_name(H_OPER), huser_get_nick(oper));
+        helpmod_message_channel(hchan, "user%s %s: Please state your questions on this channel and direct them to %s %s", (nadv - counter == 1)?"":"s", buffer, hlevel_title(huser_get_level(oper)), huser_get_nick(oper));
     else
         helpmod_message_channel(hchan, "user%s %s: Please state your questions on this channel", (nadv - counter == 1)?"":"s", buffer);
 
index 05fc6c496e8a347e884c3fbb3e9fcbf9df9c8714..8f7e31f9bc17fbf1d279d52c2bb30b6f2d2fdd08 100644 (file)
@@ -34,7 +34,7 @@ hticket *hticket_del(hticket *htick, struct hchannel_struct *hchan)
 
 hticket *hticket_add(const char *authname, time_t expiration, struct hchannel_struct *hchan)
 {
-    hticket *tmp = hticket_get(authname, hchan);
+    hticket *tmp = hticket_get(authname, hchan), **ptr;
 
     if (hchan == NULL)
         return NULL;
@@ -46,9 +46,12 @@ hticket *hticket_add(const char *authname, time_t expiration, struct hchannel_st
 
     strcpy(tmp->authname, authname);
     tmp->time_expiration = expiration;
-    tmp->next = hchan->htickets;
 
-    hchan->htickets = tmp;
+    /* find the correct position */
+    for (ptr = &hchan->htickets;*ptr && (*ptr)->time_expiration >= expiration;ptr = &(*ptr)->next);
+
+    tmp->next = *ptr;
+    *ptr = tmp;
 
     return tmp;
 }
index 2402f21cdbac5b803ca4148e2ab32c688688d7c4..34375fef24318d382fc112e8ef629ae1cbfdf765 100644 (file)
@@ -12,6 +12,7 @@
 #include "helpmod.h"
 #include "hban.h"
 #include "hgen.h"
+#include "hed.h"
 
 huser *huser_add(nick *nck)
 {
@@ -42,6 +43,8 @@ huser *huser_add(nick *nck)
     tmp->flood_val = 0;
     tmp->spam_val = 0.0;
 
+    tmp->editor = NULL;
+
     tmp->next = husers;
     husers = tmp;
 
@@ -56,9 +59,12 @@ void huser_del(huser *husr)
 
     for (;*ptr;ptr = &(*ptr)->next)
         if (*ptr  == husr)
-        {
-            huser *tmp = (*ptr)->next;
-            free(*ptr);
+       {
+           huser *tmp = (*ptr)->next;
+
+            hed_close(husr->editor);
+
+           free(*ptr);
             *ptr = tmp;
 
             return;
@@ -75,12 +81,12 @@ void huser_del_all(void)
 
 huser *huser_get(nick *nck)
 {
-    huser *tmp = husers;
+    huser *tmp;
 
     if (nck == NULL)
         return NULL;
 
-    for (;tmp;tmp = tmp->next)
+    for (tmp = husers;tmp;tmp = tmp->next)
         if (tmp->real_user == nck)
             return tmp;
     return NULL;
index f5444b04afee3457bbdb16a1568925f74644ead8..7178d4b764649f2c402a5232364b3548c07620ff 100644 (file)
@@ -11,6 +11,7 @@
 #include "hchannel.h"
 #include "haccount.h"
 
+#include "hed.h"
 #include "helpmod_entries.h"
 
 #define H_USRFLAGS_DEFAULT 0
@@ -36,6 +37,8 @@ typedef struct huser_struct
     int lc[5];
     /* end lamer control */
 
+    helpmod_editor *editor;
+
     struct huser_channel_struct *hchannels;
 
     struct huser_struct *next;
index a66743f2263a18721cae854b746de36024638429..5a920e06257b1a0c376ca78ff578e4db420783ed 100644 (file)
@@ -4,6 +4,8 @@
 
 #define HELPMOD_VERSION_2_0 0   /* Initial release, 2005 something */
 
-#define HELPMOD_VERSION_2_10 10 /*  */
+#define HELPMOD_VERSION_2_10 10 /* July 2005 */
+
+#define HELPMOD_VERSION_2_11 11 /*  */
 
 #endif