Advertisement
FERROUSSAGE

sky chat bot

Aug 26th, 2021 (edited)
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.74 KB | None | 0 0
  1. local component = require("component")
  2. local computer = require("computer")
  3. local cb = component.chat_box
  4. local event = require("event")
  5. local colors = require("colors")
  6. local terminal = require("term")
  7. local radar = component.radar
  8.  
  9. terminal.clear()
  10. print("ЧатБот варпа Sky")
  11. print("Разработал: FERROUS")
  12.  
  13. local botName = " §8Светлана: §8"
  14.  
  15. local blackList = {
  16.     "FERROUS",    
  17.     "Hedboys"
  18. }
  19.  
  20. local playersGreeted = {}
  21.  
  22. local state = false
  23.  
  24. function dump(table)
  25.     if type(table) == 'table' then
  26.        local s = '{ '
  27.        for k,v in pairs(table) do
  28.           if type(k) ~= 'number' then k = '"'..k..'"' end
  29.           s = s .. '['..k..'] = ' .. dump(v) .. ','
  30.        end
  31.        return s .. '} '
  32.     else
  33.        return tostring(table)
  34.     end
  35. end
  36.  
  37. function Ads()
  38.     cb.say(botName .. "➢ §c/warp sky - §7магазин предлагает всем заинтересованным лицам разделы под каждую основную модификацию сервера.§7 §7Прекрасное оформление, которое станет настоящей жемчужиной любого игрока!§7")
  39.     cb.say(botName .. "➢ §6[Механизмы]")
  40.     cb.say(botName .. "➢ §bМагия и пчелы- [THAUMCRAFT + WITCHERY + §bFORESTRY]§b")
  41.     cb.say(botName .. "➢ §aТехника - [IC2 + AE2 + TE]§a")
  42.     cb.say(botName .. "➢ §dСовершенно любые заказы, ритуалы, обряды§d")
  43.     cb.say(botName .. "➢ §cИ многое другое, приходите и запишите нас §cв блокноте!")
  44.  
  45.     resetArray(playersGreeted)
  46. end
  47.  
  48. function checkIsLocalChat(message)
  49.     local firstLetter = string.sub(message, 1, 1)
  50.     return firstLetter ~= "!"
  51. end
  52.  
  53. function isNumber(str)
  54.     return type(tonumber(str)) == "number"
  55. end
  56.  
  57. function thanksForUser(message, nick)
  58.     if checkIsLocalChat(message) == true then
  59.         if isNumber(message) == true then
  60.             cb.say(botName .. "§cСпасибо за покупку, " .. nick)
  61.         end
  62.     end
  63. end
  64.  
  65. function handlerMessage(message, nick)
  66.     print(nick, " написал " .. message)
  67.     thanksForUser(message, nick)
  68. end
  69.  
  70. function resetArray(array)
  71.     for i = 1, #array do
  72.         array[i] = nil
  73.     end
  74. end
  75.  
  76. function findElement(array, str)
  77.     local state = false
  78.     for k, v in pairs(array) do
  79.         if v == str then
  80.             state = true
  81.         end
  82.     end
  83.     return state
  84. end
  85.  
  86. cb.setName("§cSKY§7Bot§7")
  87. cb.setDistance(250)
  88.  
  89. for i = 1, #blackList do
  90.     computer.addUser(blackList[i])
  91. end
  92.  
  93. local t = event.timer(650, Ads, math.huge)
  94.  
  95. while true do
  96.     local _, _, nick, msg = event.pull(1, "chat_message")
  97.     if msg ~= nil and nick ~= nil then
  98.         handlerMessage(msg, nick)
  99.     end
  100.  
  101.     local players = radar.getPlayers()
  102.  
  103.     for i = 1, #players do
  104.         local current = players[i].name
  105.         if not findElement(blackList, current) then
  106.             if not findElement(playersGreeted, current) then
  107.                 table.insert(playersGreeted, current)
  108.                 print(current, " пришел на варп")
  109.                 cb.say(botName .. "§cДобро пожаловать, " .. current .. ", будем рады видеть тебя вновь!")
  110.             end
  111.         end
  112.     end
  113.  
  114.     local hour = tonumber(os.date('%H'))
  115.  
  116.     if hour % 4 == 0 and state == false then
  117.         cb.say(botName .. "§c/warp sky§7 - тот варп, который рад каждому посетителю. Спасибо, что вы остаетесь с нами. ")
  118.         state = true
  119.     end
  120.     if hour % 4 ~= 0 and state == true then
  121.         state = false
  122.     end
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement