PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: TTB on 11 July, 2006, 13:06:16

Title: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 11 July, 2006, 13:06:16
Hi,

nErBoS created one in LUA4, and Jiten converted it into LUA5.
Here is a new bot  ;D  Hope you all gonna like it. You can download the attachment, and extract it in your scripts folder!


-- Finally a good pollbot ;-)
-- Created by TTB on 11 July 2006
-- For PtokaX 0.3.3.0 or higher
-- Special thanx to nErBoS and Jiten
----------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
--------------------------------------------------------------------
--[[
There are many features on this bot. When a bot has been created, everyone only gets a PM. When ppl log into the hub, they will get a PM if they did not vote already.
Just check it out... if you have special requests, post them. I always can see what I can do :-)

Your commands:

All users:
#pollhelp - Check the commands
#poll - View the current poll
#poll <nr> - Vote when poll is active
#oldpoll - List of all oldpolls
#oldpoll <pollname> - View old poll
Operators:
#polladd <name> <nr> <subj> - Create a new poll
#pollclose - Close current poll, and add it to oldpolls
#polldel - Delete current poll (it won't be added to oldpolls)
#oldpolldel <pollname> - Delete oldpoll forever

NOTE: All commands can be done in the main chat. Only the wizard and the #poll command can be done in PM to the bot.
]]--


Have fun with this!

Get it:
-> under this post
-> or here: http://ptxscriptdb.psycho-chihuahua.net/download.php?view.264 (http://ptxscriptdb.psycho-chihuahua.net/download.php?view.264)

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Newer versions:

Version 1.2: http://forum.ptokax.org/index.php?topic=6138#msg63976 (http://forum.ptokax.org/index.php?topic=6138#msg63976)
Version 1.3: http://forum.ptokax.org/index.php?topic=6138#msg64111 (http://forum.ptokax.org/index.php?topic=6138#msg64111)
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: 6Marilyn6Manson6 on 11 July, 2006, 13:19:25
Where is link for download this bot? :S
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 11 July, 2006, 13:21:10
Quote from: 6Marilyn6Manson6 on 11 July, 2006, 13:19:25
Where is link for download this bot? :S

Check my edited note...   ???   Crappy forum  :-\
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: 6Marilyn6Manson6 on 11 July, 2006, 14:09:58
I see link in Leun post not in TTB post :P
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 11 July, 2006, 14:48:00
The file is now in the first post. Check it out  8)
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: 6Marilyn6Manson6 on 11 July, 2006, 15:06:54
Now I see it in first post... now is ok :D
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 12 July, 2006, 15:15:02
Hi,

The file has been downloaded 12 times  ;D  Do you ppl like it? Any suggestions?
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: 6Marilyn6Manson6 on 12 July, 2006, 15:33:54
Quote from: TTB on 12 July, 2006, 15:15:02
Hi,

The file has been downloaded 12 times? ;D? Do you ppl like it? Any suggestions?

Now I see it, thanks :D
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: imb on 26 July, 2006, 03:37:56
Testing, looks great so far. It was what was needed for a long time, a more sophisticated poll bot. Thanks  ;D
Posted on: 25 July 2006, 23:50:31
[22:34] Syntax ...s\0.3.3.21.nt.db\scripts\Poll.Bot.v.1.1.LUA5-TTB.lua:273: attempt to perform arithmetic on field `?' (a nil value)


First error if it's any help, not sure what caused it.
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 26 July, 2006, 09:20:39
On it... I had this error also. It was when I closed the poll. I don't know at this moment what the problem is. I have also noticed another bug. Soon I will release version 1.2.  ;D

Thanx for your report!
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: HappyTheMan on 20 September, 2006, 08:59:58
I want to post my comment about that script because: THIS IS JUST THE BEST SCRIPT I HAVE EVER SEEN!!!! All is easy, handy, good looking. Even the code is beautiful to look at!! I tried many scripts and this is THE SCRIPT. Smart scripting by a smart guy, congratulations TBB!
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 20 September, 2006, 09:44:28
Euh... the nickname is "TTB".  Thank you for your reply  ;D
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: [HE]Newbie on 21 September, 2006, 21:04:16
Nice script TTB, keep up the good work

function PollPM(curUser,data)
local s,e,cmd = string.find(data,"%b<>%s+(%S+)")
if cmd and (string.lower(cmd) == (prefix.."poll")) then
local s,e,cmd,answer = string.find(data,"%b<>%s+(%S+)%s+(%d+)")
if PollSettings["current"] == 2 then
if answer then
if PollVotes[curUser.sName] then
curUser:SendPM(bot,"# You have already voted! You can't vote again. Type "..prefix.."poll (without a number) to check the statistics!")
else
answer = tonumber(answer)
if answer > PollSettings["questions"] then
curUser:SendPM(bot,"Error! Answer "..answer.." is not in my list!")
else
PollSettings["votes"][answer] = PollSettings["votes"][answer] + 1
PollSettings["votes"]["n"] = PollSettings["votes"]["n"] + 1
WriteFile(PollSettings, "PollSettings", pollsettings)
PollVotes[curUser.sName] = 1
WriteFile(PollVotes, "PollVotes", pollvotes)
ShowPollWithResult(curUser,data)
curUser:SendPM(bot,"# Thank you for voting "..answer..". You can check always the poll by entering "..prefix.."poll in PM to "..bot..". Please vote again by our next poll.")
SendPmToNick(PollSettings["currentcreator"],bot,"# "..curUser.sName.." voted for answer : "..answer.."!")
end
end
else
if PollVotes[curUser.sName] then
ShowPollWithResult(curUser,data)
else
ShowPollWithNoResult(curUser,data)
end
end
else
curUser:SendPM(bot,"# Sorry, there is no active poll... You can't vote at this moment!")
end
end
end


Ok maybe its cool when you see who answered what in the OpChat, so i (hope) changed the text : SendPmToNick(PollSettings["currentcreator"],bot,"# "..curUser.sName.." voted for answer : "..answer.."!") <-- Pretty easy xD, but probably some guys will like it

regards newbie
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 23 October, 2006, 16:32:03
Hmz... It is more that the creator knows, how much reply's he gets on his poll. And I do not agree with this:

QuoteSendPmToNick(PollSettings["currentcreator"],bot,"# "..curUser.sName.." voted for answer : "..answer.."!")

It should be anonymous! The respond was just a check. I accually shouldn't add this to the code!

Gr. TTB

Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: speedX on 23 October, 2006, 18:46:42
Is it possible to make a progress bar or graph for this poll script?
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 23 October, 2006, 23:30:16
Progress bar of graph? Damn... then you also need to set the max of votes I suppose. And a graph is a little overdone, don't you think?! It might be possible, but it is to much work for me to create something like this.

Greetz, TTB.
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: Herodes on 24 October, 2006, 07:36:45
Quote from: TTB on 23 October, 2006, 23:30:16
Progress bar of graph? Damn... then you also need to set the max of votes I suppose. And a graph is a little overdone, don't you think?! It might be possible, but it is to much work for me to create something like this.

Greetz, TTB.
TTB search for DoBars function in the forum, and also look how the polls system on the board works (it hasn't got max votes and it has bars ;).
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 01 November, 2006, 10:02:59
Quote from: Herodes on 24 October, 2006, 07:36:45
TTB search for DoBars function in the forum, and also look how the polls system on the board works (it hasn't got max votes and it has bars ;).

I can always take a look @ it... but I don't promise anything to put it in this Poll bot. Herodes? Can you give me some link for this DoBars function? I can't find it at the board (searched @ "bars" and "DoBars").
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: Herodes on 01 November, 2006, 11:42:28
Use this one TTB:
function DoBars( val, max, length )
lenght = length or 10
local ratio = (val / ( max/length) )
return "["..string.rep("-", ratio).."?"..string.rep(" ", length-ratio).."]"
end


Ofcourse this is not tested but I suppose it works and it is meant to give you the way its supposed to work.
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 01 November, 2006, 11:44:18
Thanx....  ;D  Let's see what I can do with this.
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: Markitos on 01 November, 2006, 14:12:10
Oh it works alright! Great function Herodes.
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: speedX on 01 November, 2006, 14:30:01
Quote from: Markitos on 01 November, 2006, 14:12:10
Oh it works alright! Great function Herodes.

I donno y it didn work for me  :( , or I am still a noob  :-\
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: Markitos on 01 November, 2006, 14:49:07
You gotta make adaptations
Code (lua) Select
function DoBars( val, max, length )
lenght = length or 10
local ratio = (val / ( max/length) )
return "["..string.rep("-", ratio).."?"..string.rep(" ", length-ratio).."]"
end

ChatArrival = function(user,data)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
if cmd == "x" then
local length,max,val = 100,300,200
return user:SendData("x",DoBars(val,max,length)),1
end
end

Quote from: speedX on 01 November, 2006, 14:30:01
or I am still a noob  :-\
All of us were ;)
Title: Poll.Bot.v.1.2.LUA5-TTB
Post by: TTB on 01 November, 2006, 16:01:43
I'm bizzy with it, and have updated some little things... Soon v1.2 will be here. ;-)
Posted on: 01 November 2006, 16:12:50
Hi...

Here is v.1.2!!!
[Added] Graphical interface (bars)
[Fixed] Some little bugs

Have fun with this!!
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: speedX on 02 November, 2006, 08:49:48
Thank you for this cool script TTB ;)
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 02 November, 2006, 09:56:54
You're welcome. Any more suggestions?   ::)
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 07 November, 2006, 14:24:32
Hi...

Here is v.1.3!!!
[Added] Graph bars on oldpolls
[Added] Multiple votes for poll (#polladd edit!)
[Added] #pollusers - who voted already?--[[
There are many features on this bot. When a bot has been created, everyone only gets a PM. When ppl log into the hub, they will get a PM if they did not vote already.
Just check it out... if you have special requests, post them. I always can see what I can do :-)

Your commands:

All users:
#pollhelp - Check the commands
#poll - View the current poll
#poll <nr> - Vote when poll is active
#pollusers - List of voted ppl
#oldpoll - List of all oldpolls
#oldpoll <pollname> - View old poll
Operators:
#polladd <name> <nr> <subj> - Create a new poll
#pollclose - Close current poll, and add it to oldpolls
#polldel - Delete current poll (it won't be added to oldpolls)
#oldpolldel <pollname> - Delete oldpoll forever

NOTE: All commands can be done in the main chat. Only the wizard and the #poll command can be done in PM to the bot.
]]--
Have fun with this!!



Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: achiever on 07 November, 2006, 16:13:31
sir i used the poll bot from above link

its giving following error
[20:40] Syntax ...0.3.5.1.lua5.1.1\scripts\Poll.Bot.v.1.3.LUA5-TTB.lua:71: pollsettings.tbl for [BOT]Poll not found

plzz help,

thks

achiever.
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 07 November, 2006, 19:08:19
It is only for 5.0.2. Not for LUA 5.1
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: achiever on 08 November, 2006, 09:00:30
Quote from: TTB on 07 November, 2006, 19:08:19
It is only for 5.0.2. Not for LUA 5.1

sir,

ok i have got ur point but can this not be changed accordingly to work for LUA 5.1,if yes, plzz can u guide me about the changes to be made.

thks,

achiever
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: 6Marilyn6Manson6 on 08 November, 2006, 09:04:39
Quote from: achiever on 08 November, 2006, 09:00:30
sir,

ok i have got ur point but can this not be changed accordingly to work for LUA 5.1,if yes, plzz can u guide me about the changes to be made.

thks,

achiever

Request it at TTB :D
Title: Re: Poll.Bot.v.1.0.LUA5-TTB
Post by: TTB on 08 November, 2006, 09:37:37
I will take a look at it when I have time... I have seen also a converter somewhere. Don't know who created it. Try to search for that first.

Later....: I've found time! Here you go big fella: http://forum.ptokax.org/index.php?topic=6533#msg64166 (http://forum.ptokax.org/index.php?topic=6533#msg64166)