Poll Script

By Corrosive on Oct 23, 2007

Hello

This is my first snippet on Hawkee, please correct me on any Grammar or mistakes in the coding

---------- Commands ----------

!NewPoll - Creates a poll
!Poll - Checks the polls info
!Vote - Votes
!EndPoll - Will end the poll ( Only poll maker & Op or Hop can use )
!TurnPoll - Turn the poll script on or off on that channel ( Op or Hop only )


The Poll will not end unless told to by !EndPoll

Constructive criticism only please.

Enjoy the script, it should work, please could you credit me if you use it.

~Corrosive~

on *:TEXT:!PollHelp*:#: {
  if ( $2 == $null ) {
    msg $nick These are the commands you can use: !NewPoll 12| !EndPoll 12| !Vote 12| !Poll
    msg $nick For more information on these commands please use this command with the command you want more information on without the ! E.g "!PollHelp NewPoll" | halt
  }
  if ( $2 != $null ) {
    if ( $2 == NewPoll ) {
      msg $nick This command will make a new poll but you must set it out like this: !NewPoll YesNo (Or 1-2) <Question>
      msg $nick YesNo will make a Yes or No Voting and 1-2 will make a 1 or 2 Vote. | halt
    }
    elseif ( $2 == EndPoll ) {
      msg $nick This will end the current poll, only if you are the creator, Half-Operator or Operator. | halt
    }
    elseif ( $2 == !Vote ) {
      msg $nick This will enable you to Vote, but depending on the vote style you will have to vote like this.
      msg $nick YesNo Vote: !Vote <Yes or No>
      msg $nick 1-2 Vote: !Vote &#601; or 2> | halt
    }
    elseif ( $2 == Poll ) {
      msg $nick This will tell you the status of the current Poll. | halt
    }
    elseif ( $2 == TurnPoll ) && ( $nick ishop $chan ) || ( $nick isop $chan ) ) {
      msg $nick Using this will edit the functionality of the script, enabling you to turn the script on or off on the channel.
      msg $nick E.g !TurnPoll ON will turn the script on, on the channel. | halt
    }
    else { 
      msg $nick This is not a valid command.
    }
  }
  else { 
    notice $nick Sorry $nick but this script has messed up, if this continues please report it to the bot owner.
  }
}

on *:TEXT:!NewPoll *:#: {
  if ( %chanpoll [ $+ [ $chan ] ] == ON ) && ( %runningpoll [ $+ [ $chan ] ] == ON ) { 
    notice $nick Sorry $nick but a poll is already running, please ask %pollstarter to end his poll if you wish to make a new one
  }
  if ( %chanpoll [ $+ [ $chan ] ] == ON ) && ( %runningpoll [ $+ [ $chan ] ] == OFF ) {  
    if ( $2 == Yes/No ) || ( $2 == YesNo ) {
      set %polltype YesNo
      set %poll $3-
      set %pollstarter $nick
      set %runningpoll [ $+ [ $chan ] ] ON
      notice $nick You have started a poll, to end it please type !EndPoll
      msg $chan A Poll has been started! 
      msg $chan The Poll is: %poll  
      msg $chan To vote type !Vote Yes or No | halt
    }
    if ( $2 == 12 ) || ( $2 == 1-2 ) {
      set %polltype 1 Or 2
      set %poll $3-
      set %pollstarter $nick
      set %runningpoll [ $+ [ $chan ] ] ON
      notice $nick You have started a poll, to end it please type !EndPoll
      msg $chan A Poll has been started! 
      msg $chan The Poll is: %poll  
      msg $chan To vote type !Vote 1 or 2 | halt   
    }
    if ( $2 != 12 ) || ( $2 != 1-2 ) || ( $2 != YesNo ) || ( $2 != Yes/No ) {
      notice $nick Sorry $nick but at the moment you can only use 1 Or 2 Votes or Yes and No Votes, for more information on this command please type !PollHelp
    }
    else { 
      notice $nick Sorry $nick but there has been an error
    }
  }
  if ( %chanpoll [ $+ [ $chan ] ] == OFF ) {
    notice $nick Sorry $nick but this channel has turned off the !Poll script
  }
}

on *:TEXT:!Poll*:#: {
  if ( %polltype == 1 Or 2 ) {
    notice $nick The Poll is: %poll
    notice $nick The Votes are: %vote1 vote(s) for 1 and %vote2 vote(s) for 2. | halt
  }
  if ( %polltype == YesNo ) {
    notice $nick The Poll is: %poll
    notice $nick The Votes are: %voteyes vote(s) for Yes and %voteno vote(s) for No. | halt
  }
}

on *:TEXT:!Vote*:#: { 
  if ( %chanpoll [ $+ [ $chan ] ] == ON ) && ( ( %voted [ $+ [ $nick ] ] != NO ) && ( %voted [ $+ [ $nick ] ] != YES ) ) {
    set %voted [ $+ [ $nick ] ] NO
  }
  if ( %chanpoll [ $+ [ $chan ] ] == ON ) && ( %voted [ $+ [ $nick ] ] == YES ) {
    notice $nick Sorry $nick but you have voted already | halt
  }
  elseif ( %chanpoll [ $+ [ $chan ] ] == ON ) && ( %voted [ $+ [ $nick ] ] == NO ) {
    if ( %polltype == YesNo ) {
      if ( $2 == Yes ) {
        inc %voteyes
        set %voted [ $+ [ $nick ] ] YES
        notice $nick You voted: $2
        msg $chan Updated results! | halt
      }
      if ( $2 == No ) {
        inc %voteno
        set %voted [ $+ [ $nick ] ] YES
        notice $nick You voted: $2
        msg $chan Updated results! | halt
      }
    }
    if ( %polltype == 1 Or 2 ) {
      if ( $2 == 1 ) {
        inc %vote1
        set %voted [ $+ [ $nick ] ] YES
        notice $nick You voted: $2
        msg $chan Updated results! | halt
      }
      if ($2 == 2 ) {
        inc %vote2
        set %voted [ $+ [ $nick ] ] YES
        notice $nick You voted: $2
        msg $chan Updated results! | halt
      }
    }
    else { 
      notice $nick Sorry $nick but that is a note a valid voting option
    }
  }
  if ( %chanpoll [ $+ [ $chan ] ] == OFF ) {
    notice $nick Sorry $nick but the Poll script has been turned off in this channel. | halt
  }
}

on *:TEXT:!TurnPoll *:#:{
  if ( $nick isop $chan ) || ( $nick ishop $chan ) {
    if ( $2 == ON ) {
      if ( %chanpoll [ $+ [ $chan ] ] == ON ) {
        notice $nick The Poll script is enabled on this channel anyway | halt
      }
      set %chanpoll [ $+ [ $chan ] ] ON
      notice $nick The Poll Script for this channel has been turned 9ON
    }
    if ( $2 == OFF ) {
      if ( %chanpoll [ $+ [ $chan ] ] == OFF ) {
        notice $nick The Poll script is disabled on this channel anyway | halt
      }
      set %chanpoll [ $+ [ $chan ] ] OFF
      set %runningpoll OFF
      unset %poll
      unset %polltype
      unset %pollstarter
      set %vote1 0
      set %vote2 0
      set %voteyes 0
      set %voteno 0
      set %voted [ $+ [ $nick ] ] NO
      set %runningpoll [ $+ [ $chan ] ] OFF 
      notice $nick The Poll Script for this channel has been turned 4OFF
    }
  }
  else { 
    notice $nick Sorry $nick but you cannot change the settings of this channels status on the Poll script. | halt
  }
}

on $*:TEXT:/^[!](EndPoll|StopPoll)/Si:#:{
  if ( %runningpoll == ON ) && ( ( $nick == %pollstarter ) || ( $nick isop $chan ) ) 
  if ( %polltype == 1 Or 2 ) { 
    if ( %vote1 > %vote2 ) {
      notice $nick You have now ended the poll.
      msg $chan The winner is: 1! This Poll was ended by $nick
      unset %poll
      unset %polltype
      unset %pollstarter
      set %vote1 0
      set %vote2 0
      set %voted [ $+ [ $nick ] ] NO
      set %runningpoll [ $+ [ $chan ] ] OFF | halt
    }
    if ( %vote1 < %vote2 ) {
      notice $nick You have now ended the poll.
      msg $chan The winner is: 2! This Poll was ended by $nick
      unset %poll
      unset %polltype
      unset %pollstarter
      set %vote1 0
      set %vote2 0
      set %voted [ $+ [ $nick ] ] NO
      set %runningpoll [ $+ [ $chan ] ] OFF | halt
    }
    if ( %vote1 == %vote2 ) {
      msg $chan There was no winner, it was a draw! This Poll was ended by $nick
      unset %poll
      unset %polltype
      unset %pollstarter
      set %vote1 0
      set %vote2 0
      set %voted [ $+ [ $nick ] ] NO
      set %runningpoll [ $+ [ $chan ] ] OFF | halt
    }
  }
  if ( %runningpoll == ON ) && ( ( $nick == %pollstarter ) || ( $nick ishop $chan ) || ( $nick isop $chan ) ) 
  if ( %polltype == YesNo ) {
    if ( %voteyes > %voteno ) {
      notice $nick You have now ended the poll.
      msg $chan The winner is: Yes! This Poll was ended by $nick
      unset %poll
      unset %polltype
      unset %pollstarter
      set %voteyes 0
      set %voteno 0
      set %voted [ $+ [ $nick ] ] NO
      set %runningpoll [ $+ [ $chan ] ] OFF | halt
    }
    if ( %voteyes < %voteno ) {
      notice $nick You have now ended the poll.
      msg $chan The winner is: No! This Poll was ended by $nick
      unset %poll
      unset %polltype
      unset %pollstarter
      set %voteyes 0
      set %voteno 0
      set %voted [ $+ [ $nick ] ] NO
      set %runningpoll [ $+ [ $chan ] ] OFF | halt
    }
    if ( %voteyes == %voteno ) {
      msg $chan There was no winner, it was a draw! This Poll was ended by $nick
      unset %poll
      unset %polltype
      unset %pollstarter
      set %voteyes 0
      set %voteno 0
      set %voted [ $+ [ $nick ] ] NO
      set %runningpoll [ $+ [ $chan ] ] OFF | halt
    }
  }
  if ( %chanpoll [ $+ [ $chan ] ] == OFF ) {
    notice $nick Sorry $nick but the Poll script has been turned off in this channel. | halt
  }
}

Comments

Sign in to comment.
Wanabepc   -  Aug 20, 2009

Where is the unset for the people that have voted?

So if you make a new poll, they cant vote as it thinks they have already voted because of the last poll?

 Respond  
94killerz   -  Apr 07, 2009

Looks good. Definitely going to try it out.

 Respond  
Corrosive   -  Oct 24, 2007

It is vote for just a channel and nothing else.

 Respond  
Gummo   -  Oct 23, 2007

This script allows you to set a per-channel poll, yet its votes are for all channels, are they not?

 Respond  
Corrosive   -  Oct 23, 2007

Thanks.

 Respond  
Seax   -  Oct 23, 2007

Nice Script Will use it

 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.