Telegram Bot Code Guide: Control Panel and Message Management

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.

Verify Control Panel Commands in Telegram Bot Code

Code Explanation

Function and Variable Definitions

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);
        }
    }
            

Channel Membership Verification





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;
            

Message Handling

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,
                ])
            ]);
        }
    }
            

Error Handling

If there is an issue sending API requests, curl_error is used to display errors.


    if (curl_error($ch)) {
        var_dump(curl_error($ch));
    }
            

User Data Handling

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 and Interaction Improvement

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']],
                                ]
                            ])
                        ]);
                    }
                }
            }
        }
    }
            

Return to Main Menu in Telegram Bot Code

Code Explanation





Channel and User Management

This section of the code handles messages based on channel membership status and improves user interaction based on their responses.

Manage Channels and User Interaction in Telegram Bot Code

This section of the code handles messages based on channel membership status and improves user interaction based on their responses.


// Example code to check if a user is a member of a specific channel and respond accordingly
if (in_array($from_id, $user['userlist'])) {
    if ($textmassage == '/start') {
        SssBs('sendmessage', [
            'chat_id' => $chat_id,
            'text' => "Welcome to the bot! You are already a member of our channel.",
        ]);
    }
} else {
    SssBs('sendmessage', [
        'chat_id' => $chat_id,
        'text' => "Please join our channel first to access the bot features.",
        'reply_markup' => json_encode([
            'inline_keyboard' => [
                [['text' => "Join Channel", 'url' => "https://t.me/example_channel"]],
            ],
        ]),
    ]);
}

// Improving user interaction based on their previous responses
if ($juser["userfild"]["$from_id"]["step"] == "awaiting_response") {
    // Handle the next step based on the user's response
    SssBs('sendmessage', [
        'chat_id' => $chat_id,
        'text' => "Thank you for your response!",
    ]);
    // Clear the step
    $juser["userfild"]["$from_id"]["step"] = "none";
    file_put_contents("data/$from_id.json", json_encode($juser, true));
}
        

Sending Messages and Managing Data

After verifying channel subscription status, an administrative message is sent to the admin if the user has successfully subscribed. User data is also updated in the JSON file.


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);
    

Remaining Channels Interaction

If there are remaining channels, a message is sent to the user with details about the remaining channel, such as the current number of members and the expected number after subscription. Channel data is also updated in JSON files.


$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']]
        ]
    ])
]);
SssBs('sendmessage', [
    'chat_id' => $admin,
    'text' => "- This is a message to the bot,\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' => "- 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,
]);
}
    

Response and Update Processing





If the user subscribes to a channel, the membership status is checked and their points are updated. A message is sent to notify the user that points have been added, and channel data is updated in related files.


elseif ($data == "truechannel") {
$getjoinchannel = $cuser["userfild"]["$fromid"]["getjoin"];
$getchannel = json_decode(file_get_contents("https://api.telegram.org/bot" . $token . "/getChatMember?chat_id=@" . $getjoinchannel . "&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 user clicked 'subscribed' without actually subscribing,\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
    ]);
    $cuser = json_decode(file_get_contents("data/$fromid.json"), true);
    $coin = $cuser["userfild"]["$fromid"]["coin"];
    $arraychannel = $cuser["userfild"]["$fromid"]["arraychannel"];
    $coinchannel = $user["setmemberlist"];
    $channelincoin = $coinchannel[$arraychannel];
    $downchannel = $channelincoin - 1;
    $pluscoin = $coin + 3;
    $cuser["userfild"]["$fromid"]["channeljoin"][] = "$getjoinchannel";
    $cuser["userfild"]["$fromid"]["coin"] = "$pluscoin";
    $cuser = json_encode($cuser, true);
    file_put_contents("data/$fromid.json", $cuser);
    if ($downchannel > 0) {
        @$user = json_decode(file_get_contents("data/user.json"), true);
        $user["setmemberlist"]["$arraychannel"] = "$downchannel";
        $user["setmemberlist"] = array_values($user["setmemberlist"]);
        $user = json_encode($user, true);
        file_put_contents("data/user.json", $user);
        @$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') {
                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 to the bot,\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,
            ]);
        }
    }
    else
    {
        unset($user["setmemberlist"]["$arraychannel"]);
        unset($user["channellist"]["$arraychannel"]);
        $user["channellist"] = array_values($user["channellist"]);
        $user["setmemberlist"] = array_values($user["setmemberlist"]);
        $user = json_encode($user, true);
        file_put_contents("data/user.json", $user);
    }
}
}
    

Display Member and Channel Counts in Telegram Bot Code

Code Explanation





Check Remaining Channels

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;
    

Update and Send Message

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);
}
    

Handle No Remaining Channels

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']]
        ]
    ])
]);
}
    

Handle "Skip Channel" Option

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,
    ]);
}
}
    

Handle Main Channel Selection

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,
    ]);
}
}
    

Send Message to All Members via Telegram Bot Code

Code Explanation

Update Points on Channel Subscription

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,
]);
}
    

Handle Channel Reporting

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,",
]);
}
    

Show Points Information

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']]
        ]
    ])
]);
}
    

Show Subscribed Channels

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,
    ]);
}
}
    

Forward Message to All Members via Telegram Bot Code

Detailed Explanation of the Channel and Points Management System

Below is a detailed explanation of the remaining part of the code you provided:

1. Admin Panel Commands

Show Admin List:


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.

Return to Main Menu:






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.

2. Show Number of Members and Channels:






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.

3. Send Message to Everyone:


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.

4. Handle Purchased Points Addition:


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.

Manage Channels in Telegram Bot Code

Detailed Explanation of Control Panel Commands

1. Check Control Panel Commands


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.

2. Return to Main Menu


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.

3. Show Number of Members and Channels


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.

4. Send Message to All Members


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.

5. Forward 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.

6. Show and Delete Channels






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.

7. Send Points to Members


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.