--Made by Binga local http_service = game:GetService("HttpService") local bot_token = "" -- key here local function get_chat_ids() local url = "https://api.telegram.org/bot" .. bot_token .. "/getUpdates" local success, result = pcall(request, { Url = url, Method = "GET" }) if success then local data = http_service:JSONDecode(result.Body) local chat_ids = {} if data.ok then for _, update in ipairs(data.result) do if update.message and update.message.chat and update.message.chat.id then local chat_id = tostring(update.message.chat.id) if not table.find(chat_ids, chat_id) then table.insert(chat_ids, chat_id) end end end end return chat_ids else warn("Failed to get updates: " .. tostring(result)) return {} end end local function get_username_for_chat(chat_id) local url = "https://api.telegram.org/bot" .. bot_token .. "/getChat?chat_id=" .. chat_id local success, result = pcall(request, { Url = url, Method = "GET" }) if success then local data = http_service:JSONDecode(result.Body) if data.ok then return data.result.username else warn("Failed to get chat info: " .. tostring(data.description)) return nil end else warn("Failed to make request: " .. tostring(result)) return nil end end local function send_to_all(message_type, content, caption, button_text, button_url, poll_options, is_anonymous, latitude, longitude) local chat_ids = get_chat_ids() for _, chat_id in ipairs(chat_ids) do local url = "https://api.telegram.org/bot" .. bot_token .. "/" local payload = { chat_id = chat_id } if message_type == "text" then url = url .. "sendMessage" payload.text = content payload.parse_mode = "Markdown" elseif message_type == "photo" then url = url .. "sendPhoto" payload.photo = content payload.caption = caption or "" elseif message_type == "video" then url = url .. "sendVideo" payload.video = content payload.caption = caption or "" elseif message_type == "sticker" then url = url .. "sendSticker" payload.sticker = content elseif message_type == "button" then url = url .. "sendMessage" payload.text = content or "Click the button below:" payload.reply_markup = { inline_keyboard = {{ { text = button_text or "Click Me", url = button_url or "https://example.com" } }} } payload.reply_markup = http_service:JSONEncode(payload.reply_markup) elseif message_type == "poll" then url = url .. "sendPoll" payload.question = content payload.options = poll_options or { "Option 1", "Option 2" } payload.is_anonymous = is_anonymous or true payload.options = http_service:JSONEncode(payload.options) elseif message_type == "location" then url = url .. "sendLocation" payload.latitude = latitude payload.longitude = longitude else warn("Invalid message type!") return end local json_data = http_service:JSONEncode(payload) local success, result = pcall(request, { Url = url, Method = "POST", Headers = {["Content-Type"] = "application/json"}, Body = json_data }) if success then print("Message sent to " .. chat_id) else warn("Failed to send message to " .. chat_id .. ": " .. tostring(result)) end end end local chat_ids = get_chat_ids() for _, chat_id in ipairs(chat_ids) do local username = get_username_for_chat(chat_id) if username then print("Username: " .. username) else print("No username available for chat ID: " .. chat_id) end end -- Example Calls send_to_all("text", "Hello, Telegram users!") send_to_all("photo", "https://example.com/image.jpg", "Check this out!") send_to_all("video", "https://example.com/video.mp4", "Watch this video!") send_to_all("sticker", "https://example.com/sticker.png") send_to_all("button", "Click below!", nil, "Visit Website", "https://example.com") send_to_all("poll", "What's your favorite color?", { "Red", "Blue", "Green" }, false) send_to_all("location", nil, nil, nil, nil, nil, nil, 37.7749, -122.4194)