-
Notifications
You must be signed in to change notification settings - Fork 8
/
gwfwd.php
77 lines (67 loc) · 1.73 KB
/
gwfwd.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
<?php
$json = <<<'JSON'
{
"update_id": 346134787,
"message": {
"message_id": 4007,
"from": {
"id": 243692601,
"is_bot": false,
"first_name": "Ammar",
"last_name": "Faizi",
"username": "ammarfaizi2",
"language_code": "en"
},
"chat": {
"id": -1001347566306,
"title": "GNU/Weeb Test Driven Development",
"username": "GNUWeebTDD",
"type": "supergroup"
},
"date": 1621503523,
"reply_to_message": {
"message_id": 4006,
"from": {
"id": 243692601,
"is_bot": false,
"first_name": "Ammar",
"last_name": "Faizi",
"username": "ammarfaizi2",
"language_code": "en"
},
"chat": {
"id": -1001347566306,
"title": "GNU/Weeb Test Driven Development",
"username": "GNUWeebTDD",
"type": "supergroup"
},
"date": 1621503517,
"text": "test"
},
"text": ".delete"
}
}
JSON; /* end JSON */
function main(): int
{
global $json;
$ret = 0;
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
$conn = socket_connect($sock, "127.0.0.1", 55555);
if (!$conn)
return 1;
$payload = pack("n", strlen($json)).$json;
$write_len = socket_write($sock, $payload);
$correct_len = strlen($payload);
if ($write_len != $correct_len) {
printf("socket_write failed: write_len = %d; correct_len = %d\n",
$write_len, $correct_len);
$ret = 1;
}
socket_close($sock);
return $ret;
}
for ($i=0; $i < 1; $i++) {
main();
}
// exit(main());