Modules/IRCEcho/ircOpen

From Multi Theft Auto: Wiki
Revision as of 14:34, 13 January 2008 by VRocker (talk | contribs) (New page: __NOTOC__ Opens a connection to the specified IRC Server ==Syntax== <syntaxhighlight lang="lua"> handler ircOpen ( string hostname, int port, string nick, string channel, [ string password = ""] ) </cod...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Opens a connection to the specified IRC Server

Syntax

handler ircOpen ( string hostname, int port, string nick, string channel, [ string password = ""] )

Required arguments

  • hostname: The IRC server to connect to
  • port: The IRC server port
  • nick: The nickname you want your bot to connect as
  • channel: The channel you want the bot to join on connect

Optional arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • password: The password to enter the IRC server

Returns

Returns a pointer to the IRC connection if successful, otherwise it returns nil

Example

Example 1: This example connects to irc.gtanet.com on port 6667 as WikiTest and joins #Channel

szChans = {} --Init an array of channels for storage

function onResourceStart( res )
	if res == getThisResource() then -- If the starting resource is this one
		ircInit( ) -- Initialize the module for this resource
		pIRC = ircOpen( "irc.gtanet.com", 6667, "WikiTest", "#channel" ) -- Open the IRC connection
		if pIRC then -- If opening connection was successful
			szChans[ pIRC ] = "#channel" -- Add the channel to the table
		end
	end
end

addEventHandler( "onResourceStart", getRootElement(), onResourceStart )

See also