Merhaba Arkadaşlar,
Modulun amacı komut ile kullanıcıların rumuzlarını değiştirebiliyorsunuz..
Örn; /chgnick Nick Nick2 gibi..
Modulun amacı komut ile kullanıcıların rumuzlarını değiştirebiliyorsunuz..
Örn; /chgnick Nick Nick2 gibi..
Kod:
#include "macros.h"
#include "config.h"
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#endif
#include <fcntl.h>
#include "h.h"
#include "proto.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif
#define MSG_CHGNICK "CHGNICK"
#define TOK_CHGNICK "YZ"
DLLFUNC int m_chgnick(aClient *cptr, aClient *sptr, int parc, char *parv[]);
ModuleHeader MOD_HEADER(m_chgident)
= {
"chgnick", /* Name of module */
"$Id$", /* Version */
"/change nicknames", /* Short description of module */
"3.2-b8-1",
NULL
};
DLLFUNC int MOD_INIT(m_chgnick)(ModuleInfo *modinfo)
{
/* extern variable to export m_chgident_info to temporary
ModuleHeader *modulebuffer;
the module_load() will use this to add to the modules linked
list
*/
/*
* We call our add_Command crap here
*/
add_Command(MSG_CHGNICK, TOK_CHGNICK, m_chgnick, MAXPARA);
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
DLLFUNC int MOD_LOAD(m_chgnick)(int module_load)
{
return MOD_SUCCESS;
}
DLLFUNC int MOD_UNLOAD(m_chgnick)(int module_unload)
{
if (del_Command(MSG_CHGNICK, TOK_CHGNICK, m_chgnick) < 0)
{
sendto_realops("Failed to delete commands when unloading %s",
MOD_HEADER(m_chgnick).name);
}
return MOD_SUCCESS;
}
/*
* m_chgident - 12/07/1999 (two months after I made SETIDENT) - Stskeeps
* :prefix CHGIDENT <nick> <new identname>
* parv[0] - sender
* parv[1] - nickname
* parv[2] - identname
*
*/
int m_chgnick(aClient *cptr, aClient *sptr, int parc, char *parv[])
{
aClient *acptr;
aClient *ocptr;
char *s;
int legalident = 1;
if (MyClient(sptr) && !IsAnOper(sptr))
{
sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]);
return 0;
}
#ifdef DISABLE_USERMOD
if (MyClient(sptr))
{
sendto_one(sptr, err_str(ERR_DISABLED), me.name, sptr->name, "CHGNICK",
"This command is disabled on this server");
return 0;
}
#endif
if ((parc < 3) || !*parv[2])
{
sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, sptr->name, "CHGNICK");
return 0;
}
if (strlen(parv[2]) > (USERLEN))
{
sendnotice(sptr, "*** ChgNick Error: Requested ident too long -- rejected.");
return 0;
}
/* illegal?! */
for (s = parv[2]; *s; s++)
{
if ((*s == '~') && (s == parv[2]))
continue;
if (!isallowed(*s))
{
legalident = 0;
}
}
if (legalident == 0)
{
sendnotice(sptr, "*** /ChgNick Error: A ident may contain a-z, A-Z, 0-9, '-' & '.' - Please only use them");
return 0;
}
if ((acptr = find_person(parv[1], NULL)))
{
DYN_LOCAL(char, did_parts, acptr->user->joined);
if (MyClient(sptr) && (IsLocOp(sptr) && !MyClient(acptr)))
{
sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name,
parv[0]);
DYN_FREE(did_parts);
return 0;
}
switch (UHOST_ALLOWED)
{
case UHALLOW_NEVER:
if (MyClient(sptr))
{
sendto_one(sptr, err_str(ERR_DISABLED), me.name, sptr->name, "CHGNICK",
"This command is disabled on this server");
DYN_FREE(did_parts);
return 0;
}
break;
case UHALLOW_ALWAYS:
break;
case UHALLOW_NOCHANS:
if (IsPerson(acptr) && MyClient(sptr) && acptr->user->joined)
{
sendnotice(sptr, "*** /ChgNick can not be used while %s is on a channel", acptr->name);
DYN_FREE(did_parts);
return 0;
}
break;
case UHALLOW_REJOIN:
rejoin_doparts(acptr, did_parts);
/* join sent later when the ident has been changed */
break;
}
if (!IsULine(sptr))
{
sendto_snomask(SNO_EYES,
"%s changed the virtual nick of %s (%s@%s) to be %s",
sptr->name, acptr->name, acptr->user->username,
GetHost(acptr), parv[2]);
/* Logging ability added by XeRXeS */
ircd_log(LOG_CHGCMDS,
"CHGIDENT: %s changed the virtual nick of %s (%s@%s) to be %s",
sptr->name, acptr->name, acptr->user->username,
GetHost(acptr), parv[2]);
}
if ((ocptr = find_client(parv[2], NULL))) /* Collision */
{
sendnotice(sptr,"***/ChgNick failed -- nick collision",acptr->name);
return 0;
}
sendto_serv_butone_token(cptr, sptr->name,
MSG_CHGNICK,
TOK_CHGNICK, "%s %s", acptr->name, parv[2]);
//acptr->lastnick = TS2ts(parv[3]);
do_nick_name(parv[2]);
sendto_common_channels(acptr, ":%s NICK :%s", parv[1], parv[2]);
add_history(acptr, 1);
(void)del_from_client_hash_table(acptr->name, acptr);
hash_check_watch(acptr, RPL_LOGOFF);
sendto_snomask(SNO_NICKCHANGE,
"*** Notice -- %s (%s@%s) has been forced to change his/her nickname to %s",
acptr->name, acptr->user->username, acptr->user->realhost, parv[2]);
RunHook2(HOOKTYPE_LOCAL_NICKCHANGE, acptr, parv[2]);
strlcpy(acptr->name, parv[2], sizeof acptr->name);
add_to_client_hash_table(parv[2], acptr);
hash_check_watch(acptr, RPL_LOGON);
return 0;
}
else
{
sendto_one(sptr, err_str(ERR_NOSUCHNICK), me.name, sptr->name,
parv[1]);
return 0;
}
return 0;
}
