This guide provides a detailed explanation of how to implement and manage control panel commands, messages, and channels in your Telegram bot code. Below are the different sections covering specific functionalities within the Telegram bot system.
The code starts by defining a variable API_KEY that holds the bot's token.
Then, a function SssBs is defined to send API requests to the Telegram server.
function SssBs($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);
}
}
Membership status is verified using getChatMember to ensure the user is a member of the channel.
$forchannel = json_decode(file_get_contents("https://api.telegram.org/bot".$token."/getChatMember?chat_id=@".$channel."&user_id=".$from_id));
$tch = $forchannel->result->status;
Messages and responses are handled by checking the sent text and using the SendMessage function to send appropriate replies.
if ($textmassage == "/start" && $tc == "private") {
if (in_array($from_id, $user["userlist"]) == true) {
$coin = $cuser["userfild"]["$fromid"]["coin"];
SssBs('sendMessage', [
'chat_id' => $chat_id,
'text' => "- Welcome, dear, š¬ ā¢\n\n- In the Add Member bot ā
, š¤\n\n- Collect points and exchange them for members, šā¢",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
'reply_markup' => json_encode([
'inline_keyboard' => [
[
['text' => "- Collect Points, š” ā¢", 'callback_data' => 'sale']
],
[
['text' => "- Exchange Points for Members, š„ ā¢", 'callback_data' => 'takemember']
],
[
['text' => "- Enter Points Code, ā ā¢", 'callback_data' => 'code']
],
[
['text' => "⢠Other Commands, šÆ", 'callback_data' => 'ERE11']
]
],
'resize_keyboard' => true,
])
]);
}
}
If there is an issue sending API requests, curl_error is used to display errors.
if (curl_error($ch)) {
var_dump(curl_error($ch));
}
When receiving data from the user, it is handled by modifying files and using json_decode and json_encode for processing.
$cuser = json_decode(file_get_contents("data/$fromid.json"), true);
$cuser["userfild"]["$fromid"]["file"] = "none";
$cuser = json_encode($cuser, true);
file_put_contents("data/$fromid.json", $cuser);
User choices are handled by checking the value of $data, and specialized messages are sent based on this value.
if ($data == 'sale') {
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- Choose the easiest way for you to collect points, š ā¢\n\n... (message text)",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "- Join Channels, š¢ ā¢", 'callback_data' => 'takecoin']],
[['text' => "- Enter Points Code, ā ā¢", 'callback_data' => 'code']],
[['text' => "- Invite Link, š®", 'callback_data' => 'member']],
[['text' => "⢠Return, š", 'callback_data' => 'panel']],
]
])
]);
} elseif ($data == "takecoin") {
$rules = $cuser["userfild"]["$fromid"]["acceptrules"];
if ($rules == false) {
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "⢠- Points are collected by subscribing to channels\n\n... (message text)",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "- Completed Reading ā '", 'callback_data' => "takecoin"], ['text' => "⢠Return, š '", 'callback_data' => 'panel']]
]
])
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- This is the bot rules statement,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
$cuser["userfild"]["$fromid"]["acceptrules"] = "true";
$cuser = json_encode($cuser, true);
file_put_contents("data/$fromid.json", $cuser);
} else {
if ($tchq != 'member' && $tchq != 'creator' && $tchq != 'administrator') {
$join = $cuser["userfild"]["$fromid"]["canceljoin"];
if ($join == false) {
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- The main bot channel, if you are not subscribed, you will receive 2 points upon subscribing, š¬ '\n\n... (message text)",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "- Subscribe, š¢ '", 'url' => "https://t.me/$channel"], ['text' => "- Next, š» '", 'callback_data' => 'mainchannel']],
[['text' => "⢠Already Subscribed, š® '", 'callback_data' => 'takecoin'], ['text' => "⢠Return, š '", 'callback_data' => 'panel']],
]
])
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- This subscribed to the main bot channel,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
$cuser["userfild"]["$fromid"]["canceljoin"] = "true";
$cuser = json_encode($cuser, true);
file_put_contents("data/$fromid.json", $cuser);
} else {
$allchannel = $user["channellist"];
for ($z = 0; $z <= count($allchannel); $z++) {
$getchannel = json_decode(file_get_contents("https://api.telegram.org/bot" . $token . "/getChatMember?chat_id=" . $allchannel[$z] . "&user_id=" . $fromid));
$okchannel = $getchannel->result->status;
if ($okchannel != 'member' && $okchannel != 'creator' && $okchannel != 'administrator') {
break;
}
}
if ($allchannel[$z] == true) {
$url = file_get_contents("https://api.telegram.org/bot$token/getChat?chat_id=$allchannel[$z]");
$getchat = json_decode($url, true);
$name = $getchat["result"]["title"];
$username = $getchat["result"]["username"];
$id = $getchat["result"]["id"];
$description = $getchat["result"]["description"];
$howmember = getChatMembersCount($username, $token);
$endmember = $howmember + 1;
$coin = $cuser["userfild"]["$fromid"]["coin"];
$soos = $coin + 3;
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- Channel Username, š¢ : @$username\n- Channel Members, š : $howmember\n- Members after subscribing, š„ : $endmember\n\nāāāāāāā\nā»ļø - Subscribe to the channel š¢\nAnd get 3 points š°",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "- Get 3 Points š°", 'callback_data' => 'truechannel']],
[['text' => "⢠Skip, š '", 'callback_data' => 'nextchannel'], ['text' => "⢠Return, š '", 'callback_data' => 'panel']],
[['text' => "- Report Channel, š ā¢", 'callback_data' => 'badchannel']],
]
])
]);
}
}
}
}
}
This section of the code checks whether there are any remaining channels in the list that haven't been verified yet and retrieves channel details.
if ($allchannel[$z] == true) {
$url = file_get_contents("https://api.telegram.org/bot$token/getChat?chat_id=$allchannel[$z]");
$getchat = json_decode($url, true);
$name = $getchat["result"]["title"];
$username = $getchat["result"]["username"];
$id = $getchat["result"]["id"];
$description = $getchat["result"]["description"];
$howmember = getChatMembersCount($username, $token);
$endmember = $howmember + 1;
$coin = $cuser["userfild"]["$fromid"]["coin"];
$soos = $coin + 3;
This part of the code updates the message with details about the remaining channel and sends a notification to the admin. It also updates the user's data in JSON files.
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- Channel Username, š¢ : @$username\n- Channel Members, š : $howmember\n- Members after subscribing, š„ : $endmember\n\nāāāāāāā\nā»ļø - Subscribe to the channel š¢\nAnd get 3 points š°",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "- Get 3 Points š°", 'callback_data' => 'truechannel']],
[['text' => "⢠Skip, š", 'callback_data' => 'nextchannel'], ['text' => "⢠Return, š", 'callback_data' => 'panel']],
[['text' => "- Report Channel, š", 'callback_data' => 'badchannel']]
]
])
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- This is a message,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
$cuser = json_decode(file_get_contents("data/$fromid.json"), true);
$cuser["userfild"]["$fromid"]["getjoin"] = "$username";
$cuser["userfild"]["$fromid"]["arraychannel"] = "$z";
$cuser = json_encode($cuser, true);
file_put_contents("data/$fromid.json", $cuser);
}
If there are no remaining channels, a message is sent to the user with alternative instructions such as sharing the link instead of subscribing to channels.
else
{
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- All added channels have been exhausted; please try again to gather points, or share the link instead of subscribing to channels, š»!",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "- Share Link š»", 'callback_data' => 'takecoin'], ['text' => "⢠Return, š", 'callback_data' => 'panel']]
]
])
]);
}
When the user selects to skip a channel, the message is updated to show the next channel in the list. If there are no more channels left, a message is sent to both the user and the admin to inform them of the end of channels.
elseif($data == "nextchannel") {
SssBs('answercallbackquery', [
'callback_query_id' => $membercall,
'text' => "- Please wait a moment ... š!",
'show_alert' => false
]);
$arraychannel = $cuser["userfild"]["$fromid"]["arraychannel"];
$plusarraychannel = $arraychannel + 3;
$allchannel = $user["channellist"];
for ($z = $plusarraychannel; $z <= count($allchannel); $z++) {
$getchannel = json_decode(file_get_contents("https://api.telegram.org/bot".$token."/getChatMember?chat_id=".$allchannel[$z]."&user_id=".$fromid));
$okchannel = $getchannel->result->status;
if ($okchannel != 'member' && $okchannel != 'creator' && $okchannel != 'administrator') {
break;
}
}
if ($allchannel[$z] == true) {
$url = file_get_contents("https://api.telegram.org/bot$token/getChat?chat_id=$allchannel[$z]");
$getchat = json_decode($url, true);
$name = $getchat["result"]["title"];
$username = $getchat["result"]["username"];
$id = $getchat["result"]["id"];
$description = $getchat["result"]["description"];
$howmember = getChatMembersCount($username, $token);
$endmember = $howmember + 1;
$coin = $cuser["userfild"]["$fromid"]["coin"];
$soos = $coin + 3;
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- Channel Username, š¢ : @$username\n- Channel Members, š : $howmember\n- Members after subscribing, š„ : $endmember\n\nāāāāāāā\nā»ļø - Subscribe to the channel š¢\nAnd get 3 points š°",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "- Get 3 Points š°", 'callback_data' => 'truechannel']],
[['text' => "⢠Skip, š", 'callback_data' => 'nextchannel'], ['text' => "⢠Return, š", 'callback_data' => 'panel']],
[['text' => "- Report Channel, š", 'callback_data' => 'badchannel']]
]
])
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- This is a message,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
$cuser["userfild"]["$fromid"]["getjoin"] = "$username";
$cuser["userfild"]["$fromid"]["arraychannel"] = "$z";
$cuser = json_encode($cuser, true);
file_put_contents("data/$fromid.json", $cuser);
}
else {
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- All added channels have been exhausted; please try again to gather points, or share the link instead of subscribing to channels, š»!",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "- Refresh, š", 'callback_data' => 'takecoin'], ['text' => "⢠Return, š", 'callback_data' => 'panel']]
]
])
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- These are the remaining channels for the bot,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
}
}
This section checks whether the user is subscribed to the main channel. If subscribed, it adds points to the user's account; otherwise, it notifies the user and the admin.
elseif($data == "mainchannel") {
$getchannel = json_decode(file_get_contents("https://api.telegram.org/bot".$token."/getChatMember?chat_id=@".$channel."&user_id=".$fromid));
$okchannel = $getchannel->result->status;
if ($okchannel != 'member' && $okchannel != 'creator' && $okchannel != 'administrator') {
SssBs('answercallbackquery', [
'callback_query_id' => $membercall,
'text' => "⢠- Please subscribe first ā
",
'show_alert' => true
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- This is the message for not being subscribed,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
}
else {
SssBs('answercallbackquery', [
'callback_query_id' => $membercall,
'text' => "⢠- 3 points have been added to your account - Your points $coin",
'show_alert' => false
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- This is the message for adding points \n- [$firstname](tg://user?id=$fromid)",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
}
}
When a user subscribes to a new channel, their points are updated, and the channel is added to their list of subscribed channels. The following code demonstrates how this is achieved:
$coin = $cuser["userfild"]["$fromid"]["coin"];
$pluscoin = $coin + 3;
$cuser["userfild"]["$fromid"]["coin"] = $pluscoin;
$cuser["userfild"]["$fromid"]["channeljoin"][] = "$channel";
$cuser = json_encode($cuser, true);
file_put_contents("data/$fromid.json", $cuser);
@$user = json_decode(file_get_contents("data/user.json"), true);
$allchannel = $user["channellist"];
for ($z = 0; $z < count($allchannel); $z++) {
$getchannel = json_decode(file_get_contents("https://api.telegram.org/bot".$token."/getChatMember?chat_id=".$allchannel[$z]."&user_id=".$fromid));
$okchannel = $getchannel->result->status;
if ($okchannel != 'member' && $okchannel != 'creator' && $okchannel != 'administrator') {
$omm = $allchannel[$z];
break;
}
}
if (isset($allchannel[$z])) {
$url = file_get_contents("https://api.telegram.org/bot$token/getChat?chat_id=$allchannel[$z]");
$getchat = json_decode($url, true);
$name = $getchat["result"]["title"];
$username = $getchat["result"]["username"];
$id = $getchat["result"]["id"];
$description = $getchat["result"]["description"];
$howmember = getChatMembersCount($username, $token);
$endmember = $howmember + 1;
$coin = $cuser["userfild"]["$fromid"]["coin"];
$soos = $coin + 3;
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- Channel Username, š¢ : @$username\n- Channel Members, š : $howmember\n- Members after subscribing, š„ : $endmember\n\nāāāāāāā\nā»ļø - Subscribe to the channel š¢\nAnd get 3 points š°",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "- Get 3 Points š°", 'callback_data' => 'truechannel']],
[['text' => "⢠Skip, š", 'callback_data' => 'nextchannel'], ['text' => "⢠Return, š", 'callback_data' => 'panel']],
[['text' => "- Report Channel, š", 'callback_data' => 'badchannel']]
]
])
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- New subscription to a channel,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
$cuser = json_decode(file_get_contents("data/$fromid.json"), true);
$cuser["userfild"]["$fromid"]["getjoin"] = "$username";
$cuser["userfild"]["$fromid"]["arraychannel"] = "$z";
$cuser = json_encode($cuser, true);
file_put_contents("data/$fromid.json", $cuser);
} else {
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- All added channels have been exhausted; please try again to gather points, or share the link instead of subscribing to channels, š»!",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "- Share Link š»", 'callback_data' => 'takecoin'], ['text' => "⢠Return, š", 'callback_data' => 'panel']]
]
])
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- These are the remaining channels for the bot,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
}
If a user reports an inappropriate channel, the report is sent to the developer. The following code shows how to handle reports:
elseif ($data == "badchannel") {
$getjoinchannel = $cuser["userfild"]["$fromid"]["getjoin"];
SssBs('answercallbackquery', [
'callback_query_id' => $membercall,
'text' => "- The report has been sent to the bot developer; they will review the channel and remove it from the bot. Thank you for cooperating with us, ā„ļø!",
'show_alert' => true
]);
SssBs('sendmessage', [
'chat_id' => $Dev[0],
'text' => "- New report about a non-compliant or inappropriate channel in the bot, Channel ID: @$getjoinchannel!\n\nļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹\n⢠Information about the member who reported the channel: ššæā„ļø;\nā«ļø User ID: $fromid,\nā¾ļø Username: @$usernames,",
]);
}
Users can view the number of points they have with this code:
elseif ($data == "accont") {
$invite = $cuser["userfild"]["$fromid"]["invite"];
$coin = $cuser["userfild"]["$fromid"]["coin"];
$setchannel = $cuser["userfild"]["$fromid"]["setchannel"];
$setmember = $cuser["userfild"]["$fromid"]["setmember"];
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "⢠- Welcome dear $frist_name\n\nā¾ļø Total points: $coin\n",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "⢠Return, š", 'callback_data' => 'panel']]
]
])
]);
}
Users can view the channels they have subscribed to with the following code:
elseif ($data == "mechannel") {
$allchannel = $cuser["userfild"]["$fromid"]["channeljoin"];
$result = "";
for ($z = 0; $z < count($allchannel); $z++) {
$result .= "š @" . $allchannel[$z] . "\n";
}
if ($result) {
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- List of channels you have subscribed to, šššæ;\n\n$result\n⢠Note: Leaving a channel will deduct 2 points from your account; therefore, please be aware, š",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "⢠Return, š", 'callback_data' => 'panel']]
]
])
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- These are the channels subscribed by the user,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
} else {
SssBs('editmessagetext', [
'chat_id' => $chatid,
'message_id' => $messageid,
'text' => "- You have not subscribed to any of the bot's channels yet, dear; please subscribe and gather points before pressing the button for subscribed channels, šø.\nļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "⢠Return, š", 'callback_data' => 'panel'], ['text' => "- Gather Points, š»", 'callback_data' => 'takecoin']]
]
])
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- This user has not subscribed to any channels for the bot,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
}
}
Below is a detailed explanation of the remaining part of the code you provided:
elseif($textmassage=="/panel" or $textmassage=="/admin" or $textmassage=="Ų§ŲÆŁ
Ł"){
if ($tc == "private") {
if (in_array($from_id,$Dev)){
SssBs('sendmessage', [
'chat_id' => $chat_id,
'text' => "- Welcome dear developer, š§āā \n- Please choose from the menu below, š
\nļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹",
'reply_to_message_id' => $message_id,
'reply_markup' => json_encode([
'keyboard' => [
[['text' => "- Number of Members, š¤ '"]],
[['text' => "- Message to All, š '"], ['text' => "- Forward to All, š§āā '"]],
[['text' => "- Show Channels, š± '"], ['text' => "- Delete Channel, š '"]],
[['text' => "- Send Points, š '"]]
],
'resize_keyboard' => true
])
]);
}
}
}
Purpose: When receiving commands /panel, /admin, or "Ų§ŲÆŁ
Ł" in a private chat with the bot, if the user is in the developer list ($Dev), an admin menu is sent containing options such as showing the number of members, sending a message to everyone, showing channels, deleting a channel, and sending points.
elseif($textmassage=="⢠Return, š '"){
if ($tc == "private") {
if (in_array($from_id,$Dev)){
SssBs('sendmessage', [
'chat_id' => $chat_id,
'text' => "- Welcome dear developer, š§āā \n- Please choose from the menu below, š
\nļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹",
'reply_to_message_id' => $message_id,
'reply_markup' => json_encode([
'keyboard' => [
[['text' => "- Number of Members, š¤ '"]],
[['text' => "š Generate Points Code"]],
[['text' => "- Message to All, š '"], ['text' => "- Forward to All, š§āā '"]],
[['text' => "- Show Channels, š± '"], ['text' => "- Delete Channel, š '"]],
[['text' => "- Send Points, š '"]]
],
'resize_keyboard' => true
])
]);
$juser["userfild"]["$from_id"]["file"] = "none";
$juser = json_encode($juser, true);
file_put_contents("data/$from_id.json", $juser);
}
}
}
Purpose: Returns the developer to the main admin menu. The file status is cleared from JSON to avoid sending unwanted messages.
elseif($textmassage=="- Number of Members, š¤ '"){
if (in_array($from_id,$Dev)){
$all = count($user["userlist"]);
$order = count($user["channellist"]);
SssBs('sendmessage', [
'chat_id' => $chat_id,
'text' => "⢠Welcome dear developer; @$username !\n\nā¾ļø Number of Members: $all,\nā«ļø Number of Channels in the Funding List: $order.\nļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹",
'hide_keyboard' => true,
]);
}
}
Purpose: Displays the number of members in the user list and the number of channels in the funding list to the developer.
elseif ($textmassage == "- Message to All, š '" ) {
if (in_array($from_id,$Dev)){
SssBs('sendmessage', [
'chat_id' => $chat_id,
'text' => "- Hello; @$username !\n- Now send the message to be broadcasted to everyone, š®š¶ '",
'reply_to_message_id' => $message_id,
'reply_markup' => json_encode([
'keyboard' => [
[['text' => "⢠Return, š '"]]
],
'resize_keyboard' => true
])
]);
SssBs('sendmessage', [
'chat_id' => $admin,
'text' => "- This is a suggestion to send a message,\n- [$firstname](tg://user?id=$fromid) ",
'parse_mode' => "MarkDown",
'disable_web_page_preview' => true,
]);
$cuser["userfild"]["$fromid"]["file"] = "sendsup";
$cuser = json_encode($cuser, true);
file_put_contents("data/$fromid.json", $cuser);
}
}
elseif ($juser["userfild"]["$from_id"]["file"] == 'sendsup') {
SssBs('sendmessage', [
'chat_id' => $chat_id,
'text' => "⢠Your message has been sent to the bot developer,\n⢠Please wait for a response.",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "⢠Return, š '", 'callback_data' => 'panel']]
]
])
]);
SssBs('ForwardMessage', [
'chat_id' => $Dev[0],
'from_chat_id' => $chat_id,
'message_id' => $message_id
]);
}
Purpose: Allows the developer to send a message to all members. The state is recorded as "sendsup" to ensure the bot receives the message from the developer and forwards it to all members. The message is then forwarded to the developers.
if(file_get_contents("data/$fromid.txt") == "true"){
$pluscoin = file_get_contents("data/".$fromid."coin.txt");
$inviter = $cuser["userfild"]["$fromid"]["inviter"];
$invitercoin = $pluscoin / 100 * 20;
SssBs('answercallbackquery', [
'callback_query_id' => $membercall,
'text' => "š Adding the purchased coins...",
'show_alert' => false
]);
SssBs('sendmessage', [
'chat_id' => $inviter,
'text' => "š° Amount: $invitercoin !\n\nš Operation was successful !!",
'reply_markup' => json_encode([
'inline_keyboard' => [
[['text' => "⢠Return, š '", 'callback_data' => 'panel']]
]
])
]);
$coin = $cuser["userfild"]["$fromid"]["coin"];
$coinplus = $coin + $pluscoin;
$cuser["userfild"]["$fromid"]["coin"] = "$coinplus";
$cuser = json_encode($cuser, true);
file_put_contents("data/$fromid.json", $cuser);
$inuser = json_decode(file_get_contents("data/$inviter.json"), true);
$coininviter = $inuser["userfild"]["$inviter"]["coin"];
$coinplusinviter = $coininviter + $invitercoin;
$inuser["userfild"]["$inviter"]["coin"] = "$coinplusinviter";
$inuser = json_encode($inuser, true);
file_put_contents("data/$inviter.json", $inuser);
unlink("data/".$fromid."coin.txt");
unlink("data/$fromid.txt");
}
Purpose: Handles the process of adding purchased coins to the user's and the inviter's accounts. Points are updated in the user databases, and notifications of successful transactions are sent.
elseif($textmassage=="/panel" or $textmassage=="/admin" or $textmassage=="Ų§ŲÆŁ
Ł"){
if ($tc == "private") {
if (in_array($from_id,$Dev)){
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"- Welcome dear developer, š§āā \n- Please choose from the menu below, š
\nļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹",
'reply_to_message_id'=>$message_id,
'reply_markup'=>json_encode([
'keyboard'=>[
[['text'=>"- Number of Members, š¤ '"]],
[['text'=>"- Message to All, š '"], ['text'=>"- Forward to All, š§āā '"]],
[['text'=>"- Show Channels, š± '"], ['text'=>"- Delete Channel, š '"]],
[['text'=>"- Send Points, š '"]]
],
'resize_keyboard'=>true
])
]);
}
}
}
Purpose: Sends a welcome message to the developer and displays a list of control panel commands.
elseif($textmassage=="⢠Return, š '"){
if ($tc == "private") {
if (in_array($from_id,$Dev)){
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"- Welcome dear developer, š§āā \n- Please choose from the menu below, š
\nļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹",
'reply_to_message_id'=>$message_id,
'reply_markup'=>json_encode([
'keyboard'=>[
[['text'=>"- Number of Members, š¤ '"]],
[['text'=>"š Generate Points Code"]],
[['text'=>"- Message to All, š '"], ['text'=>"- Forward to All, š§āā '"]],
[['text'=>"- Show Channels, š± '"], ['text'=>"- Delete Channel, š '"]],
[['text'=>"- Send Points, š '"]]
],
'resize_keyboard'=>true
])
]);
$juser["userfild"]["$from_id"]["file"]="none";
$juser = json_encode($juser,true);
file_put_contents("data/$from_id.json",$juser);
}
}
}
Purpose: Returns the developer to the main menu and resets the state in the user file.
elseif($textmassage=="- Number of Members, š¤ '"){
if (in_array($from_id,$Dev)){
$all = count($user["userlist"]);
$order = count($user["channellist"]);
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"⢠Welcome dear developer; @$username !\n\nā¾ļø Number of Members: $all,\nā«ļø Number of Channels in the Funding List: $order.\nļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹",
'hide_keyboard'=>true,
]);
}
}
Purpose: Displays the number of members and the number of channels in the list.
elseif ($textmassage == "- Message to All, š '" ) {
if (in_array($from_id,$Dev)){
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"- Hello; @$username !\n- Now send the message to be broadcasted to everyone, š®š¶ '",
'reply_to_message_id'=>$message_id,
'reply_markup'=>json_encode([
'keyboard'=>[
[['text'=>"⢠Return, š '"]]
],
'resize_keyboard'=>true
])
]);
$juser["userfild"]["$from_id"]["file"]="sendtoall";
$juser = json_encode($juser,true);
file_put_contents("data/$from_id.json",$juser);
}
}
elseif ($juser["userfild"]["$from_id"]["file"] == 'sendtoall') {
$juser["userfild"]["$from_id"]["file"]="none";
$numbers = $user["userlist"];
$juser = json_encode($juser,true);
file_put_contents("data/$from_id.json",$juser);
if ($textmassage != "⢠Return, š '") {
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"- The message has been sent to all bot subscribers successfully by; @$username, š¢ !",
'reply_to_message_id'=>$message_id,
]);
for($z = 0;$z <= count($numbers)-1;$z++){
SssBs('sendmessage',[
'chat_id'=>$numbers[$z],
'text'=>"$textmassage\nļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹",
]);
}
}
}
Purpose: Allows the developer to send a message to all members.
elseif ($textmassage == "- Forward to All, š§āā '" ) {
if (in_array($from_id,$Dev)){
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"- Hello; @$username !\n- Now send the forward to be sent to everyone, š®š¶ '",
'reply_to_message_id'=>$message_id,
'reply_markup'=>json_encode([
'keyboard'=>[
[['text'=>"⢠Return, š '"]]
],
'resize_keyboard'=>true
])
]);
$juser["userfild"]["$from_id"]["file"]="fortoall";
$juser = json_encode($juser,true);
file_put_contents("data/$from_id.json",$juser);
}
}
elseif ($juser["userfild"]["$from_id"]["file"] == 'fortoall') {
$juser["userfild"]["$from_id"]["file"]="none";
$numbers = $user["userlist"];
$juser = json_encode($juser,true);
file_put_contents("data/$from_id.json",$juser);
if ($textmassage != "⢠Return, š '") {
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"- The forward has been sent to all bot subscribers successfully by; @$username, š¢ !",
'reply_to_message_id'=>$message_id,
]);
for($z = 0;$z <= count($numbers)-1;$z++){
Forward($numbers[$z], $chat_id,$message_id);
}
}
}
Purpose: Allows the developer to forward a message to all members.
elseif($textmassage=="- Show Channels, š± '"){
if (in_array($from_id,$Dev)){
$order = $user["channellist"];
$ordercount = count($user["channellist"]);
for($z = 0;$z <= count($order)-1;$z++){
$channels .= "$order[$z]\n";
}
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"⢠Welcome dear developer; @$username !\n\nā¾ļø Number of Channels in the List: $ordercount,\nā«ļø Channels in the list:\n$channels\nļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹ļ¹",
'hide_keyboard'=>true,
]);
}
}
elseif ($textmassage=="- Delete Channel, š '"){
if (in_array($from_id,$Dev)){
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"⢠Welcome dear developer; @$username !\n\nā¾ļø Please send the name of the channel you wish to delete,\nā«ļø Example: @Example_channel",
'reply_to_message_id'=>$message_id,
'reply_markup'=>json_encode([
'keyboard'=>[
[['text'=>"⢠Return, š '"]]
],
'resize_keyboard'=>true
])
]);
$juser["userfild"]["$from_id"]["file"]="delchannel";
$juser = json_encode($juser,true);
file_put_contents("data/$from_id.json",$juser);
}
}
elseif ($juser["userfild"]["$from_id"]["file"]=="delchannel"){
$juser["userfild"]["$from_id"]["file"]="none";
$channelname = $textmassage;
if (in_array($channelname,$user["channellist"])){
$index = array_search($channelname,$user["channellist"]);
unset($user["channellist"][$index]);
$user["channellist"] = array_values($user["channellist"]);
$juser = json_encode($juser,true);
file_put_contents("data/$from_id.json",$juser);
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"- The channel has been successfully removed from the list by; @$username, š¢ !",
'reply_to_message_id'=>$message_id,
]);
}else{
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"⢠The channel you wish to delete is not in the list, š !",
'reply_to_message_id'=>$message_id,
]);
}
}
Purpose: Displays the channels in the list and allows the developer to delete a channel.
elseif($textmassage=="- Send Points, š '"){
if (in_array($from_id,$Dev)){
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"⢠Welcome dear developer; @$username !\n- Now send the number of points to be sent to everyone, š®š¶ '",
'reply_to_message_id'=>$message_id,
'reply_markup'=>json_encode([
'keyboard'=>[
[['text'=>"⢠Return, š '"]]
],
'resize_keyboard'=>true
])
]);
$juser["userfild"]["$from_id"]["file"]="points";
$juser = json_encode($juser,true);
file_put_contents("data/$from_id.json",$juser);
}
}
elseif ($juser["userfild"]["$from_id"]["file"]=="points"){
$juser["userfild"]["$from_id"]["file"]="none";
$points = $textmassage;
if (is_numeric($points)){
$numbers = $user["userlist"];
for($z = 0;$z <= count($numbers)-1;$z++){
$user["userlist"]["$numbers[$z]"]["points"]+=$points;
$user["userlist"]["$numbers[$z]"]["pointstotal"]+=$points;
$user = json_encode($user,true);
file_put_contents("data/users.json",$user);
}
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"- The points have been sent to all subscribers successfully by; @$username, š¢ !",
'reply_to_message_id'=>$message_id,
]);
}else{
SssBs('sendmessage',[
'chat_id'=>$chat_id,
'text'=>"⢠Please enter a valid number of points",
'reply_to_message_id'=>$message_id,
]);
}
}
Purpose: Allows the developer to send points to all members.