mIRC Home    About    Download    Register    News    Help

Print Thread
Twitch - Random Number Giveaway :) #250675 27/01/15 04:16 AM
Joined: Jan 2015
Posts: 40
J
jimieo Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jan 2015
Posts: 40
I made this earlier for my bot, thought I'd share it here.

Enjoy!
Code:
on *:TEXT:!raffle:#:{
  if ($nick isop #) {
    set %raffle $rand(1,100)
    msg $chan /me First person to guess the number between 1 and 100 wins!
  }
}


on *:text:*:#: {
  if ($1- == %raffle) {
    msg $chan /subscribers  
    msg $chan /me Annnnnd $nick is the winner with the number %raffle $+ !!!!!!
    unset %raffle
    .timerraffle 1 10 msg $chan /subscribersoff
  }
  else { }
}


Re: Twitch - Random Number Giveaway :) [Re: jimieo] #250678 27/01/15 09:22 AM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511

Re: Twitch - Random Number Giveaway :) [Re: westor] #250679 27/01/15 09:42 AM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
I noticed this in your script westor,

Code:
alias tw_check_follow {
  if (!$1) { return }
  var %u = https://api.twitch.tv/kraken/users/ $+ $2 $+ /follows/channels/ $+ $1 $+ ?limit=1&nocache= $+ $ticks
  var %v = twc_ $+ $ticks
  JSONOpen -ud %v %u
  if (%JSONError) { var %error = 1 | goto end | return }
  var %fc = $json(%v,error)
  if (%fc) { 
    var %msg = $json(%v,message) 
    if (is not following isin %msg) { var %status = 0 }
  }
  :end
  var %status = $json(%v,created_at)
  if (%error) { msg $3 ( $+ $nick $+ ): Giveaway has ended, the winner is: $2 ( $+ $2 is NOT following the channel) | goto end2 }
  if (!%status) { msg $3 ( $+ $nick $+ ): Giveaway has ended, the winner is: $2 ( $+ $2 is NOT following the channel) }
  elseif (%status) { msg $3 ( $+ $nick $+ ): Giveaway has ended, the winner is: $2 ( $+ $2 is following the channel) }
  :end2
  JSONClose %v
}

Code:
JSONOpen -ud %v %u
stuff
JSONClose %v

but

Code:
      if (d isin %switches) {
        $+(.timer,%com) 1 0 JSONClose $1

Shouldn't need that JSONClose %v.

Re: Twitch - Random Number Giveaway :) [Re: Belhifet] #250680 27/01/15 10:33 AM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
I have added that because if an error occurred the JSONClose is closing the JSON if i did not add this then the JSON connection will be open. is something like /comclose

Re: Twitch - Random Number Giveaway :) [Re: westor] #250692 27/01/15 10:04 PM
Joined: Apr 2010
Posts: 923
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 923
The com will close when specifying the -d switch with /JSONOpen, assuming you are using my latest version, even if there is an error

Last edited by FroggieDaFrog; 27/01/15 10:14 PM.

I am SReject
My Stuff
Re: Twitch - Random Number Giveaway :) [Re: FroggieDaFrog] #252140 24/03/15 07:28 PM
Joined: Mar 2015
Posts: 19
B
Blood_Wolf89 Offline
Pikka bird
Offline
Pikka bird
B
Joined: Mar 2015
Posts: 19
I added this to my script and everything beyond it does not work... but the giveaway does work

Re: Twitch - Random Number Giveaway :) [Re: Blood_Wolf89] #252148 24/03/15 10:49 PM
Joined: Apr 2014
Posts: 170
Bramzee Offline
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170
That's because of this:

Code:
on *:text:*:#: {
  if ($1- == %raffle) {
    msg $chan /subscribers  
    msg $chan /me Annnnnd $nick is the winner with the number %raffle $+ !!!!!!
    unset %raffle
    .timerraffle 1 10 msg $chan /subscribersoff
  }
  else { }
}


Open your scripts editor and go to file > new.
Put the script in there rather than mix them all together. Also, try remaining organized by renaming each file to whatever it corresponds to (ie: Commands, Filters, Giveaways, etc...) that way when you want to add/remove/edit something you can find it a little easier.

Re: Twitch - Random Number Giveaway :) [Re: Bramzee] #252151 24/03/15 11:49 PM
Joined: Mar 2015
Posts: 19
B
Blood_Wolf89 Offline
Pikka bird
Offline
Pikka bird
B
Joined: Mar 2015
Posts: 19
So should I make a new script for each thing I have? I have things like permit urls, uptime, roulette, rps, bf4stats(with json parse) and if so should I put bf4stats and bfhstats and bf3stats all in the same file?