1 | <?php |
||
20 | class ImageCommand extends UserCommand |
||
21 | { |
||
22 | /**#@+ |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | protected $name = 'image'; |
||
26 | protected $description = 'Send Image'; |
||
27 | protected $usage = '/image'; |
||
28 | protected $version = '1.0.1'; |
||
29 | /**#@-*/ |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public function execute() |
||
35 | { |
||
36 | $message = $this->getMessage(); |
||
37 | $chat_id = $message->getChat()->getId(); |
||
38 | $text = $message->getText(true); |
||
39 | |||
40 | $data = [ |
||
41 | 'chat_id' => $chat_id, |
||
42 | 'caption' => $text, |
||
43 | ]; |
||
44 | |||
45 | //Return a random picture from the telegram->getUploadPath(). |
||
46 | return Request::sendPhoto($data, $this->ShowRandomImage($this->telegram->getUploadPath())); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Return the path to a random image in the passed directory. |
||
51 | * |
||
52 | * @param string $dir |
||
53 | * |
||
54 | * @return string |
||
55 | */ |
||
63 |