Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: anope_cmd_ban  (Read 8656 times)

0 Members and 1 Guest are viewing this topic.

Tom65789

  • Anope User
  • Offline Offline
  • Posts: 343
    • www.t65789.co.uk
anope_cmd_ban
« on: May 19, 2006, 09:40:54 PM »

was just coding and think it would be helpful if we had a anope_cmd_ban to work the like bot_raw_ban on the !kb stuff.

Pieter Bootsma

  • Team
  • *
  • Offline Offline
  • Posts: 189
    • http://geniusdex.net/
(No subject)
« Reply #1 on: May 20, 2006, 08:57:50 AM »

What's the use? Anope by default won't ban without a bot in the channel. If you have a module which can ban without a BotServ bot, it's not a big deal to write it yourself either ;)
Logged

Tom65789

  • Anope User
  • Offline Offline
  • Posts: 343
    • www.t65789.co.uk
(No subject)
« Reply #2 on: May 20, 2006, 10:33:01 AM »

its only because i couldnt be bothered to write an extra 10 lines ish lol. but yeah but when i say work like bot_raw_ban i mean so you could put it for other services so like bot_raw_ban bans the users host then kicks them but only works for BotServ bots. Whereas if i wanted to do a command like that for ChanServ like /msg ChanServ KICKBAN [nick] [reason] then have anope_cmd_ban rather than something like this for what i did:

Code: [Select]

static int do_kb_user(User *u, ChannelInfo *ci, char* params, char* reason)
{
Channel *c = ci->c;
User *u2;
int is_same, exists;
char *av[2];

if (!params) {
params = u->nick;
}

is_same = (params == u->nick) ? 1 : (stricmp(params, u->nick) == 0);

if (is_same) {
u2 = u;
exists = 1;
} else
exists = ((u2 = finduser(params)) ? 1 : 0);

if (!is_same ? !check_access(u, ci, CA_BAN) : !check_access(u, ci, CA_BANME)) {
moduleNoticeLang(s_ChanServ, u, LANG_PERMISSION_DENIED, u->nick, ci->name);
} else if (!is_same && exists && (ci->flags & CI_PEACE) && (get_access(u2, ci) >= get_access(u, ci))) {
moduleNoticeLang(s_ChanServ, u, LANG_PERMISSION_DENIED, u->nick, ci->name);
/**
* Dont ban the user on channels where he is excepted
* to prevent services <-> server wars.
**/
} else if (exists && (ircd->except && is_excepted(ci, u2))) {
notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name);
} else if (!exists && (ircd->except && is_excepted_mask(ci, params))) {
notice_lang(s_ChanServ, u, CHAN_EXCEPTED, params, ci->name);
} else if (exists && ((ircd->protectedumode && is_protected(u2)) && !is_founder(u, ci))) {
moduleNoticeLang(s_ChanServ, u, LANG_PERMISSION_DENIED, u->nick, ci->name);
} else if (exists) {
char mask[BUFSIZE];

do_up_down(u2, ci, "down");

av[0] = sstrdup("+b");
get_idealban(ci, u2, mask, sizeof(mask));
av[1] = sstrdup(mask);
anope_cmd_mode(s_ChanServ, c->name, "+b %s", av[1]);
        if (!reason && !is_protected(u2))
             anope_cmd_kick(s_ChanServ, ci->name, params, "Requested!");
        else if (!is_protected(u2))
             anope_cmd_kick(s_ChanServ, ci->name, params, reason);
chan_set_modes(s_ChanServ, c, 2, av, 1);

} else {
/* If could be a hostmask.. set whatever we get */
moduleNoticeLang(s_ChanServ, u, LANG_USER_NOT_ON_CHANNEL, params, ci->name);
}

if (av[0]) free(av[0]);
if (av[1]) free(av[1]);

return MOD_CONT;
}


could replace some of that with a simple anope_cmd_ban. and that code is a mess lol.

[Edited on 20-5-2006 by Tom65789]

Trystan Scott Lee

  • Contributor
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 343
(No subject)
« Reply #3 on: May 20, 2006, 02:48:29 PM »

At best such  a function would cover

av[0] = sstrdup("+b");
get_idealban(ci, u2, mask, sizeof(mask));
av[1] = sstrdup(mask);
anope_cmd_mode(s_ChanServ, c->name, "+b %s", av[1]);
chan_set_modes(s_ChanServ, c, 2, av, 1);

kicking the user would be more of a inclusive around something better called anope_cmd_kickban()
Logged
my God my tourniquet, return to me salvation

Tom65789

  • Anope User
  • Offline Offline
  • Posts: 343
    • www.t65789.co.uk
(No subject)
« Reply #4 on: May 20, 2006, 08:11:13 PM »

hmm yeah i suppose but something or anything to reduce the amount of coding :P

av[0] = sstrdup("+b");
get_idealban(ci, u2, mask, sizeof(mask));
av[1] = sstrdup(mask);
anope_cmd_mode(s_ChanServ, c->name, "+b %s", av[1]);
chan_set_modes(s_ChanServ, c, 2, av, 1);

im already using that bit as you can tell :)

[Edited on 20-5-2006 by Tom65789]
Pages: [1]   Go Up