@@ -123,17 +123,91 @@ Bot::onText(['hello', 'hay'], function(Request $request){
123
123
});
124
124
```
125
125
---
126
- ### Updates
127
- User Request class to get updates.
126
+ ### Controller
128
127
``` php
128
+ # app/Resources/bot.php
129
+
130
+ Bot::onText('hello', "App/Controller/HelloController@sayHello");
131
+ Bot::onText('hello', [App/Controller/HelloController::class ,"sayHello"]);
132
+ ```
133
+
134
+ ``` php
135
+ # app/Controllers/HelloController.php
136
+
129
137
use LaraGram\Request\Request;
130
138
131
- $request = new Request();
139
+ class HelloController
140
+ {
141
+ public function sayHello(Request $request)
142
+ {
143
+ $request->sendMessage(chat()->id, "hello");
144
+ }
145
+ }
146
+ ```
147
+ ---
148
+ ### Group Listeners:
149
+
150
+ Use one Controller for many listeners:
151
+ ``` php
152
+ Bot::controller("App/Controller/GreetingController")->group(function(){
153
+ Bot::onText('hello', "sayHello");
154
+ Bot::onText('hello', "sayBye");
155
+ // ...
156
+ });
157
+ ```
158
+
159
+ Conditions:
160
+
161
+ - Access Controll:
162
+ ``` php
163
+ Bot::can("administrator")->group(function(){
164
+ // ...
165
+ })
166
+ ```
167
+
168
+ ``` php
169
+ Bot::canNot("administrator")->group(function(){
170
+ // ...
171
+ })
172
+ ```
173
+
174
+ - Scope Controll:
175
+ ``` php
176
+ Bot::scope("private")->group(function(){
177
+ // ...
178
+ })
179
+ ```
132
180
133
- $text = $request->message->text;
134
- $reply_to_message_chat_id = $request->message->reply_to_message->chat->id;
135
- $callback_data = $request->callback_query->data;
136
- $new_chat_members = $request->message->new_chat_members;
181
+ ``` php
182
+ Bot::outOfScope("private")->group(function(){
183
+ // ...
184
+ })
185
+ ```
186
+
187
+ - Is Replied?
188
+ ``` php
189
+ Bot::hasReply()->group(function(){
190
+ // ...
191
+ })
192
+ ```
193
+
194
+ ``` php
195
+ Bot::hasNotReply()->group(function(){
196
+ // ...
197
+ })
198
+ ```
199
+
200
+ - Multiple Conditions:
201
+ ``` php
202
+ Bot::group(["can" => "creator", "scope" => "private"], function(){
203
+ // ...
204
+ })
205
+ ```
206
+
207
+ ``` php
208
+ Bot::canNot("administrator")->hasReply()->group(function(){
209
+ // ...
210
+ })
137
211
```
138
212
---
139
213
### [ ⬅️⬅️ Return to home] ( https://github.com/laraXgram/Document/blob/v1.10/readme.md )
0 commit comments