1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the TelegramBot package. |
4
|
|
|
* |
5
|
|
|
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Longman\TelegramBot\Commands\SystemCommands; |
12
|
|
|
|
13
|
|
|
use Longman\TelegramBot\Commands\SystemCommand; |
14
|
|
|
use Longman\TelegramBot\Entities\ServerResponse; |
15
|
|
|
use Longman\TelegramBot\Exception\TelegramException; |
16
|
|
|
use Longman\TelegramBot\Request; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Generic message command |
20
|
|
|
*/ |
21
|
|
|
class GenericmessageCommand extends SystemCommand |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $name = 'genericmessage'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
protected $description = 'Handle generic message'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $version = '1.2.0'; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var bool |
40
|
|
|
*/ |
41
|
|
|
protected $need_mysql = true; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Execution if MySQL is required but not available |
45
|
|
|
* |
46
|
|
|
* @return ServerResponse |
47
|
|
|
* @throws TelegramException |
48
|
|
|
*/ |
49
|
|
|
public function executeNoDb() |
50
|
|
|
{ |
51
|
|
|
// Try to execute any deprecated system commands. |
52
|
|
|
if (self::$execute_deprecated && $deprecated_system_command_response = $this->executeDeprecatedSystemCommand()) { |
53
|
|
|
return $deprecated_system_command_response; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return Request::emptyResponse(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Execute command |
61
|
|
|
* |
62
|
|
|
* @return ServerResponse |
63
|
|
|
* @throws TelegramException |
64
|
|
|
*/ |
65
|
|
|
public function execute() |
66
|
|
|
{ |
67
|
|
|
// Try to continue any active conversation. |
68
|
|
|
if ($active_conversation_response = $this->executeActiveConversation()) { |
69
|
|
|
return $active_conversation_response; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
// Try to execute any deprecated system commands. |
73
|
|
|
if (self::$execute_deprecated && $deprecated_system_command_response = $this->executeDeprecatedSystemCommand()) { |
74
|
|
|
return $deprecated_system_command_response; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
return Request::emptyResponse(); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|