mIRC | Twitch StreamTip

By Nucloid93 on May 02, 2016

I put together a simple StreamTip script for my Twitch bot. This is using streamtip query string APi.

You will need to use your client_id & access_token to use AUTH related APi. This script has the id & token stored in a file to prevent people from stealing your codes.

O-AUTH Example URLs:

CheckNewDonations Alias:
This alias is meant for checking if there is a new donation. I have this alias on a timer to check every 15 seconds.

StreamTip APi:
https://streamtip.com/api

JSON for mIRC:
http://hawkee.com/snippet/10194/

Commands:
!toptips - Shows the top tips for your streamtip account.
!lasttip - Shows the last tip recieved.
!currentgoal - Shows the main current tip goal for your account
!donate - Shows your streamtip link.
!dping - Shows if the streamtip APi is up.

on *:text:!toptips:*: {
  TopTips
}

alias TopTips {
  var %lasttipURL = E: \filelocation\streamtip_toptipsURL.txt
  var %link = $read(%lasttipURL)
  var %v = twc_ $+ $ticks
  JSONOpen -ud %v %link
  var %top0 = $JSON(%v,tips,0,username)
  var %top1 = $JSON(%v,tips,1,username)
  var %top2 = $JSON(%v,tips,2,username)
  var %top3 = $JSON(%v,tips,3,username)
  var %top4 = $JSON(%v,tips,4,username)
  msg $chan Top tippers: %top0 $+ , %top1 $+ , %top2 $+ , %top3 $+ , %top4 $+ . Thanks for the amazing support! <3
  :end
  JSONClose %v
}

on *:text:!lasttip:*: {
  LastTipFound
}

alias LastTipFound {
  var %lasttipURL = E: \filelocation\streamtip_tipslistURL.txt
  var %link = $read(%lasttipURL)
  var %v = twc_ $+ $ticks
  JSONOpen -ud %v %link
  var %tipName = $JSON(%v,tips,0,username)
  var %tipCount = $JSON(%v,tips,0,amount)
  var %tipSymbol = $JSON(%v,tips,0,currencySymbol)
  var %tipDate = $JSON(%v,tips,0,date)
  msg $chan Last tip recieved from %tipName for %tipSymbol $+ %tipCount $+ . thanks for the support! <3
  :end
  JSONClose %v
}

alias CheckNewDonations { 
  //echo checking for new tips from streamtip!
  var %lasttipURL = E: \filelocation\streamtip_checkerURL.txt
  var %link = $read(%lasttipURL)
  var %v = twc_ $+ $ticks
  JSONOpen -ud %v %link
  var %currentTipCount = $JSON(%v,_count)
  var %currentTipID = $JSON(%v,tips,0,_id)
  var %previousTipID = %currentTipID
  var %tipName = $JSON(%v,tips,0,username)
  var %tipCount = $JSON(%v,tips,0,amount)
  var %tipSymbol = $JSON(%v,tips,0,currencySymbol)
  var %tipDate = $JSON(%v,tips,0,date)
  if (%currentTipCount != %previousTipID) {
    msg $chan /me %tipName just tipped %tipSymbol $+ %tipCount $+ . thanks for the support! <3 <3
    return
  }
  else if (%currentTipCount == %previousTipID) {
    return
  }
  :end
  JSONClose %v
}

on *:text:!currentgoal:*: {
  if (!%currentgoal) {
    set -u1800 %currentgoal 1
    currgoal 
  }
  else msg $chan 30 minute cooldown still active!
}

on *:text:!dping:*: {
  if (($nick isop $chan) || ($nick == <username>)) || (($hasmodpowers) || ($isbroadcaster)) {
    dpingpong 
  }
  else msg $chan %gloperm
}

alias currgoal {
  var %u = https://streamtip.com/api/public/twitch/channel/goal
  var %v = twc_ $+ $ticks
  JSONOpen -ud %v %u
  ;; Returns server code. 200 = good. Anything else bad
  var %status = $JSON(%v,status)   
  ;; Title of goal
  var %title = $JSON(%v,goal,title)  
  ;; Total amount of goal 
  var %totalamount = $JSON(%v,goal,amount)
  ;; The actual progress of the goal
  var %progressamount = $JSON(%v,goal,progress,amount)
  ;; Currency symbol $ ¥ £
  var %currsym = $JSON(%v,goal,progress,currencySymbol)
  ;; The amount of tips contributed to amount
  var %currtips = $JSON(%v,goal,progress,tips)
  ;; The % percentage breakdown of the donation goal
  var %currpercen = $JSON(%v,goal,progress,percentage) 
  ;;
  ;;
  ;;
  msg $chan /me %title
  msg $chan /me %progressamount of %totalamount with %currtips tips.
  msg $chan /me https://streamtip.com/t/channel
  :end
  JSONClose %v
}

on *:text:!donate:#: {
  var %u = https://streamtip.com/api/public/twitch/channel/goal
  var %v = twc_ $+ $ticks
  JSONOpen -ud %v %u
  ;; Title of goal
  var %title = $JSON(%v,goal,title) 
  msg $chan if you want to support @lustredust, you can donate here! https://streamtip.com/t/channel/  - CurrentGoal: %title
  :end
  JSONClose %v
}

alias dpingpong {
  var %u = https://streamtip.com/api/public/twitch/channel
  var %v = twc_ $+ $ticks
  JSONOpen -ud %v %u
  var %status = $JSON(%v,status)
  var %name = $JSON(%v,name)
  var %prov = $JSON(%v,provider)
  msg $chan Streamtip Ping Pong: %status
  :end
  JSONClose %v
}

Comments

Sign in to comment.
NLRP050   -  Oct 04, 2016

You think this, or parts of this, will work with TwitchAlerts?

Technically, Editing it just a little bit, It should work.

I took the "alias CheckNewDonations" and tweaked it a little so it compares to the API page from TwitchAlerts.

Thats the only part i use and i have the following when i connect mIRC to the channel:
on 1:CONNECT:#channelname {
CheckNewDonations
}

(I'm not the best at working in mIRC.)

 Respond  
Bestpeff   -  May 05, 2016

Where do the URLs take place?? I understand that you need the client id and token but where do they go?? :/

Nucloid93  -  May 06, 2016

I have the script setup so that you need to read the URL out of a hidden flat file. For example, "var %lasttipURL = E: \filelocation\streamtip_toptipsURL.txt". I did it this way because I host my scripts on BitBucket and don't want my ID and token being released. If you really wanted to, you can remove "var %lasttipURL = E: \filelocation\streamtip_toptipsURL.txt" and use "var %link = https://streamtip.com/api/tips?client_id=Client_ID&access_token=Access_Token"

Sign in to comment

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.