#include <stdlib.h>
#include <assert.h>
-
-#include "../lib/sstring.h"
-#include "../lib/irc_string.h"
-#include "../channel/channel.h"
-#include "../localuser/localuserchannel.h"
-#include "../core/schedule.h"
+#include <string.h>
+#include <ctype.h>
#include "hchannel.h"
#include "haccount.h"
hchan->censor = NULL;
hchan->htickets = NULL;
+ hchan->ticket_message = NULL;
+ hchan->last_activity = time(NULL);
+ hchan->last_staff_activity = time(NULL);
hchan->stats = get_hstat_channel();
hchan->next = hchannels;
if ((husr = huser_get(nck)) == NULL)
husr = huser_add(nck);
-/*
- fprintf(hdebug_file, "%d ADD (hchannel_add) %s to %s\n", time(NULL), husr->real_user->nick, hchannel_get_name(hchan));
- fflush(hdebug_file);
-*/
- tmp = huser_add_channel(husr, hchan);
+
+ tmp = huser_add_channel(husr, hchan);
hchannel_add_user(hchan, husr);
if (hchan->real_channel->users->content[i] & CUMODE_OP)
while (hchan->htickets)
hticket_del(hchan->htickets, hchan);
- localpartchannel(helpmodnick, hchan->real_channel);
+ localpartchannel(helpmodnick, hchan->real_channel, "Channel Removed");
free(hchan);
return NULL;
}
-const char *hchannel_get_state(hchannel* hchan, int mask)
-{
- if (hchan->flags & mask)
- return "active";
- else
- return "inactive";
-}
-
const char *hchannel_get_name(hchannel *hchan)
{
return hchan->real_channel->index->name->content;
hchannel_user **hchanuser = &hchan->channel_users;
while (*hchanuser)
{
- if ((huser_get_level((*hchanuser)->husr) == H_PEON) && (time(NULL) - huser_on_channel((*hchanuser)->husr,hchan)->last_activity >= hchan->max_idle) && !on_queue((*hchanuser)->husr, huser_on_channel((*hchanuser)->husr, hchan)))
- {
- if (huser_on_channel((*hchanuser)->husr, hchan)->flags & H_IDLE_WARNING)
+ if (
+ (huser_get_level((*hchanuser)->husr) == H_PEON) &&
+ (time(NULL) - huser_on_channel((*hchanuser)->husr,hchan)->last_activity >= hchan->max_idle) &&
+ !(on_queue((*hchanuser)->husr, huser_on_channel((*hchanuser)->husr, hchan)))
+ )
+ {
+ 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);
+ int bantime = 10;
+ helpmod_setban(hchan, banmask, time(NULL) + bantime * HDEF_m, MCB_ADD, HLAZY);
- helpmod_kick(hchan, (*hchanuser)->husr, "Please do not idle in %s", hchannel_get_name(hchan));
+ helpmod_kick(hchan, (*hchanuser)->husr, "Please do not idle in %s (%dmin anti-idle tempban). If you still require assistance, please try again later.", hchannel_get_name(hchan), bantime);
continue;
}
else
{
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;
- }
+ }
+ hcommit_modes();
}
/* Additionally, test if the channel has queue but no idle opers / staff */
if (hchan->flags & H_QUEUE && hchan->flags & H_QUEUE_TIMEOUT)
{
hchannel_user *tmp;
for (tmp = hchan->channel_users;tmp;tmp = tmp->next)
- if (huser_get_level(tmp->husr) > H_PEON)
+ if (huser_get_level(tmp->husr) >= H_TRIAL)
{
huser_channel *huserchan = huser_on_channel(tmp->husr, hchan);
if ((time(NULL) - huserchan->last_activity < HELPMOD_QUEUE_TIMEOUT) && (huserchan->last_activity != tmp->time_joined))
for (;hchan;hchan = hchan->next)
for (hchanuser = hchan->channel_users;hchanuser;hchanuser = hchanuser->next)
if (hchanuser->husr->account == NULL && IsAccount(hchanuser->husr->real_user))
- hchanuser->husr->account = haccount_get_by_name(hchanuser->husr->real_user->authname);
+ hchanuser->husr->account = haccount_get_by_name(huser_get_auth(hchanuser->husr));
}
int hchannels_on_queue(huser *husr)
/*if (on_queue(husr, huserchan) || on_desk(husr, huserchan))*/
if (huserchan != NULL)
{
- hchannel_user *tmp, **hchanuser = &hchan->channel_users;
+ hchannel_user *tmp = NULL, **hchanuser = &hchan->channel_users;
for (;*hchanuser;hchanuser = &(*hchanuser)->next)
if ((*hchanuser)->husr == husr)
{
break;
}
*hchanuser = tmp;
+ assert(*hchanuser != NULL);
(*hchanuser)->next = NULL;
if (on_desk(husr, huserchan))
{
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;
- }
+}
+
+const char *hchannel_get_state(hchannel* hchan, int mask)
+{
+ if (hchan->flags & mask)
+ return "Yes";
+ else
+ return "No";
+}
+
+int hchannel_highlight_detection(hchannel *hchan, const char *message)
+{
+ char buffer[512], *buffer_ptr = buffer, *ptr = buffer;
+ int i, matches = 0;
+
+ strcpy(buffer, message);
+
+ /* remove commas */
+ for (i=0;i<512 && buffer[i] != '\0';i++)
+ if (buffer[i] == ',')
+ buffer[i] = ' ';
+
+ /* reset i for loop */
+ i = 0;
+ do
+ {
+ nick *tmp;
+ huser *tmp_huser;
+ huser_channel *tmp_huserchan;
+
+ if (i++ > 6)
+ break;
- scheduleoneshot(time(NULL) + 60, &hchannel_deactivate_join_flood, NULL);
- */
+ while (*buffer_ptr && isspace(*buffer_ptr))
+ buffer_ptr++;
+
+ if (*buffer_ptr == '@')
+ buffer_ptr++;
+
+ if (*buffer_ptr)
+ {
+ ptr = strchr(buffer_ptr, ' ');
+ if (ptr)
+ {
+ *ptr = '\0';
+ ptr++;
+ }
+ if ((tmp = getnickbynick(buffer_ptr)))
+ if ((tmp_huser = huser_get(tmp)))
+ if ((tmp_huserchan = huser_on_channel(tmp_huser, hchan)))
+ if ((tmp_huserchan->flags & HCUMODE_OP) && strlen(huser_get_nick(tmp_huser)) > 1)
+ matches++;
+ }
+ if (ptr == NULL)
+ break;
+ else
+ buffer_ptr = ptr;
+ } while (*ptr);
+
+ if (matches > 2)
+ return 1;
+ else
+ return 0;
}
const char *hchannel_get_sname(int flag)
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";
+ case 21:
+ return "Excessive highlight prevention";
default:
- return "error, please contact strutsi";
+ return "Error, please contact strutsi";
}
}