DeBot Framework


DeBot\Bot
core/Bot.php at line 19

Class Bot

Bot

public class Bot

DeBot Core - Bot Created by dab ??? ?? 2009 Last Edited: Jul 29 2010 Last Edited: Aug 15 2010 This file contains the structure for a SINGLE complete bot. It auto loads everything from the config based on either the Default bot config or the designated nick for this bot. It also processes every line sent to it here, and designates the line to their appropiate callbacks on the modules.

Author:
David (dab)
Version:
v1.0

Field Summary
stdclass An all around generic place holder for variables /

$bufferIn

A temporary loaction for all Information for the bot

stdclass[] nick /

$bufferOut

Messages to send to the server (Startup commands)

String The bot's nick /

$parse

Stores the bot's nick

Method Summary
void

__construct(string sNick)

This function loads all settings from the config based on provided nick.

Boolean

addServer(String sName, String sServer, Integer iPort, String sBind, Boolean bSSL)

This method adds a server to the bot (or reconnects if the connection already exists).

Boolean

check()

This command performs a check for incoming messages.

boolean

delServer(string sServer)

This function removes a server from a bot.

string

getDef()

This returns the default bot...

boolean

join(string sChan, string sPass, string sNet)

Just like the msg method but for joining channels.

boolean

me(string sTo, string sMsg, string sNet)

I noticed some people want to use a shortcut instead of writing out PRIVMSG #CHANNEL :OHI THERE! so I decided to add a quick method to send a message.

boolean

msg(string sTo, string sMsg, string sNet)

I noticed some people want to use a shortcut instead of writing out PRIVMSG #CHANNEL :OHI THERE! so I decided to add a quick method to send a message.

void

offsetExists(mixed sKey)

void

offsetGet(mixed sKey)

void

offsetSet(mixed sKey, mixed mValue)

void

offsetUnset(mixed sKey)

boolean

part(string sChan, string sNet)

Just like the join method but for joining channels.

null

process(String sLine)

This is our motherload of methods.

boolean

raw(string sMsg, String sNet)

I'm kind of proud of this command.

boolean|string

setDef(string sKey)

This sets the default bot...

Field Detail

core/Bot.php at line 72

bufferIn

public stdclass An all around generic place holder for variables / $bufferIn

A temporary loaction for all Information for the bot


core/Bot.php at line 79

bufferOut

public stdclass[] nick / $bufferOut

Messages to send to the server (Startup commands)


core/Bot.php at line 26

parse

public String The bot's nick / $parse = null

Stores the bot's nick


Method Detail

core/Bot.php at line 96

__construct

public void __construct(string sNick)

This function loads all settings from the config based on provided nick. If the nick is in the config, we pull from that, otherwise we get the default bot configuration and run with that.

Parameters:
sNick - The nick of the bot we are loading

core/Bot.php at line 164

addServer

public Boolean addServer(String sName, String sServer, Integer iPort, String sBind, Boolean bSSL)

This method adds a server to the bot (or reconnects if the connection already exists).

Parameters:
sName - The Name of the server (Used to store for future)
sServer - The IP/Host of the server to connect to
iPort - The Port to connect to
sBind - The IP to bind to (for use with multiple IPs)
bSSL - If we should attempt to connect via SSL?
Returns:
True on connect, false on failure (an error log is generated)

core/Bot.php at line 375

check

public Boolean check()

This command performs a check for incoming messages. Really the receiving part of this bot. Vital for anything to happen (It would pingout without it).


core/Bot.php at line 210

delServer

public boolean delServer(string sServer)

This function removes a server from a bot. This used to cause crashes but has since been debugged and resolved.

Parameters:
sServer - The name of the server to remove
Returns:
True on delete, false on issues

core/Bot.php at line 340

getDef

public string getDef()

This returns the default bot... this is here for legacy support. Deprecated, do not use! Use Bots::obj()->getDef() instead This will be removed after v1.1 (Within the next release)

Deprecated:
since v0.9
Returns:
the default bot

core/Bot.php at line 301

join

public boolean join(string sChan, string sPass, string sNet)

Just like the msg method but for joining channels.

Parameters:
sChan - The channel to join (with # in front)
sPass - The password for the channel
sNet - Optional, the network to send to
Returns:
True on success, false on failure

core/Bot.php at line 281

me

public boolean me(string sTo, string sMsg, string sNet)

I noticed some people want to use a shortcut instead of writing out PRIVMSG #CHANNEL :OHI THERE! so I decided to add a quick method to send a message.

Parameters:
sTo - The channel or user to send this message to
sMsg - The Message to send
sNet - Optional, the network to send a message to
Returns:
True if sent, false if not.

core/Bot.php at line 260

msg

public boolean msg(string sTo, string sMsg, string sNet)

I noticed some people want to use a shortcut instead of writing out PRIVMSG #CHANNEL :OHI THERE! so I decided to add a quick method to send a message.

Parameters:
sTo - The channel or user to send this message to
sMsg - The Message to send
sNet - Optional, the network to send a message to
Returns:
True if sent, false if not.

core/Bot.php at line 678

offsetExists

public void offsetExists(mixed sKey)

core/Bot.php at line 700

offsetGet

public void offsetGet(mixed sKey)

core/Bot.php at line 730

offsetSet

public void offsetSet(mixed sKey, mixed mValue)

core/Bot.php at line 754

offsetUnset

public void offsetUnset(mixed sKey)

core/Bot.php at line 319

part

public boolean part(string sChan, string sNet)

Just like the join method but for joining channels.

Parameters:
sChan - The channel to join (with # in front)
sNet - Optional, the network to send to
Returns:
True on success, false on failure

core/Bot.php at line 408

process

public null process(String sLine)

This is our motherload of methods. This is where we do the parsing for our incoming messages. All PINGs, PRIVMSG, Numerical Values (whois, welcome messages, etc) are done here. As with the check(), without this method, the bot will not function. Note to self, other devs. If any optimization is to be done, it will be done here. I have a feeling that the regex might be slowing it down a bit. As well as some other not needed things like Neduka. :/ It was a good idea at time of dev. After more looking, Neduka is a problem, but it is still needed. I will need to find ways of making it faster.

Parameters:
sLine - The line to parse. IRC has a tendancy to pool lines, so we split and send line by line

core/Bot.php at line 236

raw

public boolean raw(string sMsg, String sNet)

I'm kind of proud of this command. I needed a way of sending raw messages without the command being too difficult. I decided with an auto network setting, when messages are received. It isn't perfect, but it works wonders for making things simple. Especially when you are only using 1 network. Anyway, this command sends a raw line of data to the server. If you don't select a network to send to, it will send to the last server to send the bot data.

Parameters:
sMsg - The line of data to send (No \r\n needed).
sNet - Optional parameter to tell the bot what network to send to
Returns:
True if sent, otherwise false if cannot send (no network, not connectd, etc).

core/Bot.php at line 355

setDef

public boolean|string setDef(string sKey)

This sets the default bot... this is here for legacy support. Deprecated, do not use! Use Bots::obj()::setDef( $sKey ) instead This will be removed after v1.1 (Within the next release)

Deprecated:
since v0.9
Parameters:
sKey - The bot to set as default
Returns:
New nick on success, false on failure

DeBot Framework