Please somebody finish the script that has been started at tha treahd before ..please i need it :D thanx
sBot = "Poll-Bot" poll = {} pollsv = "pollsv.dat" ended = {} endedsv = "ended.dat" function Main() frmHub:RegBot(sBot) end function OnExit() if (readfrom(pollsv) ~= nil and poll[1] == nil) then LoadFromFile(pollsv) end if (readfrom(endedsv) ~= nil and ended[1] == nil) then LoadFromFile(endedsv) end SaveToFile(pollsv , poll , "poll") SaveToFile(endedsv , ended , "ended") end function DataArrival(user, data) if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then data = strsub(data,1,strlen(data)-1) s,e,cmd = strfind(data, "%b<>%s+(%S+)") if (cmd == "!createvote" and user.bOperator) then local s,e,quest = strfind(data, "%b<>%s+%S+%s+(.*)") if (quest == "") then user:SendPM(sBot, "Syntax Error, !creatvote , you must write a question.") else AddPoll(quest) user:SendPM(sBot, "The Poll is open.") end return 1 elseif (cmd == "!addoption" and user.bOperator) then local s,e,opt = strfind(data, "%b<>%s+%S+%s+(.*)") if (quest == "") then user:SendPM(sBot, "Syntax Error, !addoption , you must write a option.") else AddOption(opt) user:SendPM(sBot, "Option Added.") end return 1 elseif (cmd == "!endoption" and user.bOperator) then StartPoll() user:SendPM(sBot, "VotePoll successfully created.") return 1 elseif (cmd == "!poll") then SeeVotePoll(user) return 1 elseif (cmd == "!seepoll") then local s,e,number = strfind(data, "%b<>%s+%S+%s+(%S+)") if (number == nil or tonumber(number) == nil) then user:SendPM(sBot, "Syntax Error, !seepoll , you must write a number.") else SeePoll(user, number) end return 1 elseif (cmd == "!votefor") then local s,e,npoll,nopt = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)") if (npoll == nil or tonumber(npoll) == nil or nopt == nil or tonumber(nopt) == nil) then user:SendPM(sBot, "Syntax Error, !votefor , you must write a poll number and a vote number.") else MakeVote(user, npoll, nopt) end return 1 end end end function AddPoll(quest) if (readfrom(pollsv) ~= nil and poll[1] == nil) then LoadFromFile(pollsv) end if (readfrom(endedsv) ~= nil and ended[1] == nil) then LoadFromFile(endedsv) end local pos = 0 for i=1, getn(poll) do pos = i end poll[pos+1] = quest ended[pos+1] = "open" end function AddOption(opt) local pos = 0 local sLine = "" local nopt = 0 if (readfrom(pollsv) ~= nil and poll[1] == nil) then LoadFromFile(pollsv) end if (readfrom(endedsv) ~= nil and ended[1] == nil) then LoadFromFile(endedsv) end for i=1, getn(ended) do if (ended[i] ~= "closed") then ended[i] = "opt" pos = i break end end if (pos ~= 0) then if(readfrom(pos..".poll") == nil) then writeto(pos..".poll") write("1. "..opt.." Voted: 0") writeto() else readfrom(pos..".poll") while 1 do local line = read() if (line == nil) then nopt = nopt+1 sLine = sLine..nopt..". "..opt.." Voted: 0" break else local s,e,number = strfind(line, "(%S+)%.") if (tonumber(number) ~= nil) then nopt = tonumber(number) end sLine = sLine..line.."\r\n" end end readfrom() writeto(pos..".poll") write(sLine) writeto() end end end function StartPoll() local time = 0 local pos = 0 if (readfrom(pollsv) ~= nil and poll[1] == nil) then LoadFromFile(pollsv) end if (readfrom(endedsv) ~= nil and ended[1] == nil) then LoadFromFile(endedsv) end for i=1, getn(ended) do if (ended[i] ~= "closed") then pos = i if (ended[i] == "open") then time = 1 end break end end if (time == 1) then writeto(pos..".poll") write("1. Yes Voted: 0\r\n2. No Voted: 0") writeto() end writeto(pos..".vot") writeto() ended[pos] = "closed" end function SeeVotePoll(user) local sTmp = "" local pos = 0 if (readfrom(pollsv) ~= nil and poll[1] == nil) then LoadFromFile(pollsv) end if (readfrom(endedsv) ~= nil and ended[1] == nil) then LoadFromFile(endedsv) end for i=1, getn(poll) do if (ended[i] == "closed") then pos = pos + 1 end end if (pos == 0) then sTmp = sTmp.."There aren't any VotePoll." else sTmp = sTmp.."There is "..pos.." Vote Poll:\r\n\r\n" for i=1, getn(poll) do if (ended[i] == "closed") then sTmp = sTmp..i..". "..poll[i].."\r\n" end end end user:SendPM(sBot, sTmp) end function SeePoll(user, number) number = tonumber(number) local accept = 0 local sTmp = "" if (readfrom(pollsv) ~= nil and poll[1] == nil) then LoadFromFile(pollsv) end if (readfrom(endedsv) ~= nil and ended[1] == nil) then LoadFromFile(endedsv) end for i=1, getn(poll) do if (i == number) then accept = 1 break end end if (accept == 0) then sTmp = sTmp.."The Poll number "..number.." doesn't exist." else sTmp = sTmp.."## Poll number "..number.."\r\n" sTmp = sTmp.."## Topic: "..poll[number].."\r\n\r\n" readfrom(number..".poll") while 1 do local line = read() if (line == nil) then break else sTmp = sTmp..line.."\r\n" end end readfrom() end user:SendPM(sBot, sTmp) end function MakeVote(user, npoll, nopt) npoll = tonumber(npoll) nopt = tonumber(nopt) local accept = 0 local sTmp = "" if (readfrom(pollsv) ~= nil and poll[1] == nil) then LoadFromFile(pollsv) end if (readfrom(endedsv) ~= nil and ended[1] == nil) then LoadFromFile(endedsv) end if (poll[npoll] == nil or ended[npoll] ~= "closed") then sTmp = "There is no such Poll with the number "..npoll.."." elseif (WatchVoter(user, npoll) == 1) then sTmp = "You have already made a vote on this Vote-Poll." else readfrom(npoll..".poll") while 1 do local line = read() if (line == nil) then break else local s,e,number,other,vote = strfind(line, "(%S+)%.(.*)%s+Voted:%s+(%S+)") if (tonumber(vote) ~= nil and tonumber(number) ~= nil and tonumber(number) == nopt) then vote = tonumber(vote) + 1 sTmp = sTmp..number.."."..other.." Voted: "..vote.."\r\n" accept = 1 else sTmp = sTmp..line.."\r\n" end end end readfrom() if ( accept == 0) then sTmp = "There is no such vote option on the Poll number "..npoll.."." else writeto(npoll..".poll") write(sTmp) writeto() WriteVoter(user, npoll) sTmp = "Your Vote as been made. Thank you." end end user:SendPM(sBot, sTmp) end function WriteVoter(user, npoll) local sTmp = "" readfrom(npoll..".vot") while 1 do local line = read() if (line == nil) then local usr = strlower(user.sName) sTmp = sTmp..usr break else sTmp = sTmp..line.."\r\n" end end readfrom() writeto(npoll..".vot") write(sTmp) writeto() end function WatchVoter(user, npoll) local accept = 0 readfrom(npoll..".vot") while 1 do local line = read() if (line == nil) then break else local s,e,usr = strfind(line, "(%S+)") if (usr ~= nil and usr == strlower(user.sName)) then accept = 1 end end end readfrom() return accept end function Serialize(tTable, sTableName, sTab) assert(tTable, "tTable equals nil"); assert(sTableName, "sTableName equals nil"); assert(type(tTable) == "table", "tTable must be a table!"); assert(type(sTableName) == "string", "sTableName must be a string!"); sTab = sTab or ""; sTmp = "" sTmp = sTmp..sTab..sTableName.." = {\n" for key, value in tTable do local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key); if(type(value) == "table") then Serialize(value, sKey, sTab.."\t"); else local sValue = (type(value) == "string") and format("%q",value) or tostring(value); sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue end sTmp = sTmp..",\n" end sTmp = sTmp..sTab.."}" return sTmp end function SaveToFile(file , table , tablename) writeto(file) write(Serialize(table, tablename)) writeto() end function LoadFromFile(file) if (readfrom(file) ~= nil) then readfrom(file) dostring(read("*all")) readfrom() end end
1 And i would like that a poll be sent to mainchat on a timer once every hour and if there are say 2 or 3 polls have them sent to main chat on a timer randomly.what do ya think?
2 That files that are create 1.poll, 1.vot, can created in a folder like 'polls' ....please edit bot for me thanx 8) and add and that option on main chat timer random if 2 polls
And the command to delete polls that you want Master !delpoll