Skip to content

Commit 2be7b3c

Browse files
committed
bugfix
1 parent 35394a6 commit 2be7b3c

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# PHP Telegram Bot
2-
======================
32

43
[![Join the chat at
54
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 {
192191
// log telegram errors
193192
echo $e;
194193
}
195-
196-
197194
```
195+
198196
give to the file the permission for execution:
199197
```
200198
chmod 775 getUpdateCLI.php
@@ -224,8 +222,7 @@ $telegram->enableMySQL($credentials, $BOT_NAME.'_');
224222
All types implemented (except InputFile) according to Telegram API (2015 September 18).
225223

226224
### Commands
227-
The bot is able to recognise commands in chat with multiple bot(
228-
/command@mybot ).
225+
The bot is able to recognise commands in chat with multiple bot(/command@mybot ).
229226
It can execute command triggering a chat event. Here's the list:
230227

231228
- Group chat created (**GroupchatcreatedCommand.php**)
@@ -234,11 +231,13 @@ It can execute command triggering a chat event. Here's the list:
234231
- New chat title (**NewchattitleCommand.php**)
235232
- Left chat participant (**LeftchatparticipantCommand.php**)
236233

237-
**GenericCommand.php** lets you handle commands that don't exist or to
234+
**GenericCommand.php** let you handle commands that don't exist or to
238235
use commands as a variable:
239236
Favourite colour? **/black, /red**
240237
Favourite number? **/1, /134**
241238

239+
**GenericmessageCommand.php** let you handle any type of message.
240+
242241
Maybe you would like to develop your own commands. A good practice is
243242
to store them outside *vendor/*. This can be done adding the method:
244243

@@ -247,6 +246,8 @@ $COMMANDS_FOLDER = __DIR__.'/Commands/';
247246
$telegram->addCommandsPath($COMMANDS_FOLDER);
248247
```
249248

249+
Inside *CommandsExamples/* there are some sample that show how to use types.
250+
250251
### Admin Commands
251252
Enabling this feature, the admin bot can perform some super user command like send message to all.
252253
You can specify one or more admin with this option:
@@ -286,7 +287,7 @@ print_r($results);
286287
### Logging
287288
Thrown Exception are stored in TelegramException.log file.
288289

289-
You can also log incoming messages on a text file, set this option with the methods:
290+
Incoming update can be logged on a text file, set this option with the methods:
290291
```php
291292
$telegram->setLogRequests(true);
292293
$telegram->setLogPath($BOT_NAME.'.log');

src/DB.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ public static function insertRequest(Update $update)
238238
$forward_date = self::toTimestamp($message->getForwardDate());
239239
$photo = $message->getPhoto();
240240
$new_chat_participant = $message->getNewChatParticipant();
241+
242+
$new_chat_photo = $message->getNewChatPhoto();
241243
$left_chat_participant = $message->getLeftChatParticipant();
242244

243245
//inser user and the relation with the chat

src/Entities/Message.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public function __construct(array $data, $bot_name)
129129
}
130130
$this->photo = $photos;
131131
}
132+
132133
$this->sticker = isset($data['sticker']) ? $data['sticker'] : null;
133134
if (!empty($this->sticker)) {
134135
$this->sticker = new Sticker($this->sticker);
@@ -173,6 +174,16 @@ public function __construct(array $data, $bot_name)
173174
$this->type = 'new_chat_title';
174175
}
175176

177+
$this->new_chat_photo = isset($data['new_chat_photo']) ? $data['new_chat_photo'] : null; //array of photosize
178+
if (!empty($this->new_chat_photo)) {
179+
foreach ($this->new_chat_photo as $photo) {
180+
if (!empty($photo)) {
181+
$photos[] = new PhotoSize($photo);
182+
}
183+
}
184+
$this->new_chat_photo = $photos;
185+
}
186+
176187
$this->delete_chat_photo = isset($data['delete_chat_photo']) ? $data['delete_chat_photo'] : null;
177188
if ($this->delete_chat_photo) {
178189
$this->type = 'delete_chat_photo';
@@ -328,6 +339,13 @@ public function getNewChatTitle()
328339
return $this->new_chat_title;
329340
}
330341

342+
343+
public function getNewChatPhoto()
344+
{
345+
return $this->new_chat_photo;
346+
}
347+
348+
331349
public function getDeleteChatPhoto()
332350
{
333351
return $this->delete_chat_photo;

0 commit comments

Comments
 (0)