Quick Convert of TTB's Poll Bot.
Meaning i used the Serach and Replace function in my editor.
It dosent give any errors at startup, so i guess it works ;p
It's attached here, and can also be found on my site under API 2 > Singel Scripts
--[[-- !IMPORTANT!
The new layout makes the pollvotes table invalid.
So BEFORE upgrade to 1.4, finsih your current running poll,
or all users will be able to vote again!
--]]--
v 2.0 supports Multi lang, and has the default path set to scripts\poll\ insted of just scripts\
thank you, but i can't run them, it say what not fond tables (ptoka 0.4.1.0)
Huh? Syntax errors please...
with standard adjustment: ... 0.4.1.0\scripts\Poll.Bot.v.1.3.LUA5.1-TTB.lua:76: pollvotes.tbl for [BOT]Poll not found
Have you extracted all files?
are all files included?
[18:59] Syntax ...UB\devhub\dev1\scripts\Poll.Bot.v.1.3.LUA5.1-TTB.lua:76: pollsettings.tbl for [BOT]Poll not found
created empty file...
typing #pollhelp gives:
[20080614 - 19:02:03] <[BOT]Poll> ALERT!! I feel sick...: ...UB\devhub\dev1\scripts\Poll.Bot.v.1.3.LUA5.1-TTB.lua:161: attempt to call method 'SendData' (a nil value)
[20080614 - 19:02:03] <Daywalker> #pollhelp
replaced line 161 with: Core.SendToUser(curUser,"<"..bot.."> "..MainInfo)
#pollhelp fixed
after typing #poll this comes up:
[19:00] No syntax errors in script file Poll.Bot.v.1.3.LUA5.1-TTB.lua
[19:00] Script started.
[19:00] Syntax ...UB\devhub\dev1\scripts\Poll.Bot.v.1.3.LUA5.1-TTB.lua:94: attempt to index global 'PollSettings' (a nil value)
dunno if settings are preset or not..end of journal :)
yes, all four files from archive in folder with scripts. Tried write direct ways - too most
remains only wait, Madman I faith in you :)
Will check later.. was busy in the weekend.. and will be today to, i should have some time over tomorrow
fixed the 161 line bug.
Added the settings file to package.
The .prj that was in first realse was a misstake, is not for script.
It's a project file for my editor.
Good morning =)
Had some trouble with RC, it didnt show, so I changed each line with user.sNick to curUser.sNick and then it worked. But only for master, reg doesnt get the RC.
When master tries to create poll, it asks for pollname, nr of answers and pollsubject, then it stops and shows the line in MC without giving any chance to put in the two answer options. And no errmsg in MC or ptokax.
<-[Admin]> #polladd Test 1 2 Do you like this?
If reg or master tries to write #poll in MC this errmsg appear: <-Poll-> ALERT!! I feel sick...: Poll.Bot.v.1.3.LUA5.1-TTB.lua:334: bad argument count to 'SendPmToUser' (3 expected, got 2)
Line 334 is this: Core.SendPmToUser(curUser,"<"..bot.."> Sorry, there is no active poll... You can't vote at this moment!")
Nice to see the script come alive :D
Regards
miago
Everything found and fixed.
Should be completly bug free now ;p
Nice work :)
Found one strange thing ... when choosing to see who has voted, the line "pollcreator" gets the current user nick, not the real pollcreator.
Reguser sees this:
[2008-06-27-07:55:00] <[BOT]Poll>
**************************************************
POLL Votes
**************************************************
Pollcreator = test5
Pollname = test2
Uservotes: 1
The creator sees this:
[2008-06-27-07:55:17] <[BOT]Poll>
**************************************************
POLL Votes
**************************************************
Pollcreator = -[ADMIN]-
Pollname = test2
Uservotes: 1
Cheers
miago
found it, e version uploaded
Nice...only thing Ive got now is that when I as a master wants to see who has voted, the info shows up in pm from bot, but in main chat this is shown:
<Hubbot> *** Error: You are not allowed to use this command!
when a reg user does the same he gets info in pm from bot and nothing is shown in main.
I havent change any profiles in ptokax.
Otherwise it works like a clock now :D
cheers
miago
That text is not from this script...
Ok....gonna try find out whats wrong...
Thx again for the job done on the script :D
Cheers // miago
no problem
thanks!! interactive scripts this is cool 8)
script works! but oldpolls not saved
error: Poll.Bot.v.1.3e.LUA5.1.lua:438: bad argument #3 to 'SendPmToUser' (string expected, got nil)
Quote from: Grey777 on 01 July, 2008, 20:14:31
thanks!! interactive scripts this is cool 8)
script works! but oldpolls not saved
error: Poll.Bot.v.1.3e.LUA5.1.lua:438: bad argument #3 to 'SendPmToUser' (string expected, got nil)
+1
oldpolls was saved, but was incorrectly saved in PtokaX root folder.
i fixed it in f version.
but don't know about the line 438 error... there is no SendPmToUser there...
if appers again, please report line, and what you where doing.
It seems I have decided this error...
---------------------------------------------------------------------------------------------------
-- Show an old Poll
---------------------------------------------------------------------------------------------------
function OldPoll(curUser,data)
local _,_,_,namepoll = string.find(data,"^%b<>%s+(%S+)%s+(%S+)")
if namepoll == nil then
oTmp = ""
iets = nil
for a,b in pairs(OldPolls) do
if iets then
iets = iets..", "..a
else
iets = a
end
end
if iets == nil then
oTmp = "There are no old polls!"
else
oTmp = "Type: "..prefix.."oldpoll <pollname>. Here are the oldpolls:\r\n->["..iets.."]<-"
Core.SendToUser(curUser,"<"..bot.."> "..oTmp)
end
else
if OldPolls[namepoll] then
ooTmp = "\r\n"..string.rep("*",50).."\r\nOLD POLL: "..OldPolls[namepoll]["subject"].."\r\n"..string.rep("*",50).."\r\n\r\n"
local c = tonumber(OldPolls[namepoll]["votes"]["n"])
for a,b in pairs(OldPolls[namepoll]["active"]) do
local bar = DoBars(string.format("%.0f",(100/c)*OldPolls[namepoll]["votes"][a]),100,lengthbar)
ooTmp = ooTmp..a..". "..OldPolls[namepoll]["votes"][a].." vote(s)\t"..bar.." ("..string.format( "%.2f",(100/c)*OldPolls[namepoll]["votes"][a]).."%) vote(s) "..b.."\r\n"
end
ooTmp = ooTmp.."\r\nTotal votes: "..c.." (100.00%)\r\n"..string.rep("*",50).."\r\nPoll created by: "..OldPolls[namepoll]["currentcreator"].."\r\nPoll created on: "..OldPolls[namepoll]["date"].."\r\nPoll closed at: "..OldPolls[namepoll]["close"].."\r\n"..string.rep("*",50)
else
ooTmp = "Sorry, the old poll '"..namepoll.."' does not excist! Type "..prefix.."oldpoll for all older polls!"
end
Core.SendPmToUser(curUser,bot,ooTmp)
end
oTmp = nil
ooTmp = nil
iets = nil
return true
end
Yup... my bad...
Code moved around a little, should avoid that error now.
g version is uploaded.
I'll be at a friend, so bugs wont't be fixed untill maybe monday.. or sunday...
Discovered another mistake! Users can choose to answer several times! If you can answer several options!
Since i only converted this script, please be a bit more specific, i.e what commands user used and in what order and so...
Don't understand the problem... might be due to lack of sleep tho...
like works, else add that creator poll saw not only amount voted, but also name.
and, if possible, oldpolls in column :)
Quote from: dimetrius on 12 July, 2008, 15:33:39
Discovered another mistake! Users can choose to answer several times! If you can answer several options!
[08:40:44] <[BOT]Poll> Thank you for voting 1. You can check always the poll by entering #poll in PM to [BOT]Poll. Please vote again by our next poll.
[08:40:46] <TheTwo> #poll 1
[08:40:47] <[BOT]Poll> You have already voted 1 time(s)! You can't vote again. Type #poll (without a number) to check the statistics!
[08:40:50] <TheTwo> #poll 2
[08:40:50] <[BOT]Poll> You have already voted 1 time(s)! You can't vote again. Type #poll (without a number) to check the statistics!
[08:40:53] <TheTwo> #poll 3
[08:40:53] <[BOT]Poll> You have already voted 1 time(s)! You can't vote again. Type #poll (without a number) to check the statistics!
[08:40:55] <TheTwo> #poll 4
[08:40:55] <[BOT]Poll> You have already voted 1 time(s)! You can't vote again. Type #poll (without a number) to check the statistics!
Works fine for me...
Quote from: Grey777 on 17 July, 2008, 01:40:46
like works, else add that creator poll saw not only amount voted, but also name.
and, if possible, oldpolls in column :)
the names on users that have voted can be seen in #pollusers
Don't understand what you mean with
oldpolls in column
dimetrius, probably, bore other in mind... think that option to vote several times is not claimed (on default user must vote once). In column.... I meant approximately following: ->[poll1, poll2, poll2]<- so
->[poll1]<-
->[poll2]<-
->[poll3]<-
Or even, with the instruction of date of creation (ex. ->[poll1 (07/20/08), poll2...]<-)
Thanks for attention.
I mean that the user can vote twice for the same answer!
Of course, I may be do not understand you! English is not my mother tongue!
Incidentally I am translated your script into Russian!
Quote from: dimetrius on 20 July, 2008, 16:30:01
I mean that the user can vote twice for the same answer!
Unless you set maxvotes1user to another value then 1, users can't vote more the once.
I tried sevrel times.. i can't get the user to vote more then once.
Quote from: Grey777 on 20 July, 2008, 14:02:24
dimetrius, probably, bore other in mind... think that option to vote several times is not claimed (on default user must vote once). In column.... I meant approximately following: ->[poll1, poll2, poll2]<- so
->[poll1]<-
->[poll2]<-
->[poll3]<-
Or even, with the instruction of date of creation (ex. ->[poll1 (07/20/08), poll2...]<-)
Thanks for attention.
Like that`?
[13:43:58] <[BOT]Poll> Type: #oldpoll <pollname>. Here are the oldpolls:
->[Myfirstpoll (08:38:03 / 19-07-2008) ]<-
->[second (08:40:24 / 19-07-2008) ]<-
Precisely, it would be comfortable.
But I all the same do not understand, what for to the person to vote some times? In fact everywhere, even at forums it is possible to vote only once. Can will give an example? I certainly understand, that it is yours idea, excuse for importunity :)
Quote from: Grey777 on 21 July, 2008, 20:16:00
Precisely, it would be comfortable.
But I all the same do not understand, what for to the person to vote some times? In fact everywhere, even at forums it is possible to vote only once. Can will give an example? I certainly understand, that it is yours idea, excuse for importunity :)
+1
Quote from: Grey777 on 21 July, 2008, 20:16:00
Precisely, it would be comfortable.
But I all the same do not understand, what for to the person to vote some times? In fact everywhere, even at forums it is possible to vote only once. Can will give an example? I certainly understand, that it is yours idea, excuse for importunity :)
Done, version h uploaded...
Quote from: dimetrius on 21 July, 2008, 23:21:31
Quote from: Grey777 on 21 July, 2008, 20:16:00
Precisely, it would be comfortable.
But I all the same do not understand, what for to the person to vote some times? In fact everywhere, even at forums it is possible to vote only once. Can will give an example? I certainly understand, that it is yours idea, excuse for importunity :)
+1
huh? what +1? he wants the column in oldpolls, and he got it.
and we still don't understand what you want, you say users can vote more then once, i can't fix that, beacuse i can't reproduce the problem
Have you tried the latest version, and still have that error?
Good afternoon! Excuse for my bad English, but a mistake and it is not corrected! I have in view of what in your script when you choose that the user could leave some voices it can vote for one variant some times! In all normal forums, interrogations, there where there are some variants on a choice, it is impossible to vote for one variant some times! It is possible to choose some variants of the answer only! But not some times to vote for one variant!
When I specify that one user could vote three times it can vote for one variant of the answer!
Like it:
Quote
1. 3 vote(s) [------------------------------?] (100.00%) 1
2. 0 vote(s) [? ] (0.00%) 2
3. 0 vote(s) [? ] (0.00%) 3
4. 0 vote(s) [? ] (0.00%) 4
5. 0 vote(s) [? ] (0.00%) 5
Total votes: 3 (100.00%)
**************************************************
Poll created by: dimetrius
Poll created on: [14:08:07] / [22-07-2008]
It is necessary for me that one user could not vote for the same variant some times!
I consider that it will be good correction! I Hope me this time all have understood!
[2008-07-23 13:37] <[BOT]Poll> Thank you for voting 1. You have 2 vote(s) left on this poll. Vote again if you like! You can check always the poll by entering #poll in PM to [BOT]Poll.
[2008-07-23 13:37] <TheOne> #poll 1
[2008-07-23 13:37] <[BOT]Poll> You have already voted for this answer, please choose another one
[2008-07-23 13:37] <TheOne> #poll 1
If i understood you correctly, this is what you wanted.
set NoMultiVotes to true in script to activate it
-- v1.4: 23.07.08
-- [Added] Option to disallow users from voteing on same answer more then once, request by dimetrius
-- [Changed] Layout of pollvotes table
--[[-- !IMPORTANT!
The new layout makes the pollvotes table invalid.
So BEFORE upgrade to 1.4, finsih your current running poll,
or all users will be able to vote again!
--]]--
-- [Removed] UserDisconnected function, it did not do anything
-- [Fixed] Bug in pollusers, due to new pollvotes
Already to break have begun :)
Probably you do not understand, that I mean, I shall show then in attached picture.
It the menu should not be, and value by default =1
I hope for understanding
Quote from: Madman on 23 July, 2008, 14:25:27
-- v1.4: 23.07.08
-- [Added] Option to disallow users from voteing on same answer more then once, request by dimetrius
BIG, BIG, Thanks ;)
And...
There is one more small mistake! The order of a conclusion of results!
Quote
**************************************************
CLOSED POLL: Как настроение?
**************************************************
2. 0 (0.00%) vote(s) хорошо
3. 0 (0.00%) vote(s) так себе
1. 3 (100.00%) vote(s) супер
4. 0 (0.00%) vote(s) не фонтан
5. 0 (0.00%) vote(s) хреново
Total votes: 3 (100.00%)
**************************************************
Poll created by: dimetrius
Poll created on: [10:18:28] / [24-07-2008]
**************************************************
Change it
for a,b in pairs(PollSettings["active"]) do
PollText = PollText..a..". "..b.."\r\n"
end
to it
for a=1,table.getn(PollSettings["active"]) do
PollText = PollText..a..". "..PollSettings["active"][a].."\r\n"
end
Quote from: Grey777 on 23 July, 2008, 23:56:24
Already to break have begun :)
Probably you do not understand, that I mean, I shall show then in attached picture.
It the menu should not be, and value by default =1
I hope for understanding
The reason for you haveing a 1 there, is due to that your client rembers the last values entred in to the boxes
Script do not insert a 1 there...
Quote from: dimetrius on 24 July, 2008, 09:42:03
There is one more small mistake! The order of a conclusion of results!
Thanks, done, will upload new version later, gtg to a meeting now
Version 1.4a is uploaded
Fixing dimetrius problem, useing his code
Some changes in code:
It made for align questions numbers if its number more than 9
function Poll(curUser,data)
local PollText = "\r\n"..string.rep("*",50).."\r\nОПРОС: "..PollSettings["subject"].."\r\n"..string.rep("*",50).."\r\n\r\n"
for a=1,table.maxn(PollSettings["active"]) do
PollText = PollText..a.."."..string.rep(" ",(2-string.len(a))*2+1)..PollSettings["active"][a].."\r\n"
end
Users can answer by entering number of answer without any command:
function PollPM(curUser,data)
local s,e,cmd = string.find(data,"%b<>%s+(%S+)")
if tonumber(cmd)~=nil then
cmd=prefix..cPoll
end
if cmd and (string.lower(cmd) == (prefix..cPoll)) then
local s,e,cmd,answer = string.find(data,"%b<>%s+(%S+)%s+(%d+)")
if cmd==nil then s,e,answer = string.find(data,"%b<>%s+(%d+)") end
if PollSettings["current"] == 2 then
Entire graph have the same width regrdless of the bar value:
1. 2 vote(s) [••----------------------------] (5.26%) vote(s) 10 Гб
2. 2 vote(s) [••----------------------------] (5.26%) vote(s) 20 Гб
3. 5 vote(s) [••••--------------------------] (13.16%) vote(s) 30 Гб
4. 1 vote(s) [•-----------------------------] (2.63%) vote(s) 40 Гб
5. 15 vote(s) [••••••••••••------------------] (39.47%) vote(s) 50 Гб
6. 3 vote(s) [••----------------------------] (7.89%) vote(s) 60 Гб
7. 0 vote(s) [------------------------------] (0.00%) vote(s) 70 Гб
8. 0 vote(s) [------------------------------] (0.00%) vote(s) 80 Гб
9. 0 vote(s) [------------------------------] (0.00%) vote(s) 90 Гб
10. 9 vote(s) [•••••••-----------------------] (23.68%) vote(s) 100 Гб
11. 1 vote(s) [•-----------------------------] (2.63%) vote(s) 110 Гб
12. 0 vote(s) [------------------------------] (0.00%) vote(s) 120 Гб
13. 0 vote(s) [------------------------------] (0.00%) vote(s) 130 Гб
14. 0 vote(s) [------------------------------] (0.00%) vote(s) 140 Гб
15. 0 vote(s) [------------------------------] (0.00%) vote(s) 150 Гб
function DoBars( val, max, length )
local lenght = length or 10
local ratio = (val / ( max/length) )
return "["..string.rep("•", ratio)..string.rep("-", length-ratio).."]"
end
For OPs PollVoters gives advanced stats. It include: what answers user selected, sharesize of user for weighting his vote.
for a,_ in pairs(PollVotes) do
count = count + 1
dVotes = dVotes..count.."."..string.rep(" ",(2-string.len(count))*2+1)..a
if dVoteMax>1 then
dVotes = dVotes.." с "..PollVotes[a]["n"].."/"..dVoteMax.." голосов"
end
if Profiles[curUser.iProfile] then
local u=Core.GetUser(a)
if u~=nil then
Core.GetUserData(u,16)
dVotes = dVotes.."\t"..math.floor(u.iShareSize/1024/1024/1024*100)/100
else
dVotes = dVotes.."\t".."Офф"
end
for i,ans in pairs(PollVotes[a]) do
if i~="n" then
dVotes = dVotes.."\t"..i
end
--Core.SendPmToNick("[b]Fodin","111",""..i.." "..tostring(ans))
end
end
dVotes = dVotes.."\r\n"
end
please translate this...
dVotes = dVotes.." с "..PollVotes[a]["n"].."/"..dVoteMax.." голосов"
dVotes = dVotes.."\t".."Офф"
I have no idea what it should say.
But i'm adding the functions, with option to enable/disable them
By the way...
While we are on the subject translateing...
I seen that some ppl translate PollBot, is there any intrest in MultiLanguage support?
please translate this...
QuotedVotes = dVotes.." с "..PollVotes[a]["n"].."/"..dVoteMax.." голосов"
dVotes = dVotes.." with "..PollVotes[a]["n"].."/"..dVoteMax.." vote(s)"
Much be better:
dVotes = dVotes.." with "..PollVotes[a]["n"].."/"..dVoteMax.." vote"..(dVoteMax==1) and "s" or ""
1 vote. 2 votes.
QuotedVotes = dVotes.."\t".."Офф"
dVotes = dVotes.."\t".."Offline"
or
dVotes = dVotes.."\t".."Off"
To exclude this case, script can record sharesize when user voted. I'm too lazy to implement this. ;-) Also good idea is to do some kind of sort voters list by sharesize or by selected answer and alphabet.
But i'm adding the functions, with option to enable/disable them
Quote from: Madman on 03 August, 2008, 17:19:13
By the way...
While we are on the subject translateing...
I seen that some ppl translate PollBot, is there any intrest in MultiLanguage support?
In russian we have problem in numbering:
"vote" = "голос"
n>=5 and n<=20 "голосов"
n%10>=2 and n%10<=4 "голоса"
n%10==1 "голос"
else "голосов"
Ex: 1 голос, 11 голосов, 21 голос, 22 голоса.
I don't know how to solve this in thr multilanguage script.
Thanks for the translates...
atm i'm also to implent, to add ShareSize att vote, maybe later.
Focusing on the Multilang now...
Don't know exactly about the numbering problem in russian.. but i have an idea.
But it will have to wait untill entire support is done.
V 2.0 is here. With multi lang support.
However, i did not do some function for Russian vote...
I probarly could, but then i would end up doing for all other langs it's beein translated in to...
Damn... this bot lives! Thanks for updating it Madman.
No problem...
It gives me something to do... ;p
Greetings again. Excellent work! Here a problem with the context menu: shows only a command Pollhelp. And error: .... scripts\Poll.Bot.v.2.0.LUA5.1.lua:660: attempt to concatenate field 'polluser' (a nil value)
Thanks
Fixed, v2.0 package updated.
Download again or find line 660 and the text "prefix..tLang.tCmds.polluser" and add an s so it becomses "prefix..tLang.tCmds.pollusers"
Sorry madman if this is the wrong place where i have posted by i have been trying to use poll script made by you.
Its giving me a repeated message in mainchat which i am unable to understand can you please help me regarding it.
Quote[19:14:29] <?GiGaByTe?> ALERT!! I feel sick...: D:\hub\gigabyte\scripts\Poll.Bot.v.2.0.LUA5.1.lua:667: attempt to call field 'polladd' (a string value)
Another fix in right click.
Package updated
The "Alert! I feel sick..." seems to be familier... :D
Download the package, i fixed the error..
or edit line 667 to
Core.SendToNick(user.sNick,"$UserCommand 1 3 " ..tLang.tMenu.Root.. "\\" ..tLang.tMenu.AddPoll.."$<%[mynick]> "..prefix..tLang.tCmds.polladd.." %[line:"..tLang.tMenu.Name.."] %[line:"..tLang.tMenu.AddVotes.." %[line:"..tLang.tMenu.AddAns.."] %[line:"..tLang.tMenu.AddSubject.."]||")
And yes TTB, it's your pollbot not mine ;p
//Edit by CrazyGuy : Link to correct topic removed, topics merged
Thanks a lot madman.
Right click for operator profile isnt been shown.
Yes it is, I have Add,Close poll and so on in my RC
Can a simple addon be added to Poll Votes which reports to the master of "which user voted for which option" on command. Somewhat like this..
**************************************************
POLL Votes
**************************************************
Pollcreator = DeAn
Pollname = A
Uservotes: 1
Pollquestion: What Do you Think About 2012 Movie ?
Number of answers = 4
Nick Voted
1. DeAn with 1/1 vote(s) 1. its awesome movie.. liked it very much
2. gave_up_thinking with 1/1 vote(s) 3. havent seen yet.. but planning to see
**************************************************
Total votes: 2
Total users: 2
**************************************************
Thanks in Advance
DeAn
Ow no....!!!! Votes should be anonymous! This request is asked many times. I didn't create it and thank you Madman for not creating it either.
TTB beat me to it. But I agree with him. Votes are anonymous.
That way we can create polls like:
Is the hubowner stupid?
1 Yes
2 No
3 Most likely
And the huge amount that will vote yes, can't be banned
Not fair Madman :P Are we stupid :) anyways i agree with anonymous
at least i would not have to waste time in holding grudge against anyone :P
Anyone who can upload the lastest version of this script.
Madmans homepage is down..
thanks!
Please read the entire thread...
Suggested is to start at the beginning.
Sorry, i found the string that had to be fixed in this thread.
I got carried away and didn't read everything that carefully.
Thanks for telling me Madman :)