|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the PhpBotFramework. |
|
5
|
|
|
* |
|
6
|
|
|
* PhpBotFramework is free software: you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU Lesser General Public License as |
|
8
|
|
|
* published by the Free Software Foundation, version 3. |
|
9
|
|
|
* |
|
10
|
|
|
* PhpBotFramework is distributed in the hope that it will be useful, but |
|
11
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13
|
|
|
* Lesser General Public License for more details. |
|
14
|
|
|
* |
|
15
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
16
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace PhpBotFramework; |
|
20
|
|
|
|
|
21
|
|
|
use PhpBotFramework\Exceptions\BotException; |
|
22
|
|
|
|
|
23
|
|
|
// Use localized inline keyboard: this means you can display it in various languages. |
|
24
|
|
|
use PhpBotFramework\Localization\Button; |
|
25
|
|
|
|
|
26
|
|
|
use PhpBotFramework\Utilities\BotState; |
|
27
|
|
|
|
|
28
|
|
|
use PhpBotFramework\Database\Database; |
|
29
|
|
|
|
|
30
|
|
|
use PhpBotFramework\Database\Getter; |
|
31
|
|
|
use PhpBotFramework\Database\LongPolling; |
|
32
|
|
|
|
|
33
|
|
|
use PhpBotFramework\Localization\Localization; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* \class Bot Bot class that contains all modules. |
|
37
|
|
|
*/ |
|
38
|
|
|
class Bot extends BasicBot |
|
39
|
|
|
{ |
|
40
|
|
|
use Getter, |
|
41
|
|
|
LongPolling; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* \addtogroup Bot Bot |
|
45
|
|
|
* \brief Properties and methods to handle your Telegrams bot. |
|
46
|
|
|
* \details Here're listed all the properties and methods that offers facilities for bot's basic features. |
|
47
|
|
|
* @{ |
|
48
|
|
|
*/ |
|
49
|
|
|
|
|
50
|
|
|
/** \brief Store the inline keyboard. */ |
|
51
|
|
|
public $keyboard; |
|
52
|
|
|
|
|
53
|
|
|
/** \brief Database handler object. */ |
|
54
|
|
|
public $database; |
|
55
|
|
|
|
|
56
|
|
|
/** \brief Redis connection. */ |
|
57
|
|
|
public $redis; |
|
58
|
|
|
|
|
59
|
|
|
/** \brief Localization handler object. */ |
|
60
|
|
|
public $local; |
|
61
|
|
|
|
|
62
|
|
|
/** \brief Status handler object. */ |
|
63
|
|
|
public $status; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* \brief Construct an empty bot. |
|
67
|
|
|
* \details Construct a complete Telegram bot which can use localization, database and more other. |
|
68
|
|
|
* |
|
69
|
|
|
* @param string $token Bot token, you can request one through **BotFather** on Telegram. |
|
70
|
|
|
*/ |
|
71
|
|
|
public function __construct(string $token) |
|
72
|
|
|
{ |
|
73
|
|
|
parent::__construct($token); |
|
74
|
|
|
|
|
75
|
|
|
$this->keyboard = new Button($this); |
|
76
|
|
|
$this->status = new BotState($this); |
|
77
|
|
|
$this->local = new Localization($this); |
|
78
|
|
|
$this->database = new Database($this); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** @} */ |
|
82
|
|
|
} |
|
83
|
|
|
|