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)