This commit is contained in:
Denny Dai 2015-05-30 00:45:47 +08:00
parent 9ab379e3c2
commit 1ba0b5d908
3 changed files with 1 additions and 86 deletions

View File

@ -1,7 +1,6 @@
<?php
//init
require('classes/Telegram/Base.php');
require('classes/Telegram/Client.php');
$BOT = new DBot\Telegram\Client('unix:///tmp/tg.sck');
require_once('init.php');
?>

1
D-bot Submodule

@ -0,0 +1 @@
Subproject commit da86cbe130d2da018b2b497d903bb368a2c30966

View File

@ -1,85 +0,0 @@
<?php
namespace DBot\Telegram;
class Client extends Base
{
public function setStatusOnline()
{
return $this->exec('status_online');
}
public function setStatusOffline()
{
return $this->exec('status_offline');
}
public function msg($peer, $msg)
{
$peer = $this->escapePeer($peer);
$msg = $this->escapeStringArgument($msg);
return $this->exec('msg ' . $peer . ' ' . $msg);
}
public function addContact($phoneNumber, $firstName, $lastName)
{
$phoneNumber = preg_replace('%[^0-9]%', '', (string) $phoneNumber);
if (empty($phoneNumber)) {
return false;
}
return $this->exec('add_contact ' . $phoneNumber . ' ' . $this->escapeStringArgument($firstName)
. ' ' . $this->escapeStringArgument($lastName));
}
public function renameContact($contact, $firstName, $lastName)
{
return $this->exec('rename_contact ' . $this->escapePeer($contact)
. ' ' . $this->escapeStringArgument($firstName) . ' ' . $this->escapeStringArgument($lastName));
}
public function deleteContact($contact)
{
return $this->exec('del_contact ' . $this->escapePeer($contact));
}
public function markRead($peer)
{
return $this->exec('mark_read ' . $this->escapePeer($peer));
}
public function getContactList()
{
return explode(PHP_EOL, $this->exec('contact_list'));
}
public function getUserInfo($user)
{
return $this->exec('user_info ' . $this->escapePeer($user));
}
public function getDialogList()
{
return explode(PHP_EOL, $this->exec('dialog_list'));
}
public function getHistory($peer, $limit = null, $offset = null)
{
if ($limit !== null) {
$limit = (int) $limit;
if ($limit < 1) { //if limit is lesser than 1, telegram-cli crashes
$limit = 1;
}
$limit = ' ' . $limit;
} else {
$limit = '';
}
if ($offset !== null) {
$offset = ' ' . (int) $offset;
} else {
$offset = '';
}
return $this->exec('history ' . $this->escapePeer($peer) . $limit . $offset);
}
}