First: Timi's json parser is showing its age, probably biased but I recommend using mine(found in signature)

Second: Your bot will need an OAUTH token for each channel/stream you wish to change the title/game for.

For just your stream(or streams of accounts you own) I have a script found under mtwitch that will give you a full-access OAUTH token, that can then be used to alter such.



Code:
alias -l OAUTH {
  goto $iif(#* iswm $1, $mid($1, 2-), $1)
  
  /* EDITS START HERE; REMOVE UNNEEDED LINES */
  
  :acount1 | return Account 1's oauth here
  :acount2 | return Account 2's oauth here
  :acount3 | return Account 3's oauth here
  
  /* EDITS END */
  
  :error
  reseterror
}

on $*:TEXT:/^!(status|game)(\s|$):#:{
  var %n = $lower($regml(1))
  var %json = TwitchStreamUpdate
  var %data

    if ($0 == 1) {
        JSONOpen -du %json https://api.twitch.tv/kraken/channels/ $+ $lower($mid(#, 2-))
        if ($JSONError) {
            msg # Unable to retrieve $lower(%n $+ .)
        }
        elseif ($json(%json, %n)) {
            msg # Current %n $+ : $v1
        }
        else {
          msg # Unable to retrieve $lower(%n $+ .)
        }
    }
    elseif ($nick != $mid(#,2-)) {
      return
    }
    elseif (!$OAUTH(#)) {
      return
    }
    else {
        var %data, %json = TwitchStreamUpdate
        if (%n == status) {
            %data = {"channel":{"status":" $+ $escape($2-) $+ "}}
        }
        else {
            %data = {"channel":{"game":" $+ $escape($2-) $+ "}}
        }
        

        JSONOpen -duw %json https://api.twitch.tv/kraken/channels/ $+ $lower($mid(#, 2-))
        JSONUrlMethod %json POST
        JSONUrlHeader %json Connection close
        JSONUrlHeader %json Accept application/vnd.twitchtv.v3+json
        JSONUrlHeader %json Content-type application/json
        JSONUrlHeader %json Content-length $len(%data)
        JSONUrlHeader %json Authorization OAuth $OAUTH(#)
        JSONUrlGet %json %data

        if ($jsonerror) {
            msg # Unable to update $lower(%n $+ .)
        }
        elseif ($JSON(%json, %n)) {
            msg # Updated $lower($1) $+ : $v1
        }
        else {
            msg # Unable to update $lower(%n $+ .)
        }
    }
}

alias -l escape return $regsubex($1-, /([^a-z\d_-\.])/gi, \ $+ \t)




Last edited by FroggieDaFrog; 07/01/16 09:48 PM.

I am SReject
My Stuff