New Fortune script

By slub77 on Jan 09, 2010

Ok i have a made this script for a mess about, at first it was actually just one line long, well it read from a text file, but then i started playing with it and i ended up with the snippet you see below.

TO use
[list=1]
[]Copy/paste in to remotes
[
]Right click in channel for the Channel menu this includes: Add fortunes, View fortunes, change fortunes.
[]On the nicklist right click for the options too:change fortune, add fortune, remove fortune, view fortune
[
]For another user they must type Sfortune to get there fortune for the day, this fortune will last all day
[/list]

Brief description
:The script works by saving a set fortune you have made to an ini file.
:it saves as The users address, so they can not change name and get a new fortune, and also the fortune they were set at the time
:The menu is just a small addon that allows you to change fortunes, view fortunes, or remove fortunes, there is a diffrent menu for the Channel and the Nicklist
:The alias is simple, all it does is counts the total number of fortunes you have made in that section, by going through each one untill it reaches a number that does not exist, in other words, you have not made that many fortunes.

Ok Have fun with this little snippet.

Please Rate high, and leave some comments.

Image

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lol and i had help open to look for $right :P

on *:TEXT:Sfortune*:#:{
  if !$readini(fortune.ini, $date, $address($nick,2)) {
    :loop
    var %a $readini(fortune.ini, Fortune, $rand(1,$fortune))
    if !%a { goto loop }
    else {
      var %x %a
      notice $nick Your fortune Today is: %x
      writeini fortune.ini $date $address($nick,2) %x
    }
  }
  else { notice $nick Your fortune today is : $readini(fortune.ini, $date, $address($nick,2)) }
}

menu channel {
  Fortune
  .$style(2) Total Fortunes $fortune : noop
  .Add Fortunes:{
    var %a $calc($fortune + 1)
    var %x $?="Enter the words for fortune number %a "

    if $! = $null { echo Nothink was written }
    else {
      writeini fortune.ini fortune %a $!
      echo Wrote
    }
  }
  .$iif(!$fortune,$style(2)) View Fortunes:{
    $?="What number would you like to see, so far you have $fortune Saved"
    if !$! { halt }
    else { 
      var %x 1
      var %done $calc($fortune + 1)
      var %doneline 1
      :name

      if %doneline == %done { echo There is not that many fortunes }
      else {
        if $readini(fortune.ini, fortune, %x) && %x == $! { echo  Fortune Number $! : $readini(fortune.ini, fortune, %x) }
        else {
          inc %x
          inc %doneline
        goto name }

      }
    }
  }
  .$iif(!$fortune,$style(2)) Change fortune:{
    :fortune
    var %b $?="enter the fortune number (Total fortunes $fortune )"
    if !$! { halt }
    else {
      var %x 1
      var %done $calc($fortune + 1)
      var %doneline 1
      :name
      if %doneline = %done { 
        echo ERROR that fortune number has not been made yet
      goto fortune }

      if $readini(fortune.ini, fortune, %x) && %x == %b { 
        echo $?="change %b : $readini(fortune.ini, fortune, %x) : to?"
        if !$! { halt }
        else {
          writeini fortune.ini fortune %x $!
          echo CHANGED :D
        }
      }
      else {
        inc %x
        inc %doneline
      goto name }

    }
  }

}

menu nicklist {
  Fortune
  .$iif($readini(fortune.ini, $date, $address($1,2)),$style(2)) Set $1 a fortune:{
    :loop
    var %a $readini(fortune.ini, Fortune, $rand(1,$fortune))
    if !%a { goto loop }
    else {
      var %x %a
      echo $1 new fortune is : %x
    writeini fortune.ini $date $address($1,2) %x } 
  }

  .$iif(!$readini(fortune.ini, $date, $address($1,2)),$style(2)) View $1 fortune:echo $1 Fortune is : $readini(fortune.ini, $date, $address($1,2))
  .$iif(!$readini(fortune.ini, $date, $address($1,2)),$style(2)) Change fortune:{
    :fortune
    var %x $?="change $1 fortune to number? ( Total $fortune )"
    if !$! { halt }
    else {
      var %x 1
      var %done $calc($fortune + 1)
      var %doneline 1
      :name
      if %doneline = %done { 
        echo ERROR that fortune number has not been made yet
      goto fortune }
      else {
        if $readini(fortune.ini, fortune, %x) && %x == $! { 
          remini fortune.ini $date $address($1,2)
          writeini fortune.ini $date $address($1,2) $readini(fortune.ini, fortune, %x) 
        echo I have changed $1 fortune to : $readini(fortune.ini, fortune, %x) }
        else {
          inc %x
          inc %doneline
        goto name }
      }
    }
  }
  .$iif(!$readini(fortune.ini, $date, $address($1,2)),$style(2)) Remove fortune:{
    remini fortune.ini $date $address($1,2)
  echo Removed $1 fortune }

}

alias -l fortune {
  var %x 1
  :loop
  if $readini(fortune.ini, fortune, %x) { 
    inc %x
    goto loop 
  }
  else { 
    dec %x
    return %x 
  }
}

Comments

Sign in to comment.
dma   -  Oct 30, 2015

it only has one fortune?

slub77  -  Oct 30, 2015

If I remember right ( almost 6 years now) it's reading from a file it generates, in that file on each newline you enter a new "fortune" your self, and than the scrip will pick one at random .

The file is fortune.ini

Sign in to comment

slub77   -  Jan 10, 2010

napa, remember, i can't do socets :/ i keep meaning to learn, but everytime i go to i see something else and play around with that :/ i still gota use $chr as well :?

 Respond  
napa182   -  Jan 09, 2010

you could make this as a socket script

on $*:text:/@fortune$/iS:#: { if ($sock(fortune)) .sockclose fortune | .sockopen fortune www.fortunecookiemessage.com 80 | .sockmark fortune # $chr(91) $nick Here Is Your Random Fortune  $chr(93) } 
on *:sockopen:fortune: { sockwrite -nt $sockname GET / HTTP/1.1 | sockwrite -nt $sockname Host: $+(www.fortunecookiemessage.com,$str($crlf,2)) }
on *:sockread:fortune: {
  var %fortune | sockread %fortune
  if ($regex(%fortune,/<a href="cookie/.+">(.+)<\/a><\/h1>/)) { msg $sock(fortune).mark $regml(1) | .sockclose fortune }
}
 Respond  
SnoooP   -  Jan 09, 2010

lol =) I know :P

 Respond  
slub77   -  Jan 09, 2010

yea i saw i went on

 Respond  
SnoooP   -  Jan 09, 2010

nixtrixirc, the one in the channel there reads a fortune for the nick on join though, so it is actually quite different thinking about it now lol

 Respond  
slub77   -  Jan 09, 2010

what network?

 Respond  
SnoooP   -  Jan 09, 2010

Good job slub, we a script similair to this on our network for the zelda channel =]

 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.