OUTRAGEbot
[ class tree: OUTRAGEbot ] [ index: OUTRAGEbot ] [ all elements ]

Class: Master

Source Location: /OUTRAGEbot/System/Master.php

Class Overview


Master class for OUTRAGEbot


Author(s):

Version:

  • 1.1.1-RC6 (Git commit: 09eae40a2d1115ab2c6e5a45c9734a09722196b1)

Copyright:

  • David Weston (c) 2010 -> http://www.typefish.co.uk/licences/

Variables

Methods



Class Details

[line 27]
Master class for OUTRAGEbot

This class deals with all the interaction with plugins, how the bot acts, etc. This class also contains all of the commands, etc.

In this version, about half of the functions have been renamed, in order to be easier to remember, for example. That means, any

Note: In this documentation, there are some psuedo types that are used to describe certain arguments.

  • callback
    1.     $cCallback array($this"Function")// Different class instance
    2.     $cCallback "callLocalFunction";      // Only available in plugins
    It is used for binds and timers.




Tags:

author:  David Weston <westie@typefish.co.uk>
version:  1.1.1-RC6 (Git commit: 09eae40a2d1115ab2c6e5a45c9734a09722196b1)
copyright:  David Weston (c) 2010 -> http://www.typefish.co.uk/licences/


[ Top ]


Class Variables

$pCurrentBot =

[line 93]

Contains the instance of the current bot.



Tags:

access:  public

Type:   Socket


[ Top ]

$sCurrentChunk =

[line 100]

Contains the string/message that is sent to the bot



Tags:

access:  public

Type:   string


[ Top ]



Class Methods


method Action [line 1551]

void Action( string $sChannel, string $sMessage, [integer $mSend = SEND_DEF])

Sends an action to the specified channel.



Tags:

see:  Master::sendRaw()
access:  public


Parameters:

string   $sChannel   Channel name
string   $sMessage   Message to send
integer   $mSend   Method to send messages (see sendRaw() for details)

[ Top ]

method activatePlugin [line 1729]

bool activatePlugin( string $sPlugin)

Loads a plugin from the plugin directory.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sPlugin  

[ Top ]

method addChild [line 284]

bool addChild( string $sChild, string $sNickname, [string $sUsername = null], [string $sRealname = null])

This function creates a child. A child is an instance of the Socket, basically an IRC client.



Tags:

return:  true on success.
access:  public


Parameters:

string   $sChild   Child reference.
string   $sNickname   The child's nickname.
string   $sUsername   The child's username.
string   $sRealname   The child's real name.

[ Top ]

method addEventHandler [line 1912]

string addEventHandler( string $sEvent, callback $cCallback)

Creates an event handler, designed for lambda functions.



Tags:

return:  Event resource ID.
access:  public


Parameters:

string   $sEvent   Event name
callback   $cCallback   Callback to event handler.

[ Top ]

method addHandler [line 1950]

string addHandler( string $sInput, callback $cCallback, [array $aFormat = array()])

Create a command or event handler for IRC numerics/commands.



Tags:

return:  Bind resource ID.
access:  public


Parameters:

string   $sInput   either: IRC command/numeric name, or: 'COMMAND' for a text-based channel command.
callback   $cCallback   Callback to bind handler.
array   $aFormat   Array of arguments to pass to the bind handler.

[ Top ]

method addTimer [line 1660]

string addTimer( callback $cCallback, float $fInterval, integer $iRepeat, mixed $...)

Creates a timer, note that arguments to be passed to $cCallback to after $iRepeat.

  1.     $sKey $this->addTimer(array($this'Message')'0.5000''10''#OUTRAGEbot''Test Message');
  2.     $sKey $this->addTimer('sampleTimer''10''-1');




Tags:

return:  Timer reference ID.
access:  public


Parameters:

callback   $cCallback   Timer callback
float   $fInterval   Seconds (decimals can be used) between timer calls.
integer   $iRepeat   How many times the timer should call before it is destroyed. -1 implies infinite.
mixed   $...   Arguments to pass to timer.

[ Top ]

method ctcpReply [line 1624]

void ctcpReply( string $sNickname, string $sMessage)

Sends a CTCP reply.

  1. $this->ctcpReply('Westie''COMMAND something here');




Tags:

see:  Master::sendRaw()
access:  public


Parameters:

string   $sNickname   Nickname
string   $sMessage   CTCP reply

[ Top ]

method ctcpRequest [line 1640]

void ctcpRequest( string $sNickname, string $sRequest, [integer $mSend = SEND_DEF])

Sends a CTCP request.

  1. $this->ctcpRequest('deLUX''VERSION');




Tags:

see:  Master::sendRaw()
access:  public


Parameters:

string   $sNickname   Nickname
string   $sRequest   CTCP request
integer   $mSend   Method to send messages (see sendRaw() for details)

[ Top ]

method deactivatePlugin [line 1790]

bool deactivatePlugin( string $sPlugin)

Unloads an active plugin from memory.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sPlugin  

[ Top ]

method doesChildExist [line 396]

bool doesChildExist( string $sChild)

Checks if a child exists. Note that the child name is not necessarily the IRC nick of the bot, but in most cases it is.



Tags:

return:  true on success.
access:  public


Parameters:

string   $sChild   Child name.

[ Top ]

method Format [line 1486]

string Format( $sInputText, string $sText)

Adds formatting to the text.



Tags:

return:  Formatted text
access:  public


Parameters:

string   $sText   Text to format
   $sInputText  

[ Top ]

method getActiveTimer [line 1706]

string getActiveTimer( )

Gets the active timer ID.



Tags:

return:  Timer ID
access:  public


[ Top ]

method getChannel [line 1088]

Channel getChannel( string $sChannel)

Returns a stdClass instance of the information about a channel.

Will only work if the bot is in the channel, otherwise a blank object will be returned.




Tags:

return:  Channel information
access:  public


Parameters:

string   $sChannel   Channel name

[ Top ]

method getChannelBanList [line 1143]

array getChannelBanList( string $sChannel)

Returns the active bans in the channel requested.



Tags:

return:  List of bans
access:  public


Parameters:

string   $sChannel   Channel name

[ Top ]

method getChannelExceptList [line 1197]

array getChannelExceptList( string $sChannel)

Returns the active exceptions in the channel requested.



Tags:

return:  List of exceptions
access:  public


Parameters:

string   $sChannel   Channel name

[ Top ]

method getChannelInviteList [line 1170]

array getChannelInviteList( string $sChannel)

Returns the active invite list in the channel requested.



Tags:

return:  List of exceptions
access:  public


Parameters:

string   $sChannel   Channel name

[ Top ]

method getChannelList [line 1106]

array getChannelList( )

Returns the channels that the bot is in.



Tags:

return:  Array of channels
access:  public


[ Top ]

method getChannelTopic [line 1224]

array getChannelTopic( string $sChannel)

Returns the channel topic in the channel requested.



Tags:

return:  Topic information
access:  public


Parameters:

string   $sChannel   Channel name

[ Top ]

method getChannelUserCount [line 1118]

integer getChannelUserCount( string $sChannel)

Returns the amount of users in the channel.



Tags:

return:  Amount of users in channel
access:  public


Parameters:

string   $sChannel   Channel name

[ Top ]

method getChildConfig [line 437]

mixed getChildConfig( string $sKey)

Returns a value from the current bot's configuration.



Tags:

return:  Value that is returned.
access:  public


Parameters:

string   $sKey   Configuration key to lookup.

[ Top ]

method getChildObject [line 322]

Socket getChildObject( string $sChild)

Returns an object of a child from its reference.



Tags:

return:  Class of the socket child.
access:  public


Parameters:

string   $sChild   Child reference.

[ Top ]

method getChildren [line 303]

array getChildren( )

Returns a list of all the children that the bot has.



Tags:

return:  Array of children's names.
access:  public


[ Top ]

method getHandler [line 1980]

array getHandler( string $sKey)

Gets the information of a bind from its reference ID.



Tags:

return:  Array of bind information.
access:  public


Parameters:

string   $sKey   Bind reference ID.

[ Top ]

method getHostname [line 599]

string getHostname( string $sHost)

Get the users hostname from a hostname string.



Tags:

return:  Hostname
access:  public


Parameters:

string   $sHost   The hostmask string

[ Top ]

method getIBCCount [line 2342]

integer getIBCCount( [string $sChannel = "Default"])

Counts the amount of messages in the stack for the current bot group.



Tags:

return:  Amount of messages in the stack.
access:  public


Parameters:

string   $sChannel   Channel name

[ Top ]

method getIBCMessages [line 2326]

array getIBCMessages( [string $sChannel = "Default"])

Recieve all inter-bot-communication messages that are in the stack for this particular bot.



Tags:

return:  Array of all messages.
access:  public


Parameters:

string   $sChannel   Channel name

[ Top ]

method getNetworkConfig [line 455]

mixed getNetworkConfig( string $sKey)

Returns a value from the network configuration. This is anything that is within [~Network].



Tags:

return:  Value that is returned.
access:  public


Parameters:

string   $sKey   Configuration key to lookup.

[ Top ]

method getNextChild [line 642]

Socket getNextChild( )

This function gets the next child along in the queue.



Tags:

return:  Child object.
access:  public


[ Top ]

method getNickname [line 586]

string getNickname( string $sHost)

Get the users nickname from a hostname string.



Tags:

return:  Nickname
access:  public


Parameters:

string   $sHost   The hostmask string

[ Top ]

method getPlugin [line 1756]

Plugin getPlugin( string $sPlugin)

Gets the instance of the plugin if it exists.



Tags:

return:  Object of the plugin.
access:  public


Parameters:

string   $sPlugin   Plugin name

[ Top ]

method getPluginName [line 1773]

string getPluginName( class $pInstance)

Get the name of the plugin from the instance



Tags:

return:  Plugin name, or if not Plugin class, the object.
access:  public


Parameters:

class   $pInstance   Instance of plugin

[ Top ]

method getRequest [line 2093]

array getRequest( string $sRequest, mixed $mSearch, mixed $mEndNumeric, [mixed $iTimeout = 4], [integer $iSleep = 0.3])

Request information realtime.

The data that are you requesting (for instance, what is in $mSearch) will not be parsed by the bot. This essentially means it is the job of the code using that request to deal with parsing it properly.




Tags:

return:  The response matched to the data in $mSearch.
access:  public


Parameters:

string   $sRequest   Message to send to the server.
mixed   $mSearch   IRC numerics to cache.
mixed   $mEndNumeric   IRC numerics that signify end of stream
mixed   $iTimeout   Seconds to timeout
integer   $iSleep   Seconds to sleep before getting input.

[ Top ]

method getTimer [line 1695]

array getTimer( string $sKey)

Gets the information of a timer from its reference ID.



Tags:

return:  Array of timer information.
access:  public


Parameters:

string   $sKey   Timer reference ID.

[ Top ]

method getUser [line 1074]

User getUser( string $sNickname)

Returns information about the user in an OOP format. This only currently retrieves channel information. For this, the user must be in a channel with the bot.



Tags:

return:  Class with information.
access:  public


Parameters:

string   $sNickname   Nickname you want to get data for.

[ Top ]

method getUsername [line 573]

string getUsername( string $sHost)

Get the users username from a hostname string.



Tags:

return:  Nickname
access:  public


Parameters:

string   $sHost   The hostmask string

[ Top ]

method getWhois [line 2223]

array getWhois( string $sNickname, [boolean $bKeepModes = false], integer $iDelay)

Returns current WHOIS data about a user into an array.



Tags:

return:  Array of modes.
access:  public


Parameters:

string   $sNickname   Nickname of the user.
boolean   $bKeepModes   Keep the user perms next to the channel name
integer   $iDelay   Microseconds to wait before fetching input.

[ Top ]

method introduceFunction [line 1845]

boolean introduceFunction( string $sFunction, callback $cCallback)

Introduces a function handler.



Tags:

return:  True on success
access:  public


Parameters:

string   $sFunction   Function name
callback   $cCallback   Callback

[ Top ]

method Invite [line 2122]

void Invite( string $sChannel, string $sNickname)

Invites a user to a channel.



Tags:

access:  public


Parameters:

string   $sChannel   Channel name.
string   $sNickname   Nickname of the person to invite

[ Top ]

method isAdmin [line 1365]

bool isAdmin( )

Check if the current, active IRC user is a bot admin.



Tags:

return:  'true' on success.
access:  public


[ Top ]

method isChild [line 1381]

bool isChild( [string $sChild = ""])

Checks if either the current instance, or a specific instance is actually a child. Children differ from master bots in one variable.



Tags:

return:  true on success, null if child is non-existant.
access:  public


Parameters:

string   $sChild   Child reference.

[ Top ]

method isChildInChannel [line 1249]

bool isChildInChannel( string $sChannel)

Checks if the current child is in the channel.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sChannel   Channel to check.

[ Top ]

method isFunction [line 1871]

boolean isFunction( string $sFunction)

Checks if a function handler exists.



Tags:

return:  True on success
access:  public


Parameters:

string   $sFunction   Function name

[ Top ]

method isPluginActivated [line 1832]

bool isPluginActivated( string $sPlugin)

Check if a plugin is loaded into memory.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sPlugin  

[ Top ]

method isUserAdmin [line 1326]

bool isUserAdmin( string $sChannel, string $sUser)

Checks if that user has admin in that channel. Admins have the mode ' & ', and may not be available on all networks.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sChannel   Channel where user is
string   $sUser   Nickname to check

[ Top ]

method isUserHalfOp [line 1284]

bool isUserHalfOp( string $sChannel, string $sUser)

Checks if that user has half-op in that channel. Half operators have the mode ' % ', and may not be available on all networks.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sChannel   Channel where user is
string   $sUser   Nickname to check

[ Top ]

method isUserInChannel [line 1237]

bool isUserInChannel( string $sChannel, string $sUser)

Checks if that user is actually in that channel.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sChannel   Channel where user is
string   $sUser   Nickname to check

[ Top ]

method isUserOper [line 1305]

bool isUserOper( string $sChannel, string $sUser)

Checks if that user has operator in that channel. Operators have the mode ' @ '.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sChannel   Channel where user is
string   $sUser   Nickname to check

[ Top ]

method isUserOwner [line 1347]

bool isUserOwner( string $sChannel, string $sUser)

Checks if that user has owner in that channel. Owners have the mode ' ~ ', and may not be available on all networks.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sChannel   Channel where user is
string   $sUser   Nickname to check

[ Top ]

method isUserVoice [line 1263]

bool isUserVoice( string $sChannel, string $sUser)

Checks if that user has voice in that channel. Voicers have the mode ' + '.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sChannel   Channel where user is
string   $sUser   Nickname to check

[ Top ]

method Join [line 2147]

void Join( string $sChannel, [mixed $mSend = SEND_DEF])

Allows the bot to join a channel.



Tags:

access:  public


Parameters:

string   $sChannel   Channel name (IRC format applies!).
mixed   $mSend   Output flags

[ Top ]

method Kick [line 2135]

void Kick( string $sChannel, string $sNickname, [string $sReason = "Kick"])

Kicks a user from a channel.



Tags:

access:  public


Parameters:

string   $sChannel   Channel name.
string   $sNickname   Nickname of the person to kick.
string   $sReason   Reason of the kick.

[ Top ]

method Message [line 1537]

void Message( string $sChannel, string $sMessage, [integer $mSend = SEND_DEF])

Sends a message to the specified channel.



Tags:

see:  Master::sendRaw()
access:  public


Parameters:

string   $sChannel   Channel name or nickname
string   $sMessage   Message to send
integer   $mSend   Method to send messages (see sendRaw() for details)

[ Top ]

method Mode [line 2172]

void Mode( string $sChannel, string $sMode)

Set the modes on a channel.



Tags:

access:  public


Parameters:

string   $sChannel   Channel name
string   $sMode   Mode to be set

[ Top ]

method Notice [line 1576]

void Notice( string $sNickname, string $sMessage, [integer $mSend = SEND_DEF])

Sends a notice to the specified channel.



Tags:

see:  Master::sendRaw()
access:  public


Parameters:

string   $sNickname   Nickname
string   $sMessage   Message to send
integer   $mSend   Method to send messages (see sendRaw() for details)

[ Top ]

method parseHostmask [line 612]

array parseHostmask( string $sHost)

Get the hostmask info as an array.



Tags:

return:  Array of hostmask info
access:  public


Parameters:

string   $sHost   The hostmask string

[ Top ]

method parseModes [line 2184]

array parseModes( $sModes $sMode)

Parses a mode string into a usable array.



Tags:

return:  Array of modes.
access:  public


Parameters:

$sModes   $sMode   Mode that has just been set.

[ Top ]

method Part [line 2160]

void Part( string $sChannel, [string $sReason = null], [mixed $mSend = SEND_DEF])

Allows the bot to part a channel.



Tags:

access:  public


Parameters:

string   $sChannel   Channel name.
string   $sReason   Reason for leaving
mixed   $mSend   Method for sending messages

[ Top ]

method reactivatePlugin [line 1819]

bool reactivatePlugin( string $sPlugin)

Unloads and reloads a plugin.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sPlugin  

[ Top ]

method removeChild [line 364]

bool removeChild( string $sChild, [string $sReason = null])

Removes a child from this group.

Please note that you cannot remove the master. That would just be pointless.




Tags:

return:  true on success.
access:  public


Parameters:

string   $sChild   Child reference.
string   $sReason   Reason for quitting channel.

[ Top ]

method removeEventHandler [line 1926]

void removeEventHandler( string $sHandlerID)

Removes the event hander.



Tags:

access:  public


Parameters:

string   $sHandlerID   Event handler ID

[ Top ]

method removeFunction [line 1883]

void removeFunction( string $sFunction)

Remove a function handler.



Tags:

access:  public


Parameters:

string   $sFunction   Function name

[ Top ]

method removeHandler [line 1997]

bool removeHandler( string $sKey)

Delete a reference to a bind handler.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sKey  

[ Top ]

method removeTimer [line 1717]

bool removeTimer( string $sKey)

Removes a timer from memory.



Tags:

return:  'true' on success.
access:  public


Parameters:

string   $sKey   Timer reference ID.

[ Top ]

method resetChild [line 417]

void resetChild( string $sChild, [string $sMessage = "Rehash!"])

This function reconnects a IRC child. This is useful in cases where IRC bots have to physically disconnect from the network in order to work.



Tags:

access:  public


Parameters:

string   $sChild   Child reference.
string   $sMessage   Quit message.

[ Top ]

method sendIBCMessage [line 2312]

void sendIBCMessage( string $sBotGroup, mixed $mContents, [string $sChannel = "Default"])

Send an inter-bot-communication message to a bot-group. It will remain in the queue until it is retrieved from the stack.



Tags:

access:  public


Parameters:

string   $sBotGroup   Bot group to send the message to.
mixed   $mContents   Thing to put into the stack.
string   $sChannel   Channel name

[ Top ]

method sendRaw [line 499]

void sendRaw( string $sMessage, [mixed $mSend = SEND_DEF])

Sends RAW IRC Messages to the server.

There are many different ways of sending a message with this function - this covers all outbound functions. There are three different ways, using the definitions, a string of a child name, or an array of children's names.

as Definitions:

  • SEND_MAST: Sends a message from the master child.
  • SEND_CURR: Sends a message from the current child.
  • SEND_DIST: Sends a message from each child in succession.
  • SEND_ALL: Send a message from all children at the same time.
as a String: You can send a message from a child's name. For children that are defined in the configuration, it will be their original nickname, whilst for bots created later, it will be name you give them.

as an Array: You can send messages only from selected children. The same note above applies.

  1.     $this->sendRaw('PRIVMSG #Westie :hai there');                           // Use default settings.
  2.     $this->sendRaw('PRIVMSG #Westie :Everyone says hai!'SEND_ALL);           // All children.
  3.     $this->sendRaw('PRIVMSG #Westie :OUTRAGEbot says hai!''OUTRAGEbot');     // From the OUTRAGEbot child.




Tags:

access:  public


Parameters:

string   $sMessage   Raw IRC message you want to send.
mixed   $mSend   How to send the message (Look above).

[ Top ]

method setNickname [line 345]

void setNickname( string $sChild, string $sNewNick)

This function renames a child by its reference. The reference is (in most cases) the bot's original name. Look in the configuration for more details.



Tags:

access:  public


Parameters:

string   $sChild   Child reference.
string   $sNewNick   New nickname of the child.

[ Top ]

method stripAll [line 1522]

string stripAll( string $sText)

Strips the text of formatting and colours.



Tags:

return:  Stripped text
access:  public


Parameters:

string   $sText   Text to strip

[ Top ]

method stripColour [line 1510]

string stripColour( string $sText)

Strips the text of colours.



Tags:

return:  Stripped text
access:  public


Parameters:

string   $sText   Text to strip

[ Top ]

method stripFormat [line 1498]

string stripFormat( string $sText)

Strips the text of formatting.



Tags:

return:  Stripped text
access:  public


Parameters:

string   $sText   Text to strip

[ Top ]

method syncChannelLists [line 1131]

void syncChannelLists( string $sChannel)

Syncs the internal channel lists. Useful if there happens to be a mistake.



Tags:

access:  public


Parameters:

string   $sChannel   Channel name

[ Top ]

method triggerEvent [line 1401]

void triggerEvent( string $sEvent, mixed $...)

Invokes an event/callback from plugins.



Tags:

access:  public


Parameters:

string   $sEvent   Event to invoke
mixed   $...   Arguments to pass to event.

[ Top ]

method triggerSingleEvent [line 1438]

void triggerSingleEvent( string $sPlugin, string $sEvent, mixed $...)

Invokes an event from one plugin only.



Tags:

access:  public


Parameters:

string   $sPlugin   Plugin name
string   $sEvent   Event to invoke
mixed   $...   Arguments to pass to event.

[ Top ]

method triggerSingleEventArray [line 1456]

void triggerSingleEventArray( string $sPlugin, string $sEvent, array $aArguments, [ $iTimerCalled = false])

Invokes an event from one plugin only, but arguments are an array



Tags:

access:  public


Parameters:

string   $sPlugin   Plugin name
string   $sEvent   Event to invoke
array   $aArguments   Arguments to pass to event.
   $iTimerCalled  

[ Top ]


Documentation generated on Sat, 21 Aug 2010 19:12:01 +0100 by phpDocumentor 1.4.3