+---------------------------------------------------------------------------
|   PHP-IRC v2.1.1
|   ========================================================
|   by Manick
|   (c) 2001-2004 by http://sourceforge.net/projects/phpbots/
|   Contact: manick@manekian.net
|   irc: #manekian@irc.rizon.net
|   ========================================================
+---------------------------------------------------------------------------
|   > Module Command Reference
+---------------------------------------------------------------------------
|   > This program is free software; you can redistribute it and/or
|   > modify it under the terms of the GNU General Public License
|   > as published by the Free Software Foundation; either version 2
|   > of the License, or (at your option) any later version.
|   >
|   > This program is distributed in the hope that it will be useful,
|   > but WITHOUT ANY WARRANTY; without even the implied warranty of
|   > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
|   > GNU General Public License for more details.
|   >
|   > You should have received a copy of the GNU General Public License
|   > along with this program; if not, write to the Free Software
|   > Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+---------------------------------------------------------------------------
|   Changes
|   =======-------
|   > If you wish to suggest or submit an update/change to the source
|   > code, email me at manick@manekian.com with the change, and I
|   > will look to adding it in as soon as I can.
+---------------------------------------------------------------------------

The following file is a quickly put together command reference of all the functions that you can use to complement the php scripting language while writing your modules.

===============
Quick Reference (See below the quick reference for function descriptions)
===============

irc.php (Accessed with $this->ircClass->)
-----------------------------------------
array	parseModes($modeString)
string	getClientConf($var = "")
string 	getNick()
string	getServerConf($var)
string	timeFormat($time, $format)
string	getStatusString($status)
string	getClientIP($long = 1)
class	getChannelData($channel)
class	getUserData($user, $channel = "")
void	disconnect()
void	setClientConfigVar($var, $value)
void 	callWaitHandlers()
void	joinChannel($chan)
void	sendRaw($text, $force = false)
void	privMsg($who, $msg, $queue = 1)
void	action($who, $msg, $queue = 1)
void	notice($who, $msg, $queue = 1)
void	log($text)
void	addQuery($host, $port, $query, $line, $class, $function)
int	getStatusRaw()
bool	changeMode($chan, $act, $mode, $user)
bool	isOnline($nick, $chan)
bool	isMode($nick, $channel, $mode)
bool	isChanMode($channel, $mode, $extra = "")
bool	hostMasksMatch($mask1, $mask2)
	
timers.php (Accessed with $this->timerClass->)
----------
class	addTimer($name, $class, $function, $args, $interval, $runOnce = false)
class	getTimers()
void	removeTimer($timer) (can be either object or name)

database.php (Accessed with $this->db->)
------------
array	queryFetch($query)
array	fetchArray($object)
array	fetchRow($object)
string	getError()
bool	isConnected()
int	lastID()
int	numRows($toFetch)
int	numQueries()
void	close()
object	query($query)

dcc.php (Accessed with $this->dccClass->)
-------
array	getDccList()
int	getDownloadCount()
int	getUploadCount()
int	getChatCount()
int	getBytesDown()
int	getBytesUp()
int	addChat($nick, $host, $port, $admin, $handler)
int	addFile($nick, $host, $port, $type, $filename, $size)
class	getDcc($dcc)
void	dccInform($text, $from = null)

chat.php
----------
void	disconnect($msg = "")
void	dccSend($msg)

file.php
----------
void	disconnect($msg = "")

Useful Static Routines
-----------------------
string	socket::generatePostQuery($query, $host, $path, $httpVersion)
string	socket::generateGetQuery($query, $host, $path, $httpVersion)
string	irc::intToSizeString($size)
string	irc::myStrToLower($text)
string	irc::myStrToUpper($text)
string	irc::randomHash()
array	irc::multiLine($text)


=========================
Full Function Definitions
=========================

irc.php (Accessed with $this->ircClass->)
-----------------------------------------

-------------------------------
array	parseModes($modeString)
-------------------------------

Mode strings usually come from the $line['params'] variable.  However, they look like this:

+o-b Manick blah!*@*

This is a real mess to parse.  Thus, this function takes the line and returns an array of each mode being operated.  The format is as follows:

$modesArray = array(

  [0] = array( 'ACTION' => '+', 
               'MODE' => 'o',
               'EXTRA' => 'Manick',
               'TYPE' => USER_MODE,
             )

  [1] = array( 'ACTION' => '-', 
               'MODE' => 'b',
               'EXTRA' => 'blah!*@*',
               'TYPE' => CHANNEL_MODE,
             )
)


--------------------------------
string	getClientConf($var = "") 
--------------------------------

Will return the corresponding value for the setting of $var in bot.conf.  If $var == "", the full configuration array is returned as an array.  Also, if the setting does not exist in the configuration, this function will return an empty string, "".


--------------------------------
string 	getNick()
--------------------------------

Returns the bots current, IRC recognized nick.


--------------------------------
string	getServerConf($var)
--------------------------------

When connecting to a server, it will send these lines upon connection:
NETWORK=Rizon STATUSMSG=@%+ MODES=4 CHANLIMIT=#:30 MAXCHANNELS=30 MAXLIST=beI:100 MAXBANS=100 MAXTARGETS=4 NICKLEN=30 TOPICLEN=400 KICKLEN=400 CHANNELLEN=50 AWAYLEN=90 are supported by this server
CHANTYPES=# KNOCK EXCEPTS INVEX PREFIX=(ohv)@%+ CHANMODES=eIb,k,l,cimnpstMNORZ CASEMAPPING=rfc1459 CALLERID WALLCHOPS FNC PENALTY ETRACE are supported by this server

(These are just samples).  So, you can retrieve the value for say, CHANMODES by doing this:

getServerConf("CHANMODES");

This will return a string, "eIb,k,l,cimnpstMNORZ".


----------------------------------
string	timeFormat($time, $format)
----------------------------------
Feed this thing a timestring, and a format, and it'll send back a user friendly representation of the timestamp.

for example:

timeFormat(5, "%d days, %h hours, %m minutes, %s seconds")

This will return a string, "0 days, 0 hours, 0 minutes, 5 seconds".


----------------------------------
string	getStatusString($status)
----------------------------------

After using getStatusRaw(), you can feed its value to this function, and it'll send back what it means, like "Connecting to Server..."


----------------------------------
string	getClientIP($long = 1)
----------------------------------

This function returns the IP that the bot is using.  if you specify $long as 1, then the ip address converted to long integer form is returned.


----------------------------------
class	getChannelData($channel)
----------------------------------

This will search the channel database for the channel $channel, and then if it finds it, it will return that channels object.  See the "channelLink" class in defines.php for member information.


----------------------------------
class	getUserData($user, $channel = "")
----------------------------------

If a channel is specified, this will search the channel for the specified user's data.  If it is found, it will return it as an object.  See the "memberLink" class in defines.php for member information.  If no channel is specified, this will search the entire channel database until the member is found, and then return that object.


----------------------------------
void	disconnect()
----------------------------------

Disconnect the bot from the server...


----------------------------------
void	setClientConfigVar($var, $value)
----------------------------------

This will overwrite a configuration setting from bot.conf that the bot is currently using.  Self-explanitory.


----------------------------------
void 	callWaitHandlers()
----------------------------------

Should be depreciated now that we have addQuery, but just incase... if you are going to run a function that will take a long time, call this function within your loops to keep the server queue going and data being processed.  Of course, it won't respond to server pings or anything.  If you need to write a function that takes more than 3 minutes, go use some other scripting langauge.


----------------------------------
void	joinChannel($chan)
----------------------------------

Join the channel $chan


----------------------------------
void	sendRaw($text, $force = false)
----------------------------------

Send the raw text $text to the server.  If $force is true, then the data is sent RIGHT away, it totally bypasses the queue, everything.  It goes right to the send function, even through the socket class.  Use this if you need lightning fast responses, such as writing a channel guard script.


----------------------------------
void	privMsg($who, $msg, $queue = 1)
----------------------------------

$who = nick of user/name of channel

Send text to a channel or user.  If $queue is 1, then the data will be put at the end of the text queue, if it is 0, it'll be pushed onto the beginning of the queue.

----------------------------------
void	action($who, $msg, $queue = 1)
----------------------------------

Same as privMsg... emulates the /me command from mIRC


----------------------------------
void	notice($who, $msg, $queue = 1)
----------------------------------

Same as privMsg, except a notice.


----------------------------------
void	log($text)
----------------------------------

Write something to the log file.


----------------------------------
void	addQuery($host, $port, $query, $line, $class, $function)
----------------------------------

Also make sure you read the text about this function in the readme.txt, "Querying remote servers".  This function takes 6 arguments.

$host = the host machine you want to connect to
$port = the port you want to connect to
$query = the raw data that will be sent to the server upon connection
$line = the $line argument that was passed to your module's function (just pass this right along with addQuery)
$class = usually '$this'..
$function = the function to run after the query is complete.

See the Section 9 of readme.txt for information related to writing 'query' function types.


----------------------------------
int	getStatusRaw()
----------------------------------

Returns an integer corresponding to current server status.  See defines.php for meanings


----------------------------------
bool	changeMode($chan, $act, $mode, $user)
----------------------------------

Changes the mode of $user on $chan

$act = either "+" or "-"
$mode = some mode, like "o" (ops), or "b" (ban), or something else.
$user = whatever the mode is being applied to


----------------------------------
bool	isOnline($nick, $chan)
----------------------------------

Send back whether the nick is on the channel $chan (true or false)


----------------------------------
bool	isMode($nick, $channel, $mode)
----------------------------------

See if some $user has some $mode activated on him in $channel

$user = nick of user
$mode = any mode, such as "o", "h", "v"


----------------------------------
bool	isChanMode($channel, $mode, $extra = "")
----------------------------------

Sends back whether a specific mode is set in a channel

$mode = "b" or "s" or any other chan mode

$extra = (if you're using "b" for $mode, specify mask here)


----------------------------------
bool	hostMasksMatch($mask1, $mask2)
----------------------------------

Use this to determine whether two host masks match

	
timers.php (Accessed with $this->timerClass->)
----------------------------------------------

----------------------------------
class	addTimer($name, $class, $function, $args, $interval, $runOnce = false)
----------------------------------

Add a timer.  Please view the readme.txt documentation on this.

----------------------------------
class	getTimers()
----------------------------------

This function will return a pointer to all the active timers.  See the class "timer" in defines.php for member information.


----------------------------------
void	removeTimer($timer) (can be either object or name)
----------------------------------

Remove a timer $timer <-- can either be the name of the timer, or the timer object itself.


database.php (Accessed with $this->db->)
------------------------------------------

----------------------------------
array	queryFetch($query)
----------------------------------

Runs a query and returns the first row.  Basically does query() and then mysql_fetch_array()


----------------------------------
array	fetchArray($object)
----------------------------------

Does mysql_fetch_array() (see php.net for help)


----------------------------------
array	fetchRow($object)
----------------------------------

Does mysql_fetch_row()


----------------------------------
string	getError()
----------------------------------

Does mysql_error();


----------------------------------
bool	isConnected()
----------------------------------

Returns whether the database is connected

----------------------------------
int	lastID()
----------------------------------

Gets the last inserted 'id' row from the database.


----------------------------------
int	numRows($toFetch)
----------------------------------

Does mysql_num_rows()


----------------------------------
int	numQueries()
----------------------------------

sends back an integer of all the queries since the database class was spawned.


----------------------------------
void	close()
----------------------------------

Closes the database connection


----------------------------------
object	query($query)
----------------------------------

Runs a query, and returns the result as an object.


dcc.php (Accessed with $this->dccClass->)
-----------------------------------------

----------------------------------
array	getDccList()
----------------------------------

Returns an array of all current dcc's in progress (chat and file)


----------------------------------
int	getDownloadCount()
----------------------------------

Number of all current downloads


----------------------------------
int	getUploadCount()
----------------------------------

Number of all current uploads


----------------------------------
int	getChatCount()
----------------------------------

Number of all current dcc chat sessions


----------------------------------
int	getBytesDown()
----------------------------------

Returns number of bytes downloaded since bot was started


----------------------------------
int	getBytesUp()
----------------------------------

Returns number of bytes uploaded since bot was started


----------------------------------
int	addChat($nick, $host, $port, $admin, $handler)
----------------------------------

Use this to create a dcc chat session.

$nick = nick of user to chat with
$host = host of user to chat with
$port = port to connect to
$admin = whether the user is admin (use admin dcc chat administration)
$handler = null, usually, unless you are creating a custom dcc chat handler.  See readme.txt for more information.

If $host or $port is null, then addChat will think you are setting up a listening connection, otherwise it will try to connect to the host/port specified.


----------------------------------
int	addFile($nick, $host, $port, $type, $filename, $size)
----------------------------------

Send a file to someone, or recieve a file.

$nick = nick of person sending/receiving file
$host = host of person sending/receiving file
$port = port of transfer
$type = either UPLOAD or DOWNLOAD
$filename = full filename with full path to file
$size = size of the file, can be null if its an UPLOAD type.

See readme.txt for more information regarding file transfers.


----------------------------------
class	getDcc($dcc)
----------------------------------

$dcc = sockInt of the transfer

Returns dcc object for some sockInt, see fileserver.php for example.


----------------------------------
void	dccInform($text)
----------------------------------

Send a message to all administrators


chat.php
----------

----------------------------------
void	disconnect($msg = "")
----------------------------------

End the chat session

----------------------------------
void	dccSend($msg)
----------------------------------

Send text to the user


file.php
----------

----------------------------------
void	disconnect($msg = "")
----------------------------------

End the dcc file transfer session


Useful Static Routines
-----------------------

----------------------------------
string	socket::generatePostQuery($query, $host, $path, $httpVersion = "")
----------------------------------

Takes a query, like so:

$query = "search=blah&somesetting=5";

And turns it into a POST query you can send off to addQuery

$host = host of server you will be accessing, like "www.manekian.com"
$path = script + path of script you will be accessing, like "/search.php" or "/index.php", or just "/"
$httpVersion, you can ignore this, but sometimes you might want to set this to "1.0"


----------------------------------
string	socket::generateGetQuery($query, $host, $path, $httpVersion)
----------------------------------

Same as generatePostQuery except with Get String


----------------------------------
string	irc::intToSizeString($size)
----------------------------------

Takes a large size, and then changes it into MB, GB, KB, depending on the size.


----------------------------------
string	irc::myStrToLower($text)
----------------------------------

RFC1459 complient strtolower()


----------------------------------
string	irc::myStrToUpper($text)
----------------------------------

RFC1459 complient strtolower()


----------------------------------
string	irc::randomHash()
----------------------------------

Generates a 32 char random md5 hash


----------------------------------
array	irc::multiLine($text)
----------------------------------

Feed this a huge text string, and it will split it up into 255 max char increment lines you can send to the irc server.  It returns an array of all of these.



