<?php
function bot($method, $datas = [])
{
$url = "https://api.telegram.org/bot" . API_KEY . "/" . $method;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datas);
$res = curl_exec($ch);
if (curl_error($ch)) {
var_dump(curl_error($ch));
} else {
return json_decode($res);
}
}
function approveChatJoinRequest($channel_id, $user_id)
{
bot('approveChatJoinRequest', [
'chat_id' => $channel_id,
'user_id' => $user_id,
]);
}
function getChatMember($channel_id, $user_id)
{
$status = bot('getChatMember', [
'chat_id' => $channel_id,
'user_id' => $user_id,
]);
$status = $status->result->status;
return $status;
}
$update = json_decode(file_get_contents('php://input'));
if (isset($update)) {
if (isset($update->message)) {
$message = $update->message;
$text = $message->text;
$cid = $message->chat->id;
$mid = $message->message_id;
} elseif (isset($update->callback_query)) {
$data = $update->callback_query->data;
$mid = $update->callback_query->message->message_id;
$cid = $update->callback_query->message->chat->id;
} elseif (isset($update->chat_join_request)) {
$chname = $update->chat_join_request->chat->title;
$chuid = $update->chat_join_request->from->id;
$chid = $update->chat_join_request->chat->id;
$join = $update->chat_join_request;
}
}
if (isset($join)) {
$select = $db->query("SELECT * FROM channels WHERE main_channel=$chid AND secondary_channel IS NOT NULL");
if ($select->num_rows == 1) {
$f = $select->fetch_assoc();
$s_channel = $f['secondary_channel'];
if (in_array(getChatMember($s_channel, $chuid), ['member', 'administrator', 'creator'])) {
approveChatJoinRequest($chid, $chuid);
bot('sendMessage', [
'chat_id' => $chuid,
'text' => "Sizning so'rovingiz tasdiqlandi",
'parse_mode' => "html"
]);
} else {
file_put_contents("cache/" . $chuid . ".txt", $f['id']);
bot('sendMessage', [
'chat_id' => $chuid,
'text' => "Sizning so'rovingiz tasdiqlanishi uchun $s_channel ga obuna bo'ling, siznign so'rovingiz keyin tasdiqlanadi",
'parse_mode' => "html",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "β Obuna bo'ldim", 'callback_data' => "ok"]]
]
])
]);
}
} else {
approveChatJoinRequest($chid, $chuid);
bot('sendMessage', [
'chat_id' => $chuid,
'text' => "Sizning so'rovingiz tasdiqlandi",
'parse_mode' => "html"
]);
}
}
if ($data == "ok") {
$id = file_get_contents("cache/" . $cid . ".txt");
$select = $db->query("SELECT * FROM channels WHERE id=$id");
$f = $select->fetch_assoc();
$s_channel = $f['secondary_channel'];
if (in_array(getChatMember($s_channel, $cid), ['member', 'administrator', 'creator'])) {
$channel_id = $f['main_channel'];
approveChatJoinRequest($channel_id, $cid);
bot('sendMessage', [
'chat_id' => $cid,
'text' => "Sizning so'rovingiz tasdiqlandi",
'parse_mode' => "html"
]);
}
}
CREATE TABLE channels (
id INT AUTO_INCREMENT PRIMARY KEY,
main_channel VARCHAR(255) NOT NULL,
secondary_channel VARCHAR(255)
);
βοΈWebhookda: allowed_updates=["message","edited_channel_post", "callback_query","my_chat_member","chat_member","chat_join_request"]
π4π2β€1π1π1
  This media is not supported in your browser
    VIEW IN TELEGRAM
  Happy brithday to me :)
  Davay obunachila pul yigβib sovgβa olila nxπ
9860120140779519
9860120140779519
π€―2π€£2
  (Reklamaga etibor bermaymiz admin paneldan qoβshiladi
Please open Telegram to view this post
    VIEW IN TELEGRAM
  π3β1β1π1
  #Maslaxat
Siz biron bir lohiya boshlayotganda avval aynan nimalar qilinishi kerakligini bilib oling, hoh u telegram bot bo'lsin, hoh sayt. Loyiha struktur ko'rinishini tuzing. Malumotlar bazasini korinishini tuzing. Keyin qolgan malumotlarni toplashni boshlashingiz mumkin. Hamma malumotlar to'liq bo'lgach sekin kod yozishni boshlashingiz mumkin.
  
  Siz biron bir lohiya boshlayotganda avval aynan nimalar qilinishi kerakligini bilib oling, hoh u telegram bot bo'lsin, hoh sayt. Loyiha struktur ko'rinishini tuzing. Malumotlar bazasini korinishini tuzing. Keyin qolgan malumotlarni toplashni boshlashingiz mumkin. Hamma malumotlar to'liq bo'lgach sekin kod yozishni boshlashingiz mumkin.
dbdiagram.io
  
  A Free Database Designer for Developers and Analysts
  Quick and simple free tool to help you draw your database relationship diagrams and flow quickly using just keyboard
  Forwarded from Foydali botlar
Kanalga kelgan yangi "qo'shilish so'rovlar"ini  qabul qilishKanaldagi eski "qo'shilish so'rovlar"ini qabul qilishPlease open Telegram to view this post
    VIEW IN TELEGRAM
  PHP'da bot kodini yozadiganlar uchun GitHub link
  
  GitHub
  
  GitHub - BotirRaimqulov/phptelegrambot
  Contribute to BotirRaimqulov/phptelegrambot development by creating an account on GitHub.
  π€ Telegram botingiz uchun Webhook sozlashni osonlashtiring!
Endi Telegram botingizni sozlashda Apify Webhook sizga yordam beradi.
π https://apify.uz/webhook/
β Oddiy interfeys
β Tez sozlash
Botingizni ishga tushirishni xohlaysizmi? Boshlash uchun havolani bosing! π
Endi Telegram botingizni sozlashda Apify Webhook sizga yordam beradi.
π https://apify.uz/webhook/
β Oddiy interfeys
β Tez sozlash
Botingizni ishga tushirishni xohlaysizmi? Boshlash uchun havolani bosing! π
π1