Commit 2be7b3c3 authored by MBoretto's avatar MBoretto

bugfix

parent 35394a63
# PHP Telegram Bot # PHP Telegram Bot
======================
[![Join the chat at [![Join the chat at
https://gitter.im/akalongman/php-telegram-bot](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/akalongman/php-telegram-bot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) https://gitter.im/akalongman/php-telegram-bot](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/akalongman/php-telegram-bot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
...@@ -192,9 +191,8 @@ try { ...@@ -192,9 +191,8 @@ try {
// log telegram errors // log telegram errors
echo $e; echo $e;
} }
``` ```
give to the file the permission for execution: give to the file the permission for execution:
``` ```
chmod 775 getUpdateCLI.php chmod 775 getUpdateCLI.php
...@@ -224,8 +222,7 @@ $telegram->enableMySQL($credentials, $BOT_NAME.'_'); ...@@ -224,8 +222,7 @@ $telegram->enableMySQL($credentials, $BOT_NAME.'_');
All types implemented (except InputFile) according to Telegram API (2015 September 18). All types implemented (except InputFile) according to Telegram API (2015 September 18).
### Commands ### Commands
The bot is able to recognise commands in chat with multiple bot( The bot is able to recognise commands in chat with multiple bot(/command@mybot ).
/command@mybot ).
It can execute command triggering a chat event. Here's the list: It can execute command triggering a chat event. Here's the list:
- Group chat created (**GroupchatcreatedCommand.php**) - Group chat created (**GroupchatcreatedCommand.php**)
...@@ -234,11 +231,13 @@ It can execute command triggering a chat event. Here's the list: ...@@ -234,11 +231,13 @@ It can execute command triggering a chat event. Here's the list:
- New chat title (**NewchattitleCommand.php**) - New chat title (**NewchattitleCommand.php**)
- Left chat participant (**LeftchatparticipantCommand.php**) - Left chat participant (**LeftchatparticipantCommand.php**)
**GenericCommand.php** lets you handle commands that don't exist or to **GenericCommand.php** let you handle commands that don't exist or to
use commands as a variable: use commands as a variable:
Favourite colour? **/black, /red** Favourite colour? **/black, /red**
Favourite number? **/1, /134** Favourite number? **/1, /134**
**GenericmessageCommand.php** let you handle any type of message.
Maybe you would like to develop your own commands. A good practice is Maybe you would like to develop your own commands. A good practice is
to store them outside *vendor/*. This can be done adding the method: to store them outside *vendor/*. This can be done adding the method:
...@@ -247,6 +246,8 @@ $COMMANDS_FOLDER = __DIR__.'/Commands/'; ...@@ -247,6 +246,8 @@ $COMMANDS_FOLDER = __DIR__.'/Commands/';
$telegram->addCommandsPath($COMMANDS_FOLDER); $telegram->addCommandsPath($COMMANDS_FOLDER);
``` ```
Inside *CommandsExamples/* there are some sample that show how to use types.
### Admin Commands ### Admin Commands
Enabling this feature, the admin bot can perform some super user command like send message to all. Enabling this feature, the admin bot can perform some super user command like send message to all.
You can specify one or more admin with this option: You can specify one or more admin with this option:
...@@ -286,7 +287,7 @@ print_r($results); ...@@ -286,7 +287,7 @@ print_r($results);
### Logging ### Logging
Thrown Exception are stored in TelegramException.log file. Thrown Exception are stored in TelegramException.log file.
You can also log incoming messages on a text file, set this option with the methods: Incoming update can be logged on a text file, set this option with the methods:
```php ```php
$telegram->setLogRequests(true); $telegram->setLogRequests(true);
$telegram->setLogPath($BOT_NAME.'.log'); $telegram->setLogPath($BOT_NAME.'.log');
......
...@@ -238,6 +238,8 @@ class DB ...@@ -238,6 +238,8 @@ class DB
$forward_date = self::toTimestamp($message->getForwardDate()); $forward_date = self::toTimestamp($message->getForwardDate());
$photo = $message->getPhoto(); $photo = $message->getPhoto();
$new_chat_participant = $message->getNewChatParticipant(); $new_chat_participant = $message->getNewChatParticipant();
$new_chat_photo = $message->getNewChatPhoto();
$left_chat_participant = $message->getLeftChatParticipant(); $left_chat_participant = $message->getLeftChatParticipant();
//inser user and the relation with the chat //inser user and the relation with the chat
......
...@@ -129,6 +129,7 @@ class Message extends Entity ...@@ -129,6 +129,7 @@ class Message extends Entity
} }
$this->photo = $photos; $this->photo = $photos;
} }
$this->sticker = isset($data['sticker']) ? $data['sticker'] : null; $this->sticker = isset($data['sticker']) ? $data['sticker'] : null;
if (!empty($this->sticker)) { if (!empty($this->sticker)) {
$this->sticker = new Sticker($this->sticker); $this->sticker = new Sticker($this->sticker);
...@@ -173,6 +174,16 @@ class Message extends Entity ...@@ -173,6 +174,16 @@ class Message extends Entity
$this->type = 'new_chat_title'; $this->type = 'new_chat_title';
} }
$this->new_chat_photo = isset($data['new_chat_photo']) ? $data['new_chat_photo'] : null; //array of photosize
if (!empty($this->new_chat_photo)) {
foreach ($this->new_chat_photo as $photo) {
if (!empty($photo)) {
$photos[] = new PhotoSize($photo);
}
}
$this->new_chat_photo = $photos;
}
$this->delete_chat_photo = isset($data['delete_chat_photo']) ? $data['delete_chat_photo'] : null; $this->delete_chat_photo = isset($data['delete_chat_photo']) ? $data['delete_chat_photo'] : null;
if ($this->delete_chat_photo) { if ($this->delete_chat_photo) {
$this->type = 'delete_chat_photo'; $this->type = 'delete_chat_photo';
...@@ -328,6 +339,13 @@ class Message extends Entity ...@@ -328,6 +339,13 @@ class Message extends Entity
return $this->new_chat_title; return $this->new_chat_title;
} }
public function getNewChatPhoto()
{
return $this->new_chat_photo;
}
public function getDeleteChatPhoto() public function getDeleteChatPhoto()
{ {
return $this->delete_chat_photo; return $this->delete_chat_photo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment