-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
52 lines (30 loc) · 1.14 KB
/
index.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
<?php
echo '===cron Start===' . PHP_EOL;
require 'classes/ApiMethods.php';
require 'config.php';
$kristinaID = 69046497;
$api = new ApiMethods($group_access_tocken);
//dump($api->getMessage()->APIExecute(false));
$message_array = $api->getMessage(120)->APIExecute(false);
$api->ClearAPI();
$array_smile= ['😂','😄','😁'];
foreach ($message_array["response"]["items"] as $item_msg){
//dump($api->getUsers($item_msg["user_id"])->APIExecute(false));
$name = $api->getUsers($item_msg["user_id"])->APIExecute(false)["response"][0]['first_name'];
echo $name . ' Написал(а): ' .$item_msg["body"] . PHP_EOL;
if (preg_match('#😂|😄|😁#', $item_msg["body"])) {
$api->ClearAPI();
$rand_smile = $array_smile[mt_rand(0,2)];
dump($api->SendMessageUser($item_msg["user_id"], $rand_smile)->APIExecute());
echo 'Бот ответил: '.$rand_smile.'' .PHP_EOL;
}
}
if (!empty($api->getError())){
dump($api->getError());
}
echo '===cron End===' . PHP_EOL;
function dump($data) {
echo '<pre>';
var_dump($data);
echo '</pre>';
}