|This function is provided by the external module Basic IRC Module. You must install this module to use this function.|
This function can be used to set a channel mode the specified channel. The specified ircbot often needs to have suitable privileges in order for the change to have an effect.
bool ircSetChannelMode ( ircbot theBot, string channel, string mode )
- theBot: The ircbot which is in the channel
- channel: The name of the channel on which you want to set a channel mode
- mode: The channel mode string
Note: Does not return true if a channel mode was successfully set or false if it wasn't set. You can check if the channel mode was set by using callback event_ircOnChannelMode.
This example creates an ircbot called DummyBot makes it connect to a server and join a channel. It also includes an IRC command '!limitusers' which can used to change the channel's maximum user limit.
function resourceStart ( ) theBot = ircCreateBot ( "DummyBot" ) ircConnect ( theBot, "irc.gtanet.com", 6667 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), resourceStart ) function event_ircOnConnect ( theBot ) setTimer ( ircJoinChannel, 2000, 1, theBot, "#testchannel" ) end function event_ircOnText ( theBot, channel, sender, message ) if message:find( "!limitusers" ) then local params = split ( message, string.byte (' ') ) -- params has the string "!limitusers" which we don't need -- params has the user count if tonumber( params ) then -- check if it's a number, but don't convert it to a number ircSetChannelMode ( theBot, channel, "+l " .. params ) elseif params == "off" then -- if user passes 'off' as the number, remove the limit ircSetChannelMode ( theBot, channel, "-l" ) end end end