1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-13 02:10:27 +00:00

Add channel mode N (normal user can't change nick while on channel)

This commit is contained in:
Ian Chard 2015-06-24 15:37:56 +01:00
parent d28d838cb9
commit f64cb901ef
3 changed files with 17 additions and 0 deletions

View File

@ -172,6 +172,7 @@ GLOBAL bool
IRC_NICK( CLIENT *Client, REQUEST *Req )
{
CLIENT *intr_c, *target, *c;
CHANNEL *chan;
char *nick, *user, *hostname, *modes, *info;
int token, hops;
@ -259,6 +260,20 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
Client_SetType( Client, CLIENT_GOTNICK );
} else {
/* Nickname change */
/* Check that the user isn't on any channels set +N */
chan = Channel_First();
while (chan) {
if(Channel_IsMemberOf(chan, Client) &&
Channel_HasMode(chan, 'N') &&
!Client_HasMode(Client, 'o'))
return IRC_WriteErrClient(Client,
ERR_UNAVAILRESOURCE_MSG,
Client_ID(Client),
Channel_Name(chan));
chan = Channel_Next(chan);
}
Change_Nick(Client, target, Req->argv[0],
Client_Type(Client) == CLIENT_USER ? true : false);
IRC_SetPenalty(target, 2);

View File

@ -580,6 +580,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
case 'M': /* Only identified nicks can write */
case 'm': /* Moderated */
case 'n': /* Only members can write */
case 'N': /* Can't change nick while on this channel */
case 'Q': /* No kicks */
case 't': /* Topic locked */
if(is_oper || is_machine || is_owner ||

View File

@ -122,6 +122,7 @@
#define ERR_NICKNAMETOOLONG_MSG "432 %s %s :Nickname too long, max. %u characters"
#define ERR_FORBIDDENNICKNAME_MSG "432 %s %s :Nickname is forbidden/blocked"
#define ERR_NICKNAMEINUSE_MSG "433 %s %s :Nickname already in use"
#define ERR_UNAVAILRESOURCE_MSG "437 %s :Cannot change nickname while on %s(+N)"
#define ERR_USERNOTINCHANNEL_MSG "441 %s %s %s :They aren't on that channel"
#define ERR_NOTONCHANNEL_MSG "442 %s %s :You are not on that channel"
#define ERR_USERONCHANNEL_MSG "443 %s %s %s :is already on channel"