Looking for a Voting/Polling Script
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Looking for a Voting/Polling Script

Started by Nthrnboy, 01 January, 2004, 23:00:40

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Nthrnboy

Does anyone know of a standalone voting/polling script somewhat like the voting/polling scripting in the Channelbot script by Nathanos & Guibs.


WickeD

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

Nthrnboy

Is there any way to make this script fire a msg to a user on login to show the current running poll?

SMF spam blocked by CleanTalk