Checkchannel command changed according to requests
Showcommands now lists the commands in a bit more ordered fashion
Top10 now prints the time spent fields in a different order
+
+2.05
+Termstats now really really work (sort order fixed)
+Checkchannel now shows +o/+v and sorts the output based on those
+Checkchannel now tells the % of users authed on the channel
+Fixed the admin command description
+Checkchannel no longer shows +k channels
+Banning lamers (userlevel H_LAMER) on join now works properly
+Users no longer receive the "your userlevel has been changed" when changed to lamer
+Some code cleanup
++h users are now excluded from idle user removal
+Queue on/off when queue is in the desired state no longer produces a channel message
+Censor del can now remove patterns other than the first
+Fixed a minor typo in invite messaging
+Non-opered staff can now invite themselves to oper-only channels they have tickets to
+A month is now 30 days instead of 30 weeks
+Queue message wording changed a bit
+Fixed a bug in the command help
+
+2.06
+The voiced count in checkchannel is now correct
+Time printing was changed a bit
+Account name is now shown correctly in checkchannel
+Added a sanity check to stats calculation
+Fixed a bug when reading/writing stats from disk
+Statistics printing fields widened a bit
+Changed ban expiration printing
+statsdebug command is now statsdump
+Added a statsrepair command
+All normal users are now devoiced when the queue is turned off
+Fixed a typo in the kick command
+Out command now accepts an optional reason
+Normal users no longer receive errors for commands issued on channels
+Incorrect term find reply is now fixed
+Added sanity checking to account adding
+Fixed some command help files
+
+2.07
+top10 number parameter now works
+top10 should now work
+top10 listing order changed a bit
+Statistics should now work better
+
+2.08
+Kick and out command replies changed a bit
+Some code cleanup, mostly void* stuff removed
+Added a statsreset command
+Fixed a bug with weekly calculation of stats
+
+2.09
+Fixed a minor bug in channel daily report
+Changed report interval from 5 minutes to one hour
+Passive state support improved
+Fixed the time print bug
+The +k restriction in checkchannel was removed
+Tickets command wording changed a bit
+Fixed a typo in showticket command
+Checkchannel does not show channel topic for +i/+k channels
+Some command descriptions changed
Example: acconf +1 -3
Acconf configures the account specific H features.
Up to 6 values can be changed with one command.
-When called without parameters, acconf will print your account configuration.
\ No newline at end of file
+When called without parameters, acconf will print your account configuration.
Syntax: addchan [channel]
Example: addchan #help
Adds H to the given channel.
-Don't forget to configure the channel using chanconf as the default configuration is most likely not what you want.
\ No newline at end of file
+Don't forget to configure the channel using chanconf as the default configuration is most likely not what you want.
Syntax: aliases
Example: aliases
-Lists all aliases to the help system
\ No newline at end of file
+Lists all aliases to the help system
Syntax: autoqueue [channel] [amount]
Example: autoqueue #feds 2
Same as 'queue maintain'.
-Sets the autoqueue for the channel, autoqueue can be disabled with value of 0.
\ No newline at end of file
+Sets the autoqueue for the channel, autoqueue can be disabled with value of 0.
Following operations are supported:
list [pattern] Lists global bans based on pattern, if pattern is omitted all bans are listed
add [mask] [duration] [reason] Adds a global ban, duration and reason are optional
-del [mask1] ... [maskn] Removes global banmasks, up to 6 masks can be defined at once
\ No newline at end of file
+del [mask1] ... [maskn] Removes global banmasks, up to 6 masks can be defined at once
Following operations are supported:
add [pattern] [reason] Adds the pattern to censor with the given reason
del [#pattern] Removes the pattern for the index
-If no operation or parameters are specified, all censor entries are listed.
\ No newline at end of file
+If no operation or parameters are specified, all censor entries are listed.
add [mask1] .. [maskn] Adds bans to channel
del [mask1] .. [maskn] Removes bans from channel
list [pattern] Lists bans matching pattern
-Up to 6 masks can be given for add and del.
\ No newline at end of file
+Up to 6 masks can be given for add and del.
Most features are configured by their own command but are enabled from chanconf.
Chanconf without parameters lists channel configuration.
Up to 6 values can be disabled or enabled at once.
-NOTE: chanconf value 0 (passive mode) completely disables any H activity for a channel, it is provided as a way to disable H without delchan.
\ No newline at end of file
+NOTE: chanconf value 0 (passive mode) completely disables any H activity for a channel, it is provided as a way to disable H without delchan.
Example: delchan #feds.fi YesImSure
Deletes H from the channel.
All data related to the channel is removed.
-The YesImSure is an additional parameter to protect against accidents.
\ No newline at end of file
+The YesImSure is an additional parameter to protect against accidents.
Syntax: dequeue [channel]
Example: dequeue #feds
Same as 'queue off'.
-Turns the queue off for the given channel.
\ No newline at end of file
+Turns the queue off for the given channel.
Example: dnmo CS^kiddie
dnmo (DoNotMessageOpers) is meant to be used with the H queue system.
When used, the target is set to the last position on any channels where he/she is on queue.
-Target is also sent a message explaining the error of his/her lame behaviour.
\ No newline at end of file
+Target is also sent a message explaining the error of his/her lame behaviour.
Example: done #feds user
Same as 'queue done'.
Tells that the user is finished with and devoices him.
-Up to 6 nicks can be specified.
\ No newline at end of file
+Up to 6 nicks can be specified.
Syntax: enqueue [channel]
Example: enqueue #feds
Same as 'queue on'.
-Turns the queue on for the given channel.
\ No newline at end of file
+Turns the queue on for the given channel.
Syntax: everyoneout [channel] [reason]
Example: everyoneout #feds enough laming
Removes all normal users from the channel and sets H to enforce +i on the channel.
-If reason is omitted the default reason is 'clearing channel'.
\ No newline at end of file
+If reason is omitted the default reason is 'clearing channel'.
Example: idlekick #feds 60s
Views or sets the idle kick timeout for the channel.
Minimum value is 60 seconds, the actual timeout is "close enough" to the timeout value.
-Non-peons and Users currently in queue are not considered idle.
\ No newline at end of file
+Non-peons and Users currently in queue are not considered idle.
Syntax: kick [channel] [nick1] ... [nickn] :[reason]
Example: kick #feds luser
Kicks the target nick from the channel. Reason is optional.
-Up to 6 targets can be specified.
\ No newline at end of file
+Up to 6 targets can be specified.
Syntax: klingon [channel] [user]
Example: klingon #feds
Makes H say something in klingon on the channel.
-If a user is specified the message is targeted to that user.
\ No newline at end of file
+If a user is specified the message is targeted to that user.
Syntax: lamercontrol [channel]
Example: lamercontrol #feds strict
Views or sets the lamercontrol profile for a channel.
-To list all available lamercontrol profiles, use the keyword list.
\ No newline at end of file
+To list all available lamercontrol profiles, use the keyword list.
Syntax: listuser [pattern]
Example: listuser *
Lists H accounts based on the pattern.
-If no pattern is specified, all accounts are listed.
\ No newline at end of file
+If no pattern is specified, all accounts are listed.
Syntax: load [filename]
Example: load database1
-Loads a new help database (help command). Users currently using the help system are reset.
\ No newline at end of file
+Loads a new help database (help command). Users currently using the help system are reset.
Syntax: message <channel> <message>
Sends a message to the channel. The message sent is prefixed with your nick.
-G must be on the channel the message is sent to.
\ No newline at end of file
+G must be on the channel the message is sent to.
Syntax: next [channel] [amount]
Example: next #feds 2
Same as 'queue next'.
-Moves the queue forward by the given amount.
\ No newline at end of file
+Moves the queue forward by the given amount.
-Syntax: out [nick1 ... nickn]
-Example: out luser
+Syntax: out [nick1 ... nickn] :[reason]
+Example: out luser :Enough complaining
Removes an unwanted user from H visibility.
-Sets a short duration ban to keep the user away.
+Sets a short duration ban to keep the user away. Reason is optional.
Up to 6 users can be specified.
list Lists all users in queue
summary Gives a short summary of the queues status
reset Resets the queue
-Some common commands like done or next have a shortcut, see showcommands for a list.
\ No newline at end of file
+Some common commands like done or next have a shortcut, see showcommands for a list.
Syntax: report [channel of] [channel to]
Example: report #feds #qnet.feds
Sets the channel where some channel statistics are reported every 5 minutes.
-H must be active on both the source and the target channel.
\ No newline at end of file
+H must be active on both the source and the target channel.
Syntax: showcommands [level]
Example: showcommands
Lists all commands available to the given level.
-If the level is invalid or higher than yours, commands available to your userlevel are printed.
\ No newline at end of file
+If the level is invalid or higher than yours, commands available to your userlevel are printed.
Gives your statistics for a channel. Type must be either short or long.
Parameters ndays and nweeks tell how many lines of statistics to print. Statistics are kept for a duration of 10 weeks.
Default is to print the short statistics for the last day.
-Statistics of other users are only available to administrators.
\ No newline at end of file
+Statistics of other users are only available to administrators.
Syntax: status
Example: status
-Gives some service status information
\ No newline at end of file
+Gives some service status information.
find [pattern] Returns the first term matching the pattern
list 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.
\ No newline at end of file
+Command '?' is available to all users and is the same as term [channel] find.
Syntax: welcome [channel] [new message]
Example: welcome #feds welcome to #feds, may we recommend a good book while you're in queue ?
Views or sets the channel welcome message.
-When called with just the channel name, the welcome message for the channel is printed.
\ No newline at end of file
+When called with just the channel name, the welcome message for the channel is printed.
Syntax: whois [nick1] ... [nickn]
Example: whois user
Gives the information H has on a user.
-Up to 6 nicks can be specified.
\ No newline at end of file
+Up to 6 nicks can be specified.
{
haccount *tmp = (haccount*)malloc(sizeof (haccount));
+ if (haccount_get_by_name(name))
+ {
+ Error("helpmod", ERR_ERROR, "Attempt to add a duplicate account: %s", name);
+ return haccount_get_by_name(name);
+ }
+
if (*name == '#')
name++;
return ptr;
}
-hban *hban_huser(void *target, const char* rsn, time_t exp, int now)
+hban *hban_huser(huser *husr, const char* rsn, time_t exp, int now)
{
- const char *banmask;
- huser *husr = (huser*)target;
-
- banmask = hban_ban_string(husr->real_user, HBAN_HOST);
+ const char *banmask = hban_ban_string(husr->real_user, HBAN_HOST);
return hban_add(banmask, rsn, exp, now);
}
#include <time.h>
#include "../channel/channel.h"
-
#include "../nick/nick.h"
-
#include "../lib/sstring.h"
+/* Forward declarations */
+struct huser_struct;
+
typedef struct hban_struct
{
chanban *real_ban;
int hban_count(void);
/* the first parameter is huser* */
-hban *hban_huser(void*, const char*, time_t, int);
+hban *hban_huser(struct huser_struct*, const char*, time_t, int);
hban *hban_check(nick*);
return NULL;
}
-void hchanban_schedule_entry(void* ptr)
+void hchanban_schedule_entry(hchanban* item)
{
- hchanban *item = (hchanban*)ptr;
-
if (hchannel_is_valid(item->hchan))
helpmod_setban(item->hchan, item->banmask->content, 0, MCB_DEL, HNOW);
- hchanban_del(ptr);
+ hchanban_del(item);
}
hchanban *hchanban_get(hchannel*, const char*);
-void hchanban_schedule_entry(void*);
+void hchanban_schedule_entry(hchanban*);
#endif
scheduleoneshot(time(NULL) + 60, &hchannel_deactivate_join_flood, NULL);
}
+
/* goes to schedule */
void hchannel_deactivate_join_flood()
{
helpmod_simple_modes(hchan, 0, CHANMODE_REGONLY, 1);
hchan->flags &= ~H_JOIN_FLOOD;
}
- /*if (IsRegOnly(hchan->real_channel) && hchan->jf_control < time(NULL))
- {
- helpmod_simple_modes(hchan, 0, CHANMODE_REGONLY, 1);
- return;
- }
-
- scheduleoneshot(time(NULL) + 60, &hchannel_deactivate_join_flood, NULL);
- */
}
const char *hchannel_get_sname(int flag)
case 19:
return "Require a ticket to join";
default:
- return "error, please contact strutsi";
+ return "Error, please contact strutsi";
}
}
if (argc == 0)
{
- helpmod_reply(sender, returntype, "Incorrect syntax, nick or account required");
+ helpmod_reply(sender, returntype, "Incorrect syntax: Nick or account required");
return ;
}
if (htrm == NULL)
{
- helpmod_reply(sender, returntype, "No term found matching '%s'", argv[0]);
+ helpmod_reply(sender, returntype, "No term found matching '%s'", argv[1]);
return;
}
if (returntype != NULL && huser_get_level(sender) > H_PEON)
{
huser *husr;
int i;
+ char *reason = "Banned";
+ huser *targets[H_CMD_MAX_ARGS];
+ int ntargets = 0;
+
if (argc == 0)
{
helpmod_reply(sender, returntype, "Can not get rid of the user: User not specified");
argc = H_CMD_MAX_ARGS;
for (i=0;i<argc;i++)
{
- husr = huser_get(getnickbynick(argv[i]));
+ if (argv[i][0] == ':')
+ {
+ if (i == 0)
+ {
+ helpmod_reply(sender, returntype, "Can not get rid of users: No users specified");
+ return;
+ }
+ while (i--)
+ {
+ SKIP_WORD;
+ }
+ reason = ostr + 1;
+ break;
+ }
+
+ husr = huser_get(getnickbynick(argv[i]));
if (husr == NULL)
{
helpmod_reply(sender, returntype, "Can not get rid of the user: User %s not found", argv[i]);
{
helpmod_reply(sender, returntype, "Can not get rid of the user: User %s is not a peon", husr->real_user->nick);
continue;
- }
- {
- const char *banmask = hban_ban_string(husr->real_user, HBAN_HOST);
+ }
+ targets[ntargets++] = husr;
+ }
- hban_add(banmask, "Banned", time(NULL) + HCMD_OUT_DEFAULT, 0);
- }
- helpmod_reply(sender, returntype, "User %s is now gone", husr->real_user->nick);
+ for (i=0;i<ntargets;i++)
+ {
+ const char *banmask = hban_ban_string(targets[i]->real_user, HBAN_HOST);
+
+ hban_add(banmask, reason, time(NULL) + HCMD_OUT_DEFAULT, 0);
+
+ helpmod_reply(sender, returntype, "User %s is now gone", targets[i]->real_user->nick);
}
}
{
hchannel *hchan;
int i;
- huser *husr, *targets[6];
+ huser *husr, *targets[H_CMD_MAX_ARGS];
int ntargets = 0;
char *reason = "out";
DEFINE_HCHANNEL;
if (hchan == NULL)
{
helpmod_reply(sender, returntype, "Can not kick the user: Channel not defined or not found");
- return;
+ return;
+ }
+
+ if (argc == 0)
+ {
+ helpmod_reply(sender, returntype, "Can not kick users: No users specified");
+ return;
}
+
if (argc > H_CMD_MAX_ARGS)
argc = H_CMD_MAX_ARGS;
for (i=0;i<argc;i++)
{
if (*argv[i] == ':')
{
- while (i--)
+ if (i == 0)
+ {
+ helpmod_reply(sender, returntype, "Can not kick the user: No users defined");
+ return;
+ }
+ while (i--)
{
SKIP_WORD;
}
}
if (huser_on_channel(husr, hchan) == NULL)
{
- helpmod_reply(sender, returntype, "Can not kick the user: User %s is on channel", husr->real_user->nick, hchannel_get_name(hchan));
+ helpmod_reply(sender, returntype, "Can not kick the user: User %s is not on channel %s", husr->real_user->nick, hchannel_get_name(hchan));
continue;
}
if (huser_get_level(husr) > H_PEON)
}
targets[ntargets++] = husr;
}
- if (!ntargets)
- {
- helpmod_reply(sender, returntype, "Can not kick the user: No users defined");
- return;
- }
+
for (i=0;i<ntargets;i++)
helpmod_kick(hchan, targets[i], reason);
}
for (i=0;i<weeks;i++) /* latest weeks */
{
stat_entry = &hchan->stats->longterm[(hstat_week() - i + 10) % 10];
- helpmod_reply(sender, returntype, "%s", hstat_channel_print(stat_entry, type));
+ helpmod_reply(sender, returntype, "%s", hstat_channel_print(stat_entry, type));
}
}
}
else if (!ci_strcmp(argv[0], "staff") || !ci_strcmp(argv[0], "s"))
lvl = H_STAFF;
}
- if (argc == 2)
+ if (argc == 3)
{
int tmp;
if (sscanf(argv[1], "%d", &tmp) && (tmp >= 10) && (tmp <= 50))
helpmod_reply(sender, returntype, "Top%d most active %ss of channel %s", top_n, hlevel_name(lvl), hchannel_get_name(hchan));
for (i=0;i < arr.arrlen && i < top_n;i++)
- helpmod_reply(sender, returntype, "#%-2d %-20s %-20s %-20s",i+1,((haccount*)(arr.array[i].owner))->name->content, helpmod_strtime(arr.array[i].time_spent), helpmod_strtime(arr.array[i].prime_time_spent));
+ helpmod_reply(sender, returntype, "#%-2d %-20s %-20s %-20s",i+1,((haccount*)(arr.array[i].owner))->name->content, helpmod_strtime(arr.array[i].prime_time_spent), helpmod_strtime(arr.array[i].time_spent));
free(arr.array);
}
for (i = 0;htick;htick = htick->next, i++)
helpmod_reply(sender, returntype, "%4d %16s %48s", i, htick->authname, helpmod_strtime(time(NULL) - htick->time_expiration));
- helpmod_reply(sender, returntype, "Done listing tickets. Channel %s had %d valid tickets", hchannel_get_name(hchan), i);
+ helpmod_reply(sender, returntype, "Done listing tickets. Channel %s had %d valid ticket%s", hchannel_get_name(hchan), i, (i==1)?"":"s");
}
static void helpmod_cmd_showticket (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
helpmod_reply(sender, returntype, "Can not show the ticket: User %s does not have a valid ticket for channel %s", argv[i], hchannel_get_name(hchan));
continue;
}
- helpmod_reply(sender, returntype, "User %s has a ticket for chanenl %s expiring in %s", argv[i], hchannel_get_name(hchan), helpmod_strtime(htick->time_expiration - time(NULL)));
+ helpmod_reply(sender, returntype, "User %s has a ticket for channel %s expiring in %s", argv[i], hchannel_get_name(hchan), helpmod_strtime(htick->time_expiration - time(NULL)));
}
}
if (argc > 1 && !ci_strcmp(argv[1], "summary"))
summary_only = 1;
- if (IsKey(chan))
- {
- helpmod_reply(sender, returntype, "Can not check channel: Permission denied. Channel %s is +k", argv[0]);
- return;
- }
-
/* first pass - verify validity and count nicks */
for (i=0;i < chan->users->hashsize;i++)
{
helpmod_reply(sender, returntype, "Information on channel %s", argv[0]);
helpmod_reply(sender, returntype, "Channel created %s ago", helpmod_strtime(time(NULL) - chan->timestamp));
- helpmod_reply(sender, returntype, "Channel topic: %s", chan->topic?chan->topic->content:"Not set");
+ if (!IsKey(chan) && !IsInviteOnly(chan))
+ helpmod_reply(sender, returntype, "Channel topic: %s", chan->topic?chan->topic->content:"Not set");
helpmod_reply(sender, returntype, "Channel modes: %s", printflags(chan->flags, cmodeflags));
visiblehostmask(getnickbynumeric(numeric_array[i]), buf);
if (IsAccount(getnickbynumeric(numeric_array[i])))
- helpmod_reply(sender, returntype, "%c%s (%s)", status, buf, getnickbynumeric(numeric_array[i]));//nick_array[i]->authname);
+ helpmod_reply(sender, returntype, "%c%s (%s)", status, buf, getnickbynumeric(numeric_array[i])->authname);//nick_array[i]->authname);
else
helpmod_reply(sender, returntype, "%c%s", status, buf);
}
- helpmod_reply(sender, returntype, "Users: %d Clones: %d Opped: %d Voiced: %d Authed: %3.0f%%", nick_count, nick_count - countuniquehosts(chan), o_limit, o_limit - v_limit, ((float)authed_count / (float)nick_count) * 100.0);
+ helpmod_reply(sender, returntype, "Users: %d Clones: %d Opped: %d Voiced: %d Authed: %3.0f%%", nick_count, nick_count - countuniquehosts(chan), o_limit, v_limit - o_limit, ((float)authed_count / (float)nick_count) * 100.0);
free(numeric_array);
}
-static void helpmod_cmd_statsdebug (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+static void helpmod_cmd_statsdump (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
{
haccount *hacc = haccounts;
hstat_account *ptr;
}
}
+static void helpmod_cmd_statsrepair (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+{
+ haccount *hacc = haccounts;
+ hstat_account *ptr;
+ int i;
+
+ helpmod_reply(sender, returntype, "Repairing account statistics");
+ for (;hacc;hacc = hacc->next)
+ for (ptr = hacc->stats;ptr;ptr = ptr->next)
+ {
+ for (i = 0;i < 7;i++)
+ {
+ if (ptr->week[i].time_spent > HDEF_d)
+ {
+ ptr->week[i].time_spent = 0;
+ helpmod_reply(sender, returntype, "repaired short term TimeSpent %s @ %s : Greater than one day",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+ if (ptr->week[i].time_spent < 0)
+ {
+ ptr->week[i].time_spent = 0;
+ helpmod_reply(sender, returntype, "repaired short term TimeSpent %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+
+ if (ptr->week[i].prime_time_spent > HDEF_d)
+ {
+ ptr->week[i].prime_time_spent = 0;
+ helpmod_reply(sender, returntype, "repaired short term PrimeTimeSpent %s @ %s : Greater than one day",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+ if (ptr->week[i].prime_time_spent < 0)
+ {
+ ptr->week[i].prime_time_spent = 0;
+ helpmod_reply(sender, returntype, "repaired short term PrimeTimeSpent %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+
+ if (ptr->week[i].lines > 10000)
+ {
+ ptr->week[i].lines = 0;
+ helpmod_reply(sender, returntype, "repaired short term Lines %s @ %s : Greater than 10000",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+ if (ptr->week[i].lines < 0)
+ {
+ ptr->week[i].lines = 0;
+ helpmod_reply(sender, returntype, "repaired short term Lines %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+
+ if (ptr->week[i].words > 50000)
+ {
+ ptr->week[i].words = 0;
+ helpmod_reply(sender, returntype, "repaired short term Words %s @ %s : Greater than 50000",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+ if (ptr->week[i].words < 0)
+ {
+ ptr->week[i].words = 0;
+ helpmod_reply(sender, returntype, "repaired short term Words %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+ }
+ for (i = 0;i < 10;i++)
+ {
+ if (ptr->longterm[i].time_spent > HDEF_w)
+ {
+ ptr->longterm[i].time_spent = 0;
+ helpmod_reply(sender, returntype, "repaired long term TimeSpent %s @ %s : Greater than one week",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+ if (ptr->longterm[i].time_spent < 0)
+ {
+ ptr->longterm[i].time_spent = 0;
+ helpmod_reply(sender, returntype, "repaired long term TimeSpent %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+
+ if (ptr->longterm[i].prime_time_spent > HDEF_w)
+ {
+ ptr->longterm[i].prime_time_spent = 0;
+ helpmod_reply(sender, returntype, "repaired long term PrimeTimeSpent %s @ %s : Greater than one week",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+ if (ptr->longterm[i].prime_time_spent < 0)
+ {
+ ptr->longterm[i].prime_time_spent = 0;
+ helpmod_reply(sender, returntype, "repaired long term PrimeTimeSpent %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+
+ if (ptr->longterm[i].lines > 50000)
+ {
+ ptr->longterm[i].lines = 0;
+ helpmod_reply(sender, returntype, "repaired long term Lines %s @ %s : Greater than 50000",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+ if (ptr->longterm[i].lines < 0)
+ {
+ ptr->longterm[i].lines = 0;
+ helpmod_reply(sender, returntype, "repaired long term Lines %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+
+ if (ptr->longterm[i].words > 50000)
+ {
+ ptr->longterm[i].words = 0;
+ helpmod_reply(sender, returntype, "repaired long term Words %s @ %s : Greater than 50000",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+ if (ptr->longterm[i].words < 0)
+ {
+ ptr->longterm[i].words = 0;
+ helpmod_reply(sender, returntype, "repaired long term Words %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+ }
+ }
+ }
+ helpmod_reply(sender, returntype, "Account statistics repaired");
+
+}
+
+static void helpmod_cmd_statsreset (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+{
+ haccount *hacc = haccounts;
+ hstat_account *ptr;
+ hchannel *hchan;
+ int i, short_del, long_del;
+
+ if (argc < 2)
+ {
+ helpmod_reply(sender, returntype, "Insufficient parameters");
+ return;
+ }
+
+ if (sscanf(argv[0], "%d", &short_del) == 0)
+ {
+ helpmod_reply(sender, returntype, "Invalid parameter");
+ return;
+ }
+ if (sscanf(argv[1], "%d", &long_del) == 0)
+ {
+ helpmod_reply(sender, returntype, "Invalid parameter");
+ return;
+ }
+
+ for (;hacc;hacc = hacc->next)
+ for (ptr = hacc->stats;ptr;ptr = ptr->next)
+ {
+ for (i = 1;i < short_del + 1;i++)
+ HSTAT_ACCOUNT_ZERO(ptr->week[(hstat_day() + i) % 7]);
+ for (i = 1;i < long_del + 1;i++)
+ HSTAT_ACCOUNT_ZERO(ptr->longterm[(hstat_week() + i) % 10]);
+ }
+
+ for (hchan = hchannels;hchan;hchan = hchan->next)
+ {
+ for (i = 1;i < short_del + 1;i++)
+ HSTAT_CHANNEL_ZERO(hchan->stats->week[(hstat_day() + i) % 7]);
+ for (i = 1;i < long_del + 1;i++)
+ HSTAT_CHANNEL_ZERO(hchan->stats->longterm[(hstat_week() + i) % 10]);
+
+ }
+
+ helpmod_reply(sender, returntype, "Statistics reset complete");
+}
+
static void helpmod_cmd_message (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
{
hchannel *hchan;
hcommand_add("staff", H_OPER, helpmod_cmd_staff, "Sets the userlevel of the target to staff (lvl 3)");
hcommand_add("oper", H_OPER, helpmod_cmd_oper, "Sets the userlevel of the target to oper (lvl 4)");
hcommand_add("admin", H_ADMIN, helpmod_cmd_admin, "Sets the userlevel of the target to admin (lvl 5)");
- hcommand_add("deluser", H_OPER, helpmod_cmd_deluser, "Removes an account from H");
- hcommand_add("listuser", H_STAFF, helpmod_cmd_listuser, "Lists user accounts of H");
+ hcommand_add("deluser", H_OPER, helpmod_cmd_deluser, "Removes an account from " HELPMOD_NICK);
+ hcommand_add("listuser", H_STAFF, helpmod_cmd_listuser, "Lists user accounts of " HELPMOD_NICK);
hcommand_add("chanconf", H_STAFF, helpmod_cmd_chanconf, "Channel configuration");
- hcommand_add("acconf", H_TRIAL, helpmod_cmd_acconf, "Personalise H behaviour");
+ hcommand_add("acconf", H_TRIAL, helpmod_cmd_acconf, "Personalise " HELPMOD_NICK " behaviour");
hcommand_add("welcome", H_STAFF, helpmod_cmd_welcome, "Views or changes the channel welcome message");
hcommand_add("censor", H_STAFF, helpmod_cmd_censor, "Handles the censored patterns for a channel");
hcommand_add("top10", H_STAFF, helpmod_cmd_top10, "Shows the top 10 most active staff");
hcommand_add("report", H_OPER, helpmod_cmd_report, "Sets the channel where to report this channels statistics every 5 minutes");
- hcommand_add("whoami", H_LAMER, helpmod_cmd_whoami, "Tells who you are to H");
+ hcommand_add("whoami", H_LAMER, helpmod_cmd_whoami, "Tells who you are to " HELPMOD_NICK);
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 H to a new channel");
- hcommand_add("delchan", H_ADMIN, helpmod_cmd_delchan, "Removes H permanently from a channel");
+ 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("op", H_STAFF, helpmod_cmd_op, "Sets mode +o 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("statsdebug", H_ADMIN, helpmod_cmd_statsdebug, "Statistics debug command");
+ 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("megod", H_PEON, helpmod_cmd_megod, "Gives you userlevel 4, if you see this in the final version, please kill strutsi");*/
/*hcommand_add("test", H_PEON, helpmod_cmd_test, "Gives you userlevel 4, if you see this in the final version, please kill strutsi");*/
if (sscanf(parsed_args[0], "%d", &useless_var) && returntype == NULL)
{
helpmod_cmd_help(sender, NULL, parsed_args[0], 1, NULL);
- return;
+ return;
}
{
if (hcom == NULL)
{
- if (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)))
helpmod_reply(sender, returntype, "Unknown command '%s', please see showcommands for a list of all commands available to you", parsed_args[0]);
}
else
{
fprintf(out, "\t%s\n", bantostring(hb->real_ban));
fprintf(out, "\t%s\n", hb->reason?hb->reason->content:NULL);
- fprintf(out, "\t%d\n", hb->expiration);
+ fprintf(out, "\t%u\n", hb->expiration);
return 0;
}
if (i < 7) /* days */
entry = &hs_chan->week[(hstat_day() + i) % 7];
else /* weeks */
- entry = &hs_chan->longterm[(hstat_week() + (i-7)) % 7];
+ entry = &hs_chan->longterm[(hstat_week() + (i-7)) % 10];
if (sscanf(buf, "%d %d %d %d %d %d", &entry->time_spent, &entry->prime_time_spent, &entry->joins, &entry->queue_use, &entry->lines, &entry->words) != 6)
return -1;
if (i < 7) /* days */
entry = &hs_chan->week[(hstat_day() + i) % 7];
else /* weeks */
- entry = &hs_chan->longterm[(hstat_week() + (i-7)) % 7];
+ entry = &hs_chan->longterm[(hstat_week() + (i-7)) % 10];
fprintf(out, "\t%d %d %d %d %d %d\n", entry->time_spent, entry->prime_time_spent, entry->joins, entry->queue_use, entry->lines, entry->words);
}
if (i < 7) /* days */
entry = &hs_acc->week[(hstat_day() + i) % 7];
else /* weeks */
- entry = &hs_acc->longterm[(hstat_week() + (i-7)) % 7];
+ entry = &hs_acc->longterm[(hstat_week() + (i-7)) % 10];
if (sscanf(buf, "%d %d %d %d", &entry->time_spent, &entry->prime_time_spent, &entry->lines, &entry->words) != 4)
return -1;
if (i < 7) /* days */
entry = &hs_acc->week[(hstat_day() + i) % 7];
else /* weeks */
- entry = &hs_acc->longterm[(hstat_week() + (i-7)) % 7];
+ entry = &hs_acc->longterm[(hstat_week() + (i-7)) % 10];
fprintf(out, "\t%d %d %d %d\n", entry->time_spent, entry->prime_time_spent, entry->lines, entry->words);
}
enum
{
HDEF_s = 1,
- HDEF_m = 60,
+ HDEF_m = 60 * HDEF_s,
HDEF_h = 60 * HDEF_m,
HDEF_d = 24 * HDEF_h,
HDEF_w = 7 * HDEF_d,
int HELPMOD_ACCOUNT_EXPIRATION[] =
{
14 * HDEF_d, /* H_LAMER */
- 7 * HDEF_d, /* H_PEON */
- 2 * HDEF_M, /* H_TRIAL */
- 6 * HDEF_M, /* H_STAFF */
- 1 * HDEF_y, /* H_OPER */
- 2 * HDEF_y /* H_ADMIN */
+ 7 * HDEF_d, /* H_PEON */
+ 2 * HDEF_M, /* H_TRIAL */
+ 6 * HDEF_M, /* H_STAFF */
+ 1 * HDEF_y, /* H_OPER */
+ 2 * HDEF_y /* H_ADMIN */
};
/* new H stuff */
vsnprintf(buf,512,message,va);
va_end(va);
+ if (hchan->flags & H_PASSIVE)
+ return;
+
sendmessagetochannel(helpmodnick, hchan->real_channel, "%s", buf);
}
vsnprintf(buf,2048,message,va);
va_end(va);
+ if (hchan->flags & H_PASSIVE)
+ return;
+
while (strlen(bp) > 450)
{
for (i=0;i<50;i++)
void helpmod_invite(hchannel *hchan, huser *husr)
{
+ if (hchan->flags & H_PASSIVE)
+ return;
+
localinvite(helpmodnick, hchan->real_channel, husr->real_user);
}
return;
}
+ if (hchan->flags & H_PASSIVE)
+ return;
+
switch (mode)
{
case MC_OP:
void helpmod_setban(hchannel *hchan, const char *banstr, time_t expiration, int type, int now)
{
hmode_set_channel(hchan);
+
+ if (hchan->flags & H_PASSIVE)
+ return;
+
localdosetmode_ban(&hmodechanges, banstr, type);
if ((type == MCB_ADD) && (expiration > time(NULL)))
{
hmode_set_channel(hchan);
+ if (hchan->flags & H_PASSIVE)
+ return;
+
localdosetmode_simple(&hmodechanges, add, remove);
if (now)
void helpmod_set_topic(hchannel *hchan, const char* topic)
{
+ if (hchan->flags & H_PASSIVE)
+ return;
+
localsettopic(helpmodnick, hchan->real_channel, (char*)topic);
}
schedulerecurring(time(NULL)+1,0,HDEF_d,(ScheduleCallback)&haccount_clear_inactives,NULL);
schedulerecurring(time(NULL)+1,0,HDEF_m,(ScheduleCallback)&hban_remove_expired,NULL);
schedulerecurring(time(NULL)+1,0,30 * HDEF_s, (ScheduleCallback)&hchannel_remove_inactive_users, NULL);
- schedulerecurring(time(NULL)+1,0,5 * HDEF_m,(ScheduleCallback)&hchannel_report, NULL);
+ schedulerecurring(time(NULL)+1,0,60 * HDEF_m,(ScheduleCallback)&hchannel_report, NULL);
schedulerecurring(time(NULL) + HDEF_h, 0, 6 * HDEF_h, (ScheduleCallback)&helpmod_config_scheduled_events, NULL);
schedulerecurring(time(NULL)+1,0,10 * HDEF_m, (ScheduleCallback)&hticket_remove_expired, NULL);
schedulerecurring(hstat_get_schedule_time() - 5 * HDEF_m, 0, HDEF_d, (ScheduleCallback)&hstat_scheduler, NULL);
% Initial account (mine)
account
- strutsi
+ sdjfkl
5 0
0
/* configuration */
-#define HELPMOD_VERSION "2.05"
+#define HELPMOD_VERSION "2.09"
#define HELPMOD_USER_TIMEOUT 1200
buf+=tmp;\
}\
-
+/* This implementation might look a little evil but it does work */
const char *helpmod_strtime(int total_seconds)
{
- static char buffer[64];
- char *buf = buffer;
+ static int buffer_index = 0;
+ static char buffers[3][64];
+
+ char *buf = buffers[buffer_index];
+ char *buffer = buf;
int years, months, days, hours, minutes, seconds, tmp;
+ buffer_index = (buffer_index+1) % 3;
+
/* trivial case */
if (!total_seconds)
return "0s";
if (total_seconds < 0)
{
- *buf = '-';
- buf++;
+ *buf = '-';
+ buf++;
total_seconds = -total_seconds;
}
total_seconds %= HDEF_h;
minutes = total_seconds / HDEF_m;
- total_seconds %= 60;
+ total_seconds %= HDEF_m;
seconds = total_seconds;
TIME_PRINT(minutes, "m");
TIME_PRINT(seconds, "s");
- return buffer+1;
+ if (*buffer != '-')
+ return buffer+1;
+ else
+ return buffer;
}
int helpmod_read_strtime(const char *str)
/* matches string (const char*) to the regular expression (? and *) (const char*) */
int strregexp(const char *, const char *);
-/* prints the time in the common 1h 2m 3s format, hour is the maximum unit printed currently */
+/* prints the time in the common 1h 2m 3s format, has three internal buffers */
const char *helpmod_strtime(int);
/* reads a time string */
int helpmod_read_strtime(const char *);
huser *husr;
/* if we're not on this channel, the event is of no interest */
- if (hchan == NULL || hchan->flags & H_PASSIVE)
+ if (hchan == NULL)
return;
husr = huser_get(nck);
assert(husr != NULL); /* hook_channel_newnick should fix this */
- if (hchan->flags & H_JOINFLOOD_PROTECTION)
+ 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))
+ hchan->jf_control = time(NULL);
+ else
+ hchan->jf_control++;
- if (hchan->jf_control - time(NULL) > 25 && !IsRegOnly(hchan))
- {
- if (hchan->flags & H_REPORT && hchannel_is_valid(hchan->report_to))
+ if (hchan->jf_control - time(NULL) > 25 && !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);
}
}
+ if (hchan->flags & H_PASSIVE)
+ return;
+
if (hchan->flags & H_DO_STATS)
hstat_add_join(hchan);
hchannel_add_user(hchan, husr);
huser_add_channel(husr, hchan);
+ if (hchan->flags & H_PASSIVE)
+ return;
+
if (huser_get_level(husr) == H_LAMER || (huser_get_level(husr) == H_PEON && hban_check(nck)))
{
hban *hb = hban_check(nck);
assert(hchannel_on_channel(hchan, husr) != NULL);
assert(huserchan != NULL);
- if ((hchan->flags & H_QUEUE) && (hchan->flags & H_QUEUE_MAINTAIN)) /* && (huser_get_level(husr) == H_PEON) && (huserchan->flags & HCUMODE_VOICE) && (hchannel_count_queue(hchan)))*/
- if (serverlist[homeserver(husr->real_user->numeric)].linkstate != LS_SQUIT)
+ if ((hchan->flags & H_QUEUE) && (hchan->flags & H_QUEUE_MAINTAIN) && !(hchan->flags & H_PASSIVE)) /* && (huser_get_level(husr) == H_PEON) && (huserchan->flags & HCUMODE_VOICE) && (hchannel_count_queue(hchan)))*/
+ if (serverlist[homeserver(husr->real_user->numeric)].linkstate != LS_SQUIT)
/* if it was a netsplit, we do not trigger autoqueue */
{
oper = huserchan->responsible_oper;
/* it was someone we didn't even know */
if (husr == NULL)
- return;
+ return;
huser_del(husr);
}
huserchan->flags |= HCUMODE_OP;
+ if (hchan->flags & H_PASSIVE)
+ return;
+
/* if the +o was given by a network service, G will not interfere */
if (husr2 == NULL || strlen(husr2->real_user->nick) == 1)
return;
huserchan->flags &= ~HCUMODE_VOICE;
+ if (hchan->flags & H_PASSIVE)
+ return;
+
if ((hchan->flags & H_QUEUE) && (hchan->flags & H_QUEUE_MAINTAIN) && (huser_get_level(husr) == H_PEON) && (huserchan->flags & HCUMODE_VOICE) && (hchannel_count_queue(hchan)))
{
if (serverlist[homeserver(husr->real_user->numeric)].linkstate != LS_SQUIT)
hchannel *hchan = hchannel_get_by_channel(((channel**)args)[0]);
huser *husr;
- if (hchan == NULL)
+ if (hchan == NULL || hchan->flags & H_PASSIVE)
return;
husr = huser_get(((nick**)args)[2]);
}
/* checks a string for lameness, returns non-zero if lameness is present */
-int hlc_check(void *hchan_ptr, void *husr_ptr, const char *line)
+int hlc_check(hchannel *hchan, huser* husr, const char *line)
{
- hchannel *hchan = (hchannel*)hchan_ptr;
- huser *husr = (huser*)husr_ptr;
+// hchannel *hchan = (hchannel*)hchan_ptr;
+// huser *husr = (huser*)husr_ptr;
if (hchan == NULL || hchan->lc_profile == NULL)
return 0;
#define HLC_DEFAULT_BANTIME (60 * 60 * 24)
+/* Forward declarations */
+struct hchannel_struct;
+struct huser_struct;
+
typedef enum
{
HLC_CAPS,
void hlc_del_all(void);
hlc_profile *hlc_get(const char *);
-/* checks a string for lameness, returns non-zero if lameness is present and user is kicked */
-/* the first parameter is hchannel* and second is huser*, but since hchannel.h includes hlamer.h, this is needed */
-int hlc_check(void *, void*, 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 *);
#endif
#include "hqueue.h"
#include "hgen.h"
#include "hstat.h"
+#include "huser.h"
#include "hcommands.h"
helpmod_reply(sender, returntype, "Queue deactivated for channel %s", hchannel_get_name(hchan));
hchannel_conf_change(hchan, hchan->flags | H_QUEUE);
hchan->autoqueue = 0;
+
+ { /* devoice all users of level H_PEON */
+ hchannel_user *hchanuser;
+ huser_channel *huserchan;
+ for (hchanuser = hchan->channel_users;hchanuser != NULL;hchanuser = hchanuser->next)
+ {
+ huserchan = huser_on_channel(hchanuser->husr, hchan);
+ if (huser_get_level(hchanuser->husr) == H_PEON && huserchan->flags & HCUMODE_VOICE)
+ helpmod_channick_modes(hchanuser->husr, hchan, MC_DEVOICE, HLAZY);
+ }
+
+ }
+
}
return;
}
struct tm *tstruct = localtime(&timer);
int is_sunday = (tstruct->tm_wday == 0); /* is it sunday ? */
int i;
- hstat_cycle++;
+
+ /* Fix the hstat_cycle in case it's broken */
+ if (is_sunday)
+ hstat_cycle = hstat_cycle - (hstat_cycle % 7) + 6;
{ /* accounts */
haccount *ptr = haccounts;
- if (is_sunday)
- for (;ptr;ptr = ptr->next)
- if (ptr->level > H_PEON)
- {
- hstat_account *ptr2 = ptr->stats;
- for (;ptr2;ptr2 = ptr2->next)
- {
- HSTAT_ACCOUNT_ZERO(ptr2->longterm[(hstat_week() - 1) % 10]);
- for (i=0;i<7;i++)
- {
- HSTAT_ACCOUNT_SUM(ptr2->longterm[(hstat_week() - 1) % 10], ptr2->longterm[(hstat_week() - 1) % 10], ptr2->week[i]);
- }
- /*ptr2->longterm[(hstat_week() - 1) % 10] = ptr2->longterm[hstat_week()];*/
- /*for (i=0;i<7;i++)
- {
- HSTAT_ACCOUNT_ZERO(ptr2->week[i]);
- }*/
- }
- }
+ for (;ptr;ptr = ptr->next)
+ if (ptr->level > H_PEON)
+ {
+ hstat_account *ptr2 = ptr->stats;
+ for (;ptr2;ptr2 = ptr2->next)
+ {
+ if (is_sunday)
+ {
+ HSTAT_ACCOUNT_ZERO(ptr2->longterm[(hstat_week() + 1) % 10]);
+ for (i=0;i<7;i++)
+ {
+ HSTAT_ACCOUNT_SUM(ptr2->longterm[(hstat_week() + 1) % 10], ptr2->longterm[(hstat_week() + 1) % 10], ptr2->week[i]);
+ }
+ }
+ HSTAT_ACCOUNT_ZERO(ptr2->week[(hstat_day() + 1) % 7]);
+ /* ptr2->longterm[(hstat_week() - 1) % 10] = ptr2->longterm[hstat_week()];
+ for (i=0;i<7;i++)
+ {
+ HSTAT_ACCOUNT_ZERO(ptr2->day[i]);
+ }*/
+ }
+ }
}
{ /* hchannels */
hchannel *ptr = hchannels;
for (;ptr;ptr = ptr->next)
{
- if ((ptr->flags & H_REPORT) && hchannel_is_valid(ptr))
+ hstat_channel *ptr2;
+ if (ptr->flags & H_REPORT && hchannel_is_valid(ptr->report_to))
{
hstat_channel_entry *entry = &ptr->stats->week[hstat_day()];
helpmod_message_channel(ptr->report_to, "Daily summary for channel %s: Time spent %s, joins %d and queue usage %d", hchannel_get_name(ptr),helpmod_strtime(entry->time_spent), entry->joins, entry->queue_use);
}
- if (is_sunday)
- {
- hstat_channel *ptr2 = ptr->stats;
- HSTAT_CHANNEL_ZERO(ptr2->longterm[(hstat_week() - 1) % 10]);
+
+ ptr2 = ptr->stats;
+ if (is_sunday)
+ {
+ HSTAT_CHANNEL_ZERO(ptr2->longterm[(hstat_week() + 1) % 10]);
for (i=0;i<7;i++)
{
- HSTAT_CHANNEL_SUM(ptr2->longterm[(hstat_week() - 1) % 10], ptr2->longterm[(hstat_week() - 1) % 10], ptr2->week[i]);
+ HSTAT_CHANNEL_SUM(ptr2->longterm[(hstat_week() + 1) % 10], ptr2->longterm[(hstat_week() + 1) % 10], ptr2->week[i]);
}
- /*ptr2->longterm[(hstat_week() - 1) % 10] = ptr2->longterm[hstat_week()];*/
- /*for (i=0;i<7;i++)
- {
- HSTAT_CHANNEL_ZERO(ptr2->week[i]);
+/* ptr2->longterm[(hstat_week() - 1) % 10] = ptr2->longterm[hstat_week()];
+ for (i=0;i<7;i++)
+ {
+ HSTAT_CHANNEL_ZERO(ptr2->day[i]);
}*/
- }
+ }
+ HSTAT_CHANNEL_ZERO(ptr2->week[(hstat_day() + 1) % 7]);
}
}
+
+ hstat_cycle++;
}
int hstat_get_schedule_time(void)
return tmp;
}
-void hstat_del_channel(void* ptr)
+void hstat_del_channel(hchannel *hchan)
{
- hchannel *hchan = (hchannel*)ptr;
haccount *hacc = haccounts;
hstat_account **hs_acc;
for (;hacc;hacc = hacc->next)
return tmp;
}
-void hstat_calculate_general(void* param1, void* param2, const char *message)
+void hstat_calculate_general(hchannel *hchan, huser* husr, const char *message)
{
- hchannel *hchan = (hchannel*)param1;
- huser *husr = (huser*)param2;
hstat_account **acc_stat;
hstat_account_entry *acc_entry;
hstat_channel_entry *chan_entry;
break;
if (*acc_stat == NULL)
- /* this user has no stats for the channel -> create them */
- {
+ { /* this user has no stats for the channel -> create them */
*acc_stat = get_hstat_account();
(*acc_stat)->hchan = hchan;
}
time_spent = time(NULL) - huserchan->last_activity;
- if (time_spent < HSTAT_ACTIVITY_TRESHOLD)
+ if (time_spent > 0 && time_spent < HSTAT_ACTIVITY_TRESHOLD)
{
acc_entry->time_spent+=time_spent;
chan_entry->time_spent+=time_spent;
chan_entry->words+=wordc;
}
-void hstat_add_join(void *param)
+void hstat_add_join(hchannel *hchan)
{
- hchannel *hchan = (hchannel*)param;
hchan->stats->week[hstat_day()].joins++;
}
-void hstat_add_queue(void *param, int amount)
+void hstat_add_queue(hchannel *hchan, int amount)
{
- hchannel *hchan = (hchannel*)param;
hchan->stats->week[hstat_day()].queue_use+=amount;
}
-
const char *hstat_channel_print(hstat_channel_entry *entry, int type)
{
static char buffer[256];
switch (type)
{
case HSTAT_CHANNEL_LONG:
- sprintf(buffer, "%-15s %-15s %-10d %-10d %-10d %-10d", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent), entry->joins, entry->queue_use, entry->lines, entry->words);
+ sprintf(buffer, "%-18s %-18s %-10d %-10d %-10d %-10d", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent), entry->joins, entry->queue_use, entry->lines, entry->words);
break;
case HSTAT_CHANNEL_SHORT:
- sprintf(buffer, "%-15s %-15s", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent));
+ sprintf(buffer, "%-18s %-18s", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent));
break;
}
return buffer;
switch (type)
{
case HSTAT_ACCOUNT_LONG:
- sprintf(buffer, "%-15s %-15s %-10d %-10d", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent), entry->lines, entry->words);
+ sprintf(buffer, "%-18s %-18s %-10d %-10d", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent), entry->lines, entry->words);
break;
case HSTAT_ACCOUNT_SHORT:
- sprintf(buffer, "%-15s %-15s", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent));
+ sprintf(buffer, "%-18s %-18s", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent));
break;
}
return buffer;
switch (type)
{
case HSTAT_ACCOUNT_SHORT:
- return "TimeSpent PrimeTimeSpent";
+ return "TimeSpent PrimeTimeSpent";
case HSTAT_ACCOUNT_LONG:
- return "TimeSpent PrimeTimeSpent Lines Words";
+ return "TimeSpent PrimeTimeSpent Lines Words";
case HSTAT_CHANNEL_SHORT:
- return "TimeSpent PrimeTimeSpent";
+ return "TimeSpent PrimeTimeSpent";
case HSTAT_CHANNEL_LONG:
- return "TimeSpent PrimeTimeSpent Joins QueueUse Lines Words";
+ return "TimeSpent PrimeTimeSpent Joins QueueUse Lines Words";
default:
- return "error: please contact strutsi";
+ return "Error: please contact strutsi";
}
}
return e2->prime_time_spent - e1->prime_time_spent;
}
-hstat_accounts_array create_hstat_account_array(void* tptr, hlevel lvl)
+hstat_accounts_array create_hstat_account_array(hchannel *hchan, hlevel lvl)
{
- hchannel *hchan = (hchannel*)tptr;
hstat_accounts_array arr = {NULL, 0};
hstat_account *ptr;
hstat_account_entry_sum tmp1, tmp2;
if (!initial_arrlen)
return arr;
- arr.array = malloc(sizeof(hstat_account_entry_sum) * initial_arrlen);
+ arr.array = (hstat_account_entry_sum*)malloc(sizeof(hstat_account_entry_sum) * initial_arrlen);
for (;hacc;hacc = hacc->next)
if ((lvl == H_OPER && (hacc->level == H_OPER || hacc->level == H_ADMIN)) ||
(lvl == H_STAFF && (hacc->level == H_TRIAL || hacc->level == H_STAFF)))
- //if ((lvl == H_OPER)?(hacc->level >= H_OPER && hacc->level < H_SERVICE):(hacc->level > H_PEON || hacc->level < H_OPER))
- for (ptr = hacc->stats;ptr;ptr = ptr->next)
- if (ptr->hchan == hchan)
- {
- assert(arr.arrlen < initial_arrlen);
- tmp1 = hstat_account_last_month(ptr);
- tmp2 = hstat_account_last_week(ptr);
- HSTAT_ACCOUNT_SUM(arr.array[arr.arrlen], tmp1, tmp2);
- arr.array[arr.arrlen].owner = (void*)hacc;
- arr.arrlen++;
- }
+ for (ptr = hacc->stats;ptr;ptr = ptr->next)
+ if (ptr->hchan == hchan)
+ {
+ assert(arr.arrlen < initial_arrlen);
+ tmp1 = hstat_account_last_month(ptr);
+ tmp2 = hstat_account_last_week(ptr);
+ HSTAT_ACCOUNT_SUM(arr.array[arr.arrlen], tmp1, tmp2);
+ arr.array[arr.arrlen].owner = hacc;
+ arr.arrlen++;
+ }
qsort(arr.array, arr.arrlen, sizeof(hstat_account_entry_sum), (int(*)(const void*, const void*))hstat_account_compare);
return arr;
extern int hstat_cycle;
extern time_t hstat_last_cycle;
-#define HSTAT_ACTIVITY_TRESHOLD (3 * 60)
+/* forward declarations */
+struct haccount_struct;
+struct hchannel_struct;
+struct huser_struct;
+
+#define HSTAT_ACTIVITY_TRESHOLD (3 * HDEF_m)
#define HSTAT_ACCOUNT_SUM(sum, op1, op2)\
{\
int prime_time_spent;
int lines;
int words;
- void *owner; /* haccount* */
+ struct haccount_struct *owner; /* haccount* */
} hstat_account_entry_sum;
typedef struct hstat_channel_entry_struct
} hstat_accounts_array;
/* free() this.entries, arguments: channel, level to list */
-hstat_accounts_array create_hstat_account_array(void*, hlevel);
+hstat_accounts_array create_hstat_account_array(struct hchannel_struct*, hlevel);
hstat_channel *get_hstat_channel(void);
hstat_account *get_hstat_account(void);
const char *hstat_account_print(hstat_account_entry*, int);
-/* void* = hchannel*, huser* */
-void hstat_calculate_general(void*, void*, const char *);
+void hstat_calculate_general(struct hchannel_struct*, struct huser_struct*, const char *);
-/* void* = hchannel* */
-void hstat_add_join(void*);
-void hstat_del_channel(void*);
+void hstat_add_join(struct hchannel_struct*);
+void hstat_del_channel(struct hchannel_struct*);
-/* void* = hchannel* */
-void hstat_add_queue(void*, int);
+void hstat_add_queue(struct hchannel_struct*, int);
int is_prime_time(void); /* tells if now is the "main" time in #feds */