#include "module.h" void doIdentify(User *u, NickAlias *na) { if (u->nc && (u->nc == na->nc)) return; if (!(na->status & NS_IDENTIFIED) && !(na->status & NS_RECOGNIZED)) { if (na->last_usermask) delete [] na->last_usermask; na->last_usermask = new char[u->GetIdent().length() + u->GetDisplayedHost().length() + 2]; sprintf(na->last_usermask, "%s@%s", u->GetIdent().c_str(), u->GetDisplayedHost().c_str()); if (na->last_realname) delete [] na->last_realname; na->last_realname = sstrdup(u->realname); } na->status |= NS_IDENTIFIED; na->last_seen = time(NULL); u->nc = na->nc; ircdproto->SendAccountLogin(u, u->nc); ircdproto->SetAutoIdentificationToken(u); FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(u)); alog("%s: %s!%s@%s automatically identified for nick %s", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, u->nick); notice_lang(s_NickServ, u, NICK_IDENTIFY_SUCCEEDED); if (ircd->vhost) do_on_id(u); if (NSModeOnID) do_setmodes(u); if (NSForceEmail && u->nc && !u->nc->email) { notice_lang(s_NickServ, u, NICK_IDENTIFY_EMAIL_REQUIRED); notice_help(s_NickServ, u, NICK_IDENTIFY_EMAIL_HOWTO); } if (!(na->status & NS_RECOGNIZED)) check_memos(u); /* Clear any timers */ if (na->nc->flags & NI_KILLPROTECT) del_ns_timeout(na, 0); // TO_COLLIDE } EventReturn my_ghost(User *u, const std::vector ¶ms) { const char *target = params[0].c_str(); const char *passwd = params.size() > 1 ? params[1].c_str() : NULL; NickAlias *na = findnick(target); if (/* finduser(target) // target is still online || */ (!na) // target is not registered || (na->status & NS_FORBIDDEN) // target is a forbidden nick || (na->nc->flags & NI_SUSPENDED) // target is a suspended nick || (!stricmp(target, u->nick))) // dont ghost self { // do nothing } else if (passwd) { if (enc_check_password(passwd, na->nc->pass)==1) { ircdproto->SendForceNickChange(u->nick, target, time(NULL)); doIdentify(u,na); } } else { if (u->nc == na->nc || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) { ircdproto->SendForceNickChange(u->nick, target, time(NULL)); doIdentify(u,na); } } return EVENT_CONTINUE; } class NSAGhost : public Module { public: NSAGhost(const std::string &modname, const std::string &creator) : Module(modname, creator) { this->SetAuthor("DukePyrolator"); this->SetVersion("1.0alpha"); this->SetType(THIRD); ModuleManager::Attach(I_OnPostCommand, this); } void OnPostCommand(User *u, const std::string &service, const std::string &command, const std::vector ¶ms) { if (service == s_NickServ) { if (command == "GHOST") { my_ghost(u, params); } else if (command == "RELEASE") { my_ghost(u, params); } } } }; MODULE_INIT(NSAGhost)