Vote 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

Vote script.

Started by Tuben, 03 November, 2003, 14:51:54

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tuben

Trying too do a Vote script..But have not find any good way..

Is it somone that have a good one ?
-Dark-Mind-[ DOWNLOAD ]

Ron_Doe

#1
Found a poll bot  ,    have not tryed this one myself  tho...

-- 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

thanks  DarkElf  did not notice  that one   :)
don`t drink and drive-just smoke and fly     :))

DarkElf

Remove the code:--------------------------------
is not a part of script :P

Bye
Please sorry my bad english, i'm learning it :-D

\\100Gb ][ MeGaShArE @ I?? - ?u?i?N Owner [/I]
100gb.ifs-fusion.net:666 Only EliTe ShArE min 100gb
-={ I?? - ?u?i?N }=- N??Owner

Snoris

QuoteOriginally posted by DarkElf
Remove the code:--------------------------------
is not a part of script :P

Bye

Erhm....???The -------------------------
comes out when ur writing the LUA codes in [Code] barrels....
*INFO* =p

Tuben

Nice..Checking it out ;)
-Dark-Mind-[ DOWNLOAD ]

mOrrI

i got one problem with this bot,....

same user can vote more than 1 time ;)

DarkElf

Snoris: remove the "code:--------------"
not "---------" i know -- is not read from script..
Please sorry my bad english, i'm learning it :-D

\\100Gb ][ MeGaShArE @ I?? - ?u?i?N Owner [/I]
100gb.ifs-fusion.net:666 Only EliTe ShArE min 100gb
-={ I?? - ?u?i?N }=- N??Owner

SMF spam blocked by CleanTalk