Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $token = "d229ca7525**************************************1ee4bff93c8c640a";
- $id = "-188435782";
- function send($token, $id , $message)
- {
- $url = 'https://api.vk.com/method/messages.send';
- $rand = rand(1000000000, 9999999999);
- $params = array(
- 'user_id' => $id,
- 'message' => $message,
- 'random_id' => $rand,
- 'access_token' => $token,
- 'v' => '5.95',
- );
- // В $result вернется id отправленного сообщения
- $result = file_get_contents($url, false, stream_context_create(array(
- 'http' => array(
- 'method' => 'POST',
- 'header' => 'Content-type: application/x-www-form-urlencoded',
- 'content' => http_build_query($params)
- )
- )));
- }
- function ArrayLetters($length, $proto, $dead) {
- $dict = file("wordlist/" . $length . "_letters.txt", FILE_IGNORE_NEW_LINES);
- $exp = '/^' . str_replace('*', '\w{1}', $proto) . '$/u';
- $words = array_filter($dict, function ($v) use ($exp, $dead) {
- $dw = true;
- foreach (array_diff(preg_split('//u', $dead), ['']) as $d) {
- if (preg_match('/' . $d . '/u', $v)) {
- $dw = false;
- break;
- };
- }
- return (preg_match($exp, $v) && $dw);
- });
- $letters = [];
- foreach ($words as $v) {
- $imp = implode('|', preg_split('//u', str_replace('*', '', $proto)));
- foreach (array_diff(preg_split('//u', preg_replace('/(' . $imp . ')/u', '', $v)), ['']) as $w) {
- $letters[] = $w;
- }
- }
- $percentageLetters = [];
- $count = count($words);
- foreach (array_unique($letters) as $v) {
- $c = 0;
- foreach ($words as $w) {
- if (preg_match('/' . $v . '/u', $w)) $c++;
- }
- $percentageLetters[] = ['letter' => $v, 'percent' => round(($c / $count * 100), 1) . '%'];
- }
- uasort($percentageLetters, function ($a, $b) {
- return ((float)$a['percent'] > (float)$b['percent']) ? -1 : 1;
- });
- /* массив букв со 100% вероятностью */
- $arrPercent100 = array_values(array_filter($percentageLetters, function($data) {
- return ((float)$data['percent'] == 100);
- }));
- /* буква с самым большим процентом */
- $mostLetter = array_shift($percentageLetters);
- if ($arrPercent100) {
- print_r($arrPercent100);
- }
- elseif ($mostLetter) {
- print_r($mostLetter);
- }
- }
- function getlastmess($token, $id, $type)
- {
- $url = 'https://api.vk.com/method/messages.getHistory';
- $params = array(
- 'count' => 1,
- 'user_id' => $id,
- 'access_token' => $token,
- 'v' => '5.95',
- );
- // В $result вернется id отправленного сообщения
- $result = file_get_contents($url, false, stream_context_create(array(
- 'http' => array(
- 'method' => 'POST',
- 'header' => 'Content-type: application/x-www-form-urlencoded',
- 'content' => http_build_query($params)
- )
- )));
- $arresult = json_decode($result, true);
- $lastmes = $arresult['response']['items'][0]['text'];
- $exparresult = explode("\n",$lastmes);
- switch ($type) {
- case "proto":
- $letters = str_replace('📗 Отгаданные буквы:', '', $exparresult[0]);
- break;
- case "dead":
- $letters = str_replace(array('👿 Неверные попытки:', ', '), '', $exparresult[1]);
- break;
- }
- return $letters;
- }
- $length = strlen(getlastmess($token, $id, "proto"))-1;
- $proto = getlastmess($token, $id, "proto");
- $dead = getlastmess($token, $id, "dead");
- ArrayLetters($length, $proto, $dead);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement