View difference between Paste ID: mU5tygaH and eNpeFEgV
SHOW: | | - or go back to the newest paste.
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")
10+
print("ЧатБот варпа P")
11-
print("Разработал: FERROUS")
11+
12
local botName = " §8warp P: §8"
13-
local botName = " §8Светлана: §8"
13+
14
local blackList = {
15
    "Pipidastro",
16-
    "FERROUS",    
16+
    "Alex25764"
17-
    "Hedboys"
17+
18
19
local playersGreeted = {}
20
21
local state = false
22
23
function dump(table)
24
    if type(table) == 'table' then
25
       local s = '{ '
26
       for k,v in pairs(table) do
27
          if type(k) ~= 'number' then k = '"'..k..'"' end
28
          s = s .. '['..k..'] = ' .. dump(v) .. ','
29
       end
30
       return s .. '} '
31
    else
32
       return tostring(table)
33
    end
34
end
35
36
local function Ads()
37-
function Ads()
37+
    cb.say(botName .. "➢ §c/warp P - §7магазин предлагает всем заинтересованным лицам разделы под каждую основную модификацию сервера.§7 §7Прекрасное оформление, которое станет настоящей жемчужиной любого игрока!§7")
38-
    cb.say(botName .. "➢ §c/warp sky - §7магазин предлагает всем заинтересованным лицам разделы под каждую основную модификацию сервера.§7 §7Прекрасное оформление, которое станет настоящей жемчужиной любого игрока!§7")
38+
39
    cb.say(botName .. "➢ §bДраконы и пчелы- [DraconicEvolution + §bFORESTRY]§b")
40-
    cb.say(botName .. "➢ §bМагия и пчелы- [THAUMCRAFT + WITCHERY + §bFORESTRY]§b")
40+
41
    cb.say(botName .. "➢ §cИ многое другое, приходите и запишите нас §cв блокноте!")
42-
    cb.say(botName .. "➢ §dСовершенно любые заказы, ритуалы, обряды§d")
42+
43
44
local function checkIsLocalChat(message)
45-
    resetArray(playersGreeted)
45+
46
    return firstLetter ~= "!"
47
end
48-
function checkIsLocalChat(message)
48+
49
local function isNumber(str)
50
    return type(tonumber(str)) == "number"
51
end
52
53-
function isNumber(str)
53+
local function thanksForUser(message, nick)
54
    if checkIsLocalChat(message) == true then
55
        if isNumber(message) == true then
56
            cb.say(botName .. "§cСпасибо за покупку, " .. nick)
57-
function thanksForUser(message, nick)
57+
58
    end
59
end
60
61
local function handlerMessage(message, nick)
62
    print(nick, " написал " .. message)
63
    thanksForUser(message, nick)
64
end
65-
function handlerMessage(message, nick)
65+
66
local function resetArray(array)
67
    for i = 1, #array do 
68
        array[i] = nil
69
    end
70-
function resetArray(array)
70+
71
72
local function findElement(array, str)
73
    local state = false
74
    for k, v in pairs(array) do 
75
        if v == str then 
76-
function findElement(array, str)
76+
77
        end
78
    end
79
    return state
80
end
81
82
cb.setName("§aP")
83
cb.setDistance(250)
84
85
for i = 1, #blackList do 
86-
cb.setName("§cSKY§7Bot§7")
86+
87
end
88
89
while true do 
90
    local _, _, nick, msg = event.pull(1, "chat_message")
91
    if msg ~= nil and nick ~= nil then
92
        handlerMessage(msg, nick)
93-
local t = event.timer(650, Ads, math.huge)
93+
94
95
    local players = radar.getPlayers()
96
97
    for i = 1, #players do 
98
        local current = players[i].name
99
        if not findElement(blackList, current) then 
100
            if not findElement(playersGreeted, current) then 
101
                table.insert(playersGreeted, current)
102
                print(current, " пришел на варп")
103
                cb.say(botName .. "§cДобро пожаловать, " .. current .. ", будем рады видеть тебя вновь!")
104
            end
105
        end
106
    end
107
108
    local hour = tonumber(os.date('%H'))
109
110
    if hour % 8 == 0 and state == false then
111
        resetArray(playersGreeted)
112
        Ads()
113
        state = true
114
    end
115
    if hour % 8 ~= 0 and state == true then
116-
    if hour % 4 == 0 and state == false then
116+
117-
        cb.say(botName .. "§c/warp sky§7 - тот варп, который рад каждому посетителю. Спасибо, что вы остаетесь с нами. ")
117+
118
end