-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements new Bot API v3.1 changes. Close #38
- Loading branch information
Camilo Sperberg
committed
Jun 30, 2017
1 parent
b03e4fe
commit bb3ad1f
Showing
9 changed files
with
364 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Methods; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; | ||
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; | ||
|
||
/** | ||
* Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator | ||
* in the chat for this to work and must have the appropriate admin rights. Returns True on success | ||
* | ||
* Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off | ||
* in the target group | ||
* | ||
* Objects defined as-is july 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#deletechatphoto | ||
*/ | ||
class DeleteChatPhoto extends TelegramMethods | ||
{ | ||
/** | ||
* Unique identifier for the target chat or username of the target supergroup or channel (in the format | ||
* @channelusername) | ||
* @var string | ||
*/ | ||
public $chat_id = ''; | ||
|
||
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes | ||
{ | ||
return new ResultBoolean($data->getResultBoolean(), $logger); | ||
} | ||
|
||
public function getMandatoryFields(): array | ||
{ | ||
return [ | ||
'chat_id', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Methods; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; | ||
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultString; | ||
|
||
/** | ||
* Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the chat | ||
* for this to work and must have the appropriate admin rights. Returns exported invite link as String on success | ||
* | ||
* Objects defined as-is july 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#exportchatinvitelink | ||
*/ | ||
class ExportChatInviteLink extends TelegramMethods | ||
{ | ||
/** | ||
* Unique identifier for the target chat or username of the target supergroup or channel (in the format | ||
* @channelusername) | ||
* @var string | ||
*/ | ||
public $chat_id = ''; | ||
|
||
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes | ||
{ | ||
return new ResultString($data->getResultString(), $logger); | ||
} | ||
|
||
public function getMandatoryFields(): array | ||
{ | ||
return [ | ||
'chat_id', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Methods; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; | ||
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; | ||
|
||
/** | ||
* Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to work and | ||
* must have the appropriate admin rights. Returns True on success | ||
* | ||
* Objects defined as-is july 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#pinchatmessage | ||
*/ | ||
class PinChatMessage extends TelegramMethods | ||
{ | ||
/** | ||
* Unique identifier for the target chat or username of the target supergroup or channel (in the format | ||
* @var string | ||
*/ | ||
public $chat_id = ''; | ||
|
||
/** | ||
* Identifier of a message to pin | ||
* @var int | ||
*/ | ||
public $message_id = 0; | ||
|
||
/** | ||
* Optional. Pass True, if it is not necessary to send a notification to all group members about the new pinned | ||
* message | ||
* @var bool | ||
*/ | ||
public $disable_notification = false; | ||
|
||
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes | ||
{ | ||
return new ResultBoolean($data->getResultBoolean(), $logger); | ||
} | ||
|
||
public function getMandatoryFields(): array | ||
{ | ||
return [ | ||
'chat_id', | ||
'message_id', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Methods; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; | ||
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; | ||
|
||
/** | ||
* Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat | ||
* for this to work and must have the appropriate admin rights. Returns True on success | ||
* | ||
* Objects defined as-is july 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#setchatdescription | ||
*/ | ||
class SetChatDescription extends TelegramMethods | ||
{ | ||
/** | ||
* Unique identifier for the target chat or username of the target supergroup or channel (in the format | ||
* @var string | ||
*/ | ||
public $chat_id = ''; | ||
|
||
/** | ||
* New chat description, 1-255 characters | ||
* @var string | ||
*/ | ||
public $description; | ||
|
||
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes | ||
{ | ||
return new ResultBoolean($data->getResultBoolean(), $logger); | ||
} | ||
|
||
public function getMandatoryFields(): array | ||
{ | ||
return [ | ||
'chat_id', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Methods; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; | ||
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile; | ||
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; | ||
|
||
/** | ||
* Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be | ||
* an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success | ||
* | ||
* Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off | ||
* in the target group | ||
* | ||
* Objects defined as-is july 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#setchatphoto | ||
*/ | ||
class SetChatPhoto extends TelegramMethods | ||
{ | ||
/** | ||
* Unique identifier for the target chat or username of the target supergroup or channel (in the format | ||
* @channelusername) | ||
* @var string | ||
*/ | ||
public $chat_id = ''; | ||
|
||
/** | ||
* New chat photo, uploaded using multipart/form-data | ||
* @var InputFile | ||
*/ | ||
public $photo; | ||
|
||
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes | ||
{ | ||
return new ResultBoolean($data->getResultBoolean(), $logger); | ||
} | ||
|
||
public function getMandatoryFields(): array | ||
{ | ||
return [ | ||
'chat_id', | ||
'photo', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Methods; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; | ||
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; | ||
|
||
/** | ||
* Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an | ||
* administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success | ||
* | ||
* Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off | ||
* in the target group | ||
* | ||
* Objects defined as-is july 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#setchattitle | ||
*/ | ||
class SetChatTitle extends TelegramMethods | ||
{ | ||
/** | ||
* Unique identifier for the target chat or username of the target supergroup or channel (in the format | ||
* @var string | ||
*/ | ||
public $chat_id = ''; | ||
|
||
/** | ||
* New chat title, 1-255 characters | ||
* @var string | ||
*/ | ||
public $title = ''; | ||
|
||
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes | ||
{ | ||
return new ResultBoolean($data->getResultBoolean(), $logger); | ||
} | ||
|
||
public function getMandatoryFields(): array | ||
{ | ||
return [ | ||
'chat_id', | ||
'title', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Methods; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; | ||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; | ||
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; | ||
|
||
/** | ||
* Use this method to unpin a message in a supergroup chat. The bot must be an administrator in the chat for this to | ||
* work and must have the appropriate admin rights. Returns True on success | ||
* | ||
* Objects defined as-is july 2017 | ||
* | ||
* @see https://core.telegram.org/bots/api#unpinchatmessage | ||
*/ | ||
class UnpinChatMessage extends TelegramMethods | ||
{ | ||
/** | ||
* Unique identifier for the target chat or username of the target supergroup or channel (in the format | ||
* @var string | ||
*/ | ||
public $chat_id = ''; | ||
|
||
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes | ||
{ | ||
return new ResultBoolean($data->getResultBoolean(), $logger); | ||
} | ||
|
||
public function getMandatoryFields(): array | ||
{ | ||
return [ | ||
'chat_id', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types\Custom; | ||
|
||
use unreal4u\TelegramAPI\Abstracts\CustomType; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* Some API calls respond with int types | ||
*/ | ||
class ResultString extends CustomType | ||
{ | ||
public $data = ''; | ||
|
||
public function __construct(string $result, LoggerInterface $logger = null) | ||
{ | ||
$this->logger = $logger; | ||
$this->data = $result; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return (string)$this->data; | ||
} | ||
} |