-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
134 lines (129 loc) · 3.74 KB
/
test.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
<?php
require __DIR__."/bootstrap/telegram/autoload.php";
$json = '{
"update_id": 345849982,
"message": {
"message_id": 2793,
"from": {
"id": 243692601,
"is_bot": false,
"first_name": "Ammar",
"last_name": "Faizi",
"username": "ammarfaizi2",
"language_code": "en"
},
"chat": {
"id": -1001149709623,
"title": "Test Driven Development",
"type": "supergroup",
"username": null
},
"date": 1595141419,
"reply_to_message": {
"message_id": 2668,
"from": {
"id": 466965678,
"is_bot": true,
"first_name": "Tea Inside",
"username": "TeaInsideBot"
},
"chat": {
"id": -1001149709623,
"title": "Test Driven Development",
"type": "supergroup"
},
"date": 1595121822,
"text": "This command can only be used in private message!"
},
"text": "/debug",
"entities": [
{
"offset": 0,
"length": 6,
"type": "bot_command"
}
]
}
}';
// $json = '{
// "update_id": 345883499,
// "message": {
// "message_id": 5242,
// "from": {
// "id": 639393712,
// "is_bot": false,
// "first_name": "Ammar",
// "last_name": "Faizi^",
// "username": "ammarfaizi2",
// "language_code": "en"
// },
// "chat": {
// "id": -1001226735471,
// "title": "Private Cloud",
// "type": "supergroup",
// "username": null
// },
// "date": 1598704512,
// "reply_to_message": {
// "message_id": 5129,
// "from": {
// "id": 639393712,
// "is_bot": false,
// "first_name": "Vasco De",
// "last_name": "Gamma",
// "username": "ieralliv"
// },
// "chat": {
// "id": -1001226735471,
// "title": "Private Cloud",
// "type": "supergroup"
// },
// "date": 1598521697,
// "new_chat_participant": {
// "id": 639393712,
// "is_bot": false,
// "first_name": "Vasco De",
// "last_name": "Gamma",
// "username": "ieralliv"
// },
// "new_chat_member": {
// "id": 639393712,
// "is_bot": false,
// "first_name": "Vasco De",
// "last_name": "Gamma",
// "username": "ieralliv"
// },
// "new_chat_members": [
// {
// "id": 639393712,
// "is_bot": false,
// "first_name": "Vasco De",
// "last_name": "Gamma",
// "username": "ieralliv"
// }
// ]
// },
// "text": "3583084xxx",
// "entities": [
// {
// "offset": 0,
// "length": 6,
// "type": "bot_command"
// }
// ]
// }
// }';
loadConfig("telegram/telegram_bot");
go(function () use ($json) {
$saber = \Swlib\Saber::create(
[
"base_uri" => "http://127.0.0.1:8000",
"headers" => ["Content-Type" => \Swlib\Http\ContentType::JSON]
]
);
$ret = $saber->post(
"/webhook/telegram/r1.php?key=".TELEGRAM_WEBHOOK_KEY,
json_decode($json, true)
);
echo $ret->getBody()->__toString()."\n";
});