!poll / !vote script

By FRISH on Oct 08, 2007

This is a poll script where you can set a poll as anything and vote for anything. To use just put in the remotes section (Alt+R) of your bot.

To activate a poll use:
!poll Does frish rox?
To vote use:
!vote
so you could use:
!Vote yes
!Vote no (but ya wont wanna for this question :P)
!Vote pie tastes good
or whatever you want to vote for.

The poll lasts 45 seconds and shows the top answers at the end, enjoy :)

Updates:
*Ops can now stop the poll using !pollhalt

note: There can only be 1 poll at a time and only in one channel

alias resultpollcode {
  var %toknum 1
  if (%voteoptions) {
    while ($gettok(%nforoptions,%toknum,44)) {
      var %pollresults $addtok(%pollresults,11[ 12 $+ $gettok(%voteoptions,%toknum,9) $+ : $gettok(%nforoptions,%toknum,44) 11],0)
      inc %toknum
    }
    msg %pollchannel 12{{<<< Results: %pollresults 12>>>}}
    msg %pollchannel 9>>>3Top results with a score of $gettok($sorttok(%nforoptions,44,nr),1,44) are:9<<<
    var %toppollnum 1
    while ($gettok($sorttok(%nforoptions,44,nr),%toppollnum,44) == $gettok($sorttok(%nforoptions,44,nr),1,44)) {
      msg %pollchannel 3>>>9 $+ $gettok(%voteoptions,$findtok(%nforoptions,$gettok($sorttok(%nforoptions,44,nr),%toppollnum,44),%toppollnum,44),9) $+ 3<<<
      inc %toppollnum
    }
  }
  else msg %pollchannel 12{{<<< Results: No Results! >>>}}
  unset %voteoptions | unset %nforoptions | unset %votenicks | unset %pollison | unset %pollchannel
}

on *:text:*:#:{
  if ($1 == !poll) {
    if (%pollison == 1) { notice $nick poll is already on }
    elseif (!$2) { .notice $nick enter something to vote for }
    else {
      set -e %pollison 1
      set -e %pollchannel #
      msg # 4{{<<< Vote for: $2- 4>>>}}
      .timerpoll 1 30 msg # 0615 secs left to vote for 4{{<<< $2- 4>>>}}
      .timerpoll 1 45 msg # 4{{<<< Poll over for: $2- 4>>>}}
      .timerpoll 1 45 resultpollcode
    }
  }
elseif ($1 == !pollhalt && %pollison && $nick isop #) {
  msg # 4>>poll halted<<
  .timerpoll off
  unset %voteoptions | unset %nforoptions | unset %votenicks | unset %pollison | unset %pollchannel
}
elseif ($1 == !vote) {
  if (# != %pollchannel) { .notice $nick sorry theres already a poll in %pollchannel }
  elseif ($address($nick,2) isin %votenicks) { .notice $nick you cant vote more than once! }
  elseif (!$2) { Usage: !vote <what to vote for> }
  elseif ($address($nick,2) !isin %votenicks) && (%pollison == 1) { 
    if ($istok(%voteoptions,$strip($2-,burc),9)) { set %nforoptions $puttok(%nforoptions,$calc($gettok(%nforoptions,$findtok(%voteoptions,$strip($2-,burc),1,9),44)  + 1),$findtok(%voteoptions,$strip($2-,burc),1,9),44) }
    else {
      set -e %voteoptions $addtok(%voteoptions,$strip($2-,burc),9) 
      set -e %nforoptions %nforoptions $+ ,1
    }
    set -e %votenicks $addtok(%votenicks,$address($nick,2),44)
    .notice $nick thanks for your vote ;)
    }
  }
}

Comments

Sign in to comment.
RoTeX   -  Jul 05, 2008

How do i remake it so it post the top 3 answers and not only the top voted?

 Respond  
Eugenio   -  Jul 02, 2008

ROFL

 Respond  
frishy   -  Jul 01, 2008

rofl. im gonna presume ur joking.

i only came back today just to look how thing changed, im not gonna reinstall mirc and spend my time on finding out why ur script doesnt work.

if you have other scripts in your remotes that possibly could affect it, but seriously i cannot help any further, my mirc scripting days are well over.

you have 3 options

1 try putting the code in a blank remotes section to see if it works then

2 adjust the code to see if you can fix it for your mirc

3 give up on the snippet

Another possibility is that they updated mirc in which my script no longer works. IDK why that would happen if it did (probably not, who knows) but this is the only help i can give ;p, i mean the code is too complex for me to be revising over (and im lazy ;p)

 Respond  
Eugenio   -  Jul 01, 2008

erm well I understand the code jaysus....what im saying is that the bloody alias dont work for me.........gtf back on mIRC and test -.-\'

 Respond  
frishy   -  Jul 01, 2008

on :text::#:{
if ($1 == !poll) {
...
set -e %pollchannel #
...
}

alias resultpollcode {
...
msg %pollchannel 12{{<<< Results: %pollresults 12>>>}}
...

so by seeing this it msgs the channel the result. since its not working for you i would probably say you are talking to a bot using this script not in a channel. if you did this in a channel and not chat then im sorry but i cant help since its been like a year since i quit.

 Respond  
Eugenio   -  Jul 01, 2008

ffs I might be n00b but im not THAT n00b, bloody hell YES I tested seperatly not me typng !poll -.-\'
and just what is the point in /resultpollcode..........it doesnt do anything cept gimme that msg in my status window which I showed ^^^^^^

 Respond  
frishy   -  Jul 01, 2008

my old email doesnt work so made a new account since forgot password lol and i dont go on mirc anymore.

$addtok has a format of:
$addtok(TextToAddTo,TextBeingAdded,Position,AsciiChar)
In the script above, it looks like there is only:
$addtok(TextToAddTo,TextBeingAdded,Position)
try:
Quote:
$addtok(%pollresults,[ $+ $gettok(%voteoptions,%toknum,9) $+ $gettok(%nforoptions,%toknum,44) ],0,32)

from what i remember (may be wrong) the last parameter is optional so if you leave the last one out then there is a null being added between each token so combines the strings.

Anyway the script was fine when i used to use it and im sure it didnt have any errors.

eugenio did u type !poll when u had the script yourself, if so then thats ur problem this script is used for a bot but can easily be changed to on input.

RESULTPOLLCODE Unknown command

erm and what is the point in /pollcode or w/e it is ?!?

/resultpollcode is a subroutine because im lazy and no point since i quit mirc ;p i can only assube that its an alias to neaten the coding, to save code repetition (possibly coz mine used to have an on input too)

 Respond  
Eugenio   -  Jul 01, 2008

erm atm this script FAILZ one sec and I will post what I get.

{{<<< No such nick/channel

{{<<< No such nick/channel

{{<<< No such nick/channel

{{<<< No such nick/channel

{{<<< No such nick/channel

RESULTPOLLCODE Unknown command

erm and what is the point in /pollcode or w/e it is ?!?

 Respond  
vaseline28   -  Jul 01, 2008

$addtok has a format of:
$addtok(TextToAddTo,TextBeingAdded,Position,AsciiChar)
In the script above, it looks like there is only:
$addtok(TextToAddTo,TextBeingAdded,Position)
try:

$addtok(%pollresults,[ $+ $gettok(%voteoptions,%toknum,9) $+ $gettok(%nforoptions,%toknum,44) ],0,32)

 Respond  
RoTeX   -  Jul 01, 2008
  • Invalid format: $addtok (line 5, poll.mrc)
    var %pollresults $addtok(%pollresults,11[ 12 $+ $gettok(%voteoptions,%toknum,9) $+ : $gettok(%nforoptions,%toknum,44) 11],0)

Why?

 Respond  
FRISH   -  Oct 14, 2007

ty, and why make it a dialog? Theres no need is there? =/

 Respond  
Tippy   -  Oct 14, 2007

Frish...you should probley make it a dailog. Other wise good job

 Respond  
FRISH   -  Oct 12, 2007

Ok just updated the code for ya ;)
usage: !pollhalt (must be op)

 Respond  
koutrelakosn   -  Oct 11, 2007

ok afte the poll is o what i type and can u just edit ur script so u just gotta type !endpoll or in mirc type /newpoll or something plz

 Respond  
FRISH   -  Oct 11, 2007

if ya stop the poll then ya must type:

//unset %voteoptions | unset %nforoptions | unset %votenicks | unset %pollison | unset %pollchannel

then it will work again ;)

 Respond  
koutrelakosn   -  Oct 10, 2007

How do u end the poll i ended but i cant start a new one y is that and how i start new one.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.