mirror of
https://github.com/anope/anope.git
synced 2026-07-02 04:46:39 +02:00
fe39b96db7
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1977 5417fbe8-f217-4b02-8779-1006273d7864
155 lines
3.4 KiB
C
155 lines
3.4 KiB
C
/* NickServ core functions
|
|
*
|
|
* (C) 2003-2009 Anope Team
|
|
* Contact us at team@anope.org
|
|
*
|
|
* Please read COPYING and README for further details.
|
|
*
|
|
* Based on the original code of Epona by Lara.
|
|
* Based on the original code of Services by Andy Church.
|
|
*
|
|
* $Id$
|
|
*
|
|
*/
|
|
/*************************************************************************/
|
|
|
|
#include "module.h"
|
|
|
|
void myNickServHelp(User *u);
|
|
NickAlias *makenick(const char *nick);
|
|
|
|
class CommandNSForbid : public Command
|
|
{
|
|
public:
|
|
CommandNSForbid() : Command("FORBID", 1, 2)
|
|
{
|
|
}
|
|
|
|
CommandReturn Execute(User *u, std::vector<std::string> ¶ms)
|
|
{
|
|
NickAlias *na;
|
|
const char *nick = params[0].c_str();
|
|
const char *reason = params.size() > 1 ? params[1].c_str();
|
|
|
|
/* Assumes that permission checking has already been done. */
|
|
if (ForceForbidReason && !reason) {
|
|
this->OnSyntaxError(u);
|
|
return MOD_CONT;
|
|
}
|
|
|
|
if (readonly)
|
|
notice_lang(s_NickServ, u, READ_ONLY_MODE);
|
|
if (!ircdproto->IsNickValid(nick))
|
|
{
|
|
notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick);
|
|
return MOD_CONT;
|
|
}
|
|
if ((na = findnick(nick)))
|
|
{
|
|
if (NSSecureAdmins && nick_is_services_admin(na->nc) && !is_services_root(u))
|
|
{
|
|
notice_lang(s_NickServ, u, PERMISSION_DENIED);
|
|
return MOD_CONT;
|
|
}
|
|
delnick(na);
|
|
}
|
|
na = makenick(nick);
|
|
if (na)
|
|
{
|
|
na->status |= NS_FORBIDDEN;
|
|
na->last_usermask = sstrdup(u->nick);
|
|
if (reason)
|
|
na->last_realname = sstrdup(reason);
|
|
|
|
na->u = finduser(na->nick);
|
|
if (na->u)
|
|
na->u->na = na;
|
|
|
|
if (na->u)
|
|
{
|
|
notice_lang(s_NickServ, na->u, FORCENICKCHANGE_NOW);
|
|
collide(na, 0);
|
|
}
|
|
|
|
|
|
if (ircd->sqline)
|
|
ircdproto->SendSQLine(na->nick, reason ? reason : "Forbidden");
|
|
|
|
if (WallForbid)
|
|
ircdproto->SendGlobops(s_NickServ, "\2%s\2 used FORBID on \2%s\2", u->nick, nick);
|
|
|
|
alog("%s: %s set FORBID for nick %s", s_NickServ, u->nick, nick);
|
|
notice_lang(s_NickServ, u, NICK_FORBID_SUCCEEDED, nick);
|
|
send_event(EVENT_NICK_FORBIDDEN, 1, nick);
|
|
}
|
|
else
|
|
{
|
|
alog("%s: Valid FORBID for %s by %s failed", s_NickServ, nick, u->nick);
|
|
notice_lang(s_NickServ, u, NICK_FORBID_FAILED, nick);
|
|
}
|
|
return MOD_CONT;
|
|
}
|
|
|
|
bool OnHelp(User *u, const std::string &subcommand)
|
|
{
|
|
if (!is_services_admin(u))
|
|
return false;
|
|
|
|
notice_lang(s_NickServ, u, NICK_SERVADMIN_HELP_FORBID);
|
|
return true;
|
|
}
|
|
|
|
void OnSyntaxError(User *u)
|
|
{
|
|
syntax_error(s_NickServ, u, "FORBID", ForceForbidReason ? NICK_FORBID_SYNTAX_REASON : NICK_FORBID_SYNTAX);
|
|
}
|
|
};
|
|
|
|
class NSForbid : public Module
|
|
{
|
|
public:
|
|
NSForbid(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
|
{
|
|
this->SetAuthor("Anope");
|
|
this->SetVersion("$Id$");
|
|
this->SetType(CORE);
|
|
|
|
this->AddCommand(NICKSERV, new CommandNSForbid(), MOD_UNIQUE);
|
|
|
|
this->SetNickHelp(myNickServHelp);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Add the help response to anopes /ns help output.
|
|
* @param u The user who is requesting help
|
|
**/
|
|
void myNickServHelp(User *u)
|
|
{
|
|
if (is_services_admin(u))
|
|
notice_lang(s_NickServ, u, NICK_HELP_CMD_FORBID);
|
|
}
|
|
|
|
NickAlias *makenick(const char *nick)
|
|
{
|
|
NickAlias *na;
|
|
NickCore *nc;
|
|
|
|
/* First make the core */
|
|
nc = new NickCore();
|
|
nc->display = sstrdup(nick);
|
|
slist_init(&nc->aliases);
|
|
insert_core(nc);
|
|
alog("%s: group %s has been created", s_NickServ, nc->display);
|
|
|
|
/* Then make the alias */
|
|
na = new NickAlias;
|
|
na->nick = sstrdup(nick);
|
|
na->nc = nc;
|
|
slist_add(&nc->aliases, na);
|
|
alpha_insert_alias(na);
|
|
return na;
|
|
}
|
|
|
|
MODULE_INIT("ns_forbid", NSForbid)
|