Poll system by jonypaul

By jonypaul on Aug 14, 2006

Well i big poll snippet, but that isnt really that complex. I think that it'll kinda explain itself, but if you dunno what to do type /commands . I sugest this on a bot, it'll look nicer.
PS: i normaly get a lot of coments about the unnecessary "/" i use, but it really is the way i work....stupid, but it is ^^

on *:LOAD: {
  echo -a 7|0 jonypaul's Poll System 7|
  echo -a 7|0 To start, right click a channel and set the channel you want this script to work on. Put a "#" if you want it to work on every channel you are on 7|
  echo -a 7|0 Then, type /commands to see what you can do 7| 
}

on *:TEXT:!poll*:%channels: {
  if (on isin %poll) { /msg $chan The Poll is already on. To halt it type !haltpoll. }  
  if (on !isin %poll) { 
    if ($2 == $null) { /msg $chan Please specify the poll you want to make. | halt } 
    if ($2 != $null) { 
      /set %todaypoll $2-  
      /msg $chan The poll is about to start. Now please specify the options. To do so type !addoption <number> <answer>. When ou finish adding the options, type !lockpoll  
      /set %starterpoll $nick 
      /set %poll on 
    }
  }
}

on *:TEXT:!lockpoll:%channels: {
  if ($nick isin %starterpoll) {
    /set %lock on
    /msg $chan The Poll has been locked. Option adding is now over. To unlock, type !unlockpoll
  }
  if ($nick !isin %starterpoll) notice $nick Sorry, only the person who started the poll may lock the options. 
}

on *:TEXT:!unlockpoll:%channels: {
  if ($nick isin %starterpoll) {
    /set %lock off
    /msg $chan The Poll has been unlocked. To lock, type !lockpoll
  }
  if ($nick !isin %starterpoll) notice $nick Sorry, only the person who started the poll may lock the options. 
}

on *:TEXT:!todaypoll:%channels:msg $chan Today's poll is: " %todaypoll ".

on *:TEXT:!addoption*:%channels: {
  if (on !isin %lock)  {
    if (on isin %poll) { 
      if ($2 == 1) { /set %answer1 $3- | /notice $nick Option 1 has been set. To remove it type !remoption 1 }
      if ($2 == 2) { /set %answer2 $3- | /notice $nick Option 2 has been set. To remove it type !remoption 2 }
      if ($2 == 3) { /set %answer3 $3- | /notice $nick Option 3 has been set. To remove it type !remoption 3 }
      if ($2 == 4) { /set %answer4 $3- | /notice $nick Option 4 has been set. To remove it type !remoption 4 }
      if ($2 == 5) { /set %answer5 $3- | /notice $nick Option 5 has been set. To remove it type !remoption 5 }
    }
    if (off isin %poll) { /notice $nick The Poll is not on. To turn it on type !poll }
  }
  if (on isin %lock) { /notice $nick Sorry, but option adding and removing is now over. }
}

on *:TEXT:!remoption*:%channels: {
  if (on !isin %lock) {
    if (on isin %poll) {
      if ($2 == 1) { /unset %answer1  | /notice $nick Option 1 has been removed. }
      if ($2 == 2) { /unset %answer2  | /notice $nick Option 2 has been removed. }
      if ($2 == 3) { /unset %answer3  | /notice $nick Option 3 has been removed. }
      if ($2 == 4) { /unset %answer4  | /notice $nick Option 4 has been removed. }
      if ($2 == 5) { /unset %answer5  | /notice $nick Option 5 has been removed. }
    }
    if (off isin %poll) notice $nick The Poll is not on. To turn it on type !poll
  }
  if (on isin %lock) notice $nick Sorry, but option adding and removing is now over.
}

on *:TEXT:!vote*:%channels: {
  if (on isin %poll) {
    if ($address isin %voter) notice $nick Sorry, you are only allowed to vote once per poll.
    if ($address !isin %voter) {
      if (($2 == 1) && (%answer1 != 0)) { /inc %votes1 1 | /notice $nick Thanks for voting. Your vote has been saved | /set %voter $addtok(%voter,$address,32) }
      if (($2 == 2) && (%answer2 != 0)) { /inc %votes2 1 | /notice $nick Thanks for voting. Your vote has been saved | /set %voter $addtok(%voter,$address,32) }
      if (($2 == 3) && (%answer3 != 0)) { /inc %votes3 1 | /notice $nick Thanks for voting. Your vote has been saved | /set %voter $addtok(%voter,$address,32) }
      if (($2 == 4) && (%answer4 != 0)) { /inc %votes4 1 | /notice $nick Thanks for voting. Your vote has been saved | /set %voter $addtok(%voter,$address,32) } 
      if (($2 == 5) && (%answer5 != 0)) { /inc %votes5 1 | /notice $nick Thanks for voting. Your vote has been saved | /set %voter $addtok(%voter,$address,32) }
      if (($2 == 1) && (%answer1 == 0)) { /notice $nick Your vote hasn't been saved because the number you vote for is not an option. Type !options to see the available options. } 
      if (($2 == 2) && (%answer2 == 0)) { /notice $nick Your vote hasn't been saved because the number you vote for is not an option. Type !options to see the available options. }
      if (($2 == 3) && (%answer3 == 0)) { /notice $nick Your vote hasn't been saved because the number you vote for is not an option. Type !options to see the available options. }
      if (($2 == 4) && (%answer4 == 0)) { /notice $nick Your vote hasn't been saved because the number you vote for is not an option. Type !options to see the available options. }
      if (($2 == 5) && (%answer5 == 0)) { /notice $nick Your vote hasn't been saved because the number you vote for is not an option. Type !options to see the available options. }
    }      
    if (off isin %poll) notice $nick The Poll is not on. To turn it on type !poll
  }
}
on *:TEXT:!options:%channels: { 
  if (on isin %poll) {
    /notice $nick The Options are:  
    /notice $nick 1. - %answer1 - 
    /notice $nick 2. - %answer2 -
    /notice $nick 3. - %answer3 -
    /notice $nick 4. - %answer4 -
    /notice $nick 5. - %answer5 -
    /notice $nick To vote type !vote <number> 
  }
  if (off isin %poll) notice $nick The Poll is not on. To turn it on type !poll
}

on *:TEXT:!results:%channels: { 
  if (on isin %poll) {
    /msg $chan The Poll results are currently: 
    /msg $chan %todaypoll
    /msg $chan 1. - %answer1 - 7 %votes1
    /msg $chan 2. - %answer2 - 7 %votes2
    /msg $chan 3. - %answer3 - 7 %votes3
    /msg $chan 4. - %answer4 - 7 %votes4
    /msg $chan 5. - %answer5 - 7 %votes5
  }
  if (off isin %poll) notice $nick The Poll is not on. To turn it on type !poll
}

on *:text:!haltpoll:%channels: {
  if ($nick !isin %starterpoll) notice $nick Only the person who started this Poll can end it.
  if ($nick isin %starterpoll) {
    /unset  %todaypoll
    /unset %answer1
    /unset %answer2
    /unset %answer3
    /unset %answer4
    /unset %answer5
    /unset %votes1
    /unset %votes2
    /unset %votes3
    /unset %votes4
    /unset %votes5
    /unset %voter
    /unset %starterpoll 
    /set %poll off
    /set %lock off 
    /msg $chan The Poll has been halted and all its results, answers and voters erased. To start a new one type !poll
  }
}

on *:TEXT:!commands:%channels: {
  if (1 isin %commands) notice $nick Please wait 5 seconds to use the !commands trigger again.
  if (1 !isin %commands) {
    notice $nick The Poll commands are:
    notice $nick !poll <question> - starts a poll. Ex: !poll Im i cool?
    notice $nick !addoption <number> <option> - This will add an option. You can add up to 5 options. Ex: !addoption 1 Yes
    notice $nick !remoption <number> - Will remove the requested option.
    notice $nick !vote <number> - Vote on the option you like the most. 
    notice $nick !options - Shows all the available options
    notice $nick !results - Shows you the current results of the poll
    notice $nick !todaypoll - Shows you the current poll. 
    notice $nick !haltpoll - Stops the current poll
    notice $nick !lockpoll - Locks option adding
    notice $nick !unlockpoll - Unlocks option adding
    inc %commands 1
    timer 1 5 unset %commands
  }
}

alias commands {
  echo -a The Poll commands are:
  echo -a !poll <question> - starts a poll. Ex: !poll Im i cool?
  echo -a !addoption <number> <option> - This will add an option. You can add up to 5 options. Ex: !addoption 1 Yes
  echo -a !remoption <number> - Will remove the requested option.
  echo -a !vote <number> - Vote on the option you like the most. 
  echo -a !options - Shows all the available options
  echo -a !results - Shows you the current results of the poll
  echo -a !todaypoll - Shows you the current poll. 
  echo -a !haltpoll - Stops the current poll
  echo -a !lockpoll - Locks option adding
  echo -a !unlockpoll - Unlocks option adding
  echo -a !commands - Shows all the commands to a user on the channel
}

on *:join:%channels: { /notice $nick Hi $nick $+ . Today, our poll is: %todaypoll . To know what you can do to vote, type !commands. Thanks! }

menu channel {
  Poll
  .Set Channels:/set %channels $?="Set the channel you want the poll to work on"
}

Comments

Sign in to comment.
Storm2108   -  Apr 11, 2007

Hmmm id give it 4/10

 Respond  
jonypaul   -  Aug 18, 2006

ok i see what u mean :)
Updated it...only one command per 5 seconds

Erroneous  -  Nov 16, 2013

I know this is a bit outdated but using a new line command (i.e. $&) instead of a notice or echo command will cut down on flood outs. Put it all on one line like:

notice $nick The Poll commands are: $& !poll <question> - starts a poll. Ex: !poll Im i cool? $& !addoption <number> <option> - This will add an option. You can add up to 5 options. Ex: !addoption 1 Yes $& !remoption <number> - Will remove the requested option. $& !vote <number> - Vote on the option you like the most. $& !options - Shows all the available options $& !results - Shows you the current results of the poll $& !todaypoll - Shows you the current poll. $& !haltpoll - Stops the current poll $& !lockpoll - Locks option adding $& !unlockpoll - Unlocks option adding
Sign in to comment

krimson   -  Aug 17, 2006

you should test this and have 3 people typing !commands with very short delays. dumping text this large will get you flooded out. nickserv can do that because it\'s a registered service, and it doesn\'t exceed flood.

 Respond  
krimson   -  Aug 16, 2006

when typing !commands, you\'re basically dumping 11 lines of text. what if somebody actually uses this script on a larger scale? without using a queue system to manage the output, the user would obviously flood off

 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.