GLOBAL void
Channel_Init( void )
{
- CHANNEL *sc;
-
My_Channels = NULL;
My_Cl2Chan = NULL;
-
- sc = Channel_Create("&SERVER");
- if (sc) {
- Channel_SetModes(sc, "mnPt");
- Channel_SetTopic(sc, Client_ThisServer(), "Server Messages");
- }
} /* Channel_Init */
}
+/**
+ * Generate predefined persistent channels and &SERVER
+ */
GLOBAL void
Channel_InitPredefined( void )
{
- /* Generate predefined persistent channels */
-
CHANNEL *new_chan;
const struct Conf_Channel *conf_chan;
const char *c;
}
if (channel_count)
array_free(&Conf_Channels);
+
+ /* Make sure the local &SERVER channel exists */
+ if (!Channel_Search("&SERVER")) {
+ new_chan = Channel_Create("&SERVER");
+ if (new_chan) {
+ Channel_SetModes(new_chan, "mnPt");
+ Channel_SetTopic(new_chan, Client_ThisServer(),
+ "Server Messages");
+ } else
+ Log(LOG_ERR, "Failed to create \"&SERVER\" channel!");
+ } else
+ LogDebug("Required channel \"&SERVER\" already exists, ok.");
} /* Channel_InitPredefined */
}
}
+ /* Check that the client to be kicked is on the specified channel */
+ if (!Channel_IsMemberOf(chan, Target)) {
+ IRC_WriteStrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
+ Client_ID(Origin), Client_ID(Target), Name );
+ return;
+ }
+
if(Client_Type(Peer) == CLIENT_USER) {
+ /* Channel mode 'Q' and user mode 'q' on target: nobody but
+ * IRC Operators and servers can kick the target user */
+ if ((strchr(Channel_Modes(chan), 'Q')
+ || Client_HasMode(Target, 'q')
+ || Client_Type(Target) == CLIENT_SERVICE)
+ && !Client_HasMode(Origin, 'o')) {
+ IRC_WriteStrClient(Origin, ERR_KICKDENY_MSG,
+ Client_ID(Origin), Name,
+ Client_ID(Target));
+ return;
+ }
+
/* Check if client has the rights to kick target */
ptr = Channel_UserModes(chan, Peer);
target_modes = Channel_UserModes(chan, Target);
}
ptr++;
}
-
+
if(!can_kick) {
- IRC_WriteStrClient(Origin, ERR_CHANOPPRIVTOLOW_MSG,
+ IRC_WriteStrClient(Origin, ERR_CHANOPPRIVTOOLOW_MSG,
Client_ID(Origin), Name);
return;
}
}
- /* Check that the client to be kicked is on the specified channel */
- if (!Channel_IsMemberOf(chan, Target)) {
- IRC_WriteStrClient(Origin, ERR_USERNOTINCHANNEL_MSG,
- Client_ID(Origin), Client_ID(Target), Name );
- return;
- }
-
/* Kick Client from channel */
Remove_Client( REMOVE_KICK, chan, Target, Origin, Reason, true);
} /* Channel_Kick */
if (strchr(Channel_Modes(Chan), 'n') && !is_member)
return false;
+ if (strchr(Channel_Modes(Chan), 'M') && !Client_HasMode(From, 'R')
+ && !Client_HasMode(From, 'o'))
+ return false;
+
if (has_voice || is_halfop || is_op || is_chanadmin || is_owner)
return true;
if (!Can_Send_To_Channel(Chan, From)) {
if (! SendErrors)
return CONNECTED; /* no error, see RFC 2812 */
- return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG,
+ if (strchr(Channel_Modes(Chan), 'M'))
+ return IRC_WriteStrClient(From, ERR_NEEDREGGEDNICK_MSG,
+ Client_ID(From), Channel_Name(Chan));
+ else
+ return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG,
Client_ID(From), Channel_Name(Chan));
}