-- 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) 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 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=="#showresult") then user:SendPM(botname,"Current poll is:"..PollDescription) for a,b in Poll do user:SendPM(botname,a..":"..b.." votes") end end end end end