voting scritp - pollbot
 

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

voting scritp - pollbot

Started by Pieltre, 24 November, 2003, 21:49:22

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

Pieltre

Hi,

I'm using the voting script named by default pollbot (in may case Voting_bot), that you can find pretty much everywhere (I'll paste it below in any case).  The problem with the script is that any user, who doesn't understand very well how it works can easily delete any ongoing poll, since the creation and deletion command are available to all, and not only to OPs.  Also, the script is blind to who gets to vote and, consequently, how many times they get to vote... Another major problem is the fact that the bot only logs the poll presently running and overwrites the old poll in the log...

If any of your talented guys could correct any of those bugs or direct me to a script that doesn't suffer from those bugs, I'd be very happy.  Pieltre

Here's the script I use:

botname = "Voting_bot"
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
if (cmd=="+savepoll") then
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)
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

Fire Koboy

I would be very interested too to get this final script....
Thanx to work on it guys....
:)
Tcho
Burn Baby, Burn...

pHaTTy

hmm this looks weird to me, different style to how i script but here goes my attemp loool

botname = "Voting_bot" 
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...") 
					return 1
				elseif (cmd=="+addpolloption") then 
					arg= GetArgs(data) 
					Poll[arg]=0 
					user:SendPM(botname,"poll option "..arg.."added") 
					return 1
				elseif (cmd=="+savepoll") then 
					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") 
					return 1
				elseif (cmd=="+loadpoll") then 
					local handle=openfile("poll.dat","r") 
					PollDescription=read(handle) 
					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 
							closefile(handle) 
							user:SendPM(botname,"Poll has been successfully loaded") 
						return 1
						end 
					end
				end
			end
		end
	end
end


try that :)

-phatty
Resistance is futile!

Fire Koboy

Thanx a lot for this script....I will try it when finishing job thursday...and keep you aware if working well or not...

sorry for my bad english....
Burn Baby, Burn...

SMF spam blocked by CleanTalk