Modules/bIRC/ircGetBotState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with '{{ml_birc}} __NOTOC__ This function is used to retrieve the current state of specified {{ml_birc|ircbot}}. ==Syntax== <syntaxhighlight lang="lua"> string ircGetBotState ( ircbot theBot ) </co…')
 
No edit summary
 
Line 16: Line 16:
*'''connecting'''
*'''connecting'''
*'''connected'''
*'''connected'''
If invalid arguments were passed, it returns ''false''.


==Example==
==Example==
This example creates an ircbot called ''DummyBot'' makes it connect to a server. During the connection progress bot's current states are printed out to the server log.
This example creates an ircbot called ''DummyBot'' and makes it connect to a server. During the connection progress bot's current states are printed out to the server log.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function resourceStart ()
function resourceStart ()

Latest revision as of 09:24, 30 July 2009

Package-x-generic.png This function is provided by the external module Basic IRC Module. You must install this module to use this function.

This function is used to retrieve the current state of specified ircbot.

Syntax

string ircGetBotState ( ircbot theBot )

Required Arguments

  • theBot: The ircbot which current state you want to get

Returns

Returns a string of the ircbot's current state. Possible values are:

  • disconnected
  • connecting
  • connected

If invalid arguments were passed, it returns false.

Example

This example creates an ircbot called DummyBot and makes it connect to a server. During the connection progress bot's current states are printed out to the server log.

function resourceStart ()
    dummyBot = ircCreateBot ( "DummyBot" )
    outputServerLog ( "DummyBot is now " .. ircGetBotState ( dummyBot ) ) -- "disconnected"
    ircConnect ( dummyBot, "irc.gtanet.com", 6667 )
    outputServerLog ( "DummyBot is now " .. ircGetBotState ( dummyBot ) ) -- "connecting"
end
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), resourceStart )

function event_ircOnConnect ( theBot )
    outputServerLog ( ircGetName ( theBot ) .. " is now " .. ircGetBotState ( theBot ) ) -- "connected"
end

See Also

Bot functions

Creation

Connection

Other

IRC functions

Channel

User

Communication

Other