Does anyone know of a standalone voting/polling script somewhat like the voting/polling scripting in the Channelbot script by Nathanos & Guibs.
code:--------------------------------------------------------------------------------
-- PollBot by aMutex 12.01.2003
botname = "PollBot"
Poll = {}
PollDescription = ""
function GetArgs(data)
s,e,whoTo,from,cmd,arg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)")
return arg
end
function Main()
frmHub:RegBot(botname)
SetTimer(60000)
StartTimer()
end
function DataArrival(user, data)
if(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (user.bOperator) then
if (cmd=="#createpoll") then
arg= GetArgs(data)
PollDescription = arg
Poll={}
user:SendPM(botname,"poll succesfully created...")
end
if (cmd=="#addpolloption") then
arg= GetArgs(data)
Poll[arg]=0
user:SendPM(botname,"poll option "..arg.."added")
end
if (cmd=="#savepoll") then
remove("poll.dat")
local handle=openfile("poll.dat","a")
write(handle,PollDescription.."\n")
for a,b in Poll do
write(handle,a.."?"..b.."\n")
end
closefile(handle)
user:SendPM(botname,"Poll has been successfully saved")
end
if (cmd=="#loadpoll") then
local handle=openfile("poll.dat","r")
PollDescription=read(handle)
Poll={}
while 1 do
local line = read(handle)
if line == nil then break
else
user:SendPM(botname,line.." ")
x,y,a=strfind(line,"([^?]*)")
x,y,b=strfind(line,"([^?]*)$")
Poll[a]=b
end
end
closefile(handle)
user:SendPM(botname,"Poll has been successfully loaded")
end
end
if (cmd=="#vote") then
arg= GetArgs(data)
if( Poll[arg] == nil ) then
user:SendPM(botname,"No such poll-option ...")
else
Poll[arg] = Poll[arg] +1
user:SendPM(botname,"Successfully voted for: "..arg)
end
end
if (cmd=="#showpoll") then
user:SendPM(botname,"Current poll is:"..PollDescription)
for a,b in Poll do
user:SendPM(botname,a..":"..b.." votes")
end
end
if (cmd=="#help") then
user:SendPM(botname,"This is a pollbot ...")
user:SendPM(botname,".....................")
user:SendPM(botname,"commands:")
user:SendPM(botname,"create a poll: #createpoll description")
user:SendPM(botname,"add a poll option: #addpolloption option")
user:SendPM(botname,"load a poll: #loadpoll")
user:SendPM(botname,"save a poll option: #savepoll")
user:SendPM(botname,"vote for an option: #vote option")
user:SendPM(botname,"show the current poll: #showpoll")
end
end
end
end
function OnTimer()
remove("poll.dat")
local handle=openfile("poll.dat","a")
write(handle,PollDescription.."\n")
for a,b in Poll do
write(handle,a.."?"..b.."\n")
end
closefile(handle)
end
//WickeD
Is there any way to make this script fire a msg to a user on login to show the current running poll?