Created
June 3, 2019 07:01
-
-
Save ennjoy/ecf7efc06fc50e83a8f21ae2634cc945 to your computer and use it in GitHub Desktop.
ivinete bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-Type: text/json; charset=utf-8'); | |
$access_token = 'lETl8LzRgipgWwFK9ElnKpLQ9y3kZH8keKLAEhUF7CMcW0A5JAo3hpvCnl7uaIcnUWWcg1XfFsdGIPetPTJQ7WNT86ov2A4XK4M2'; | |
file_get_contents('https://api.ivinete.ru/method/account.setOnline?access_token='. $access_token); | |
for($i=0 ; $i<6 ; $i++) { | |
$conversations_params = [ | |
'count' => 1, | |
'access_token' => $access_token | |
]; | |
$conversations = json_decode(file_get_contents('https://api.ivinete.ru/method/messages.getConversations?'. http_build_query($conversations_params)), true); | |
$item = $conversations[response][items]; | |
foreach ($item as $user) { | |
$user_id = $user[conversation][user_id]; | |
$first_name = $user[conversation][first_name]; | |
$messages_params = [ | |
'user_id' => $user_id, | |
'count' => 1, | |
'access_token' => $access_token | |
]; | |
$messages = json_decode(file_get_contents('https://api.ivinete.ru/method/messages.getHistory?'. http_build_query($messages_params)), true); | |
$item_messages = $messages[response][items][0]; | |
$read_state = $item_messages[read_state]; | |
$message = mb_strtolower($item_messages[text]); | |
include_once 'command.php'; | |
foreach($messages_array as $k => $v) { | |
if ($message == $k) { | |
$otwet = $v; | |
} | |
} | |
if ($read_state == 0) { | |
$message_send_params = [ | |
'user_id' => $user_id, | |
'message' => $otwet, | |
'access_token' => $access_token | |
]; | |
file_get_contents('https://api.ivinete.ru/method/messages.send?'. http_build_query($message_send_params)); | |
$markasread_params = [ | |
'user_id' => $user_id, | |
'access_token' => $access_token | |
]; | |
file_get_contents('https://api.ivinete.ru/method/messages.markAsRead?'. http_build_query($markasread_params)); | |
echo('ok'); | |
} else { | |
echo('error'); | |
} | |
} | |
unset($user); | |
sleep(10); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment