Class: Net_SmartIRC

Source Location: Program_Root/SmartIRC.php

Class Overview

Net_SmartIRC

Author(s):

Version:

Copyright:

Variables

Methods


Child classes:

Inherited Variables

Inherited Methods



Class Details

Tags:

[ Top ]


Class Variables

$channel =

Tags:

Type: mixed

Overrides:

[ Top ]

$nreplycodes =

Tags:

Type: mixed

Overrides:

[ Top ]

$replycodes =

Tags:

Type: mixed

Overrides:

[ Top ]

$_actionhandler = array()

Tags:

Type: mixed

Overrides:

[ Top ]

$_actionhandlerid = 0

Tags:

Type: mixed

Overrides:

[ Top ]

$_address =

Tags:

Type: mixed

Overrides:

[ Top ]

$_autoreconnect = false

Tags:

Type: mixed

Overrides:

[ Top ]

$_benchmark = false

Tags:

Type: mixed

Overrides:

[ Top ]

$_benchmark_starttime =

Tags:

Type: mixed

Overrides:

[ Top ]

$_benchmark_stoptime =

Tags:

Type: mixed

Overrides:

[ Top ]

$_channels = array()

Tags:

Type: mixed

Overrides:

[ Top ]

$_channelsynching = false

Tags:

Type: mixed

Overrides:

[ Top ]

$_ctcpversion =

Tags:

Type: mixed

Overrides:

[ Top ]

$_debug = SMARTIRC_DEBUG_NOTICE

Tags:

Type: mixed

Overrides:

[ Top ]

$_disconnecttime = 1000

Tags:

Type: mixed

Overrides:

[ Top ]

$_lastrx =

Tags:

Type: mixed

Overrides:

[ Top ]

$_lasttx =

Tags:

Type: mixed

Overrides:

[ Top ]

$_logdestination = SMARTIRC_STDOUT

Tags:

Type: mixed

Overrides:

[ Top ]

$_logfile = Net_SmartIRC.log

Tags:

Type: mixed

Overrides:

[ Top ]

$_logfilefp =

Tags:

Type: mixed

Overrides:

[ Top ]

$_loggedin = false

Tags:

Type: mixed

Overrides:

[ Top ]

$_maxtimer = 300000

Tags:

Type: mixed

Overrides:

[ Top ]

$_messagebuffer = array()

Tags:

Type: mixed

Overrides:

[ Top ]

$_messagebuffersize =

Tags:

Type: mixed

Overrides:

[ Top ]

$_messagehandlerobject =

Tags:

Type: mixed

Overrides:

[ Top ]

$_mintimer = false

Tags:

Type: mixed

Overrides:

[ Top ]

$_motd = array()

Tags:

Type: mixed

Overrides:

[ Top ]

$_nick =

Tags:

Type: mixed

Overrides:

[ Top ]

$_password =

Tags:

Type: mixed

Overrides:

[ Top ]

$_port =

Tags:

Type: mixed

Overrides:

[ Top ]

$_realname =

Tags:

Type: mixed

Overrides:

[ Top ]

$_receivedelay = 100

Tags:

Type: mixed

Overrides:

[ Top ]

$_rxtimeout = 300

Tags:

Type: mixed

Overrides:

[ Top ]

$_selecttimeout =

Tags:

Type: mixed

Overrides:

[ Top ]

$_senddelay = 250

Tags:

Type: mixed

Overrides:

[ Top ]

$_socket =

Tags:

Type: mixed

Overrides:

[ Top ]

$_state = false

Tags:

Type: mixed

Overrides:

[ Top ]

$_timehandler = array()

Tags:

Type: mixed

Overrides:

[ Top ]

$_timehandlerid = 0

Tags:

Type: mixed

Overrides:

[ Top ]

$_txtimeout = 300

Tags:

Type: mixed

Overrides:

[ Top ]

$_usermode =

Tags:

Type: mixed

Overrides:

[ Top ]

$_username =

Tags:

Type: mixed

Overrides:

[ Top ]

$_usesockets = false

Tags:

Type: mixed

Overrides:

[ Top ]


Class Methods

ban

void ban ( $channel, [$hostmask = null] )

bans a hostmask for the given channel or requests the current banlist
The banlist will be requested if no hostmask is specified

Tags:

Parameters:

  • string $channel -
  • string $hostmask -

[ Top ]

changeNick

void changeNick ( $newnick )

changes the own nickname
Trys to set a new nickname, nickcollisions are handled.

Tags:

Parameters:

  • string $newnick -

[ Top ]

channel

reference &channel ( $channelname )

returns an object reference to the specified channel
If the channel does not exist (because not joint) false will be returned.

Tags:

  • Return - to the channel object

Parameters:

  • string $channelname -

[ Top ]

connect

void connect ( $address, $port )

Creates the sockets and connects to the IRC server on the given port.

Tags:

Parameters:

  • string $address -
  • integer $port -

[ Top ]

deop

void deop ( $channel, $nickname )

deops an user in the given channel

Tags:

Parameters:

  • string $channel -
  • string $nickname -

[ Top ]

devoice

void devoice ( $channel, $nickname )

devoice a user in the given channel

Tags:

Parameters:

  • string $channel -
  • string $nickname -

[ Top ]

disconnect

boolean disconnect ( [$quickdisconnect = false] )

disconnects from the IRC server nicely with a QUIT or just destroys the socket
disconnects from the IRC server in the given quickness mode.
$quickdisconnect:
true, just close the socket
false, send QUIT and wait $_disconnectime $_disconnectime before closing the socket

Tags:

Parameters:

  • boolean $quickdisconnect - default: false

[ Top ]

getList

void getList ( [$channelarray = null] )

gets a list of one ore more channels
Requests a full channellist if $channelarray is not given.
(use it with care, usualy its a looooong list)

Tags:

Parameters:

  • mixed $channelarray -

[ Top ]

getMotd

array getMotd ( )

returns the motd

Tags:

Parameters:

[ Top ]

getTopic

void getTopic ( $channel )

gets the topic of a channel

Tags:

Parameters:

  • string $channel -

[ Top ]

getUsermode

string getUsermode ( )

returns the usermode

Tags:

Parameters:

[ Top ]

invite

void invite ( $nickname, $channel )

invites a user to the specified channel

Tags:

Parameters:

  • string $nickname -
  • string $channel -

[ Top ]

join

void join ( $channelarray, [$key = null] )

Joins one or more IRC channels with an optional key.

Tags:

Parameters:

  • mixed $channelarray -
  • string $key -

[ Top ]

kick

void kick ( $channel, $nicknamearray, [$reason = null] )

Kicks one or more user from an IRC channel with an optional reason.

Tags:

Parameters:

  • string $channel -
  • mixed $nicknamearray -
  • string $reason -

[ Top ]

listen

boolean listen ( )

goes into receive mode
Goes into receive and idle mode. Only call this if you want to "spawn" the bot.
No further lines of PHP code will be processed after this call, only the bot methods!

Tags:

Parameters:

[ Top ]

listenFor

array listenFor ( $messagetype )

waits for a special message type and puts the answer in $result
Creates a special actionhandler for that given TYPE and returns the answer.
This will only receive the requested type, immediately quit and disconnect from the IRC server.
Made for showing IRC statistics on your homepage, or other IRC related information.

Tags:

  • Return - answer from the IRC server for this $messagetype

Parameters:

  • integer $messagetype - see in the documentation 'Message Types'

[ Top ]

log

void log ( $level, $entry )

adds an entry to the log
Adds an entry to the log with Linux style log format.
Possible $level constants (can also be combined with "|"s)
SMARTIRC_DEBUG_NOTICE
SMARTIRC_DEBUG_CONNECTION
SMARTIRC_DEBUG_SOCKET
SMARTIRC_DEBUG_IRCMESSAGES
SMARTIRC_DEBUG_MESSAGETYPES
SMARTIRC_DEBUG_ACTIONHANDLER
SMARTIRC_DEBUG_TIMEHANDLER
SMARTIRC_DEBUG_MESSAGEHANDLER

Tags:

Parameters:

  • integer $level - bit constants (SMARTIRC_DEBUG_*)
  • string $entry - the new log entry

[ Top ]

login

void login ( $nick, $realname, [$usermode = 0], [$username = null], [$password = null] )

login and register nickname on the IRC network
Registers the nickname and user information on the IRC network.

Tags:

Parameters:

  • string $nick -
  • string $realname -
  • integer $usermode -
  • string $username -
  • string $password -

[ Top ]

message

boolean message ( $type, $destination, $message )

sends a new message
Sends a message to a channel or user.

Tags:

Parameters:

  • integer $type - specifies the type, like QUERY/ACTION or CTCP see 'Message Types'
  • string $destination - can be a user or channel
  • string $message - the message

[ Top ]

mode

void mode ( $target, [$newmode = null] )

sets or gets the mode of an user or channel
Changes/requests the mode of the given target.

Tags:

Parameters:

  • string $target - the target, can be an user (only yourself) or a channel
  • string $newmode - the new mode like +mt

[ Top ]

names

void names ( [$channelarray = null] )

requests all nicknames of one or more channels
The requested nickname list also includes op and voice state

Tags:

Parameters:

  • mixed $channelarray -

[ Top ]

constructor Net_SmartIRC

void constructor Net_SmartIRC ( )

Tags:

Parameters:

[ Top ]

op

void op ( $channel, $nickname )

ops an user in the given channel

Tags:

Parameters:

  • string $channel -
  • string $nickname -

[ Top ]

part

void part ( $channelarray, [$reason = null] )

parts from one or more IRC channels with an optional reason

Tags:

Parameters:

  • mixed $channelarray -
  • string $reason -

[ Top ]

quit

void quit ( [$quitmessage = null] )

sends QUIT to IRC server and disconnects

Tags:

Parameters:

  • string $quitmessage - optional quitmessage

[ Top ]

reconnect

void reconnect ( )

reconnects to the IRC server with the same login info,
it also rejoins the channels

Tags:

Parameters:

[ Top ]

registerActionhandler

integer registerActionhandler ( $handlertype, $regexhandler, &$object, $methodname )

registers a new actionhandler and returns the assigned id
Registers an actionhandler in Net_SmartIRC for calling it later.
The actionhandler id is needed for unregistering the actionhandler.

Tags:

  • Return - assigned actionhandler id

Parameters:

  • integer $handlertype - bits constants, see in this documentation Message Types
  • string $regexhandler - the message that has to be in the IRC message in regex syntax
  • object $object - a reference to the objects of the method
  • string $methodname - the methodname that will be called when the handler happens

[ Top ]

registerTimehandler

integer registerTimehandler ( $interval, &$object, $methodname )

registers a timehandler and returns the assigned id
Registers a timehandler in Net_SmartIRC, which will be called in the specified interval.
The timehandler id is needed for unregistering the timehandler.

Tags:

  • Return - assigned timehandler id

Parameters:

  • integer $interval - interval time in milliseconds
  • object $object - a reference to the objects of the method
  • string $methodname - the methodname that will be called when the handler happens

[ Top ]

setAutoReconnect

void setAutoReconnect ( $boolean )

enables/disables autoreconnecting

Tags:

Parameters:

  • boolean $boolean -

[ Top ]

setBenchmark

void setBenchmark ( $boolean )

enables/disables the benchmark engine

Tags:

Parameters:

  • boolean $boolean -

[ Top ]

setChannelSynching

void setChannelSynching ( $boolean )

enables/disables channel synching

Tags:

Parameters:

  • boolean $boolean -

[ Top ]

setCtcpVersion

void setCtcpVersion ( $versionstring )

sets the CTCP version reply string

Tags:

Parameters:

  • string $versionstring -

[ Top ]

setDebug

void setDebug ( $level )

sets the level of debug messages
Sets the debug level (bitwise), useful for testing/developing your code.
A full list of avialable debug levels see 'Debug Levels'.
Default: SMARTIRC_DEBUG_NOTICE

Tags:

Parameters:

  • integer $level -

[ Top ]

setDisconnecttime

void setDisconnecttime ( $milliseconds )

sets the delaytime before closing the socket when disconnect

Tags:

Parameters:

  • integer $milliseconds -

[ Top ]

setLogdestination

void setLogdestination ( $type )

sets the destination of all log messages
Sets the destination of log messages.
$type can be:
SMARTIRC_FILE for saving the log into a file
SMARTIRC_STDOUT for echoing the log to stdout
SMARTIRC_SYSLOG for sending the log to the syslog
Default: SMARTIRC_STDOUT

Tags:

Parameters:

  • integer $type - must be on of the constants

[ Top ]

setLogfile

void setLogfile ( $file )

sets the file for the log if the destination is set to file
Sets the logfile, if setLogdestination logdestination is set to SMARTIRC_FILE.
This should be only used with full path!

Tags:

Parameters:

  • string $file -

[ Top ]

setReceivedelay

void setReceivedelay ( $milliseconds )

sets the delay for receiving data from the IRC server
Sets the delaytime between messages that are received, this reduces your CPU load.
Don't set this too low (min 100ms).
Default: 100

Tags:

Parameters:

  • integer $milliseconds -

[ Top ]

setReceiveTimeout

void setReceiveTimeout ( $seconds )

sets the receive timeout
If the timeout occurs, the connection will be reinitialized
Default: 300 seconds

Tags:

Parameters:

  • integer $seconds -

[ Top ]

setSenddelay

void setSenddelay ( $milliseconds )

sets the delay for sending data to the IRC server
Sets the delaytime between messages that are sent, because IRC servers doesn't like floods.
This will avoid sending your messages too fast to the IRC server.
Default: 250

Tags:

Parameters:

  • integer $milliseconds -

[ Top ]

setTopic

void setTopic ( $channel, $newtopic )

sets a new topic of a channel

Tags:

Parameters:

  • string $channel -
  • string $newtopic -

[ Top ]

setTransmitTimeout

void setTransmitTimeout ( $seconds )

sets the transmit timeout
If the timeout occurs, the connection will be reinitialized
Default: 300 seconds

Tags:

Parameters:

  • integer $seconds -

[ Top ]

setUseSockets

void setUseSockets ( $boolean )

enables/disables the usage of real sockets
Enables/disables the usage of real sockets instead of fsocks
(works only if your PHP build has loaded the PHP socket extension)
Default: false

Tags:

Parameters:

  • bool $boolean -

[ Top ]

showBenchmark

void showBenchmark ( )

shows the benchmark result

Tags:

Parameters:

[ Top ]

startBenchmark

void startBenchmark ( )

starts the benchmark (sets the counters)

Tags:

Parameters:

[ Top ]

stopBenchmark

void stopBenchmark ( )

stops the benchmark and displays the result

Tags:

Parameters:

[ Top ]

unban

void unban ( $channel, $hostmask )

unbans a hostmask on the given channel

Tags:

Parameters:

  • string $channel -
  • string $hostmask -

[ Top ]

unregisterActionhandler

boolean unregisterActionhandler ( $handlertype, $regexhandler, &$object, $methodname )

unregisters an existing actionhandler

Tags:

Parameters:

  • integer $handlertype -
  • string $regexhandler -
  • object $object -
  • string $methodname -

[ Top ]

unregisterActionid

boolean unregisterActionid ( $id )

unregisters an existing actionhandler via the id

Tags:

Parameters:

  • integer $id -

[ Top ]

unregisterTimeid

boolean unregisterTimeid ( $id )

unregisters an existing timehandler via the id

Tags:

Parameters:

  • integer $id -

[ Top ]

voice

void voice ( $channel, $nickname )

voice a user in the given channel

Tags:

Parameters:

  • string $channel -
  • string $nickname -

[ Top ]

who

void who ( $target )

requests a 'WHO' from the specified target

Tags:

Parameters:

  • string $target -

[ Top ]

whois

void whois ( $target )

requests a 'WHOIS' from the specified target

Tags:

Parameters:

  • string $target -

[ Top ]

whowas

void whowas ( $target )

requests a 'WHOWAS' from the specified target
(if he left the IRC network)

Tags:

Parameters:

  • string $target -

[ Top ]

_adduser

void _adduser ( &$channel, &$newuser )

adds an user to the channelobject or updates his info

Tags:

Parameters:

  • object $channel -
  • object $newuser -

[ Top ]

_calculateselecttimeout

void _calculateselecttimeout ( $microseconds )

Tags:

Parameters:

[ Top ]

_checkbuffer

void _checkbuffer ( )

checks the buffer if there are messages to send

Tags:

Parameters:

[ Top ]

_checktimeout

void _checktimeout ( )

Checks if a receive or transmit timeout occured and reconnects if configured

Tags:

Parameters:

[ Top ]

_checktimer

void _checktimer ( )

Checks the running timers and calls the registered timehandler,
when the interval is reached.

Tags:

Parameters:

[ Top ]

_gettype

integer _gettype ( $line )

determines the messagetype of $line
Analyses the type of an IRC message and returns the type.

Tags:

  • Return - SMARTIRC_TYPE_* constant

Parameters:

  • string $line -

[ Top ]

_handleactionhandler

void _handleactionhandler ( &$ircdata )

tries to find a actionhandler for the received message ($ircdata) and calls it

Tags:

Parameters:

  • object $ircdata -

[ Top ]

_handlemessage

void _handlemessage ( $messagecode, &$ircdata )

tries to find a messagehandler for the received message ($ircdata) and calls it

Tags:

Parameters:

  • string $messagecode -
  • object $ircdata -

[ Top ]

_microint

float _microint ( )

getting current microtime, needed for benchmarks

Tags:

Parameters:

[ Top ]

_nicknameinuse

void _nicknameinuse ( )

changes a already used nickname to a new nickname plus 3 random digits

Tags:

Parameters:

[ Top ]

_pong

void _pong ( $data )

sends the pong for keeping alive
Sends the PONG signal as reply of the PING from the IRC server.

Tags:

Parameters:

  • string $data -

[ Top ]

_rawreceive

void _rawreceive ( )

goes into main idle loop for waiting messages from the IRC server

Tags:

Parameters:

[ Top ]

_rawsend

boolean _rawsend ( $data )

sends a raw message to the IRC server (don't use this!!)
Use message() or _send() instead.

Tags:

Parameters:

  • string $data -

[ Top ]

_removeuser

void _removeuser ( &$ircdata )

removes an user from one channel or all if he quits

Tags:

Parameters:

  • object $ircdata -

[ Top ]

_reorderactionhandler

void _reorderactionhandler ( )

reorders the actionhandler array, needed after removing one

Tags:

Parameters:

[ Top ]

_reordertimehandler

void _reordertimehandler ( )

reorders the timehandler array, needed after removing one

Tags:

Parameters:

[ Top ]

_selecttimeout

void _selecttimeout ( )

Tags:

Parameters:

[ Top ]

_send

boolean _send ( $data, [$priority = SMARTIRC_MEDIUM] )

sends an IRC message
Adds a message to the messagequeue, with the optional priority.
$priority:
SMARTIRC_CRITICAL
SMARTIRC_HIGH
SMARTIRC_MEDIUM
SMARTIRC_LOW

Tags:

Parameters:

  • string $data -
  • integer $priority - must be one of the priority constants

[ Top ]

_state

integer _state ( )

returns the current connection state

Tags:

  • Return - SMARTIRC_STATE_CONNECTED or SMARTIRC_STATE_DISCONNECTED

Parameters:

[ Top ]

_updatemintimer

void _updatemintimer ( )

updates _mintimer to the smallest timer interval

Tags:

Parameters:

[ Top ]

_updatestate

boolean _updatestate ( )

updates the current connection state

Tags:

Parameters:

[ Top ]


Documention generated on Mon, 6 Jan 2003 02:15:56 +0100 by phpDocumentor 1.1.0