I want when users click only one button out of 8 buttons if try to use other buttons…
- User
I want when users click only one button out of 8 buttons if try to use other buttons then popup message show "Buy premium" only AllowedIds are use all the buttons this the code {// Determine user handle (username or first name) var hh = user.username ? "@" + user.username : user.first_name
// Set user property User.setProperty("UserDone", true, "boolean")
// Initialize or update global status var globalStatus = Libs.ResourcesLib.anotherChatRes("status", "global")
// Get or initialize the list of full bot users var FullBotUser = Bot.getProperty("FullBotUser") || [] if (!FullBotUser.includes(hh)) { FullBotUser.push(hh) Bot.setProperty("FullBotUser", FullBotUser, "json") }
// Format user name with link var name = "" + user.first_name + ""
// Get or initialize user records let totalUsers = Bot.getProperty("userRecords") || [] if (!totalUsers.some(u => u.id === user.telegramid)) { totalUsers.push({ id: user.telegramid }) Bot.setProperty("userRecords", totalUsers, "json") } const totalUsersCount = totalUsers.length
// Get or initialize broadcast list var broadcast = Bot.getProperty("Broadcast") || [] if (!broadcast.includes(user.telegramid)) { broadcast.push(user.telegramid) Bot.setProperty("Broadcast", broadcast, "json") }
// Handle new user notification if (!User.getProperty("UserDone")) { User.setProperty("UserDone", true, "boolean") Libs.ResourcesLib.anotherChatRes("status", "global").add(1)
var isNewUser = !User.getProperty("seen") if (isNewUser) { var userCount = Libs.ResourcesLib.anotherChatRes("to", "global") userCount.add(1)
var logsChannelId = "-1002078281897" var currentDate = new Date().toLocaleDateString("en-US", { timeZone: "Asia/Kolkata" }) var currentTime = new Date().toLocaleTimeString("en-US", { timeZone: "Asia/Kolkata" }) var botName = bot.name Api.sendMessage({ chat_id: logsChannelId, text: `🥳 *New User Notification* 🔔\n\n*➲ User:* [${ user.first_name }](tg://user?id=${user.telegramid})\n*➲ Username:* @${ user.username }\n*➲ ID:* ${ user.telegramid }\n\n*➲ Date:* ${currentDate}\n*➲ Time:* ${currentTime}\n*➲ Bot Name:* @${botName}\n*➲ Total Users:* ${userCount.value()}`, parse_mode: "Markdown" }) User.setProperty("seen", true, "boolean")} }
// Advertisement messages var ads = [ "@MaximXEmojis - Dive into a collection of expressive emojis for every mood! Join now and add flair to your conversations.", "@MaximXSticker - Discover vibrant and diverse sticker packs to enhance your messaging experience. Join us for a visual delight!", "@MaximXBots - Engage with cutting-edge bots designed for fun, utility, and more. Join the bot revolution and elevate your Telegram experience!", "@MaximXWallpaper - Immerse yourself in a gallery of stunning wallpapers to revamp your device's look. Join for a daily dose of aesthetic inspiration." ] var randomAd = ads[Math.floor(Math.random() * ads.length)]
// Photo URLs var photos = [ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" ] var randomPhoto = photos[Math.floor(Math.random() * photos.length)]
- Assistant
To achieve the functionality where only one button out of 8 buttons is allowed to be clicked, and if the user tries to click other buttons, a popup message showing "Buy premium" should appear, you can add the following code inside the existing code snippet provided:
// AllowedIds are those which can use all the buttons var AllowedIds = ["123456789"] // Add allowed user IDs here // Handle button click if (request.data) { if (!AllowedIds.includes(String(user.telegramid))) { // If user is not allowed, display popup message Bot.sendInlineKeyboard( [{ text: "Buy premium", callback_data: "buy_premium" }], "Only premium users are allowed to use multiple buttons." ) } else { // User is allowed to click the button switch (request.data) { case "button1": // Add functionality for button 1 break case "button2": // Add functionality for button 2 break // Add cases for other buttons here } } }