mkdir("step");
mkdir("ball");
if ($txt == "/test") {
$num1 = rand(1, 30);
$num2 = rand(30, 60);
$javob = $num1 + $num2;
$xato1 = $javob - rand(1, 10);
$xato2 = $javob + rand(1, 10);
$answers = array("$xato1", "$xato2", "$javob");
shuffle($answers);
$true_id = array_keys($answers, "$javob")[0];
$bot->request('SendPoll', [
'chat_id' => $cid,
'question' => $num1 . " + " . $num2 . " = ??",
'allows_multiple_answers' => true,
'type' => 'quiz',
'explanation' => "To'g'ri javob " . $javob . " edi", //malumot berish
'open_period' => 10, //javob berish vaqti
'correct_option_id' => $true_id, //0 dan boshlanadi tog'ri javob varyanti
'is_anonymous' => false, //anonim bolishi
'options' => json_encode($answers),
]);
file_put_contents("step/$cid.txt", $true_id);
file_put_contents("ball/$cid.txt", "0");
}
if (isset($update->poll_answer)) {
$answer_id = $update->poll_answer->option_ids[0];
$user = $update->poll_answer->user->id;
$true_id = file_get_contents("step/$user.txt");
$ball = file_get_contents("ball/$user.txt");
if ($answer_id == $true_id) {
$num1 = rand(1, 30);
$num2 = rand(30, 60);
$javob = $num1 + $num2;
$xato1 = $javob - rand(1, 10);
$xato2 = $javob + rand(1, 10);
$answers = array("$xato1", "$xato2", "$javob");
shuffle($answers);
$true_id = array_keys($answers, "$javob")[0];
file_put_contents("step/$user.txt", $true_id);
$bot->request('SendPoll', [
'chat_id' => $user,
'question' => $num1 . " + " . $num2 . " = ??",
'allows_multiple_answers' => true,
'type' => 'quiz',
'explanation' => "To'g'ri javob " . $javob . " edi", //malumot berish
'open_period' => 10, //javob berish vaqti
'correct_option_id' => $true_id, //0 dan boshlanadi tog'ri javob varyanti
'is_anonymous' => false, //anonim bolishi
'options' => json_encode($answers),
]);
file_put_contents("ball/$user.txt", $ball + 10);
} else {
$bot->request('sendmessage', [
'chat_id' => $user,
'text' => "Siz $ball to'pladingiz va o'yinni yakunladingiz, Yangi test uchun /test"
]);
unlink("ball/$user.txt");
unlink("step/$user.txt");
}
}
Kimgadur kerak bolib qolar)
mkdir("ball");
if ($txt == "/test") {
$num1 = rand(1, 30);
$num2 = rand(30, 60);
$javob = $num1 + $num2;
$xato1 = $javob - rand(1, 10);
$xato2 = $javob + rand(1, 10);
$answers = array("$xato1", "$xato2", "$javob");
shuffle($answers);
$true_id = array_keys($answers, "$javob")[0];
$bot->request('SendPoll', [
'chat_id' => $cid,
'question' => $num1 . " + " . $num2 . " = ??",
'allows_multiple_answers' => true,
'type' => 'quiz',
'explanation' => "To'g'ri javob " . $javob . " edi", //malumot berish
'open_period' => 10, //javob berish vaqti
'correct_option_id' => $true_id, //0 dan boshlanadi tog'ri javob varyanti
'is_anonymous' => false, //anonim bolishi
'options' => json_encode($answers),
]);
file_put_contents("step/$cid.txt", $true_id);
file_put_contents("ball/$cid.txt", "0");
}
if (isset($update->poll_answer)) {
$answer_id = $update->poll_answer->option_ids[0];
$user = $update->poll_answer->user->id;
$true_id = file_get_contents("step/$user.txt");
$ball = file_get_contents("ball/$user.txt");
if ($answer_id == $true_id) {
$num1 = rand(1, 30);
$num2 = rand(30, 60);
$javob = $num1 + $num2;
$xato1 = $javob - rand(1, 10);
$xato2 = $javob + rand(1, 10);
$answers = array("$xato1", "$xato2", "$javob");
shuffle($answers);
$true_id = array_keys($answers, "$javob")[0];
file_put_contents("step/$user.txt", $true_id);
$bot->request('SendPoll', [
'chat_id' => $user,
'question' => $num1 . " + " . $num2 . " = ??",
'allows_multiple_answers' => true,
'type' => 'quiz',
'explanation' => "To'g'ri javob " . $javob . " edi", //malumot berish
'open_period' => 10, //javob berish vaqti
'correct_option_id' => $true_id, //0 dan boshlanadi tog'ri javob varyanti
'is_anonymous' => false, //anonim bolishi
'options' => json_encode($answers),
]);
file_put_contents("ball/$user.txt", $ball + 10);
} else {
$bot->request('sendmessage', [
'chat_id' => $user,
'text' => "Siz $ball to'pladingiz va o'yinni yakunladingiz, Yangi test uchun /test"
]);
unlink("ball/$user.txt");
unlink("step/$user.txt");
}
}
Kimgadur kerak bolib qolar)