Custom Survey Generator

By uncled1023 on Jan 22, 2010

This is a custom survey system. To create a survey, just type /survey, or right click anywhere to select the option you want.

Current Features:
~ Multiple Channels or Amsg all open channels
~ Reopen last survey
~ Choose how many answers you want to give
~ Nicks only allowed to vote once
~ Custom survey timer, or set to 0 to end it yourself whenever you want
~ add channels in the middle of a survey
~ Nicks allowed to view current results at any time.

Current Commands:
/survey - starts a new survey
/end_survey - ends the current survey and displays the results to all the survey active channels
/add_chan - Adds a channel to the active survey channel list and tells the channel the current survey information
/restarts_survey - Starts the last created survey and posts it to the last channels in the Active Survey Channel list

User Commands:
!vote - votes for the given answer
!results - displays the current survey results

To use the survey in multiple channels, type the channels with a comma in between them. Ex: #mirc,#hawkee

To use the survey in all the channels, type "all" instead of a channel name.

Just post the following code into your remote file or create a new file.

UPDATE 1/24/10

  • Added verifier to make sure if a channel name or "all" wasn't typed in, the survey would not start.
  • Added announcement to chan(s) of how long the survey is lasting for when you set the survey timer.
  • Added ability to choose how many answers you want to give.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
;       Survey   System          ;
;     Created by Uncled1023      ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;

menu nicklist,channel,query,status {
  Survey
  .Start Survey: survey
  .End survey: end_survey
  .Add channel to survey: add_chan
  .Restart the Survey: restart_survey
}

alias survey {
  if (%survey.status == 1) {
    notice $me There has already been a survey created.  If you want to add a channel to your survey, type /add_chan
  }
  else {
    set %survey.chan none
    var %answers 1
    set %survey.answers 0

    set %survey.chan $?="Survey Chan(s):    (For all chans, type 'all')"
    set %survey.question $?="Question:"
    set %survey.answers $?="Number of Answers"

    while (%answers <= %survey.answers) {
      set %survey. [ $+ [ %answers ] ] $?="Answer"
      inc %answers 1
    }

    set %survey.timer $?="Survey Time Limit:    (For no time limit, type '0')"
    var %answers 1
    while (%answers <= %survey.answers) {
      set %survey.results. [ $+ [ %answers ] ] 0
      inc %answers 1
    }

    if (*#* iswm %survey.chan) {
      set %survey.status 1
      if (%survey.timer == 0) { }
      else {
        msg %survey.chan The survey has been set for: %survey.timer Seconds
        .timer 1 %survey.timer end_survey
      }
      msg %survey.chan Survey: %survey.question
      var %answers 1
      var %message Answer Choices: 
      while (%answers <= %survey.answers) { 
        %message = %message ( $+ %answers $+ ) $+ %survey. [ $+ [ %answers ] ]
        inc %answers 1 
      }    

      msg %survey.chan %message
      msg %survey.chan To vote, please type !vote followed by the number of the choice you pick, for example !vote 2.  To view the current results, please type !results
    }
    else if (*all* iswm %survey.chan) {
      set %survey.status 1
      if (%survey.timer == 0) { }
      else {
        amsg The survey has been set for: %survey.timer Second
        .timer 1 %survey.timer end_survey
      }
      amsg Survey: %survey.question
      var %answers 1
      var %message Answer Choices: 
      while (%answers <= %survey.answers) { 
        %message = %message ( $+ %answers $+ ) $+ %survey. [ $+ [ %answers ] ]
        inc %answers 1 
      }    

      amsg %message
      amsg To vote, please type !vote followed by the number of the choice you pick, for example !vote 2.  To view the current results, please type !results
    } 
    else {
      notice $me You did not enter a correct channel.
    }
  }
}

alias add_chan {
  if ( %survey.status == 1) {
    set %survey.new_chan $?="Survey Chan(s):"
    %survey.chan = %survey.chan $+ , $+ %survey.new_chan
    msg %survey.new_chan Survey: %survey.question
    var %answers 1
    var %message Answer Choices: 
    while (%answers <= %survey.answers) { 
      %message = %message ( $+ %answers $+ ) $+ %survey. [ $+ [ %answers ] ]
      inc %answers 1 
    }    

    msg %survey.chan %message
    msg %survey.new_chan To vote, please type !vote followed by the number of the choice you pick, for example !vote 2.  To view the current results, please type !results
  } 
  else {
    notice $me Sorry, but there is not a survey going on at this time.
  }
}

alias restart_survey {
  if ( %survey.status == 0) {
    %survey.status = 1
    msg %survey.chan The survey has been reopened.  The question was %survey.question
    var %answers 1
    var %message Answer Choices: 
    while (%answers <= %survey.answers) { 
      %message = %message ( $+ %answers $+ ) $+ %survey. [ $+ [ %answers ] ]
      inc %answers 1 
    }    

    msg %survey.chan %message
    msg %survey.chan To vote, please type !vote followed by the number of the choice you pick, for example !vote 2.  To view the current results, please type !results
  } 
  else {
    notice $me Sorry, but there is already a survey going on at this time.
  }
}

alias end_survey {
  if ( %survey.status == 1) {
    if (*#* iswm %survey.chan ) {
      set %survey.status 0
      msg %survey.chan The survey has now ended.
      msg %survey.chan The Results to %survey.question are as follows.
      var %answers 1
      while (%answers <= %survey.answers) { 
        msg %survey.chan %survey. [ $+ [ %answers ] ] recieved %survey.results. [ $+ [ %answers ] ] votes.
        inc %answers 1 
      }    
    }
    else if ( all iswm %survey.chan ) {
      set %survey.status 0
      amsg The survey has now ended.
      amsg The Results to %survey.question are as follows.
      var %answers 1
      while (%answers <= %survey.answers) { 
        amsg %survey. [ $+ [ %answers ] ] recieved %survey.results. [ $+ [ %answers ] ] votes.
        inc %answers 1 
      }
    }
    else {
      notice $me Sorry, there was an error.
    }
    rlevel survey
  } 
  else {
    notice $me Sorry, but there is not a survey going on at this time.
  }

}

on survey:text:!vote *:#: {
  notice $nick Sorry, but you can only vote once.
}  

on *:text:!vote *:#: {
  if ( %survey.status == 1) {
    if ($$2 > 0 && $$2 <= %survey.answers) {
      notice $nick Thank you for voting for %survey. [ $+ [ $$2 ] ]
      inc %survey.results. [ $+ [ $$2 ] ] 1
      auser survey $nick
    } 
    else {
      notice $nick You have entered in a wrong choice, please try again
    }
  } 
  else {
    notice $nick Sorry, but there is not a survey going on at this time.
  }
}

} 

on *:text:!results:#: {
  if ( %survey.status == 1) {
    notice $nick The current results to %survey.question are as follows.
    var %answers 1
    while (%answers <= %survey.answers) { 
      notice $nick %survey. [ $+ [ %answers ] ] recieved %survey.results. [ $+ [ %answers ] ] votes.
      inc %answers 1 
    }   
  } 
  else {
    notice $nick Sorry, but there is not a survey going on at this time.
  }
}

Comments

Sign in to comment.
uncled1023   -  Jan 24, 2010

Added new features and fixes.

 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.