DAmnPHP
From Botdom Documentation
- The correct title of this article is dAmnPHP. The initial letter is capitalized due to technical limitations.
dAmnPHP is a small set of functions for handling dAmn sockets in PHP. The package is named after the class included with the package, and is made by photofroggy. Here we have documentation for the dAmnPHP class.
Contents |
Properties
protected $Version = 2; // Current version of dAmnPHP protected $server = array(); // Connection configuration. protected $Client; // Client string. protected $_login = array(); // Login details. protected $socket = Null; // Socket resource. protected $cookie = Null; // deviantART.com login cookie. protected $token = Null; // deviantART.com authtoken. public $connecting = Null; // Whether we are in the process of connecting or not. public $login = Null; // Whether we are in the process of logging in or not. public $connected = Null; // Whether we are fully connected to dAmn or not. public $close = Null; // Whether the connection is being closed or not. protected $buffer = Null; // Stream buffer, used to capture split packets. public $chat = array(); // Joined channels. This is not managed by the class. public $users = array(); // Known users. This is not managed by the class. public $disconnects = 0; // Disconnects. This is not managed by the class. static $tablumps = array(); // Tablump regexes.
Methods
__construct
Called when the class is instantiated. Stores relevent information.
Parameters: $login - array. Login details to be used for the connection. $owner - string. Owner of the client in use. $trigger - string. Trigger character being used (for bots). $author - string. Author of the client in use. $client - string. Name of the client in use.
Example:
$dAmn = new dAmnPHP( array( 'username' => 'foo', 'password' => 'bar', ), 'photofroggy', '!', 'photofroggy', 'Contra 2 fix/public' );
Time, Clock, Message, Notice and Warning
See here.
init
This method grabs an authtoken and opens a connection to dAmn using the data provided in __construct. This method calls the authtoken and connect methods.
Example:
$dAmn->init();
Returns true if dAmnPHP manages to connect, false on failure.
authtoken
Grab an authtoken! Authtoken is not returned, it is stored in a class property.
Parameters: $username - string. Username to get an authtoken for. $password - string. Password to use. Both must be valid.
Example:
$dAmn->authtoken('foo', 'bar');
connect
Open a connection to dAmn, and send a handshake!
Example:
$dAmn->connect();
Returns true on success, false on failure.
Sets property $connecting to true.
login
Sends a login packet to dAmn using the stored data.
Example:
$dAmn->login();
Sets property $login to true.
deform_chat
Deformat a channel namespace for dAmn.
Parameters: $namespace - string. Namespace to deformat. $discard - string. Username to be discarded when deformatting a private channel namespace. Uses the provided login name if set to false (default).
Example:
$channel = $dAmn->deform_chat('chat:Botdom'); // $channel = '#Botdom' $channel = $dAmn->deform_chat('pchat:foo:photofroggy'); // $channel = '@photofroggy'
format_chat
Format a channel namespace for dAmn.
Parameters: $channel - string. Channel to format.
Example:
$namespace = $dAmn->format_chat('#Botdom'); // $namespace = 'chat:Botdom'

