telegram.php
7.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
use Telegram\Bot\Commands\HelpCommand;
return [
/*
|--------------------------------------------------------------------------
| Your Telegram Bots
|--------------------------------------------------------------------------
| You may use multiple bots at once using the manager class. Each bot
| that you own should be configured here.
|
| Here are each of the telegram bots config parameters.
|
| Supported Params:
|
| - name: The *personal* name you would like to refer to your bot as.
|
| - token: Your Telegram Bot's Access Token.
Refer for more details: https://core.telegram.org/bots#botfather
| Example: (string) '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11'.
|
| - commands: (Optional) Commands to register for this bot,
| Supported Values: "Command Group Name", "Shared Command Name", "Full Path to Class".
| Default: Registers Global Commands.
| Example: (array) [
| 'admin', // Command Group Name.
| 'status', // Shared Command Name.
| Acme\Project\Commands\BotFather\HelloCommand::class,
| Acme\Project\Commands\BotFather\ByeCommand::class,
| ]
*/
'bots' => [
'channel_bot' => [
'token' => env('TELEGRAM_BOT_API_KEY'),
]
],
/*
|--------------------------------------------------------------------------
| Default Bot Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the bots you wish to use as
| your default bot for regular use.
|
*/
'default' => 'channel_bot',
/*
|--------------------------------------------------------------------------
| Asynchronous Requests [Optional]
|--------------------------------------------------------------------------
|
| When set to True, All the requests would be made non-blocking (Async).
|
| Default: false
| Possible Values: (Boolean) "true" OR "false"
|
*/
'async_requests' => env('TELEGRAM_ASYNC_REQUESTS', false),
/*
|--------------------------------------------------------------------------
| HTTP Client Handler [Optional]
|--------------------------------------------------------------------------
|
| If you'd like to use a custom HTTP Client Handler.
| Should be an instance of \Telegram\Bot\HttpClients\HttpClientInterface
|
| Default: GuzzlePHP
|
*/
'http_client_handler' => null,
/*
|--------------------------------------------------------------------------
| Base Bot Url [Optional]
|--------------------------------------------------------------------------
|
| If you'd like to use a custom Base Bot Url.
| Should be a local bot api endpoint or a proxy to the telegram api endpoint
|
| Default: https://api.telegram.org/bot
|
*/
'base_bot_url' => null,
/*
|--------------------------------------------------------------------------
| Resolve Injected Dependencies in commands [Optional]
|--------------------------------------------------------------------------
|
| Using Laravel's IoC container, we can easily type hint dependencies in
| our command's constructor and have them automatically resolved for us.
|
| Default: true
| Possible Values: (Boolean) "true" OR "false"
|
*/
'resolve_command_dependencies' => true,
/*
|--------------------------------------------------------------------------
| Register Telegram Global Commands [Optional]
|--------------------------------------------------------------------------
|
| If you'd like to use the SDK's built in command handler system,
| You can register all the global commands here.
|
| Global commands will apply to all the bots in system and are always active.
|
| The command class should extend the \Telegram\Bot\Commands\Command class.
|
| Default: The SDK registers, a help command which when a user sends /help
| will respond with a list of available commands and description.
|
*/
'commands' => [
HelpCommand::class,
],
/*
|--------------------------------------------------------------------------
| Command Groups [Optional]
|--------------------------------------------------------------------------
|
| You can organize a set of commands into groups which can later,
| be re-used across all your bots.
|
| You can create 4 types of groups:
| 1. Group using full path to command classes.
| 2. Group using shared commands: Provide the key name of the shared command
| and the system will automatically resolve to the appropriate command.
| 3. Group using other groups of commands: You can create a group which uses other
| groups of commands to bundle them into one group.
| 4. You can create a group with a combination of 1, 2 and 3 all together in one group.
|
| Examples shown below are by the group type for you to understand each of them.
*/
'command_groups' => [
/* // Group Type: 1
'commmon' => [
Acme\Project\Commands\TodoCommand::class,
Acme\Project\Commands\TaskCommand::class,
],
*/
/* // Group Type: 2
'subscription' => [
'start', // Shared Command Name.
'stop', // Shared Command Name.
],
*/
/* // Group Type: 3
'auth' => [
Acme\Project\Commands\LoginCommand::class,
Acme\Project\Commands\SomeCommand::class,
],
'stats' => [
Acme\Project\Commands\UserStatsCommand::class,
Acme\Project\Commands\SubscriberStatsCommand::class,
Acme\Project\Commands\ReportsCommand::class,
],
'admin' => [
'auth', // Command Group Name.
'stats' // Command Group Name.
],
*/
/* // Group Type: 4
'myBot' => [
'admin', // Command Group Name.
'subscription', // Command Group Name.
'status', // Shared Command Name.
'Acme\Project\Commands\BotCommand' // Full Path to Command Class.
],
*/
],
/*
|--------------------------------------------------------------------------
| Shared Commands [Optional]
|--------------------------------------------------------------------------
|
| Shared commands let you register commands that can be shared between,
| one or more bots across the project.
|
| This will help you prevent from having to register same set of commands,
| for each bot over and over again and make it easier to maintain them.
|
| Shared commands are not active by default, You need to use the key name to register them,
| individually in a group of commands or in bot commands.
| Think of this as a central storage, to register, reuse and maintain them across all bots.
|
*/
'shared_commands' => [
// 'start' => Acme\Project\Commands\StartCommand::class,
// 'stop' => Acme\Project\Commands\StopCommand::class,
// 'status' => Acme\Project\Commands\StatusCommand::class,
],
];