on *:TEXT:!title:#: {
;; create a JSON handle
;; that will retrieve data from a url(-u)
;; but wait(-w) for /JSONHttpFetch to be called before making the request
;; once this script finishes, destroy the handle(-d)
JSONOpen -uwd streamtitle https://api.twitch.tv/kraken/channels/ $+ $remove($chan,$chr(35))
;; Set the Client-ID request header
JSONHttpHeader streamtitle Client-ID avm4vi7zv0xpjkpi3d4x0qzk8xbrdw8
;; make the request to twitch
JSONHttpFetch streamtitle
;; check for errors and that the response from twitch's servers
;; contains a value for 'status'
if (!$JSONError && $JSON(streamtitle, status).value !== $null) {
;; msg the channel with that value
msg $chan [Title] $v1
}
;; an error occurred
else {
msg $chan [Title] An error occured
}
}