Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------
- -- ТЕСТЕР МОД. СОСТАВА --
- -- edited by SanyaRamzik --
- -- https://pastebin.com/U1eLaRbS таблица --
- --------------------------------------------
- -- Основные команды: -start [nickname] --
- -- -stop --
- -- -local ; -global --
- --------------------------------------------
- local com=require('component')
- local bot=com.chat_box
- local gpu=com.gpu
- local event=require('event')
- local W,H=gpu.getResolution()
- -- ############# --
- varName="§8HiTechCraft";
- varPrefix="§4Тестер";
- local whiteList = {'SanyaRamzik'}
- local data=io.open("\\dbTester.txt","a")
- local exp='test'
- local testKey=false
- local dbMass={}
- local num=1
- local trueCount=0
- -- ############# --
- function txtFind(text, string)
- if text:find(string)~=nil then return true
- else return false end
- end
- function split( str, del )
- local t = {}
- repeat
- local b, e = str:find( del, 1, true )
- if b ~= nil then
- t[ #t + 1 ] = str:sub( 1, b - 1 )
- str = str:sub( e + 1 )
- end
- until b == nil
- t[ #t + 1 ] = str
- return t
- end
- function SAY(text)
- chatNameString="§8[§4" .. varPrefix .. "§8]" .. varName .. "§f: ";
- bot.say(chatNameString .. text);
- end
- local function conf(stat)
- bot.setName(stat .. "§8");
- end
- function TakeQuest()
- for line in io.lines("\\dbTester.txt") do dbMass[#dbMass+1]=line; end
- end
- function test(nick,msg,db)
- if nick==exp then
- local answ=split(db[num+1],':')
- local answKey=true
- local answSetter=0
- for i=1,#answ do
- if i~=3 and txtFind(msg,answ[i])==false then answKey=false end
- if i==3 and msg:find("(%d+)[^%d]")~=nil then
- local wh=split(answ[i],' ')
- local min_max=split(wh[1],'-')
- local min=tonumber(min_max[1]); local max=tonumber(min_max[2])
- _,_,n=msg:find("(%d+)[^%d]"); n=tonumber(n)
- if txtFind(msg,'hour') then n=n*60
- elseif txtFind(msg,'day') then n=n*60*24
- elseif txtFind(msg,'week') then n=n*60*24*7
- end
- if txtFind(tostring(wh[2]),'hour') then min=min*60; max=max*60
- elseif txtFind(tostring(wh[2]),'day') then min=min*60*24; max=max*60*24
- elseif txtFind(tostring(wh[2]),'week') then min=min*60*24*7; max=max*60*24*7
- end
- if n<min or n>max then answKey=false end
- end
- end
- if answKey==true then trueCount=trueCount+1; end
- SAY(tostring(answKey)..' --засчитано: '..trueCount..'/'..tostring(math.floor(#dbMass/3)))
- num=num+3
- end
- end
- local function botMSG(nick,msg)
- local ModKey=false
- for i=1,#whiteList do if nick==whiteList[i] then ModKey=true end end
- if ModKey==true then
- if txtFind(msg,'-start')==true and testKey==false then k=split(msg,' '); exp=k[2]; testKey=true; num=1; SAY('§cTEST STARTED')
- elseif msg=='-stop' and testKey==true then testKey=false; trueCount=0; num=1; SAY('§cTEST STOPED')
- elseif msg=='-local' then conf("§fL")
- elseif msg=='-global' then conf("§6G")
- elseif msg=='-exit' then os.exit() end
- end
- end
- -- ############## --
- conf("§fL"); TakeQuest()
- gpu.setBackground(0x000000); gpu.setForeground(0xffffff); gpu.fill(1,1,W,H,' ')
- local d=5
- gpu.set(W/2-(string.len('-start')/2)+1,d,'-start'); d=d+2
- gpu.set(W/2-(string.len('-stop')/2)+1,d,'-stop'); d=d+2
- gpu.set(W/2-(string.len('-exit')/2)+1,d,'-exit'); d=d+2
- gpu.set(W/2-(string.len('-local')/2)+1,d,'-local'); d=d+2
- gpu.set(W/2-(string.len('-global')/2)+1,d,'-global'); d=d+3
- gpu.set(10,d,"устное/warn/tempmute/mute/tempban/ban [num] min/hours/days [пункт]")
- gpu.set(10,d+1,"либо -")
- while true do
- if num>#dbMass then testKey=false; SAY('Тест пройден; Stoped') trueCount=0 end
- if testKey==true then os.sleep(2)
- varName='§8Нарушитель' m=split(dbMass[num],'%'); for i=1,#m do SAY(m[i]) end varName='§8HiTechCraft' end
- local _, add, nick, msg = event.pull("chat_message")
- os.sleep(1)
- if testKey==true then test(nick,msg,dbMass) end
- botMSG(nick,msg)
- end
Add Comment
Please, Sign In to add comment