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