\Net_SmartIRC

main SmartIRC class

Copyright (c) 2002-2004 Mirco Bauer meebey@meebey.net http://www.meebey.net

Full LGPL License: http://www.gnu.org/licenses/lgpl.txt

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Summary

Methods
Properties
Constants
message()
join()
part()
kick()
getList()
names()
setTopic()
getTopic()
mode()
founder()
defounder()
admin()
deadmin()
op()
deop()
hop()
dehop()
voice()
devoice()
ban()
unban()
invite()
changeNick()
who()
whois()
whowas()
quit()
__construct()
__get()
__call()
setAutoRetry()
setAutoRetryMax()
setBenchmark()
setBindAddress()
setChannelSyncing()
setCtcpVersion()
setDebugLevel()
setDisconnectTime()
setLogDestination()
setLogFile()
setModulePath()
setReceiveDelay()
setReconnectDelay()
setRunAsDaemon()
setSendDelay()
setReceiveTimeout()
setTransmitTimeout()
setUserSyncing()
startBenchmark()
stopBenchmark()
showBenchmark()
log()
getMotd()
getUsermode()
getChannel()
getUser()
connect()
disconnect()
reconnect()
login()
perform()
send()
isMe()
isJoined()
isFounder()
isAdmin()
isOpped()
isHopped()
isVoiced()
isBanned()
interrupt()
listen()
listenOnce()
listenFor()
registerActionHandler()
unregisterActionHandler()
unregisterActionId()
registerTimeHandler()
unregisterTimeId()
loadModule()
unloadModule()
loadedModules()
isError()
$nreplycodes
DEF_AUTORETRY_MAX
DEF_DISCONNECT_TIME
DEF_LOGFILE
DEF_MAX_TIMER
DEF_RECEIVE_DELAY
DEF_RECONNECT_DELAY
DEF_SEND_DELAY
DEF_TX_RX_TIMEOUT
IP_PATTERN
_event_ping()
_event_error()
_event_join()
_event_part()
_event_kick()
_event_quit()
_event_nick()
_event_mode()
_event_topic()
_event_privmsg()
_event_rpl_welcome()
_event_rpl_motdstart()
_event_rpl_motd()
_event_rpl_endofmotd()
_event_rpl_umodeis()
_event_rpl_channelmodeis()
_event_rpl_whoreply()
_event_rpl_namreply()
_event_rpl_banlist()
_event_rpl_endofbanlist()
_event_rpl_topic()
_event_err_nicknameinuse()
throwError()
$_socket
$_address
$_port
$_bindto
$_nick
$_username
$_realname
$_usermode
$_password
$_performs
$_state
$_actionhandler
$_timehandler
$_debuglevel
$_messagebuffer
$_messagebuffersize
$_receivedelay
$_senddelay
$_logdestination
$_logfilefp
$_logfile
$_disconnecttime
$_loggedin
$_benchmark
$_benchmark_starttime
$_benchmark_stoptime
$_actionhandlerid
$_timehandlerid
$_motd
$_channels
$_channelsyncing
$_users
$_usersyncing
$_modulepath
$_modules
$_ctcpversion
$_mintimer
$_maxtimer
$_txtimeout
$_rxtimeout
$_lastrx
$_lasttx
$_lastsentmsgtime
$_reconnectdelay
$_autoretry
$_autoretrymax
$_autoretrycount
$_connectionerror
$_runasdaemon
$_interrupt
N/A
No private methods found
No private properties found
N/A

Constants

DEF_AUTORETRY_MAX

DEF_AUTORETRY_MAX

DEF_DISCONNECT_TIME

DEF_DISCONNECT_TIME

DEF_LOGFILE

DEF_LOGFILE

DEF_MAX_TIMER

DEF_MAX_TIMER

DEF_RECEIVE_DELAY

DEF_RECEIVE_DELAY

DEF_RECONNECT_DELAY

DEF_RECONNECT_DELAY

DEF_SEND_DELAY

DEF_SEND_DELAY

DEF_TX_RX_TIMEOUT

DEF_TX_RX_TIMEOUT

IP_PATTERN

IP_PATTERN

Properties

$nreplycodes

$nreplycodes : array

All numeric IRC replycodes, the index is the numeric replycode.

Type

array

$_socket

$_socket : resource

Type

resource

$_address

$_address : string

Type

string

$_port

$_port : integer

Type

integer

$_bindto

$_bindto : string

Type

string

$_nick

$_nick : string

Type

string

$_username

$_username : string

Type

string

$_realname

$_realname : string

Type

string

$_usermode

$_usermode : string

Type

string

$_password

$_password : string

Type

string

$_performs

$_performs : array

Type

array

$_state

$_state : boolean

Type

boolean

$_actionhandler

$_actionhandler : array

Type

array

$_timehandler

$_timehandler : array

Type

array

$_debuglevel

$_debuglevel : integer

Type

integer

$_messagebuffer

$_messagebuffer : array

Type

array

$_messagebuffersize

$_messagebuffersize : integer

Type

integer

$_receivedelay

$_receivedelay : integer

Type

integer

$_senddelay

$_senddelay : integer

Type

integer

$_logdestination

$_logdestination : integer

Type

integer

$_logfilefp

$_logfilefp : resource

Type

resource

$_logfile

$_logfile : string

Type

string

$_disconnecttime

$_disconnecttime : integer

Type

integer

$_loggedin

$_loggedin : boolean

Type

boolean

$_benchmark

$_benchmark : boolean

Type

boolean

$_benchmark_starttime

$_benchmark_starttime : integer

Type

integer

$_benchmark_stoptime

$_benchmark_stoptime : integer

Type

integer

$_actionhandlerid

$_actionhandlerid : integer

Type

integer

$_timehandlerid

$_timehandlerid : integer

Type

integer

$_motd

$_motd : array

Type

array

$_channels

$_channels : array

Stores all channels in this array where we are joined, works only if channelsyncing is activated.

Eg. for accessing a user, use it like this: (in this example the SmartIRC object is stored in $irc) $irc->getUser('#test', 'meebey')->nick;

Type

array

$_channelsyncing

$_channelsyncing : boolean

Type

boolean

$_users

$_users : array

Stores all users that had/have contact with us (channel/query/notice etc.), works only if usersyncing is activated.

Eg. for accessing a user, use it like this: (in this example the SmartIRC object is stored in $irc) $irc->user['meebey']->host;

Type

array

$_usersyncing

$_usersyncing : boolean

Type

boolean

$_modulepath

$_modulepath : string

Stores the path to the modules that can be loaded.

Type

string

$_modules

$_modules : string

Stores all objects of the modules.

Type

string

$_ctcpversion

$_ctcpversion : string

Type

string

$_mintimer

$_mintimer : mixed

Type

mixed

$_maxtimer

$_maxtimer : integer

Type

integer

$_txtimeout

$_txtimeout : integer

Type

integer

$_rxtimeout

$_rxtimeout : integer

Type

integer

$_lastrx

$_lastrx : integer

Type

integer

$_lasttx

$_lasttx : integer

Type

integer

$_lastsentmsgtime

$_lastsentmsgtime : 

Type

$_reconnectdelay

$_reconnectdelay : integer

Type

integer

$_autoretry

$_autoretry : boolean

Type

boolean

$_autoretrymax

$_autoretrymax : integer

Type

integer

$_autoretrycount

$_autoretrycount : integer

Type

integer

$_connectionerror

$_connectionerror : boolean

Type

boolean

$_runasdaemon

$_runasdaemon : boolean

Type

boolean

$_interrupt

$_interrupt : boolean

Type

boolean

Methods

message()

message(integer  $type, string  $destination, mixed  $messagearray, integer  $priority = SMARTIRC_MEDIUM) : boolean|\Net_SmartIRC

sends a new message

Sends a message to a channel or user.

Parameters

integer $type

specifies the type, like QUERY/ACTION or CTCP see 'Message Types'

string $destination

can be a user or channel

mixed $messagearray

the message

integer $priority

the priority level of the message

Returns

boolean|\Net_SmartIRC

join()

join(mixed  $channelarray, string  $key = null, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

Joins one or more IRC channels with an optional key.

Parameters

mixed $channelarray
string $key
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

part()

part(mixed  $channelarray, string  $reason = null, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

parts from one or more IRC channels with an optional reason

Parameters

mixed $channelarray
string $reason
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

kick()

kick(string  $channel, mixed  $nicknamearray, string  $reason = null, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

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

Parameters

string $channel
mixed $nicknamearray
string $reason
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

getList()

getList(mixed  $channelarray = null, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

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)

Parameters

mixed $channelarray
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

names()

names(mixed  $channelarray = null, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

requests all nicknames of one or more channels

The requested nickname list also includes op and voice state

Parameters

mixed $channelarray
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

setTopic()

setTopic(string  $channel, string  $newtopic, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

sets a new topic of a channel

Parameters

string $channel
string $newtopic
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

getTopic()

getTopic(string  $channel, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

gets the topic of a channel

Parameters

string $channel
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

mode()

mode(string  $target, string  $newmode = null, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

sets or gets the mode of an user or channel

Changes/requests the mode of the given target.

Parameters

string $target

the target, can be an user (only yourself) or a channel

string $newmode

the new mode like +mt

integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

founder()

founder(string  $channel, string  $nickname, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

founders an user in the given channel

Parameters

string $channel
string $nickname
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

defounder()

defounder(string  $channel, string  $nickname, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

defounders an user in the given channel

Parameters

string $channel
string $nickname
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

admin()

admin(string  $channel, string  $nickname, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

admins an user in the given channel

Parameters

string $channel
string $nickname
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

deadmin()

deadmin(string  $channel, string  $nickname, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

deadmins an user in the given channel

Parameters

string $channel
string $nickname
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

op()

op(string  $channel, string  $nickname, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

ops an user in the given channel

Parameters

string $channel
string $nickname
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

deop()

deop(string  $channel, string  $nickname, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

deops an user in the given channel

Parameters

string $channel
string $nickname
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

hop()

hop(string  $channel, string  $nickname, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

hops an user in the given channel

Parameters

string $channel
string $nickname
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

dehop()

dehop(string  $channel, string  $nickname, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

dehops an user in the given channel

Parameters

string $channel
string $nickname
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

voice()

voice(string  $channel, string  $nickname, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

voice a user in the given channel

Parameters

string $channel
string $nickname
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

devoice()

devoice(string  $channel, string  $nickname, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

devoice a user in the given channel

Parameters

string $channel
string $nickname
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

ban()

ban(string  $channel, string  $hostmask = null, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

bans a hostmask for the given channel or requests the current banlist

The banlist will be requested if no hostmask is specified

Parameters

string $channel
string $hostmask
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

unban()

unban(string  $channel, string  $hostmask, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

unbans a hostmask on the given channel

Parameters

string $channel
string $hostmask
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

invite()

invite(string  $nickname, string  $channel, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

invites a user to the specified channel

Parameters

string $nickname
string $channel
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

changeNick()

changeNick(string  $newnick, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

changes the own nickname

Trys to set a new nickname, nickcollisions are handled.

Parameters

string $newnick
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

who()

who(string  $target, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

requests a 'WHO' from the specified target

Parameters

string $target
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

whois()

whois(string  $target, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

requests a 'WHOIS' from the specified target

Parameters

string $target
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

whowas()

whowas(string  $target, integer  $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC

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

Parameters

string $target
integer $priority

message priority, default is SMARTIRC_MEDIUM

Returns

\Net_SmartIRC

quit()

quit(string  $quitmessage = null, integer  $priority = SMARTIRC_CRITICAL) : \Net_SmartIRC

sends QUIT to IRC server and disconnects

Parameters

string $quitmessage

optional quitmessage

integer $priority

message priority, default is SMARTIRC_CRITICAL

Returns

\Net_SmartIRC

__construct()

__construct(array  $params = array()) : object

Constructor. Initiates the messagebuffer and "links" the replycodes from global into properties. Also some PHP runtime settings are configured.

Parameters

array $params

Properties to set during instantiation

Returns

object

__get()

__get(string  $name) : mixed

Keeps BC since private properties were once publicly accessible.

Parameters

string $name

The property name asked for

Returns

mixed —

the property's value

__call()

__call(string  $method, array  $args) : mixed|void

Handle calls to renamed or deprecated functions

Parameters

string $method
array $args

Returns

mixed|void

setAutoRetry()

setAutoRetry(boolean  $boolean) : boolean

Enables/disables autoretry for connecting to a server.

Parameters

boolean $boolean

Returns

boolean

setAutoRetryMax()

setAutoRetryMax(integer|null  $autoretrymax = null) : integer

Sets the maximum number of attempts to connect to a server before giving up.

Parameters

integer|null $autoretrymax

Returns

integer

setBenchmark()

setBenchmark(boolean  $boolean) : boolean

Enables/disables the benchmark engine.

Parameters

boolean $boolean

Returns

boolean

setBindAddress()

setBindAddress(string  $addr = '0', integer  $port) : string

Sets an IP address (and optionally, a port) to bind the socket to.

Limits the bot to claiming only one of the machine's IPs as its home. Call with no parameters to unbind.

Parameters

string $addr
integer $port

Returns

string —

The bound address with port

setChannelSyncing()

setChannelSyncing(boolean  $boolean) : boolean

Enables/disables channel syncing.

Channel syncing means, all users on all channel we are joined are tracked in the channel array. This makes it very handy for botcoding.

Parameters

boolean $boolean

Returns

boolean

setCtcpVersion()

setCtcpVersion(string  $versionstring) : string

Sets the CTCP version reply string.

Parameters

string $versionstring

Returns

string

setDebugLevel()

setDebugLevel(integer  $level) : integer

Sets the level of debug messages.

Sets the debug level (bitwise), useful for testing/developing your code. Here the list of all possible debug levels: SMARTIRC_DEBUG_NONE SMARTIRC_DEBUG_NOTICE SMARTIRC_DEBUG_CONNECTION SMARTIRC_DEBUG_SOCKET SMARTIRC_DEBUG_IRCMESSAGES SMARTIRC_DEBUG_MESSAGETYPES SMARTIRC_DEBUG_ACTIONHANDLER SMARTIRC_DEBUG_TIMEHANDLER SMARTIRC_DEBUG_MESSAGEHANDLER SMARTIRC_DEBUG_CHANNELSYNCING SMARTIRC_DEBUG_MODULES SMARTIRC_DEBUG_USERSYNCING SMARTIRC_DEBUG_ALL

Default: SMARTIRC_DEBUG_NOTICE

Parameters

integer $level

Returns

integer

setDisconnectTime()

setDisconnectTime(integer|null  $milliseconds = null) : integer

Sets the delaytime before closing the socket when disconnect.

Parameters

integer|null $milliseconds

Returns

integer

setLogDestination()

setLogDestination(integer  $type) : integer

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

Parameters

integer $type

must be on of the constants

Returns

integer

setLogFile()

setLogFile(string  $file) : string

Sets the file for the log if the destination is set to file.

Sets the logfile, if \setLogDestination is set to SMARTIRC_FILE. This should be only used with full path!

Parameters

string $file

Returns

string

setModulePath()

setModulePath(integer  $path) : string

Sets the paths for the modules.

Parameters

integer $path

Returns

string

setReceiveDelay()

setReceiveDelay(integer|null  $milliseconds = null) : integer

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

Parameters

integer|null $milliseconds

Returns

integer

setReconnectDelay()

setReconnectDelay(integer|null  $milliseconds = null) : integer

Sets the delaytime before attempting reconnect.

Value of 0 disables the delay entirely.

Parameters

integer|null $milliseconds

Returns

integer

setRunAsDaemon()

setRunAsDaemon(boolean  $boolean) : boolean

Sets whether the script should be run as a daemon or not ( actually disables/enables ignore_user_abort() )

Parameters

boolean $boolean

Returns

boolean

setSendDelay()

setSendDelay(integer|null  $milliseconds = null) : integer

Sets the delay for sending data to the IRC server.

Sets the delay time between sending messages, to avoid flooding IRC servers. If your bot has special flooding permissions on the network you're connected to, you can set this quite low to send messages faster. Default: 250

Parameters

integer|null $milliseconds

Returns

integer

setReceiveTimeout()

setReceiveTimeout(integer|null  $seconds = null) : integer

Sets the receive timeout.

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

Parameters

integer|null $seconds

Returns

integer

setTransmitTimeout()

setTransmitTimeout(integer|null  $seconds = null) : integer

Sets the transmit timeout.

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

Parameters

integer|null $seconds

Returns

integer

setUserSyncing()

setUserSyncing(boolean  $boolean) : boolean

Enables/disables user syncing.

User syncing means, all users we have or had contact with through channel, query or notice are tracked in the $irc->user array. This is very handy for botcoding.

Parameters

boolean $boolean

Returns

boolean

startBenchmark()

startBenchmark() : \Net_SmartIRC

Starts the benchmark (sets the counters).

Returns

\Net_SmartIRC

stopBenchmark()

stopBenchmark() : \Net_SmartIRC

Stops the benchmark and displays the result.

Returns

\Net_SmartIRC

showBenchmark()

showBenchmark() : \Net_SmartIRC

Shows the benchmark result.

Returns

\Net_SmartIRC

log()

log(integer  $level, string  $entry, string|null  $file = null, integer|null  $line = null) : boolean

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_NONE SMARTIRC_DEBUG_NOTICE SMARTIRC_DEBUG_CONNECTION SMARTIRC_DEBUG_SOCKET SMARTIRC_DEBUG_IRCMESSAGES SMARTIRC_DEBUG_MESSAGETYPES SMARTIRC_DEBUG_ACTIONHANDLER SMARTIRC_DEBUG_TIMEHANDLER SMARTIRC_DEBUG_MESSAGEHANDLER SMARTIRC_DEBUG_CHANNELSYNCING SMARTIRC_DEBUG_MODULES SMARTIRC_DEBUG_USERSYNCING SMARTIRC_DEBUG_ALL

Parameters

integer $level

bit constants (SMARTIRCDEBUG*)

string $entry

the new log entry

string|null $file

The source file originating the log() call

integer|null $line

The line of code that called log()

Returns

boolean

getMotd()

getMotd() : array

Returns the full motd.

Returns

array

getUsermode()

getUsermode() : string

Returns the usermode.

Returns

string

getChannel()

getChannel(string  $channelname) : object

Returns a reference to the channel object of the specified channelname.

Parameters

string $channelname

Returns

object

getUser()

getUser(string  $channelname, string  $username) : object

Returns a reference to the user object for the specified username and channelname.

Parameters

string $channelname
string $username

Returns

object

connect()

connect(string  $addr, integer  $port = 6667, boolean  $reconnecting = false) : boolean|\Net_SmartIRC

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

Returns this SmartIRC object on success, and false on failure.

Parameters

string $addr
integer $port
boolean $reconnecting

For internal use only

Returns

boolean|\Net_SmartIRC

disconnect()

disconnect(boolean  $quick = false) : boolean|\Net_SmartIRC

Disconnects from the IRC server nicely with a QUIT or just destroys the socket.

Disconnects from the IRC server in the given quickness mode. $quick:

  • true, just close the socket
  • false, send QUIT and wait \$_disconnectime before closing the socket

Parameters

boolean $quick

default: false

Returns

boolean|\Net_SmartIRC

reconnect()

reconnect() : boolean|\Net_SmartIRC

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

Returns

boolean|\Net_SmartIRC

login()

login(string  $nick, string  $realname, integer  $usermode, string  $username = null, string  $password = null) : \Net_SmartIRC

login and register nickname on the IRC network

Registers the nickname and user information on the IRC network.

Parameters

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

Returns

\Net_SmartIRC

perform()

perform(string  $cmd) : \Net_SmartIRC

adds a command to the list of commands to be sent after login() info

Parameters

string $cmd

the command to add to the perform list

Returns

\Net_SmartIRC

send()

send(string  $data, integer  $priority = SMARTIRC_MEDIUM) : boolean|\Net_SmartIRC

sends an IRC message

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

Parameters

string $data
integer $priority

must be one of the priority constants

Returns

boolean|\Net_SmartIRC

isMe()

isMe(string  $nickname) : boolean

checks if the passed nickname is our own nickname

Parameters

string $nickname

Returns

boolean

isJoined()

isJoined(string  $channel, string  $nickname = null) : boolean

checks if we or the given user is joined to the specified channel and returns the result ChannelSyncing is required for this.

Parameters

string $channel
string $nickname

Returns

boolean

isFounder()

isFounder(string  $channel, string  $nickname = null) : boolean

Checks if we or the given user is founder on the specified channel and returns the result.

ChannelSyncing is required for this.

Parameters

string $channel
string $nickname

Returns

boolean

isAdmin()

isAdmin(string  $channel, string  $nickname = null) : boolean

Checks if we or the given user is admin on the specified channel and returns the result.

ChannelSyncing is required for this.

Parameters

string $channel
string $nickname

Returns

boolean

isOpped()

isOpped(string  $channel, string  $nickname = null) : boolean

Checks if we or the given user is opped on the specified channel and returns the result.

ChannelSyncing is required for this.

Parameters

string $channel
string $nickname

Returns

boolean

isHopped()

isHopped(string  $channel, string  $nickname = null) : boolean

Checks if we or the given user is hopped on the specified channel and returns the result.

ChannelSyncing is required for this.

Parameters

string $channel
string $nickname

Returns

boolean

isVoiced()

isVoiced(string  $channel, string  $nickname = null) : boolean

Checks if we or the given user is voiced on the specified channel and returns the result.

ChannelSyncing is required for this.

Parameters

string $channel
string $nickname

Returns

boolean

isBanned()

isBanned(string  $channel, string  $hostmask) : boolean

Checks if the hostmask is on the specified channel banned and returns the result.

ChannelSyncing is required for this.

Parameters

string $channel
string $hostmask

Returns

boolean

interrupt()

interrupt(boolean  $ival = true) : boolean

Provides a mechanism to interrupt a listen() loop by a bot or something

Parameters

boolean $ival

Whether to interrupt the next listen iteration

Returns

boolean

listen()

listen() : \Net_SmartIRC

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!

Returns

\Net_SmartIRC

listenOnce()

listenOnce() : boolean|\Net_SmartIRC

goes into receive mode _only_ for one pass

Goes into receive mode. It will return when one pass is complete. Use this when you want to connect to multiple IRC servers.

Returns

boolean|\Net_SmartIRC

listenFor()

listenFor(integer  $messagetype, string  $regex = '.*') : array

waits for a special message type and returns the answer

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.

Parameters

integer $messagetype

see in the documentation 'Message Types'

string $regex

the pattern to match on

Returns

array —

answer from the IRC server for this $messagetype

registerActionHandler()

registerActionHandler(integer  $handlertype, string  $regexhandler, object|callable  $object, string  $methodname = '') : integer

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.

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|callable $object

either an object with the method, or a callable

string $methodname

the methodname that will be called when the handler happens

Returns

integer —

assigned actionhandler id

unregisterActionHandler()

unregisterActionHandler(integer  $handlertype, string  $regexhandler, object  $object, string  $methodname = '') : boolean

unregisters an existing actionhandler

Parameters

integer $handlertype
string $regexhandler
object $object
string $methodname

Returns

boolean

unregisterActionId()

unregisterActionId(integer|array  $id) : boolean|void

unregisters an existing actionhandler via the id

Parameters

integer|array $id

Returns

boolean|void

registerTimeHandler()

registerTimeHandler(integer  $interval, object  $object, string  $methodname = '') : integer

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.

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

Returns

integer —

assigned timehandler id

unregisterTimeId()

unregisterTimeId(integer  $id) : boolean

unregisters an existing timehandler via the id

Parameters

integer $id

Returns

boolean

loadModule()

loadModule(string  $name) : boolean|\Net_SmartIRC

loads a module using preset path and given name

Parameters

string $name

Returns

boolean|\Net_SmartIRC

unloadModule()

unloadModule(string  $name) : boolean|\Net_SmartIRC

unloads a module by the name originally loaded with

Parameters

string $name

Returns

boolean|\Net_SmartIRC

loadedModules()

loadedModules() : array

Returns an array of the module names that are currently loaded

Returns

array

isError()

isError(  $object) 

Parameters

$object

_event_ping()

_event_ping(  $ircdata) 

Parameters

$ircdata

_event_error()

_event_error(  $ircdata) 

Parameters

$ircdata

_event_join()

_event_join(  $ircdata) 

Parameters

$ircdata

_event_part()

_event_part(  $ircdata) 

Parameters

$ircdata

_event_kick()

_event_kick(  $ircdata) 

Parameters

$ircdata

_event_quit()

_event_quit(  $ircdata) 

Parameters

$ircdata

_event_nick()

_event_nick(  $ircdata) 

Parameters

$ircdata

_event_mode()

_event_mode(  $ircdata) 

Parameters

$ircdata

_event_topic()

_event_topic(  $ircdata) 

Parameters

$ircdata

_event_privmsg()

_event_privmsg(  $ircdata) 

Parameters

$ircdata

_event_rpl_welcome()

_event_rpl_welcome(  $ircdata) 

Parameters

$ircdata

_event_rpl_motdstart()

_event_rpl_motdstart(  $ircdata) 

Parameters

$ircdata

_event_rpl_motd()

_event_rpl_motd(  $ircdata) 

Parameters

$ircdata

_event_rpl_endofmotd()

_event_rpl_endofmotd(  $ircdata) 

Parameters

$ircdata

_event_rpl_umodeis()

_event_rpl_umodeis(  $ircdata) 

Parameters

$ircdata

_event_rpl_channelmodeis()

_event_rpl_channelmodeis(  $ircdata) 

Parameters

$ircdata

_event_rpl_whoreply()

_event_rpl_whoreply(  $ircdata) 

Parameters

$ircdata

_event_rpl_namreply()

_event_rpl_namreply(  $ircdata) 

Parameters

$ircdata

_event_rpl_banlist()

_event_rpl_banlist(  $ircdata) 

Parameters

$ircdata

_event_rpl_endofbanlist()

_event_rpl_endofbanlist(  $ircdata) 

Parameters

$ircdata

_event_rpl_topic()

_event_rpl_topic(  $ircdata) 

Parameters

$ircdata

_event_err_nicknameinuse()

_event_err_nicknameinuse(  $ircdata) 

Parameters

$ircdata

throwError()

throwError(  $message) 

Parameters

$message