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
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
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.
-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:
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.
-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.
{
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;
}
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
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;
return "warn";
case HCENSOR_KICK:
return "kick";
+ case HCENSOR_CHANBAN:
+ return "chanban";
case HCENSOR_BAN:
return "ban";
default:
{
HCENSOR_WARN,
HCENSOR_KICK,
+ HCENSOR_CHANBAN,
HCENSOR_BAN
} hcensor_type;
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);
hchan->censor = NULL;
hchan->htickets = NULL;
+ hchan->ticket_message = NULL;
hchan->last_activity = time(NULL);
hchan->last_staff_activity = time(NULL);
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;
{
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;
}
}
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";
}
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,
#define H_CHANFLAGS_DEFAULT (H_CHANNEL_COMMANDS)
-#define HCHANNEL_CONF_COUNT 19
+#define HCHANNEL_CONF_COUNT 20
typedef struct hchannel_struct
{
hlc_profile *lc_profile;
struct hticket_struct *htickets;
+ sstring *ticket_message;
struct hchannel_struct *next;
} hchannel;
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
+#include <sys/types.h>
+#include <dirent.h>
#include "../nick/nick.h"
#include "../channel/channel.h"
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));
}
}
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);
{
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
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;
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))))
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;
}
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);
}
}
-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;
}
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];
{
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[])
}
}
-
channel_stats = hchan->stats;
if (!days && !weeks)
{
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)
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]);
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;
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;
DEFINE_HCHANNEL;
+ HCHANNEL_VERIFY_AUTHORITY(hchan, sender);
+
if (hchan == NULL)
origin = hterms;
else
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;
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");
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");*/
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)))
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
-
#include <stdio.h>
#include <ctype.h>
#include <string.h>
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)
{
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))
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))
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));
{
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))
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))
{
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)
helpmod_line_fix(&ptr);
if ((hlc_prof = hlc_add(ptr)) == NULL)
- return -1;
+ return -1;
/* caps */
fgets(ptr = buf, 256, in);
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";
+ }
+}
const char *hlevel_name(hlevel);
+const char *hlevel_title(hlevel);
+
#endif
#include "hgen.h"
#include "hdef.h"
#include "hticket.h"
+#include "hed.h"
int HELPMOD_ACCOUNT_EXPIRATION[] =
{
hban *hbans;
huser *husers;
hchanban *hchanbans;
+helpmod_editor *helpmod_editors;
modechanges hmodechanges;
time_t helpmod_startup_time;
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 */
/* 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
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')
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);
int helpmod_read_strtime(const char *str)
{
- int sum = 0;
- int tmp_sum;
- int tmp;
-
+ int sum = 0, tmp_sum, tmp;
while (*str)
{
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;
+}
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
#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)
{
nick *nck = ((nick**)args)[1];
huser *husr;
-
}
*/
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)
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 */
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);
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);
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);
}
#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);
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;
}
{
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;
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];
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;
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";
+ }
+}
+
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;
/* 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
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));
}
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);
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;
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;
}
#include "helpmod.h"
#include "hban.h"
#include "hgen.h"
+#include "hed.h"
huser *huser_add(nick *nck)
{
tmp->flood_val = 0;
tmp->spam_val = 0.0;
+ tmp->editor = NULL;
+
tmp->next = husers;
husers = tmp;
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;
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;
#include "hchannel.h"
#include "haccount.h"
+#include "hed.h"
#include "helpmod_entries.h"
#define H_USRFLAGS_DEFAULT 0
int lc[5];
/* end lamer control */
+ helpmod_editor *editor;
+
struct huser_channel_struct *hchannels;
struct huser_struct *next;
#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