|This function is provided by the external module Basic IRC Module. You must install this module to use this function.|
This function returns the hostmask of a specified user in format user@host. The specified ircbot has to be in one of the channels the specified user is in.
string ircGetUserHost ( ircbot theBot, string user )
- theBot: The ircbot which is in the channel
- user: The user whose hostmask you want to get
Returns the host of specified user if it could be retrieved, or false if it failed or invalid arguments were passed.
This example creates an ircbot called DummyBot makes it connect to a server and join a channel. It also includes an IRC command '!ban' which can be used to ban users (unable to talk or join) from IRC without kicking them from the channel.
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( "!ban" ) then local params = split ( message, string.byte (' ') ) -- params has the string "!ban" which we don't need -- params has the user name if ircIsInChannel ( theBot, channel, params ) then local userHost = ircGetUserHost ( theBot, params ) if userHost then -- if user host was successfully received local hostMask = ircFormatHost ( params .. "!" .. userHost ) if hostMask then -- and if formatting was successful ircSetChannelMode ( theBot, channel, "+b " .. hostMask ) end else ircSendMessage ( theBot, channel, "Failed to retrieve user host!" ) end end end end