Skip to content

Commit 1823c9a

Browse files
committed
Update ImageCommand.php
Return Random Picture from the UploadPath();
1 parent d5338d3 commit 1823c9a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

examples/Commands/ImageCommand.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ public function execute()
4141
$data['chat_id'] = $chat_id;
4242
$data['caption'] = $text;
4343

44-
return Request::sendPhoto($data, $this->telegram->getUploadPath().'/'.'image.jpg');
44+
//return Request::sendPhoto($data, $this->telegram->getUploadPath().'/'.'image.jpg');
45+
return Request::sendPhoto($data, $this->ShowRandomImage($this->telegram->getUploadPath()));
4546
}
47+
//return random picture from the telegram->getUploadPath();
48+
49+
private function ShowRandomImage($dir) {
50+
$image_list = scandir($dir);
51+
return $dir . "/" . $image_list[mt_rand(2, count($image_list) - 1)];
52+
}
53+
4654
}

0 commit comments

Comments
 (0)