Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
### Added
Browse files Browse the repository at this point in the history
- Added custom method: `clearUpdates()`. It's an alias for `$this->getUpdates(-1);`
- Added `TelegramLimits` class constants to get the download/upload file limit.
### Changed
- Updated to __Telegram Bot API 4.1__
- You can now get the string argument at the array index position with the `getArgs()` method. Pass:
    - True to get an array of strings;
    - False to get a string;
    - Integer to get the string at the array index position.
  • Loading branch information
Lukasss93 committed Aug 27, 2018
1 parent 715140e commit becec90
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 33 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.6.11]
### Added
- Added custom method: `clearUpdates()`. It's an alias for `$this->getUpdates(-1);`
- Added `TelegramLimits` class constants to get the download/upload file limit.
### Changed
- Updated to __Telegram Bot API 4.1__
- You can now get the string argument at the array index position with the `getArgs()` method. Pass:
- True to get an array of strings;
- False to get a string;
- Integer to get the string at the array index position.

## [1.6.10]
### Fixed
- `JsonMapper Exception` PHPDoc message in all methods.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Framework for Telegram Bot API",
"license": "MIT",
"type": "project",
"version": "1.6.10",
"version": "1.6.11",
"authors": [
{
"name": "Luca Patera",
Expand Down
32 changes: 9 additions & 23 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TelegramBot-PHP

[![API](https://img.shields.io/badge/Telegram%20Bot%20API-v4.0%20--%20July%2026%2C%202018-blue.svg)](https://core.telegram.org/bots/api)
[![API](https://img.shields.io/badge/Telegram%20Bot%20API-v4.1%20--%20August%2027%2C%202018-blue.svg)](https://core.telegram.org/bots/api)
![PHP](https://img.shields.io/badge/php-%3E%3D5.6-8892bf.svg)
![CURL](https://img.shields.io/badge/cURL-required-green.svg)

Expand Down Expand Up @@ -251,27 +251,13 @@ Changelog
All notable changes to this project will be documented [here](https://github.com/Lukasss93/telegrambot-php/blob/master/CHANGELOG.md).

### Recent changes
## [1.6.10]
### Fixed
- `JsonMapper Exception` PHPDoc message in all methods.
- Exception using `sendMessage + split message feature` with unicode strings.
- Missing php extensions in `composer.json`.

## [1.6.9]
## [1.6.11]
### Added
- Added 3 classes in constants namespace:
- *MessageEntityTypes*
- *PassportSources*
- *PassportTypes*
- Added custom method: `clearUpdates()`. It's an alias for `$this->getUpdates(-1);`
- Added `TelegramLimits` class constants to get the download/upload file limit.
### Changed
- Updated to __Telegram Bot API 4.0__
- Updated license file.
- Updated phpdocs in methods.
- Updated code indentation.
- Replaced whitespaces with tabs.
### Removed
- Removed unused variables.
### Fixed
- JsonMapper Exception `true` type
- `$pay` parameter unused in `buildInlineKeyboardButton()` method.
- Missing `$allowed_updates` parameter to `getUpdates()` method.
- Updated to __Telegram Bot API 4.1__
- You can now get the string argument at the array index position with the `getArgs()` method. Pass:
- True to get an array of strings;
- False to get a string;
- Integer to get the string at the array index position.
24 changes: 24 additions & 0 deletions src/Constants/TelegramLimits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Created by PhpStorm.
* User: Luca Patera
* Date: 27/08/2018
* Time: 23:30
*/

namespace TelegramBot\Constants;


class TelegramLimits {

/**
* Download file limit in Byte. (20 MB)
* For the moment, bots can download files of up to 20MB in size.
*/
const DOWNLOAD=20971520;

/**
* Upload file limit in Byte. (50 MB)
*/
const UPLOAD=52428800;
}
9 changes: 9 additions & 0 deletions src/TelegramBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ public function getWebhookUpdate() {
return $current;
}

/**
* Clear all updates stored on Telegram Server.
* This method is an alias for "$this->getUpdates(-1);"
* @throws \TelegramBot\TelegramException
*/
public function clearUpdates(){
$this->getUpdates(-1);
}

//endregion

//region AVAILABLE METHODS
Expand Down
24 changes: 21 additions & 3 deletions src/Types/EncryptedPassportElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Contains information about documents or other Telegram Passport elements shared with the bot by the user.
* Class EncryptedPassportElement
* @package TelegramBot\Types
* @link https://core.telegram.org/bots/api#encryptedpassportelement
* @link https://core.telegram.org/bots/api#encryptedpassportelement
*/
class EncryptedPassportElement {

Expand All @@ -24,10 +24,14 @@ class EncryptedPassportElement {
*/
public $data;

/** @var string $phone_number Optional. User's verified phone number, available only for “phone_number” type */
/**
* @var string $phone_number Optional. User's verified phone number, available only for “phone_number” type
*/
public $phone_number;

/** @var string $email Optional. User's verified email address, available only for “email” type */
/**
* @var string $email Optional. User's verified email address, available only for “email” type
*/
public $email;

/**
Expand Down Expand Up @@ -57,4 +61,18 @@ class EncryptedPassportElement {
* be decrypted and verified using the accompanying EncryptedCredentials.
*/
public $selfie;

/**
* @var PassportFile[] $translation Optional. Array of encrypted files with translated versions of documents
* provided by the user. Available if requested for “passport”, “driver_license”, “identity_card”,
* “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and
* “temporary_registration” types. Files can be decrypted and verified using the accompanying
* EncryptedCredentials.
*/
public $translation;

/**
* @var string $hash Base64-encoded element hash for using in PassportElementErrorUnspecified
*/
public $hash;
}
17 changes: 11 additions & 6 deletions src/Types/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ public function isCommand() {
}

/**
* Returns only the command string without @BotUsername
* Returns only the command string without [at]BotUsername
* Example:
* IN: /hello or /hello@MyDearBot
* IN: /hello or /hello[at]MyDearBot
* OUT: /hello
* @return string
*/
Expand All @@ -169,20 +169,25 @@ public function getCommand() {

/**
* Returns the args as array or as string
* @param bool $asString
* @param bool|int $asStringorKey True to get an array of strings;
* False to get a string;
* Integer to get the string at the array index position.
* @return array|string
*/
public function getArgs($asString = false) {
public function getArgs($asStringorKey = false) {
if($this->text !== null) {
$commandArray = explode(' ', $this->text);
array_shift($commandArray);

if($asString) {
if($asStringorKey === true) {
return implode(' ', $commandArray);
}
else {
else if($asStringorKey === false) {
return $commandArray;
}
else if(is_int($asStringorKey)){
return $commandArray[$asStringorKey];
}
}
return null;
}
Expand Down
34 changes: 34 additions & 0 deletions src/Types/PassportElementErrorTranslationFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace TelegramBot\Types;

/**
* Represents an issue with one of the files that constitute the translation of a document. The error is considered
* resolved when the file changes
* @package TelegramBot\Types
* @link https://core.telegram.org/bots/api#passportelementerrortranslationfile
*/
class PassportElementErrorTranslationFile {

/**
* @var string $source Error source, must be translation_file
*/
public $source;

/**
* @var string $type Type of element of the user's Telegram Passport which has the issue, one of “passport”,
* “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”,
* “rental_agreement”, “passport_registration”, “temporary_registration”
*/
public $type;

/**
* @var string $file_hash Base64-encoded file hash
*/
public $file_hash;

/**
* @var string $message Error message
*/
public $message;
}
34 changes: 34 additions & 0 deletions src/Types/PassportElementErrorTranslationFiles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace TelegramBot\Types;

/**
* Represents an issue with one of the files that constitute the translation of a document. The error is considered
* resolved when the file changes.
* @package TelegramBot\Types
* @link https://core.telegram.org/bots/api#passportelementerrortranslationfiles
*/
class PassportElementErrorTranslationFiles {

/**
* @var string $source Error source, must be translation_files
*/
public $source;

/**
* @var string $type Type of element of the user's Telegram Passport which has the issue, one of “passport”,
* “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”,
* “rental_agreement”, “passport_registration”, “temporary_registration”
*/
public $type;

/**
* @var string[] $file_hashes List of base64-encoded file hashes
*/
public $file_hashes;

/**
* @var string $message Error message
*/
public $message;
}
31 changes: 31 additions & 0 deletions src/Types/PassportElementErrorUnspecified.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace TelegramBot\Types;

/**
* Represents an issue in an unspecified place. The error is considered resolved when new data is added.
* @package TelegramBot\Types
* @link https://core.telegram.org/bots/api#passportelementerrorunspecified
*/
class PassportElementErrorUnspecified {

/**
* @var string $source Error source, must be unspecified
*/
public $source;

/**
* @var string $type Type of element of the user's Telegram Passport which has the issue
*/
public $type;

/**
* @var string $element_hash Base64-encoded element hash
*/
public $element_hash;

/**
* @var string $message Error message
*/
public $message;
}

0 comments on commit becec90

Please sign in to comment.