Results 1 to 5 of 5

Thread: Feetys Poll Script

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    18

    Default Feetys Poll Script

    yeah. I made this in february.

    This was my first time ever using dialog boxes.
    I'm sure a lot of code could be cleaned up, it is messy imo.
    Feel free to make changes.

    Commands:
    /addpoll - Adds poll
    /unsetpoll - Unsets all poll-related variables, there shouldn't be any leftover though :x
    !poll - Shows the current Poll
    !castvote1 - Casts vote for option 1
    !castvote2 - Casts vote for option 2
    !results - Shows the results of the current poll.


    Code:
    ;---------------Feety's Poll Script-----------;
    ;
    ;- Created: Sometime in February 2009.
    ;
    ;- Description:
    ;- Poll script using dialog boxes and many other events.
    ;-
    ;- Last Updated: April 8, 2009
    ;- 
    ;- Changelog:
    ;- 4/8/09: Pretty much prepared it for the release.
    ;- sometime in February: created it.
    ;
    ;- Commands:
    ;- /addpoll - Adds poll
    ;- /unsetpoll - Unsets all poll-related variables, there shouldn't be any leftover though :x
    ;- !poll - Shows the current Poll
    ;- !castvote1 - Casts vote for option 1
    ;- !castvote2 - Casts vote for option 2
    ;- !results - Shows the results of the current poll.
    ;
    ;- Other Info:
    ;- There are some bugs that I can't figure out, so if you figure them out, please post. Known bug: If a person has notify off or has already voted, after a day or so it will ask them again.
    ;- You can find me on Channel #pancakes
    ;- site: http://www.radicalwhale.net
    ;
    ;---------------------------------------------;
     
     
    ;Menu...yeah.
    menu * {
     
      Poll Creator { addpoll }
     
    }
     
    ;Basically this will active from a timer, see the on join part.
    ;It will see if they have already voted, and if they have not, it will notify them. Unless
    ;they chose not to be.
     
    alias polljoin {
      ;//echo $address(%pollpnick,5)
      if (%pollpnick == $me) { /unsetpoll | halt }
      if ($ini(polls.ini,%pollpchan)) {
        set %pollnotifer notify $+ %pollpchan $+ .txt
        set %polltempfile voters $+ %pollpchan $+ .txt
        if (($read(%polltempfile,w,%pollwildsite)) || ($read(%pollnotifer,w,%pollwildsite))) {
     
          /unsetpoll
          halt
        }
        else {
     
          set %pollquestion $readini(polls.ini,n,%pollpchan,question)
          notice %pollpnick 8,1Hello %pollpnick $+ , It seems that you have not voted for the latest poll! type '!poll' to see it! || The Current Poll is ' $+ %pollquestion $+ ' || If you do not want to be notified about new polls then type '!notify off'.
          /unsetpoll
          halt
        }
      }
      else {
     
        /unsetpoll
        halt
      }
    }
     
     
    ;Just sets variables for when someone joins. Timers are there so if someone has a vhost
    ;it wont get the raw host, by 5 seconds their vhost should be activated.
    ;Here lay the only bug I have come across, Sometimes it will still notify the person even
    ;if they don't want to be or have already voted.
     
    on *:join:#:{
      set %pollpchan $chan
      set %pollpNick $nick
      timer 1 5 set %pollwildsite $wildsite
      timer 1 5 set %pollpchan $chan
      timer 1 5 set %pollpnick $nick
      timer 1 10 polljoin
    }
     
    ;Allows user to specify if they should be notified of new polls.
     
    on *:Text:!notify*:#:{
      if ($2 == off) { 
        /write notify $+ $chan $+ .txt $wildsite
        notice $nick You will no longer be notified about new polls when you join. To turn it back on type '!notify on'.
      }
      else { 
        if ($2 == on) {
          /write -ds $+ $wildsite notify $+ $chan $+ .txt
          notice $nick You will now be notified about new polls when join.
        }
        else {
          halt
        }
      }
    }
     
    ;jonesy44's Truncate script.
     
    alias truncate {
      if ($isid) {
        if ($1 !isnum) { return 2* $truncate: incorrect paramater $+($qt($1),;) $truncate(maxlength,text) }
        else { return $mid($2-,0,$iif(c isin $prop,$calc($1 + $numtok($mid($2-,0,$1),32)),$1)) $iif(e !isin $prop,$iif($len($2-) > $1,..)) }
      }
      else { echo -a 2* $!truncate: error; this alias can only be used as an identifier ($truncate form) }
    }
     
    ;Alas the poll, pretty self explanitory.
     
    on *:text:!poll:#:{
      if (!$ini(polls.ini,$chan)) { notice $nick sorry no poll for this channel | halt }
      set %pollquestion $readini(polls.ini,n,$chan,question)
      set %pollchoice1 $readini(polls.ini,n,$chan,choice1)
      set %pollchoice2 $readini(polls.ini,n,$chan,choice2)
      set %pollvotes $readini(polls.ini,n,$chan,votes)
      set %pollc2votes $readini(polls.ini,n,$chan,c2votes)
      set %pollc1votes $readini(polls.ini,n,$chan,c1votes)
     
      notice $nick -=The current poll for $chan is as followed=-
      notice $nick Question: %pollquestion 
      notice $nick Choice #1: %pollchoice1
      notice $nick Choice #2: %pollchoice2
      notice $nick to vote, type '!castvote 1' or '!castvote 2'.
      notice $nick After you vote you can use '!results' to see the data.
     
      /unsetpoll
    }
     
    ;casting a vote, makes sure they havent voted yet.
     
    on *:text:!castvote*:#:{
      set %pollc2votes $readini(polls.ini,n,$chan,c2votes)
      set %pollc1votes $readini(polls.ini,n,$chan,c1votes)
      set %pollvotes $readini(polls.ini,n,$chan,votes)
      set %pollchoice1 $readini(polls.ini,n,$chan,choice1)
      set %pollchoice2 $readini(polls.ini,n,$chan,choice2)
     
      set %polltempfile voters $+ $chan $+ .txt
      if ($read(%polltempfile,w,$wildsite)) {
        notice $nick You have already voted for this poll.
        /unsetpoll
        halt
      }
      else {
        if ($2 == 1) {
          notice $nick You have voted for Choice #1 ( $+ %pollchoice1 $+ )
          /inc %pollc1votes
          /inc %pollvotes
          /writeini polls.ini $chan c1votes %pollc1votes
          /writeini polls.ini $chan votes %pollvotes
          /write %polltempfile $wildsite
          /unsetpoll
        }
        else {
          if ($2 == 2) {
            notice $nick You have voted for Choice #2 ( $+ %pollchoice2 $+ )
            /inc %pollc2votes
            /inc %pollvotes
            /writeini polls.ini $chan c2votes %pollc2votes
            /writeini polls.ini $chan votes %pollvotes
            /write %polltempfile $wildsite
            /unsetpoll
          }
          else {
            /unsetpoll
            halt
          }
        }
      }
    }
     
    ;results of the poll. Makes sure they have voted in order to see this.
     
    on *:text:!results:#:{
      set %polltempfile voters $+ $chan $+ .txt
      if ($read(%polltempfile,w,$wildsite)) {
        set %pollquestion $readini(polls.ini,n,$chan,question)
        set %pollchoice1 $readini(polls.ini,n,$chan,choice1)
        set %pollchoice2 $readini(polls.ini,n,$chan,choice2)
        set %pollvotes $readini(polls.ini,n,$chan,votes)
        set %pollc2votes $readini(polls.ini,n,$chan,c2votes)
        set %pollc1votes $readini(polls.ini,n,$chan,c1votes)
     
        notice $nick -=The current poll is as followed=-
        notice $nick Question: %pollquestion 
        notice $nick Choice #1: %pollchoice1 ( %pollc1votes votes || $truncate(5,$calc((%pollc1votes / %pollvotes) * 100)).e $+ % )
        notice $nick Choice #2: %pollchoice2 ( %pollc2votes votes || $truncate(5,$calc((%pollc2votes / %pollvotes) * 100)).e $+ % )
        notice $nick Total Votes: %pollvotes
        /unsetpoll
     
      }
      else {
        notice $nick You need to vote before you can see results.
        /unsetpoll
      }
    }
     
    ;an alias to add a poll.
     
    alias addpoll {
      /dialog -m poll poll
    }
     
    ;the dialog box.
     
    dialog poll {
      title "Poll Creator"
      size 169 260 169 260
      text "Create a Poll!", 1, 10 10 140 20
     
      ;poll question
      Box "Enter the poll question below:", 2, 6 35 156 39
      edit "", 3, 9 50 150 20, autohs
     
      ;option 1
      Box "Option #1:", 4, 6 80 156 39
      edit "", 5, 9 95 150 20, autohs
     
      ;option 2
      Box "Option #2:", 6, 6 120 156 39
      edit "", 7, 9 135 150 20, autohs
     
      ;Channel
      Box "Channel:", 10, 6 160 156 39
      edit $active, 11, 9 175 150 20, autohs
     
      ;buttons
      button "Create Poll!",8, 9 220 70 30, ok
      button "Cancel :(",9, 90 220 70 30, cancel
    }
     
     
    ;and procedure to create the poll.
    on *:dialog:poll:sclick:8:{
     
     
      if ($ini(polls.ini, $did(11).text)) {
        set %pollquestion $readini(polls.ini,n,$did(11).text,question)
        set %pollchoice1 $readini(polls.ini,n,$did(11).text,choice1)
        set %pollchoice2 $readini(polls.ini,n,$did(11).text,choice2)
        set %pollvotes $readini(polls.ini,n,$did(11).text,votes)
        set %pollc2votes $readini(polls.ini,n,$did(11).text,c2votes)
        set %pollc1votes $readini(polls.ini,n,$did(11).text,c1votes)
        msg $did(11).text The Current Poll has closed! The Final Results Are As Followed:
        msg $did(11).text Question: %pollquestion 
        msg $did(11).text Choice #1: %pollchoice1 ( %pollc1votes votes || $truncate(5,$calc((%pollc1votes / %pollvotes) * 100)).e $+ %poll )
        msg $did(11).text Choice #2: %pollchoice2 ( %pollc2votes votes || $truncate(5,$calc((%pollc2votes / %pollvotes) * 100)).e $+ %poll )
        msg $did(11).text With a total of %pollvotes vote(s).
      }
     
      /remini polls.ini $did(11).text
      set %pollquestion $did(3).text
      set %pollchoice1 $did(5).text
      set %pollchoice2 $did(7).text
      set %pollfilename voters $+ $did(11).text $+ .txt
      /write -c %pollfilename
      /write notify $+ $did(11).text $+ .txt
      /writeini polls.ini $did(11).text question %pollquestion
      /writeini polls.ini $did(11).text choice1 %pollchoice1
      /writeini polls.ini $did(11).text choice2 %pollchoice2
      /writeini polls.ini $did(11).text votes 0
      /writeini polls.ini $did(11).text c1votes 0
      /writeini polls.ini $did(11).text c2votes 0
     
      timer 1 10 msg $did(11).text Hey guys! A new poll titled ' $+ %pollquestion $+ ' has been created! Type !poll to see it.
      /unsetpoll
    }
     
    ;This unsets every variable, I probably missed one D:
    alias unsetpoll {
      unset %pollquestion
      unset %pollchoice1
      unset %pollchoice2
      unset %pollfilename
      unset %polltempfile
      unset %pollvotes
      unset %pollc1votes
      unset %pollc2votes
      unset %pollwildsite
      unset %pollpNick
      unset %pollpchan
      unset %pollnotifer
    }
    I'll be posting more scripts soon. I need to clean them up and fix bugs.

    If you have any suggestions for scripts or criticism please post ;x
    Last edited by Yteef; 04-23-2009 at 11:51 AM.

  2. #2
    Junior Member
    Join Date
    Jun 2009
    Posts
    1

    Default

    Nice one - and sweeeeet alias you got in there! haaa.

  3. #3
    Rizon Staff Jason's Avatar
    Join Date
    Oct 2002
    Location
    Guadalajara
    Posts
    538

    Default

    Not to steal some of your potential users on this but Rizon is hoping to add a network Poll bot that rooms can assign and use as they see fit similar to Quotes Stats and the other bots in which we have. It will be a little while but it is on the todo list.
    Rizon CEO
    Jason
    Jason@Rizon.net

  4. #4
    Junior Member
    Join Date
    Feb 2009
    Posts
    18

    Default

    naw its straight.
    I don't even use this script anymore nevermind update it ;o

  5. #5
    Member goldenwolf's Avatar
    Join Date
    Apr 2009
    Location
    Toronto Canada
    Posts
    39

    Default

    Quote Originally Posted by Yteef View Post
    naw its straight.
    I don't even use this script anymore nevermind update it ;o
    Hmmm
    its IRC script, probably slow compared to other languages :/
    Golden|Wolf Seraphim

Similar Threads

  1. Multi-owner script
    By twilightNoir in forum IRC client scripts and addons
    Replies: 4
    Last Post: 04-15-2019, 09:59 AM
  2. making a ban script on clirc
    By benbop1992 in forum Nintendo DS
    Replies: 1
    Last Post: 11-04-2009, 03:50 PM
  3. mIRC: WHOIS script
    By darkex in forum IRC client scripts and addons
    Replies: 0
    Last Post: 10-14-2009, 07:35 PM
  4. Bomb script
    By Danfire0 in forum IRC client scripts and addons
    Replies: 3
    Last Post: 08-18-2009, 08:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •