Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local computer = require("computer")
- local cb = component.chat_box
- local event = require("event")
- local colors = require("colors")
- local terminal = require("term")
- local radar = component.radar
- terminal.clear()
- print("ЧатБот варпа P")
- local botName = " §8warp P: §8"
- local blackList = {
- "Pipidastro",
- "Alex25764"
- }
- local playersGreeted = {}
- local state = false
- function dump(table)
- if type(table) == 'table' then
- local s = '{ '
- for k,v in pairs(table) do
- if type(k) ~= 'number' then k = '"'..k..'"' end
- s = s .. '['..k..'] = ' .. dump(v) .. ','
- end
- return s .. '} '
- else
- return tostring(table)
- end
- end
- local function Ads()
- cb.say(botName .. "➢ §c/warp P - §7магазин предлагает всем заинтересованным лицам разделы под каждую основную модификацию сервера.§7 §7Прекрасное оформление, которое станет настоящей жемчужиной любого игрока!§7")
- cb.say(botName .. "➢ §6[Механизмы]")
- cb.say(botName .. "➢ §bДраконы и пчелы- [DraconicEvolution + §bFORESTRY]§b")
- cb.say(botName .. "➢ §aТехника - [IC2 + AE2 + TE]§a")
- cb.say(botName .. "➢ §cИ многое другое, приходите и запишите нас §cв блокноте!")
- end
- local function checkIsLocalChat(message)
- local firstLetter = string.sub(message, 1, 1)
- return firstLetter ~= "!"
- end
- local function isNumber(str)
- return type(tonumber(str)) == "number"
- end
- local function thanksForUser(message, nick)
- if checkIsLocalChat(message) == true then
- if isNumber(message) == true then
- cb.say(botName .. "§cСпасибо за покупку, " .. nick)
- end
- end
- end
- local function handlerMessage(message, nick)
- print(nick, " написал " .. message)
- thanksForUser(message, nick)
- end
- local function resetArray(array)
- for i = 1, #array do
- array[i] = nil
- end
- end
- local function findElement(array, str)
- local state = false
- for k, v in pairs(array) do
- if v == str then
- state = true
- end
- end
- return state
- end
- cb.setName("§aP")
- cb.setDistance(250)
- for i = 1, #blackList do
- computer.addUser(blackList[i])
- end
- while true do
- local _, _, nick, msg = event.pull(1, "chat_message")
- if msg ~= nil and nick ~= nil then
- handlerMessage(msg, nick)
- end
- local players = radar.getPlayers()
- for i = 1, #players do
- local current = players[i].name
- if not findElement(blackList, current) then
- if not findElement(playersGreeted, current) then
- table.insert(playersGreeted, current)
- print(current, " пришел на варп")
- cb.say(botName .. "§cДобро пожаловать, " .. current .. ", будем рады видеть тебя вновь!")
- end
- end
- end
- local hour = tonumber(os.date('%H'))
- if hour % 8 == 0 and state == false then
- resetArray(playersGreeted)
- Ads()
- state = true
- end
- if hour % 8 ~= 0 and state == true then
- state = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement