/* $ModDesc: Provides the NICKLOCK command, allows an oper to chage a users nick and lock them to it until they quit */
-Server *Srv;
+static Server *Srv;
class cmd_nicklock : public command_t
{
}
if (Srv->IsNick(std::string(parameters[1])))
{
- server = user->server;
- me = Srv->GetServerName().c_str();
-
- if (server == me)
- {
- // give them a lock flag
- Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
- Srv->ChangeUserNick(source,std::string(parameters[1]));
- // only attempt to set their lockflag after we know the change succeeded
- source = Srv->FindNick(std::string(parameters[1]));
- if (source)
- source->Extend("nick_locked", "ON");
- }
- else
- {
- WriteServ(user->fd,"947 %s %s :Can't lock the nickname of a non-local user",user->nick,source->nick);
- }
+ // give them a lock flag
+ Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
+ Srv->ChangeUserNick(source,std::string(parameters[1]));
+ // only attempt to set their lockflag after we know the change succeeded
+ source = Srv->FindNick(std::string(parameters[1]));
+ if (source)
+ source->Extend("nick_locked", "ON");
}
}
}
void Implements(char* List)
{
- List[I_OnUserPreNick] = List[I_OnUserQuit] = 1;
+ List[I_OnUserPreNick] = List[I_OnUserQuit] = List[I_OnCleanup] = 1;
}
virtual int OnUserPreNick(userrec* user, std::string newnick)
return 0;
}
- virtual void OnUserQuit(userrec* user, std::string reason)
- {
- user->Shrink("nick_locked");
- }
+ virtual void OnUserQuit(userrec* user, std::string reason)
+ {
+ user->Shrink("nick_locked");
+ }
+ virtual void OnCleanup(int target_type, void* item)
+ {
+ if(target_type == TYPE_USER)
+ {
+ userrec* user = (userrec*)item;
+ user->Shrink("nick_locked");
+ }
+ }
};
// stuff down here is the module-factory stuff. For basic modules you can ignore this.