DAmnPHP

From Botdom Documentation
Jump to: navigation, search
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.

Properties

  • int $Ver - Variable containing the version of dAmnPHP.
  • array $server - This array holds the configuration data for the connections used.
  • string $Client - Variable containing brief information about the client.
  • socket resource $socket - Variable holding a reference to the socket connection.
  • bool $connecting - Flag determining whether the client is connecting or not. Not maintained by dAmnPHP!
  • bool $login - Flag determining whether the client is logging in or not. Not maintained by dAmnPHP!
  • bool $connected - Flag determining whether the client is connected or not. Not maintained by dAmnPHP!
  • bool $close - Flag determining whether the connection is being closed or not. Not maintained by dAmnPHP!
  • string $buffer - Stream buffer, used to capture split packets.
  • array $chat - Joined channels. This is not managed by dAmnPHP.
  • integer $disconnects - Number of disconnects that have occured. This is not managed by dAmnPHP.
  • array $tablumps - Array containing the regular expressions used to decode dAmn's tablumps.

Methods

Time, Clock, Message, Notice and Warning

See here.

array getCookie(string $username, string $password)

This returns a deviantART cookie as an array. Returns Null on failure, and returns 1 if no connection could be made. Example: <php>$cookie = $dAmn->getCookie('username', 'password'); echo 'authtoken: ' . $cookie['authtoken'] . "\n";</php>

bool connect(void)

Open a connection to dAmn, and send a handshake!
Example: <php>$dAmn->connect();</php> Returns true on success, false on failure.
Sets property $dAmn->connecting to true.

void login(string $username, string $authtoken)

Sends a login packet to dAmn.
Example: <php>$dAmn->login('username', $cookie['authtoken']);</php> Sets property $dAmn->login to true.

string deform_chat(string $namespace[, string $discard_name])

Deformat a channel namespace for dAmn. if $discard_name is set, then $discard_name will be removed from the string if it is found in a private chat namespace. Example: <php>$channel = $dAmn->deform_chat('chat:Botdom'); // $channel = '#Botdom' $channel = $dAmn->deform_chat('pchat:foo:photofroggy'); // $channel = 'pchat:foo:photofroggy' $channel = $dAmn->deform_chat('pchat:foo:photofroggy', 'foo'); // $channel = '@photofroggy'</php>

string format_chat(string $channel[, string $user])

Formats channel names to dAmn namespaces. If the channel is a pchat (starts with '@'), then $user is used when formatting the namespace.

Parameters:
 $channel - string. Channel to format.

Example: <php>$namespace = $dAmn->format_chat('#Botdom'); // $namespace = 'chat:Botdom' $namespace = $dAmn->format_chat('@photofroggy', 'pfbot'); // $namespace = 'pchat:pfbot:photofroggy'</php>

void join(string $namespace)

Join a channel on dAmn! This will send a join packet to the dAmn server.
Example: <php>$dAmn->join('chat:Botdom');</php>

void part(string $namespace)

Part a channel on dAmn! This will send a part packet to the dAmn server.
Example: <php>$dAmn->part('chat:Botdom');</php>

void say(string $namespace, string $message)

Send message $message to channel $namespace on dAmn.
Example: <php>$dAmn->say('chat:Botdom', 'Hello, world!');</php>

void action(string $namespace, string $action)

Send a /me packet to $namespace with action $action to dAmn.
Example: <php>$dAmn->action('chat:Botdom', 'is a script');</php>

void npmsg(string $namespace, string $message)

Send a non-parsed message to $namespace on dAmn.
Example: <php>$dAmn->npmsg('chat:Botdom', 'No emoticons here :(');</php>

void promote(string $namespace, string $username[, string $privilege_class])

Promote $username in $namespace to privilege class $privilege_class on dAmn. If $privilege_class is not set, the user will just be promoted by one privilege class.
Example: <php>$dAmn->promote('chat:Botdom', 'foo', 'BotOwners');</php>

void demote(string $namespace, string $username[, string $privilege_class])

Demote $username in $namespace to privilege class $privilege_class on dAmn. If $privilege_class is not set, the user will just be demoted by one privilege class.
Example: <php>$dAmn->demote('chat:Botdom', 'foo', 'Silenced');</php>

void kick(string $namespace, string $username[, string $reason])

Kick $username from $namespace on dAmn with reason $reason. If $reason is not set, no reason is sent.
Example: <php>$dAmn->kick('chat:Botdom', 'foo', 'you\'re such a foo!');</php>

void ban(string $namespace, string $username)

Ban user $username from channel $namespace on dAmn.
Example: <php>$dAmn->ban('chat:Botdom', 'foo');</php>

void unban(string $namespace, string $username)

Unban user $username from channel $namespace on dAmn.
Example: <php>$dAmn->unban('chat:Botdom', 'foo');</php>

void get(string $namespace, string $property)

Get property $property for channel $namespace on dAmn.
Example: <php>$dAmn->get('chat:Botdom', 'topic');</php>

void set(string $namespace, string $property, string $value)

Set property $property to $value in $namespace on dAmn.
Example: <php>$dAmn->set('chat:Botdom', 'topic', 'This is a topic, foo!');</php>

void admin(string $namespace, string $command)

Send admin command $command to channel $namespace on dAmn.
Example: <php>$dAmn->admin('chat:Botdom', 'show privclass');</php>

void disconnect(void)

Send a disconnect packet to dAmn!
Example: <php>$dAmn->disconnect();</php>

void send(string $packet)

Send a packet to dAmn!
Example: <php>$dAmn->send("send chat:Botdom\n\nmsg main\n\nHello, world!\n"); // This is the same as $dAmn->say('chat:Botdom', 'Hello, world!');</php>

mixed read(void)

Read some packets from dAmn! The packets are returned as an array! Returns false on error.
Example: <php>$packets = $dAmn->read();</php>