/** * unban_self.C: Do not load chanserv/ban and chanserv/unban_self together. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2005-2007 William Pitcock, et al. * Rights to this code are as documented in doc/pod/license.pod. * * This file contains a ChanServ UNBAN which can only unbans the source * * $Id: unban_self.C,v 1.8 2007/09/22 14:27:27 pippijn Exp $ */ #include "atheme.h" #include #include #include static char const rcsid[] = "$Id: unban_self.C,v 1.8 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("chanserv/unban_self", false, "The Ermyth Team "); static void cs_cmd_unban (sourceinfo_t *si, int parc, char *parv[]); command_t const cs_unban = { "UNBAN", N_("Unbans you on a channel."), AC_NONE, 2, cs_cmd_unban }; E cmdvec cs_cmdtree; E helpvec cs_helptree; bool _modinit (module *m) { cs_cmdtree << cs_unban; help_addentry (cs_helptree, "UNBAN", "help/chanserv/unban", NULL); return true; } void _moddeinit () { cs_cmdtree >> cs_unban; help_delentry (cs_helptree, "UNBAN"); } static void cs_cmd_unban (sourceinfo_t *si, int parc, char *parv[]) { char *channel = parv[0]; char *target = parv[1]; channel_t *c = channel_find (channel); mychan_t *mc = mychan_t::find (channel); user_t *tu; chanban_t *cb; if (si->su == NULL) { command_fail (si, fault::noprivs, _("\2%s\2 can only be executed via IRC."), "UNBAN"); return; } if (!channel) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "UNBAN"); command_fail (si, fault::needmoreparams, _("Syntax: UNBAN <#channel>")); return; } if (target && irccasecmp (target, si->su->nick)) { command_fail (si, fault::noprivs, _("You may only unban yourself via %s."), si->service->name); if (validhostmask (target)) command_fail (si, fault::noprivs, _("Try \2/mode %s -b %s\2"), channel, target); return; } if (!mc) { command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), channel); return; } if (!c) { command_fail (si, fault::nosuch_target, _("\2%s\2 is currently empty."), channel); return; } if (!si->smu) { command_fail (si, fault::noprivs, _("You are not logged in.")); return; } if (!chanacs_source_has_flag (mc, si, CA_REMOVE)) { command_fail (si, fault::noprivs, _("You are not authorized to perform this operation.")); return; } tu = si->su; { node_t *n, *tn; char hostbuf2[BUFSIZE]; int count = 0; snprintf (hostbuf2, BUFSIZE, "%s!%s@%s", tu->nick, tu->user, tu->vhost); for (n = phandler->next_matching_ban (c, tu, 'b', c->bans.head); n != NULL; n = phandler->next_matching_ban (c, tu, 'b', tn)) { tn = n->next; cb = static_cast (n->data); logcommand (si, CMDLOG_DO, "%s UNBAN %s (for user %s)", mc->name, cb->mask, hostbuf2); modestack_mode_param (chansvs.nick, c, MTYPE_DEL, cb->type, cb->mask); chanban_delete (cb); count++; } if (count > 0) command_success_nodata (si, _("Unbanned \2%s\2 on \2%s\2 (%d ban%s removed)."), target, channel, count, (count != 1 ? "s" : "")); else command_success_nodata (si, _("No bans found matching \2%s\2 on \2%s\2."), target, channel); return; } }