// Determine user handle (username or first name) var hh = user.username ? "@" +…
- User
// 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 = [ "https://te.legra.ph/file/0325da0c1422acc1ee7a3.jpg", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" ] var randomPhoto = photos[Math.floor(Math.random() * photos.length)]
- Assistant
The code provided seems to handle various tasks related to user interaction and bot functionality. Here is a summary of the key actions being performed in the code:
- Determining the user handle (username or first name) to use in messages.
- Setting a user property to mark that the user has completed a certain action.
- Initializing or updating a global status resource.
- Managing a list of full bot users.
- Formatting the user's name with a clickable link.
- Managing user records and counts.
- Managing a broadcast list for sending messages to multiple users.
- Handling new user notifications and sending them to a specified channel.
- Displaying advertisement messages randomly.
- Showing random photos with captions and advertisement links.
- Providing inline keyboard buttons for user interaction.
Overall, the code is designed to enhance user engagement and provide a personalized experience within the Telegram bot environment. If you have any specific questions or need further clarification on any part of the code, feel free to ask.