The most reasonable new functionality - about 30 new Phurple\Client callbacks implemented, which give control over almost any event in the conversation.
Windows PHP users HEADS UP - Windows builds are available now. Besides the extension DLL an appropriate libpurple build is needed, which is available in the
sourceforge files section.
Besides the new client callbacks, several new methods are implemented in other classes. That makes possible Jabber conferencing and better IRC integration. The windows binaries are usable with PHP 5.3+ and use native libpurple.dll builds.
Here's a small new example, you can find some more on
github. This new example illustrates the usage of the IRC libpurple plugin. The callbacks have to be implemented in the Phurple\Client class.
PHP:
<?php
ob_implicit_flush(true);
use Phurple\Client;
use Phurple\Account;
use Phurple\Conversation;
use Phurple\Connection;
use Phurple\Buddy;
use Phurple\BuddyList;
class IrcClient extends Client
{
protected function writeIM($conversation, $buddy, $alias, $message, $flags, $time)
{/*{{{*/
printf( "(%s) %s %s: %s\n",
is_object($buddy) ? $buddy->getName() : $conversation->getName(),
date("H:i:s", $time),
is_object($buddy) ? $buddy->getAlias() : $buddy,
$message
);
if(self::MESSAGE_NICK == ($flags & self::MESSAGE_NICK)) {
$conversation->sendIM("$buddy, why did you say '$message'?");
} else if(self::MESSAGE_RECV == ($flags & self::MESSAGE_RECV)) {
$conversation->sendIM(md5(uniqid()));
}
}/*}}}*/
protected function onSignedOn($connection)
{/*{{{*/
$account = $connection->getAccount();
$conversation = new Conversation(self::CONV_TYPE_CHAT, $account, "#somechannel");
}/*}}}*/
protected function loopHeartBeat()
{/*{{{*/
static $countdown = 0;
/* Loop for one minute and exit */
if ($countdown > 60) {
$this->disconnect();
$this->quitLoop();
}
$countdown++;
}/*}}}*/
protected function chatJoined($conversation)
{/*{{{*/
$buddy = "somebuddy";
if (!$conversation->isUserInChat($buddy)) {
$conversation->inviteUser($buddy, "common buddy!");
$conversation->sendIM("{$buddy}, just starting a conversation. hi there");
} else {
$conversation->sendIM("{$buddy}, got you ;)");
}
}/*}}}*/
}
try {/*{{{*/
$user_dir = "/tmp/phurple-test";
if(!file_exists($user_dir) || !is_dir($user_dir)) {
mkdir($user_dir);
}
IrcClient::setUserDir($user_dir);
IrcClient::setUiId("TestUI");
$client = IrcClient::getInstance();
$client->addAccount("irc://mybot@irc.freenode.net");
$client->connect();
$client->runLoop(1000);
} catch (Exception $e) {
echo "[Phurple]: " . $e->getMessage() . "\n";
die();
}/*}}}*/`
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
In this example one of the new callbacks is used, the Phurple\Client::chatJoined(). It's invoked when the account has joined a chat. Please consult the documentation for other available callbacks.
I'd also specially notice the usage of Phurple\Client::runLoop() method. Invoked with a numeric argument it'll cause Phurple\Client::loopHeartBeat() to be called with the given interval. That allows to implement timeout exit in an elegant way without having to use Phurple\Client::iterate() outside the class.
Regarding Windows usage - the binaries supplied are native Visual Studio builds. That means the libpurple.dll usage is limited to the binaries on the phurple sourcefourge project page (or any other native builds). Don't try to use the binaries from the Pidgin distribution, they're compiled with gcc and are not in any way compatible with native builds.
That's it for now, enjoy the new release
