DEF_AUTORETRY_MAX
DEF_AUTORETRY_MAX
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
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.
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 |
join(mixed $channelarray, string $key = null, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
Joins one or more IRC channels with an optional key.
mixed | $channelarray | |
string | $key | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
part(mixed $channelarray, string $reason = null, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
parts from one or more IRC channels with an optional reason
mixed | $channelarray | |
string | $reason | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
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.
string | $channel | |
mixed | $nicknamearray | |
string | $reason | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
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)
mixed | $channelarray | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
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
mixed | $channelarray | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
setTopic(string $channel, string $newtopic, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
sets a new topic of a channel
string | $channel | |
string | $newtopic | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
getTopic(string $channel, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
gets the topic of a channel
string | $channel | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
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.
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 |
founder(string $channel, string $nickname, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
founders an user in the given channel
string | $channel | |
string | $nickname | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
defounder(string $channel, string $nickname, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
defounders an user in the given channel
string | $channel | |
string | $nickname | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
admin(string $channel, string $nickname, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
admins an user in the given channel
string | $channel | |
string | $nickname | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
deadmin(string $channel, string $nickname, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
deadmins an user in the given channel
string | $channel | |
string | $nickname | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
op(string $channel, string $nickname, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
ops an user in the given channel
string | $channel | |
string | $nickname | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
deop(string $channel, string $nickname, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
deops an user in the given channel
string | $channel | |
string | $nickname | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
hop(string $channel, string $nickname, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
hops an user in the given channel
string | $channel | |
string | $nickname | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
dehop(string $channel, string $nickname, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
dehops an user in the given channel
string | $channel | |
string | $nickname | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
voice(string $channel, string $nickname, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
voice a user in the given channel
string | $channel | |
string | $nickname | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
devoice(string $channel, string $nickname, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
devoice a user in the given channel
string | $channel | |
string | $nickname | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
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
string | $channel | |
string | $hostmask | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
unban(string $channel, string $hostmask, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
unbans a hostmask on the given channel
string | $channel | |
string | $hostmask | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
invite(string $nickname, string $channel, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
invites a user to the specified channel
string | $nickname | |
string | $channel | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
changeNick(string $newnick, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
changes the own nickname
Trys to set a new nickname, nickcollisions are handled.
string | $newnick | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
who(string $target, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
requests a 'WHO' from the specified target
string | $target | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
whois(string $target, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
requests a 'WHOIS' from the specified target
string | $target | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
whowas(string $target, integer $priority = SMARTIRC_MEDIUM) : \Net_SmartIRC
requests a 'WHOWAS' from the specified target (if he left the IRC network)
string | $target | |
integer | $priority | message priority, default is SMARTIRC_MEDIUM |
quit(string $quitmessage = null, integer $priority = SMARTIRC_CRITICAL) : \Net_SmartIRC
sends QUIT to IRC server and disconnects
string | $quitmessage | optional quitmessage |
integer | $priority | message priority, default is SMARTIRC_CRITICAL |
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.
string | $addr | |
integer | $port |
The bound address with port
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
integer | $level |
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
integer | $type | must be on of the constants |
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
integer|null | $milliseconds |
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
integer|null | $milliseconds |
startBenchmark() : \Net_SmartIRC
Starts the benchmark (sets the counters).
stopBenchmark() : \Net_SmartIRC
Stops the benchmark and displays the result.
showBenchmark() : \Net_SmartIRC
Shows the benchmark result.
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
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() |
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.
string | $addr | |
integer | $port | |
boolean | $reconnecting | For internal use only |
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:
boolean | $quick | default: false |
reconnect() : boolean|\Net_SmartIRC
Reconnects to the IRC server with the same login info, it also rejoins the channels
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.
string | $nick | |
string | $realname | |
integer | $usermode | |
string | $username | |
string | $password |
perform(string $cmd) : \Net_SmartIRC
adds a command to the list of commands to be sent after login() info
string | $cmd | the command to add to the perform list |
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
string | $data | |
integer | $priority | must be one of the priority constants |
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!
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.
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.
integer | $messagetype | see in the documentation 'Message Types' |
string | $regex | the pattern to match on |
answer from the IRC server for this $messagetype
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.
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 |
assigned actionhandler id
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.
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 |
assigned timehandler id
loadModule(string $name) : boolean|\Net_SmartIRC
loads a module using preset path and given name
string | $name |
unloadModule(string $name) : boolean|\Net_SmartIRC
unloads a module by the name originally loaded with
string | $name |