Randomly distributed food v1.85

By Jelly on Jul 07, 2009

DO NOT FORGET TO DO /addoriginalfoods EVERY TIME THE SCRIPT UPDATES, IF YOU DONT THERE WILL BE ERRORS

summary of the script: It will cause you/your bot to randomly hand out baked goods to a random person in a random channel (as long as the channel is enabled for the script, read more below)

/addoriginalfoods this will write all the original foods I had in the ini file to foodstuffs.ini, this only has to be used once.

/addfood used to add new foods to foodstuffs.ini, for example /addfood strawberry 5 pie the addfood command can also be used to add new headers such as /addfood blueberry 1 muffin but the script doesnt support this naturally so you will have to add it in yourself. (Or, if you can come up with like 7 things under a header, post them and I'll add them.)

/food on/off turns the script on and off, this doesnt need to be on for the above commands, however it does need to be on for the script to hand out food

/foodchannel on/off adds a channel / removes a channel from the enabled channels list

/starttimer used by other parts of the script to set a timer, the $r value can be changed, I have it set to 5,10 minutes

/foodtime contains the parts of the script that handle handing out food, it sets the channel and nick for each food to a variable just to make the script a little shorter and cleaner.

/foodignore add/del should a person request they not be given food, this will add them to a list that (should) will prevent them from being selected as %nickforfood

/foodcheck
followed by a nick to check if they're on the nofood list or not.

!ignoreme / !unignoreme
used by other people (possibly for their away nicks, or just that dont want to be highlighted.) to stop food from being given to them.

!food on / !food off
can be used by an op in a channel to turn food distribution on/off for that channel.

!amiignored
Tells someone if they're ignored or not

!isfoodon
Tells someone if food distribution is enabled for that channel or not

!suggestfood
Allows people to make little suggestions for different food items, theres a spam limit on it though.

!optout
Allows people to opt out of getting certain flavored foods (untested)

!optin
Does the same as above but opts back in (untested)

!ownercontrol on
sets the channel to ownercontrol so only people who the script has seen get +q can control it in that channel

!ownerfood on
owner command for setting +q food on, so noone without it can say otherwise

!ownerfood off
opposite of the above.

/checksuggest opens the suggestion ini

!info explains what the script does because noone gets it

!clearowners - clears the owners list if you're +q and unsets all owner control options

!foodstats /foodstats - outputs how many of each food you've given out

script in action:

»18:21:56« Jelly gives `Moe a chocolate coronet.
»18:21:56«
Jelly gives Ash a plate of warm banana eclair croissants.
»18:21:56« Jelly gives Vampy a strawberry meringue pie.
»18:19:43«
Jelly gives Ciarran4 a sweet cherry sorbetto.
»17:56:10« * Jelly gives Kyle an apple strudel.

known issues:

Script crashes if you're not on any channels that the script is enabled for.

;Randomly Distributed Food v1.85 by Jelly on SwiftIRC
;all code is open source.

;on connect triggering of the script if its enabled.
on *:CONNECT:{
  if ($readini(foodstuffs.ini,food,on) != no) {
    .timer 1 180 /foodtime
    .timer 1 180 amsg 12Food distribution is now on! Type 4!foodcmds12 to see available commands! [one time amsg, doesn't mean its on for the channel, it means its on for usage.]
    .timer 1 180 echo -a 12Don't forget to check for the latest version at8 http://www.hawkee.com/snippet/6387/ 12its updated often!
  }
}

on *:quit:{
  if ($nick == $me) { 
    /timertesting off
  }
}

;yay menus
menu nicklist {
  Randomly Distributed Food 
  .Ignore {
    /foodignore add $$1
  }
  .Unignore {
    /foodignore del $$1
  }
}

;yay menus 
menu channel {
  Randomly Distributed Food 
  .Ignore {
    noop $$?="Who do you want to ignore?" {
      /foodignore add $!
    }
  }
  .Unignore {
    noop $$?="Who do you want to unignore?" {
      /foodignore del $!
    }
  }
  .Check suggestions {
    /checksuggest
  }
}

;used to add my version of foodstuffs.ini's contents in terms of food items, only needs to be used once
alias addoriginalfoods {
  writeini -n foodstuffs.ini chocolate 1 a pair of tiny chocolate cakes and fruit kabobs.
  writeini -n foodstuffs.ini chocolate 2 a chocolate cupcake with rainbow sprinkles.
  writeini -n foodstuffs.ini chocolate 3 a chocolate velvet pie.
  writeini -n foodstuffs.ini chocolate 4 a handful of chocolate truffles.
  writeini -n foodstuffs.ini chocolate 5 a german chocolate coconut bar.
  writeini -n foodstuffs.ini chocolate 6 a chocolate raspberry trifle.
  writeini -n foodstuffs.ini chocolate 7 a chocolate tiramisu layer cake.
  writeini -n foodstuffs.ini chocolate 8 a chocolate “berried treasure” bar.
  writeini -n foodstuffs.ini chocolate 9 a chocolate coronet.
  writeini -n foodstuffs.ini chocolate 10 a handful of chocolate covered pretzels.
  writeini -n foodstuffs.ini chocolate 11 a bowl of chocolate mousse.
  writeini -n foodstuffs.ini chocolate 12 a chocolate pate with cranberry coulis.
  writeini -n foodstuffs.ini chocolate 13 a chocolate banana cream pie.
  writeini -n foodstuffs.ini chocolate 14 a german chocolate cake
  writeini -n foodstuffs.ini vanilla 1 a plate of vanilla-caramel flan.
  writeini -n foodstuffs.ini vanilla 2 a double vanilla poundcake with rum-vanilla glaze.
  writeini -n foodstuffs.ini vanilla 3 a vanilla cupcake with chocolate sprinkles.
  writeini -n foodstuffs.ini vanilla 4 a pear-vanilla ice.
  writeini -n foodstuffs.ini vanilla 5 an angelica and vanilla custard.
  writeini -n foodstuffs.ini vanilla 6 a bowl of vanilla wafer banana pudding.
  writeini -n foodstuffs.ini vanilla 7 a vanilla coronet.
  writeini -n foodstuffs.ini vanilla 8 a handful of vanilla covered pretzels.
  writeini -n foodstuffs.ini vanilla 9 a cup of vanilla milk.
  writeini -n foodstuffs.ini strawberry 1 strawberry milkshake.
  writeini -n foodstuffs.ini strawberry 2 strawberry ice cream cone.
  writeini -n foodstuffs.ini strawberry 3 strawberry shortcake.
  writeini -n foodstuffs.ini strawberry 4 strawberry cupcake.
  writeini -n foodstuffs.ini strawberry 5 strawberry meringue pie.
  writeini -n foodstuffs.ini strawberry 6 some strawberry cheesecake tartlets.
  writeini -n foodstuffs.ini strawberry 7 strawberry truffle pie.
  writeini -n foodstuffs.ini strawberry 8 strawberry trifle.
  writeini -n foodstuffs.ini strawberry 9 strawberry italian ice.
  writeini -n foodstuffs.ini strawberry 10 strawberry chiffon pie.
  writeini -n foodstuffs.ini strawberry 11 strawberry daiquiri.
  writeini -n foodstuffs.ini strawberry 12 strawberry rhubarb crunch.
  writeini -n foodstuffs.ini strawberry 13 strawberry and hazelnut rhubarb crisp.
  writeini -n foodstuffs.ini cherry 1 cherry italian ice.
  writeini -n foodstuffs.ini cherry 2 cup of cherry coke.
  writeini -n foodstuffs.ini cherry 3 late-summer cherry pie.
  writeini -n foodstuffs.ini cherry 4 cherry-almond clafouti.
  writeini -n foodstuffs.ini cherry 5 sweet cherry sorbetto.
  writeini -n foodstuffs.ini cherry 6 ricotta and cherry strudel.
  writeini -n foodstuffs.ini cherry 7 cherry-vanilla bean ice cream with cherry sauce.
  writeini -n foodstuffs.ini cherry 8 cherry, almond and apricot tart.
  writeini -n foodstuffs.ini cherry 9 cherry-almond trifle.
  writeini -n foodstuffs.ini apple 1 a cup of apple cider.
  writeini -n foodstuffs.ini apple 2 a lattice apple pie.
  writeini -n foodstuffs.ini apple 3 an apple turnover.
  writeini -n foodstuffs.ini apple 4 an apple crisp.
  writeini -n foodstuffs.ini apple 5 some old fashioned apple dumplings.
  writeini -n foodstuffs.ini apple 6 an apple-pecan cobbler.
  writeini -n foodstuffs.ini apple 7 an apple strudel.
  writeini -n foodstuffs.ini apple 8 an apple crumble.
  writeini -n foodstuffs.ini apple 9 a french apple tart.
  writeini -n foodstuffs.ini banana 1 a plate of baked banana bliss.
  writeini -n foodstuffs.ini banana 2 a baked banana crumble.
  writeini -n foodstuffs.ini banana 3 a banana boston cream pie.
  writeini -n foodstuffs.ini banana 4 a banana caramel fluff.
  writeini -n foodstuffs.ini banana 5 a banana-chocolate parfait. 
  writeini -n foodstuffs.ini banana 6 a banana cobbler.
  writeini -n foodstuffs.ini banana 7 a plate of warm banana eclair croissants.
  writeini -n foodstuffs.ini banana 8 a banana-pecan crunch.
  writeini -n foodstuffs.ini banana 9 a banana-pineapple delight.
  writeini -n foodstuffs.ini banana 10 some banana schnitzels.
  writeini -n foodstuffs.ini flavors 1 chocolate
  writeini -n foodstuffs.ini flavors 2 vanilla
  writeini -n foodstuffs.ini flavors 3 strawberry
  writeini -n foodstuffs.ini flavors 4 cherry
  writeini -n foodstuffs.ini flavors 5 apple
  writeini -n foodstuffs.ini flavors 6 banana
  echo -a 12Done adding original foods!
}

;used to add foods to foodstuffs.ini, type /addfood <header> <identifier> <food> and it'll become an option when the script runs
alias addfood {
  writeini -n foodstuffs.ini $1 $2 $3
  echo -a 8 $1 $2 $3 12 has been added.
}

;turns the script on / off
alias food {
  if ($1 == on) {
    if ($readini(foodstuffs.ini,food,on) = yes) {
      echo -a 4(Error) 12Food distribution is already enabled!
    }
    else {
      writeini -n foodstuffs.ini food on yes
      /foodtime
      echo -a 12Food distribution is now on.
    }
  }
  if ($1 == off) {
    if ($readini(foodstuffs.ini,food,on) != yes) {
      echo -a 4(Error) 12Food distribution is already disabled!
    }
    else {
      /writeini -n foodstuffs.ini food on no
      /timertesting off 
      echo -a 12Food distribution is now off
    }
  }
}

;enables distribution of food for individual channels (script only gives out food to channels that have been enabled) alternatively removes channels from the enabled list
alias foodchannel {
  if ($1 == on) {
    if ($readini(foodstuffs.ini,channels,$chan) == $chan) {
      echo -a 4(Error)8 $chan 12is already on the list.
    }
    else {
      writeini -n foodstuffs.ini channels $chan $chan
      echo -a 8 $chan 12has been added to the list.
    }
  }
  else {
    if ($1 == off) {
      if ($readini(foodstuffs.ini,channels,$chan) == $null) {
        echo -a 4(Error)8 $chan 12isn't on the list.
      }
      else { 
        remini foodstuffs.ini channels $chan $chan 
        echo -a 8 $chan 12has been removed from the list
      }
    }
  }
}

;used to add/remove nicks from the "no food" list (basically, enables you to have the script ignore certain nicks if it selects them as %nickforfood)
alias foodignore {
  if ($1 == add) { 
    if ($readini(foodstuffs.ini,nofood,$2) = $2) { 
      echo -a 4(Error)8 $2 12is already ignored!
    }
    else {
      writeini -n foodstuffs.ini nofood $2 $2
      echo -a 8 $2 12will 4no longer12 receive food :(
    }
  }
  if ($1 == del) { 
    if ($readini(foodstuffs.ini,nofood,$2) == $null) {
      echo -a 4(Error)8 $2 12isn't ignored.
    }
    else {
      remini foodstuffs.ini nofood $2 $2
      echo -a 8 $2 12will receive food again! :)
    }
  }
}

;used so people dont have to ask you to ignore them if they're bothered by the script.
on *:TEXT:!ignoreme:#:{
  if ($readini(foodstuffs.ini,nofood,$nick) = $nick) {
    notice $nick 4(Error) 8You're 12already ignored! 
  }
  else {
    writeini -n foodstuffs.ini nofood $nick $nick
    notice $nick 8You 12wont get food anymore, to undo this, type 4!unignoreme
  }
}

;used so people can un-ignore themselves
on *:TEXT:!unignoreme:#:{
  if ($readini(foodstuffs.ini,nofood,$nick) = $null) {
    notice $nick 4(Error) 8You're 12not ignored so I cant unignore you.
  }
  else {
    remini foodstuffs.ini nofood $nick $nick
    notice $nick 8You'll 12get food again now, to undo this, type 4!ignoreme
  }
}

;used so other people chan check if they're ignored
on *:TEXT:!amiignored:#:{
  if ($readini(foodstuffs.ini,nofood,$nick) = $nick) { 
    notice $nick 8You're 4ignored 12on this nick and will not recieve food. 
  }
  if ($readini(foodstuffs.ini,nofood,$nick) == $null) { 
    notice $nick 8You're 4not ignored 12on this nick. Enjoy your food.
  }
}

;used so people can check if food is enabled for a channel
on *:TEXT:!isfoodon:#:{
  if ($readini(foodstuffs.ini,channels,$chan) = $chan) {
    notice $nick 12Food is currently 8enabled12 for being given out in8 $chan 12This was set by8 $readini(foodstuffs.ini,enabler,$chan) $+ ,12 to disable it, have an op use the 4!food off 12command. To have it exclude you, type 4!ignoreme.
  }
  if ($readini(foodstuffs.ini,channels,$chan) = $null) {
    notice $nick 12Food is currently 8disabled12 for being given out in8 $chan 12This was set by8 $readini(foodstuffs.ini,disabler,$chan) $+ ,12 to enable it, have an op use the 4!food on 12command.
  }
}

;used by an @op in a channel to add/remove a channel from the list without your consent
on *:TEXT:!food on:#:{ 
  if ($nick isop $chan) { 
    if ($readini(foodstuffs.ini,ownercontrol,$chan) != $null) {
      if ($readini(foodstuffs.ini,ownerenabled,$chan) != $null) {
        notice $nick 4(Error)8 $chan 12was4 disabled12 for distribution by8 $readini(foodstuffs.ini,ownerenabler,$chan) 12while they had 4+q12. To re-enable it, you'll need to get someone with 4+q12 to type 4!ownerfood on12.
        { halt }
      }
    }
    if ($readini(foodstuffs.ini,ownercontrol,$chan) == on) { 
      notice $nick 4Owner control12 is currently on in8 $chan $+ 12, have someone with 4+q12 use the 4!ownercontrol off12 command to disable this.
      { halt }
    }
    if ($readini(foodstuffs.ini,channels,$chan) = $chan) {
      notice $nick 8 $chan 12is already 4enabled12 for distribution of food. To undo this, type 4"!Food off" 12(Channel enabled by8 $readini(foodstuffs.ini,enabler,$chan) $+ 12)
      { halt }
    }
    else {
      writeini -n foodstuffs.ini channels $chan $chan
      writeini -n foodstuffs.ini enabler $chan $nick 
      notice $nick 12Food is now enabled for distribution in8 $chan $+ 12, to undo this type 4"!food off"
    }
  }
}

;the opposite of !food on
on *:TEXT:!food off:#:{
  if ($nick isop $chan) { 
    if ($readini(foodstuffs.ini,ownerenabled,$chan) == yes) {
      if ($readini(foodstuffs.ini,ownercontrol,$chan) == on) {
        notice $nick 8 $chan 12was 4enabled12 for distribution by8 $readini(foodstuffs.ini,ownerenabler,$chan) 12while they had 4+q.12 To disable it, you'll need to get someone with 4+q12 to type 4!ownerfood off12.
        { halt }
      }
    }
    if ($readini(foodstuffs.ini,ownercontrol,$chan) == on) { 
      notice $nick 4Owner control12 is currently on in8 $chan $+ 12, have someone with 4+q12 use the 4!ownercontrol off12 command to disable this.
      { halt }
    }
    if ($readini(foodstuffs.ini,channels,$chan) = $null) {
      notice $nick 8 $chan 12is already 4disabled12 for distribution of food. To undo this, type 4"!Food on"12 (Channel was disabled by8 $readini(foodstuffs.ini,disabler,$chan) $+ 12)
      { halt }
    }
    else {
      remini foodstuffs.ini channels $chan $chan 
      writeini -n foodstuffs.ini disabler $chan $nick
      notice $nick 12Food is now 4disabled 12for distribution in8 $chan $+ , 12to undo this, type4 "!food on"
    }
  }
}

;outputs remote commands
on *:TEXT:!foodcmds:#:{
  notice $nick 12Remote commands are4 !foodstats !ignoreme !unignoreme !food on !food off !amiignored !isfoodon !suggestfood !info !ownercontrol on !ownercontrol off !ownerfood on !ownerfood off !optin <flavor> !optout <flavor> 12 - For in depth descriptions of what each command does, look here ->8 http://www.hawkee.com/snippet/6387/
}

;used so people can make their suggestions-but not too quickly. 
on *:TEXT:!suggestfood *:#:{
  if ($readini(foodsuggest.ini,tempignore,$nick) != $null) {
    notice $nick 8You 12are trying to suggest too quickly, please wait 30 seconds. Then try again. { halt }
  }
  else {
    if ($readini(foodsuggest.ini,$nick,%suggestvar) == $2-) {
      notice $nick 8You've 12already suggested that food.
      else {
        inc %suggestvar
        writeini -n foodsuggest.ini $nick %suggestvar $2-
        writeini -n foodsuggest.ini tempignore $nick $nick
        notice $nick 12Thank you for the suggestion.
        .timer 2 30 remini foodsuggest.ini tempignore $nick $nick
      }
    }
  }
}

;outputs ..info..
on *:TEXT:!info:#:{
  notice $nick 12Basically, if this script is enabled it'll pick a random person in a random channel to give a random item of food to. You cannot trigger it remotely, just enable/disable it. 
}

;Used either as an alias or from the channel menu to check suggestions.
alias checksuggest {
  run foodsuggest.ini
}

;used to check if someone is ignored
alias foodcheck {
  if ($readini(foodstuffs.ini,nofood,$1) = $1) {
    echo -a 8 $1 12is 4ignored12 and will not receive food.
  }
  if ($readini(foodstuffs.ini,nofood,$1) == $null) {
    echo -a 8 $1 12is 4not ignored12 and will receive food.
  }
}

;used to time the next distribution of food
alias startTimer {
  .timertesting 1 $rand(300,600) /foodtime startTimer
}

on *:RAWMODE:#:{
  if (+q isin $1) {
    if ($readini(foodstuffs.ini,owners,$chan) != $null) {
      writeini -n foodstuffs.ini owners $chan $addtok($readini(foodstuffs.ini,owners,$chan),$2,32)
    }
    else {
      writeini -n foodstuffs.ini owners $chan $2
    }
  } 
}

on *:TEXT:!ownerfood on:#:{
  if ($readini(foodstuffs.ini,ownercontrol,$chan) != $null) {
    if ($readini(foodstuffs.ini,owners,$chan) != $null) {
      var %ownernames $readini(foodstuffs.ini,owners,$chan)
      var %ownernames2 $istok(%ownernames,$nick,32)
      if (%ownernames2) {
        writeini -n foodstuffs.ini ownerenabler $chan $nick
        writeini -n foodstuffs.ini ownerenabled $chan yes
        remini foodstuffs.ini channels $chan $chan 
        writeini -n foodstuffs.ini channels $chan $chan
        notice $nick 8 $chan 12has been 4enabled12 with owner control. To shut owner control off, type 4!ownercontrol off12 to disable food while retaining owner control, type 4!ownerfood off12.
      }
      else {
        notice $nick 8You12 do not have 4+q12 in 8 $chan 12 or I have not seen it. If you do have 4+q12 type 4/hop12 so that I can record it.
      }
    }
    if ($readini(foodstuffs.ini,owners,$chan) == $null) {
      notice $nick 12I don't have any owners recorded for8 $chan $+ 12, if you are one, please4 /hop 12 so I can record it, and try again.
    }
  }
  if ($readini(foodstuffs.ini,ownercontrol,$chan) == $null) {
    notice $nick 4Owner control12must be enabled for8 $chan 12 in order for you to use this commmand.
  }
}

on *:TEXT:!ownerfood off:#:{
  if ($chan == #Jelly) {  { halt } }
  else {
    if ($readini(foodstuffs.ini,ownercontrol,$chan) != $null) {
      if ($readini(foodstuffs.ini,owners,$chan) != $null) {
        var %ownernames3 $readini(foodstuffs.ini,owners,$chan)
        var %ownernames4 $istok(%ownernames3,$nick,32)
        if (%ownernames4) {
          writeini -n foodstuffs.ini ownerenabler $chan $nick
          remini foodstuffs.ini ownerenabled $chan
          remini foodstuffs.ini channels $chan $chan 
          notice $nick 8 $chan 12has been 4disabled12 with owner control. To shut owner control off, type 4!ownercontrol off12 to enable food while retaining owner control, type 4!ownerfood on12.
        }
        else {
          notice $nick 8You12 do not have 4+q12 in 8 $chan 12 or I have not seen it. If you do have 4+q12 type 4/hop12 so that I can record it.
        }
      }
      if ($readini(foodstuffs.ini,owners,$chan) == $null) {
        notice $nick 12I don't have any owners recorded for8 $chan $+ 12, if you are one, please4 /hop 12 so I can record it, and try again.
      }
    }
    if ($readini(foodstuffs.ini,ownercontrol,$chan) == $null) {
      notice $nick 4Owner control12must be enabled for8 $chan 12 in order for you to use this commmand.
    }
  }
}

on *:TEXT:!ownercontrol*:#:{
  if ($readini(foodstuffs.ini,owners,$chan) != $null) {
    var %ownernames5 $readini(foodstuffs.ini,owners,$chan)
    var %ownernames6 $istok(%ownernames5,$nick,32)
    if (%ownernames6) {
      if ($2 == on) {
        if ($readini(foodstuffs.ini,ownercontrol,$chan) == on) {
          notice $nick 8 $chan 12is already under 4owner control12. To shut it off, type 4!ownercontrol off12.
        }
        else {
          writeini -n foodstuffs.ini ownercontrol $chan on
          notice $nick 8 $chan 12is now under owner control. (This means that only people with 4+q12 can enable/disable food distribution.) To undo this, type 4!ownercontrol off
        }
      }
      if ($2 == off) {
        if ($readini(foodstuffs.ini,ownercontrol,$chan) == $null) {
          notice $nick 8 $chan 12is is not currently under 4owner control12 so I cannot remove it. To enable it, type 4!ownercontrol on12.
        }
        else {
          remini foodstuffs.ini ownerenabled $chan
          remini foodstuffs.ini ownercontrol $chan
          notice $nick 8 $chan 12is no longer under owner control. (This means that @ops can now control whether or not food is given out.) To undo this, type 4!ownercontrol on
        }
      }
    }    
    else { 
      notice $nick 4(Error)12I don't have you recorded as an owner for8 $chan $+ 12, if you are one, please4 /hop 12 so I can record it, and try again.
    }
  }
}

on *:Join:#:{
  if ($nick == $me) { 
    writeini -n foodstuffs.ini currentchans $chan $chan
  }
}

on *:Part:#:{
  if ($nick == $me) {
    remini foodstuffs.ini currentchans $chan
  }
}

on *:disconnect:{
  remini foodstuffs.ini currentchans
}

;opt out for certain foods 
on *:TEXT:!optout*:#:{
  if ($2 == chocolate) {
    if ($readini(foodstuffs.ini,chocolateopt,$nick) != $null) {
      notice $nick 4(Error)8You're12 already set to 4opt out12 for8 chocolate12.
    }
    else {
      writeini -n foodstuffs.ini chocolateopt $nick $nick
      notice $nick 8You're12 now set to 4opt out12 for8 chocolate12 to undo this, type 4!optin chocolate
    }
  }
  if ($2 == vanilla) {
    if ($readini(foodstuffs.ini,vanillaopt,$nick) != $null) {
      notice $nick 4(Error)8You're12 already set to 4opt out12 for8 vanilla12.
    }
    else {
      writeini -n foodstuffs.ini vanillaopt $nick $nick 
      notice $nick 8You're12 now set to 4opt out12 for8 vanilla12 to undo this, type 4!optin vanilla
    }
  }
  if ($2 == strawberry) {
    if ($readini(foodstuffs.ini,strawberryopt,$nick) != $null) {
      notice $nick 4(Error)8You're12 already set to 4opt out12 for8 strawberry12.
    }
    else {
      writeini -n foodstuffs.ini strawberryopt $nick $nick 
      notice $nick 8You're12 now set to 4opt out12 for8 strawberry12 to undo this, type 4!optin strawberry
    }
  }
  if ($2 == cherry) {
    if ($readini(foodstuffs.ini,cherryopt,$nick) != $null) {
      notice $nick 4(Error)8You're12 already set to 4opt out12 for8 cherry12.
    }
    else {
      writeini -n foodstuffs.ini cherryopt $nick $nick 
      notice $nick 8You're12 now set to 4opt out12 for8 cherry12 to undo this, type 4!optin cherry
    }
  }
  if ($2 == apple) {
    if ($readini(foodstuffs.ini,appleopt,$nick) != $null) {
      notice $nick 4(Error)8You're12 already set to 4opt out12 for8 apple12.
    }
    else {
      writeini -n foodstuffs.ini appleopt $nick $nick 
      notice $nick 8You're12 now set to 4opt out12 for8 apple12 to undo this, type 4!optin apple
    }
  }
  if ($2 == banana) {
    if ($readini(foodstuffs.ini,bananaopt,$nick) != $null) {
      notice $nick 4(Error)8You're12 already set to 4opt out12 for8 banana12.
    }
    else {
      writeini -n foodstuffs.ini bananaopt $nick $nick 
      notice $nick 8You're12 now set to 4opt out12 for8 banana12 to undo this, type 4!optin banana
    }
  }
}

;opt back in for certain foods
on *:TEXT:!optin*:#:{
  if ($2 == chocolate) {
    if ($readini(foodstuffs.ini,chocolateopt,$nick) == $null) {
      notice $nick 4(Error)8You're12 already set to 4opt in12 for8 chocolate12.
    }
    else {
      remini foodstuffs.ini chocolateopt $nick
      notice $nick 8You're12 now set to 4opt in12 for8 chocolate12 to undo this, type 4!optout chocolate
    }
  }
  if ($2 == vanilla) {
    if ($readini(foodstuffs.ini,vanillaopt,$nick) == $null) {
      notice $nick 4(Error)8You're12 already set to 4opt in12 for8 vanilla12.

    }
    else {
      remini foodstuffs.ini vanillaopt $nick
      notice $nick 8You're12 now set to 4opt in12 for8 vanilla12 to undo this, type 4!optout vanilla
    }
  }
  if ($2 == strawberry) {
    if ($readini(foodstuffs.ini,strawberryopt,$nick) == $null) {
      notice $nick 4(Error)8You're12 already set to 4opt in12 for8 strawberry12.
    }
    else {
      remini foodstuffs.ini strawberryopt $nick
      notice $nick 8You're12 now set to 4opt in12 for8 strawberry12 to undo this, type 4!optout strawberry
    }
  }
  if ($2 == cherry) {
    if ($readini(foodstuffs.ini,cherryopt,$nick) == $null) {
      notice $nick 4(Error)8You're12 already set to 4opt in12 for8 cherry12.
    }
    else {
      remini foodstuffs.ini cherryopt $nick 
      notice $nick 8You're12 now set to 4opt in12 for8 cherry12 to undo this, type 4!optout cherry
    }
  }
  if ($2 == apple) {
    if ($readini(foodstuffs.ini,appleopt,$nick) == $null) {
      notice $nick 4(Error)8You're12 already set to 4opt in12 for8 apple12.
    }
    else {
      remini foodstuffs.ini appleopt $nick 
      notice $nick 8You're12 now set to 4opt in12 for8 apple12 to undo this, type 4!optout apple
    }
  }
  if ($2 == banana) {
    if ($readini(foodstuffs.ini,bananaopt,$nick) == $null) {
      notice $nick 4(Error)8You're12 already set to 4opt in12 for8 banana12.
    }
    else {
      remini foodstuffs.ini bananaopt $nick 
      notice $nick 8You're12 now set to 4opt in12 for8 banana12 to undo this, type 4!optout banana
    }
  }
}

on *:TEXT:!foodstats:#:{
  notice $nick 12I've given out:8 $num(%chocolatecount) 4 chocolate12 foods,8 $num(%vanillacount) 4 vanilla12foods,8 $num(%strawberrycount) 4 strawberry12 foods,8 $num(%cherrycount) 4 cherry12 foods,8 $num(%applecount) 4 apple12 foods, and8 $num(%bananacount) 4 banana12 foods. The total amount of food I've given out is8 $num($calc(%chocolatecount + %vanillacount + %strawberrycount + %cherrycount + %applecount + %bananacount)))
}

alias foodstats {
  echo -a  12I've given out:8 $num(%chocolatecount) 4 chocolate12 foods,8 $num(%vanillacount) 4 vanilla12foods,8 $num(%strawberrycount) 4 strawberry12 foods,8 $num(%cherrycount) 4 cherry12 foods,8 $num(%applecount) 4 apple12 foods, and8 $num(%bananacount) 4 banana12 foods. The total amount of food I've given out is8 $num($calc(%chocolatecount + %vanillacount + %strawberrycount + %cherrycount + %applecount + %bananacount)))
}

;used to purge owners
On *:TEXT:!Clearowners:#:{
  var %ownernames5 $readini(foodstuffs.ini,owners,$chan)
  var %ownernames6 $istok(%ownernames5,$nick,32)
  if (%ownernames6) {
    remini foodstuffs.ini ownerfood $chan
    remini foodstuffs.ini ownerenabler $chan
    remini foodstuffs.ini ownerdisabler $chan
    remini foodstuffs.ini ownercontrol $chan
    notice $nick 12The8 owner food12 and8 owner control12 settings have been4 cleared12 for8 $chan $+ . 
    remini foodstuffs.ini owners $chan
    notice $nick 12The list of owners I had recorded for8 $chan 12has been4 cleared.
    unset %ownernames6
    unset %ownernames5
  }
  else {
    if ($readini(foodstuffs.ini,owners,$nick) == $null) {
      notice $nick 8You're12 not recorded as an owner for8 $chan $+ ,12 please type8 /hop12 so I can record your +q.
    }
    if ($readini(foodstuffs.ini,owners,$chan) == $null) {
      notice $nick 12  I4 do not12 have any owners recorded for8 $chan $+ ,12 please type 8/hop12 so I can record your +q.
    }
  }
}

;main part of the script, activated by /food on as well as the timer above
alias foodtime {
  if ($readini(foodstuffs.ini,food,on) != no) {
    /startTimer
    set %channelforfood $readini(foodstuffs.ini,n,currentchans,$ini(foodstuffs.ini,currentchans,$r(1,$ini(foodstuffs.ini,currentchans,0))))
    while !$readini(foodstuffs.ini,channels,%channelforfood) { set %channelforfood $readini(foodstuffs.ini,n,currentchans,$ini(foodstuffs.ini,currentchans,$r(1,$ini(foodstuffs.ini,currentchans,0)))) }
    set %nickforfood $nick(%channelforfood,$r(1,$nick(%channelforfood,0)))
    while ($readini(foodstuffs.ini,nofood,%nickforfood)) { set %nickforfood $nick(%channelforfood,$r(1,$nick(%channelforfood,0)))    } 
    set %foodvar $readini(foodstuffs.ini,n,flavors,$ini(foodstuffs.ini,flavors,$r(1,$ini(foodstuffs.ini,flavors,0))))
    while ($readini(foodstuffs.ini,%foodvar $+ opt,%nickforfood)) { set %foodvar $readini(foodstuffs.ini,n,flavors,$ini(foodstuffs.ini,flavors,$r(1,$ini(foodstuffs.ini,flavors,0))))   }
    if (%foodvar == chocolate) { 
      describe %channelforfood gives %nickforfood $readini(foodstuffs.ini,n,%foodvar,$ini(foodstuffs.ini,%foodvar,$r(1,$ini(foodstuffs.ini,%foodvar,0))))
      inc %chocolatecount
    }
    if (%foodvar == vanilla) {
      describe %channelforfood gives %nickforfood $readini(foodstuffs.ini,n,%foodvar,$ini(foodstuffs.ini,%foodvar,$r(1,$ini(foodstuffs.ini,%foodvar,0))))
      inc %vanillacount
    }
    if (%foodvar == strawberry) {
      describe %channelforfood gives %nickforfood a $readini(foodstuffs.ini,n,%foodvar,$ini(foodstuffs.ini,%foodvar,$r(1,$ini(foodstuffs.ini,%foodvar,0))))
      inc %strawberrycount
    }
    if (%foodvar == cherry) {
      describe %channelforfood gives %nickforfood a $readini(foodstuffs.ini,n,%foodvar,$ini(foodstuffs.ini,%foodvar,$r(1,$ini(foodstuffs.ini,%foodvar,0))))
      inc %cherrycount
    }
    if (%foodvar == apple) { 
      inc %applecount
      describe %channelforfood gives %nickforfood $readini(foodstuffs.ini,n,%foodvar,$ini(foodstuffs.ini,%foodvar,$r(1,$ini(foodstuffs.ini,%foodvar,0))))
    }
    if (%foodvar == banana) { 
      inc %bananacount
      describe %channelforfood gives %nickforfood $readini(foodstuffs.ini,n,%foodvar,$ini(foodstuffs.ini,%foodvar,$r(1,$ini(foodstuffs.ini,%foodvar,0))))
      unset %foodvar
      unset %channelforfood
      unset %nickforfood
    }
  }
}

alias num { return $bytes($1-,db) }

Comments

Sign in to comment.
Jelly   -  Jul 31, 2010

Added at least two commands

!foodstats
/foodstats
!clearowners

 Respond  
Jelly   -  Sep 19, 2009

Epic update:

Updated Error messages to say (Error)

Added colors

!ownercontrol on

!ownercontrol off

!ownerfood on

!ownerfood off

!suggestfood

/check suggest

fixed the sending of messages to channels you're not on, however if you're not on a channel that is in the enabled list, it causes and inf loop.

Changed the way flavors get picked, to go along with

!optin

!optout

Added nicklist and channel menus; will update them to do more later.

added owner caching

Might have added more, who knows at this point.

 Respond  
Jelly   -  Jul 30, 2009

Update:

On connect triggering of the script if its enabled

Ability for OPs to Add/Remove channels from the enabled list

Ability to check if you're ignored (anyone)

Ability to check if a channel is added (anyone)

Output of all remote commands

Error messages when attempting to preform a redundant action (adding an ignored person to ignore list, adding an added channel to the channel list, /food on when /food on has already been done, ect)

Noticed an error but I haven't figured out how to fix it yet.

 Respond  
Jelly   -  Jul 29, 2009

Added !ignoreme / !unignore me so people will be able to add themselves to the ignore list at their leisure.

Added punctuation.

Currently, the ignore list works with nicks and that is why that works, I wont be changing it to $address because people may just want their away nick ignored.

 Respond  
Jelly   -  Jul 28, 2009

Update.

Made Chocolate/vanilla foods more creative (they were really basic like "cookie, muffin" to begin with.)
Added Banana foods and support for them
Added a way to check whether or not someone is on the ignore list for the food. (/foodcheck )

Someone sent me a PM telling me the apple/cherry update didnt work. That is false, you need to do /addoriginalfoods to get these new items or they wont work.

 Respond  
Jelly   -  Jul 17, 2009

Update:

Fix'd the exclude option (somehow o.O)

 Respond  
Jelly   -  Jul 15, 2009

Actually, I lied. The ignore doesnt really work and I dont know how to fix it :3

 Respond  
Jelly   -  Jul 13, 2009

Update:

missing an end bracket which prevented the script from executing properly.

 Respond  
Jelly   -  Jul 13, 2009

Updated:

Fixed a typo in the first couple of writeini of /addoriginalfoods that wrote it to my testing ini, you'll need to do /addoriginalfoods anyway to add these updates so that'll fix itself.

Added: cherry and apple desserts

Added: more strawberry, vanilla and chocolate desserts

Added: support for excluding people from being given food.

 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.