Modules/bIRC/ircGetChannelUsers: Difference between revisions
Jump to navigation
Jump to search
(Created page with '{{ml_birc}} __NOTOC__ This function can be used to list out all the users a specified channel. ==Syntax== <syntaxhighlight lang="lua"> table ircGetChannelUsers ( ircbot theBot, string channel…') |
No edit summary |
||
Line 9: | Line 9: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theBot:''' The ircbot which is | *'''theBot:''' The ircbot which is connected to the channel | ||
*'''channel:''' The channel which users you want to get | *'''channel:''' The channel which users you want to get | ||
Line 18: | Line 18: | ||
This example adds a command ''listusers'' which can be used to print out all users in the specified channel to the console. | This example adds a command ''listusers'' which can be used to print out all users in the specified channel to the console. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function printOutUsers ( thePlayer, commandName, name, channel ) | ||
local theBot = ircGetBotByName ( name ) | local theBot = ircGetBotByName ( name ) | ||
if not theBot then | if not theBot then | ||
Line 38: | Line 38: | ||
end | end | ||
end | end | ||
addCommandHandler ( " | addCommandHandler ( "listusers", printOutUsers ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{ml_birc functions}} | {{ml_birc functions}} |
Latest revision as of 11:10, 30 July 2009
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 list out all the users a specified channel.
Syntax
table ircGetChannelUsers ( ircbot theBot, string channel )
Required Arguments
- theBot: The ircbot which is connected to the channel
- channel: The channel which users you want to get
Returns
Returns a table over all channel users. Returns an empty table if there's no users on that channel or false if invalid arguments were passed.
Example
This example adds a command listusers which can be used to print out all users in the specified channel to the console.
function printOutUsers ( thePlayer, commandName, name, channel ) local theBot = ircGetBotByName ( name ) if not theBot then outputConsole ( "There's no ircbot called " .. name .. "!", thePlayer ) else if ircIsInChannel ( theBot, channel ) then local users = ircGetChannelUsers ( theBot, channel ) if #users == 0 then outputConsole ( "There's no users on " .. channel .. "!", thePlayer ) else outputConsole ( "There is " .. #users .. " on " .. channel .. ":", thePlayer ) for key, value in ipairs ( users ) do outputConsole ( "- " .. value, thePlayer ) end end else outputConsole ( name .. " is not on " .. channel .. "!", thePlayer ) end end end addCommandHandler ( "listusers", printOutUsers )
See Also
Bot functions
Creation
Connection
Other
IRC functions
Channel
- ircGetChannelMode
- ircGetChannelTopic
- ircGetChannelUsers
- ircGetConnectedChannels
- ircJoinChannel
- ircPartChannel
- ircSetChannelMode
- ircSetChannelTopic