示例#1
0
void hchannel_mode_check(hchannel *hchan)
{
    if (((hchan->flags & H_MAINTAIN_M) || (hchan->flags & H_QUEUE)) && !IsModerated(hchan->real_channel))
        helpmod_simple_modes(hchan, CHANMODE_MODERATE, 0,0);
    else if (!((hchan->flags & H_MAINTAIN_M) || (hchan->flags & H_QUEUE)) && IsModerated(hchan->real_channel))
        helpmod_simple_modes(hchan, 0, CHANMODE_MODERATE ,0);
    if (hchan->flags & H_MAINTAIN_I && !IsInviteOnly(hchan->real_channel))
        helpmod_simple_modes(hchan, CHANMODE_INVITEONLY, 0,0);
    else if (!(hchan->flags & H_MAINTAIN_I) && IsInviteOnly(hchan->real_channel))
        helpmod_simple_modes(hchan, 0, CHANMODE_INVITEONLY, 0);
}
示例#2
0
/* goes to schedule */
void hchannel_deactivate_join_flood()
{
    hchannel *hchan = hchannels;
    for (;hchan;hchan = hchan->next)
        if (hchan->flags & H_JOIN_FLOOD)
        {
            helpmod_simple_modes(hchan, 0, CHANMODE_REGONLY, 1);
            hchan->flags &= ~H_JOIN_FLOOD;
        }
}
示例#3
0
void hchannel_activate_join_flood(hchannel *hchan)
{
    hchannel_user **hchanuser = &hchan->channel_users;
    helpmod_simple_modes(hchan, CHANMODE_REGONLY, 0, 1);

    /* clean the channel of the already joined clients */
    while (*hchanuser)
        if (((*hchanuser)->time_joined > (time(NULL) - 5)) && huser_get_level((*hchanuser)->husr) < H_STAFF)
            helpmod_kick(hchan, (*hchanuser)->husr, "Join flood");
        else
            hchanuser = &(*hchanuser)->next;

    hchan->flags |= H_JOIN_FLOOD;

    scheduleoneshot(time(NULL) + 60, &hchannel_deactivate_join_flood, NULL);
}
示例#4
0
文件: hqueue.c 项目: quakenet/newserv
void helpmod_queue_handler (huser *sender, channel* returntype, hchannel *hchan, int hqueue_action, char* ostr, int argc, char *argv[])
{
    if (hchan == NULL)
    {
        helpmod_reply(sender, returntype, "Can not handle queue: Channel not defined or not found");
        return;
    }
    switch (hqueue_action) /* easy ones */
    {
    case HQ_ON:
        if (hchan->flags & H_QUEUE)
            helpmod_reply(sender, returntype, "Can not activate queue: Queue is already active on channel %s", hchannel_get_name(hchan));
        else
        {
            hchan->flags |= H_QUEUE;
            helpmod_reply(sender, returntype, "Queue activated for channel %s", hchannel_get_name(hchan));
	    hchannel_conf_change(hchan, hchan->flags & ~(H_QUEUE));
	    hchan->autoqueue = 0;
	}
        return;
    case HQ_OFF:
        if (!(hchan->flags & H_QUEUE))
            helpmod_reply(sender, returntype, "Can not deactive queue: Queue is not active on %s", hchannel_get_name(hchan));
        else
        {
            hchan->flags &= ~H_QUEUE;
            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;
    }
    if (!(hchan->flags & H_QUEUE))
    {
        helpmod_reply(sender, returntype, "Can not handle queue: Queue not active on channel %s", hchannel_get_name(hchan));
        return;
    }
    /* now to the real deal */
    switch (hqueue_action)
    {
    case HQ_DONE:
        {
            int i;
            if (argc == 0)
            {
                helpmod_reply(sender, returntype, "Can not advance queue: User not specified");
                return;
            }
            if (argc > H_CMD_MAX_ARGS)
                argc = H_CMD_MAX_ARGS;

            for (i=0;i<argc;i++)
            {
                huser *husr = huser_get(getnickbynick(argv[i]));
                if (husr == NULL)
                {
                    helpmod_reply(sender, returntype, "Can not advance queue: User %s not found", argv[i]);
                    continue;
                }
                helpmod_channick_modes(husr, hchan, MC_DEVOICE, HLAZY);
            }

            hqueue_handle_queue(hchan, sender);
        }
        return;
    case HQ_NEXT:
        {
            int nnext = 1;
            if (argc > 0)
            {
                if (!sscanf(argv[0], "%d", &nnext) || nnext <= 0 || nnext > 25 /* magic number */)
                {
                    helpmod_reply(sender, returntype, "Can not advance queue: Integer [1, 25] expected");
                    return;
                }
            }
            hqueue_advance(hchan, sender, nnext);
        }
        return;
    case HQ_MAINTAIN:
        {
            int tmp;
            if (argc == 0)
            {
                helpmod_reply(sender, returntype, "Autoqueue for channel %s is currently %d (%s)", hchannel_get_name(hchan), hchan->autoqueue, hchannel_get_state(hchan, H_QUEUE_MAINTAIN));
                return;
            }
            if (!sscanf(argv[0], "%d", &tmp) || tmp < 0 || tmp > 25)
            {
                helpmod_reply(sender, returntype, "Can not set auto queue: Integer [0, 20] expected");
                return;
            }
            hchan->autoqueue = tmp;
            if (tmp == 0)
            {
                if (hchan->flags & H_QUEUE_MAINTAIN)
                {
                    hchan->flags &= ~(H_QUEUE_MAINTAIN);
                    helpmod_reply(sender, returntype, "Autoqueue is now disabled for channel %s", hchannel_get_name(hchan));
                }
                else
                    helpmod_reply(sender, returntype, "Autoqueue is not enabled for channel %s", hchannel_get_name(hchan));
            }
            else if (!(hchan->flags & H_QUEUE_MAINTAIN))
            {
                hchan->flags |= H_QUEUE_MAINTAIN;
                helpmod_reply(sender, returntype, "Autoqueue for channel %s activated and set to %d succesfully", hchannel_get_name(hchan), hchan->autoqueue);
            }
            else
                helpmod_reply(sender, returntype, "Autoqueue for channel %s set to %d succesfully", hchannel_get_name(hchan), hchan->autoqueue);
            hqueue_handle_queue(hchan, sender);
        }
        return;
    case HQ_LIST:
        {
            int count = hqueue_count_in_queue(hchan);
            hqueue_entry *hqueue = hqueue_get_next(hchan);

            char buffer[512];
            buffer[0] = '\0';

            helpmod_reply(sender, returntype, "Channel %s has following users in queue (%d user%s total):", hchannel_get_name(hchan), count, (count==1)?"":"s");

            for (;hqueue;hqueue = hqueue_get_next(NULL))
            {
                if (strlen(buffer) >= 250)
                {
                    helpmod_reply(sender, returntype, "%s", buffer);
                    buffer[0] = '\0';
                }
                if (hqueue_on_queue(hqueue))
                    sprintf(buffer+strlen(buffer) /* :) */, "%s (%s@%s) [%s] ", huser_get_nick(hqueue->hchanuser->husr), huser_get_ident(hqueue->hchanuser->husr), huser_get_host(hqueue->hchanuser->husr), helpmod_strtime(time(NULL) - hqueue->hchanuser->time_joined));
            }
            if  (buffer[0])
                helpmod_reply(sender, returntype, "%s", buffer);
        }
        return;
    case HQ_NONE: /* if no parameters are given print the summary */
    case HQ_SUMMARY:
        {
            int count_on = hqueue_count_in_queue(hchan);
            int count_off = hqueue_count_off_queue(hchan);
            int average = hqueue_average_time(hchan);

            helpmod_reply(sender, returntype, "Channel %s has %d user%s in queue, %d user%s being helped, average time in queue %s", hchannel_get_name(hchan), count_on, (count_on==1)?"":"s", count_off, (count_off==1)?"":"s", helpmod_strtime(average));
        }
        return;
    case HQ_RESET:
        {
            hchannel_user *hchanuser = hchan->channel_users;
            for (;hchanuser;hchanuser = hchanuser->next)
            {
                if (huser_get_level(hchanuser->husr) == H_PEON)
                {
                    huser_channel *huserchan = huser_on_channel(hchanuser->husr, hchan);
                    assert (huserchan != NULL);
                    if (huserchan->flags & HCUMODE_VOICE)
                        helpmod_channick_modes(hchanuser->husr, hchan, MC_DEVOICE, HLAZY);
                    huserchan->flags &= ~(HQUEUE_DONE | H_IDLE_WARNING);
                }
            }
            if (!IsModerated(hchan->real_channel))
                helpmod_simple_modes(hchan, CHANMODE_MODERATE, 0, 0);
            helpmod_message_channel(hchan, "Channel queue has been reset");
            helpmod_reply(sender, returntype, "Queue for channel %s has been reset", hchannel_get_name(hchan));
        }
        return;
    }
}