-
Notifications
You must be signed in to change notification settings - Fork 0
/
baleupdate.php
executable file
·341 lines (274 loc) · 7.47 KB
/
baleupdate.php
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
/**
* @package Bale Php
* @link https://github.com/smartwf/balephp
* @author Smart <Hooshmandmrh@gmail.com>
*/
// get update data
$update = json_decode(file_get_contents("php://input"));
class BaleUpdate{
//update type
protected static $update_type;
// chat id
protected static $chat_id;
//user id
protected static $user_id;
// chat type
protected static $chat_type;
//message id
protected static $message_id;
// message type
protected static $message_type;
//message date
protected static $message_date;
//message
protected static $message;
//sticker
protected static $sticker;
//contact
protected static $contact;
//location
protected static $location;
//file
protected static $file;
//file name
protected static $file_name;
// file type
protected static $file_type;
//file width
protected static $file_width;
//file height
protected static $file_height;
//file duration
protected static $file_duration;
//file thumb
protected static $file_thumb;
//file caption of message
protected static $caption;
//pay information
protected static $pay;
/**
*** initialize Class and get updates
*
* @return null
*/
public static function getNewUpdate(){
// $type
$type = '$type';
// get update variable
global $update;
// update Type
self::$update_type = $update->body->$type;
self::$chat_id = $update->body->peer->$type.'|'.$update->body->peer->id.'|'.$update->body->peer->accessHash;
self::$chat_type = $update->body->peer->$type;
self::$user_id = $update->body->sender->$type.'|'.$update->body->sender->id.'|'.$update->body->sender->accessHash;
self::$message = $update->body->message;
self::$message_id = $update->body->randomId;
self::$message_type = $update->body->message->$type;
self::$message_date = $update->body->date;
self::$sticker = self::$message->stickerId.'|'.self::$message->stickerCollectionId.'|'.self::$message->stickerCollectionAccessHash.'|'.self::$message->image512->fileLocation->fileId.'|'.self::$message->image512->fileLocation->accessHash.'|'.self::$message->image256->fileSize.'|'.self::$message->image512->fileSize;
$rawJson = json_decode(self::$message->rawJson);
self::$contact = $rawJson->data->contact;
self::$location = $rawJson->data->location;
self::$file = self::$message->fileId.'|'.self::$message->accessHashm.'|'.self::$message->fileSize;
self::$file_name = self::$message->name;
self::$file_type = self::$message->mimeType;
self::$file_width = self::$message->ext->width;
self::$file_height = self::$message->ext->height;
self::$file_duration = self::$message->ext->duration;
self::$file_thumb = self::$message->thumb->thumb;
self::$caption = self::$message->caption->text;
self::$pay = new \stdClass();
self::$pay->description = self::$message->message->transferInfo->items[4]->value->text;
self::$pay->amount = self::$message->message->transferInfo->items[8]->value->value;
self::$pay->date = self::$message->message->transferInfo->items[9]->value->value;
self::$pay->status = strtolower(self::$message->message->transferInfo->items[10]->value->text);
self::$pay->trace_id = strtolower(self::$message->message->transferInfo->items[12]->value->value);
self::$pay->payer = new \stdClass();
$msg = self::$message->message->message->items[0]->value;
$s = strpos($msg,'واریزکننده') + 35;
$e = strpos($msg,'شماره پیگیری') -$s-18;
$payer = explode('-',substr($msg,$s,$e));
self::$pay->payer->name = trim($payer[0]);
self::$pay->payer->username = trim($payer[1]);
}
/**
*** is group
*
* @return bool
*/
public static function isGroup(){
if (self::$chat_type == 'Group')
return true;
return false;
}
/**
*** is user
*
* @return bool
*/
public static function isUser(){
if (self::$chat_type == 'User')
return true;
return false;
}
/**
*** use this method to get update type
*
* @return bool
*/
public static function updateType(){
return self::$update_type;
}
/**
*** use this method to get chat id
*
* @return string
*/
public static function chatId(){
return self::$chat_id;
}
/**
*** use this method to get user id
*
* @return string
*/
public static function userId(){
return self::$user_id;
}
/**
*** use this method to get message id
*
* @return string
*/
public static function messageId(){
return self::$message_id;
}
/**
*** use this method to get message
*
* @return string
*/
public static function message(){
return self::$message;
}
/**
*** use this method to get sticker
*
* @return string
*/
public static function sticker(){
return self::$sticker;
}
/**
*** use this method to get chat type
*
* @return string
*/
public static function chatType(){
return self::$chat_type;
}
/**
*** use this method to get chat id
*
* @return string
*/
public static function messageDate(){
return self::$message_date;
}
/**
*** use this method to get message type
*
* @return string
*/
public static function messageType(){
return self::$message_type;
}
/**
*** use this method to get contact
*
* @return object
*/
public static function contact(){
return self::$contact;
}
/**
*** use this method to get location
* @return object
*/
public static function location(){
return self::$location;
}
/**
*** use this method to get file
*
* @return string
*/
public static function file(){
return self::$file;
}
/**
*** use this method to get file name
*
* @return string
*/
public static function fileName(){
return self::$file_name;
}
/**
*** use this method to get file type
*
* @return string
*/
public static function fileType(){
return self::$file_type;
}
/**
*** use this method to get file width
*
* @return int
*/
public static function fileWidth(){
return self::$file_width;
}
/**
*** use this method to get file height
*
* @return int
*/
public static function fileHeight(){
return self::$file_height;
}
/**
*** use this method to get file duration
*
* @return int
*/
public static function fileDuration(){
return self::$file_duration;
}
/**
*** use this method to get caption
*
* @return string
*/
public static function caption(){
return self::$caption;
}
/**
*** use this method to get file thumb
*
* @return string
*/
public static function fileThumb(){
return self::$file_thumb;
}
/**
*** use this method to get pay
*
* @return object
*/
public static function pay(){
return self::$pay;
}
}