#include <string.h>
#include <assert.h>
-#include "../core/hooks.h"
-#include "../localuser/localuser.h"
-
#include "helpmod.h"
#include "hchannel.h"
#include "haccount.h"
#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)
+static void helpmod_hook_join(int unused, void *args)
{
channel *chan = ((channel**)args)[0];
hchannel *hchan = hchannel_get_by_channel(chan);
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) > 12 && !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)
return;
}
- if (huser_get_level(husr) > H_PEON && (huser_get_account_flags(husr) & H_AUTO_OP) && hchannel_authority(hchan, husr))
+ if (huser_get_level(husr) >= H_STAFF && (huser_get_account_flags(husr) & H_AUTO_OP) && hchannel_authority(hchan, husr))
helpmod_channick_modes(husr, hchan ,MC_OP,HNOW);
- if (huser_get_level(husr) > H_PEON && (huser_get_account_flags(husr) & H_AUTO_VOICE) && hchannel_authority(hchan, husr))
+ if (huser_get_level(husr) >= H_TRIAL && (huser_get_account_flags(husr) & H_AUTO_VOICE) && hchannel_authority(hchan, husr))
helpmod_channick_modes(husr, hchan, MC_VOICE,HNOW);
if (hchan->flags & H_WELCOME && *hchan->real_channel->index->name->content)
}
}
-void helpmod_hook_channel_newnick(int unused, void *args)
+static void helpmod_hook_channel_newnick(int unused, void *args)
{
channel *chan = ((channel**)args)[0];
hchannel *hchan = hchannel_get_by_channel(chan);
if (hchan->flags & H_PASSIVE)
return;
- if (huser_get_level(husr) == H_LAMER || (huser_get_level(husr) == H_PEON && hban_check(nck)))
+ huser_activity(husr, NULL);
+
+ if (huser_get_level(husr) == H_LAMER || (huser_get_level(husr) <= H_TRIAL && hban_check(nck)))
{
hban *hb = hban_check(nck);
helpmod_setban(hchan, banmask, time(NULL) + 1 * HDEF_d, MCB_ADD, HNOW);
if (hb)
- helpmod_kick(hchan, husr,hban_get_reason(hb));
+ helpmod_kick(hchan, husr, "%s", hban_get_reason(hb));
else
helpmod_kick(hchan, husr, "Your presence on channel %s is not wanted", hchannel_get_name(hchan));
hqueue_handle_queue(hchan, NULL);
}
-void helpmod_hook_channel_lostnick(int unused, void *args)
+static void helpmod_hook_channel_lostnick(int unused, void *args)
{
channel *chan = ((channel**)args)[0];
hchannel *hchan = hchannel_get_by_channel(chan);
hqueue_handle_queue(hchan, oper);
}
-void helpmod_hook_nick_lostnick(int unused, void *args)
+static 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 */
huser_del(husr);
}
-void helpmod_hook_channel_opped(int unused, void *args)
+static void helpmod_hook_channel_opped(int unused, void *args)
{
hchannel *hchan = hchannel_get_by_channel(((channel**)args)[0]);
huser_channel *huserchan;
helpmod_channick_modes(husr, hchan, MC_DEOP ,HNOW);
}
-void helpmod_hook_channel_deopped(int unused, void *args)
+static void helpmod_hook_channel_deopped(int unused, void *args)
{
hchannel *hchan = hchannel_get_by_channel(((channel**)args)[0]);
huser_channel *huserchan;
assert(huserchan != NULL);
huserchan->flags &= ~HCUMODE_OP;
-
}
-void helpmod_hook_channel_voiced(int unused, void *args)
+static void helpmod_hook_channel_voiced(int unused, void *args)
{
hchannel *hchan = hchannel_get_by_channel(((channel**)args)[0]);
huser_channel *huserchan;
}
}
-void helpmod_hook_channel_devoiced(int unused, void *args)
+static void helpmod_hook_channel_devoiced(int unused, void *args)
{
hchannel *hchan = hchannel_get_by_channel(((channel**)args)[0]);
huser_channel *huserchan;
}
}
-void helpmod_hook_channel_topic(int unused, void *args)
+static void helpmod_hook_channel_topic(int unused, void *args)
{
hchannel *hchan = hchannel_get_by_channel(((channel**)args)[0]);
huser *husr;
}
}
-void helpmod_hook_nick_account(int unused, void *args)
+static void helpmod_hook_nick_account(int unused, void *args)
{
nick *nck = (nick*)args;
huser *husr = huser_get(nck);
+ huser_channel *huserchan, *huserchannext;
if (husr == NULL)
return;
else
- husr->account = haccount_get_by_name(nck->authname);
+ husr->account = haccount_get_by_name(nck->authname);
+
+ if (huser_get_level(husr) == H_LAMER) {
+ for (huserchan = husr->hchannels; huserchan; huserchan = huserchannext) {
+ huserchannext = huserchan->next;
+ helpmod_kick(huserchan->hchan, husr, "Your presence on channel %s is not wanted", hchannel_get_name(huserchan->hchan));
+ }
+ }
+}
+
+static void helpmod_hook_server_newserver(int unused, void *args)
+{
+ hchannel *hchan;
+ long numeric = (long)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);
}