- if ((Req->argc < 1) || (Req->argc > 2))
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command);
-
- if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
- else from = Client;
- if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
-
- /* Welcher Channel? */
- chan = Channel_Search( Req->argv[0] );
- if( ! chan ) return IRC_WriteStrClient( from, ERR_NOSUCHCHANNEL_MSG, Client_ID( from ), Req->argv[0] );
-
- /* Ist der User Mitglied in dem Channel? */
- if( ! Channel_IsMemberOf( chan, from )) return IRC_WriteStrClient( from, ERR_NOTONCHANNEL_MSG, Client_ID( from ), Req->argv[0] );
-
- if( Req->argc == 1 )
- {
+ IRC_SetPenalty(Client, 1);
+
+ _IRC_ARGC_GE_OR_RETURN_(Client, Req, 1)
+ _IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
+ _IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
+
+ chan = Channel_Search(Req->argv[0]);
+ if (!chan)
+ return IRC_WriteStrClient(from, ERR_NOSUCHCHANNEL_MSG,
+ Client_ID(from), Req->argv[0]);
+
+ /* Only remote servers and channel members are allowed to change the
+ * channel topic, and IRC opreators when the Conf_OperCanMode option
+ * is set in the server configuration. */
+ if (Client_Type(Client) != CLIENT_SERVER) {
+ topic_power = Client_HasMode(from, 'o');
+ if (!Channel_IsMemberOf(chan, from)
+ && !(Conf_OperCanMode && topic_power))
+ return IRC_WriteStrClient(from, ERR_NOTONCHANNEL_MSG,
+ Client_ID(from), Req->argv[0]);
+ } else
+ topic_power = true;
+
+ if (Req->argc == 1) {