Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local internet = require("internet")
- local tty = require("tty")
- local fs = require("filesystem")
- local gpu = component.gpu
- local radar = component.radar -- Используем радар из Computronics
- local oldback = gpu.getBackground()
- local oldfore = gpu.getForeground()
- -- Запрашиваем у пользователя данные для Telegram
- print("Enter your Telegram Bot Token:")
- local botToken = io.read()
- print("Enter your Telegram Chat ID:")
- local chatID = io.read()
- tty.clear()
- io.write([===[
- .-_; ;_-.
- / / \ \
- | | | |
- \ \.---./ /
- .-"~ .---. ~"-.
- ,`.-~/ .'`---`'. \~-.`,
- '` | | \(_)/ | | `'
- , \ \ | | / / ,
- ;`'.,_\ `-'-' /_,.'`;
- '-._ _.-'^'-._ _.-'
- `` ``
- ]===])
- print("Primitive tracking program v2.0")
- print("By HappyWindinkg")
- print()
- print("List of offenders:")
- -- Функция для кодирования URL
- local function urlencode(str)
- if (str) then
- str = string.gsub(str, "\n", "\r\n")
- str = string.gsub(str, "([^%w ])",
- function (c) return string.format("%%%02X", string.byte(c)) end)
- str = string.gsub(str, " ", "+")
- end
- return str
- end
- -- Функция для отправки данных в Telegram
- local function telegramGET(chatid, text)
- local result, reason = internet.request("https://api.telegram.org/bot" .. botToken .. "/sendMessage?chat_id=" .. chatID .. "&text=" .. urlencode(text))
- local info = ""
- if result then
- for chunk in result do
- info = info .. chunk
- end
- return info
- else
- return "Error: " .. (reason or "unknown error")
- end
- end
- -- Функция для записи никнеймов в файл
- local function saveToFile(filename, text)
- local file, err = io.open(filename, "a")
- if not file then
- print("Error opening file: " .. (err or "unknown error"))
- return
- end
- file:write(text .. "\n")
- file:close()
- end
- -- Основной цикл программы
- local whiteList = {"cloud", "LeShyj", "entity.Cat.name", "reload", "karnel"}
- local detectedPlayers = {}
- while true do
- local players = radar.getPlayers()
- for _, player in ipairs(players) do
- local name = player.name
- if not detectedPlayers[name] then
- detectedPlayers[name] = true
- print(name)
- local unauthorized = true
- for _, whitelisted in ipairs(whiteList) do
- if whitelisted == name then
- unauthorized = false
- break
- end
- end
- if unauthorized then
- local alertMessage = "Unauthorized visitor detected: " .. name .. " " .. os.date("%x %X")
- print(alertMessage)
- local telegramSuccess, telegramResponse = pcall(telegramGET, chatID, alertMessage)
- if telegramSuccess then
- gpu.setForeground(0x00FF00)
- print("Data sent to Telegram successfully.")
- saveToFile("/home/1.txt", name .. " " .. os.date("%x %X"))
- gpu.setForeground(oldfore)
- else
- gpu.setForeground(0xFF0000)
- print("Error sending to Telegram.")
- saveToFile("/home/1.txt", name .. " " .. os.date("%x %X"))
- gpu.setForeground(oldfore)
- end
- end
- end
- end
- os.sleep(1) -- Задержка для уменьшения нагрузки на систему
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement