alias twitchfollow {
if !$2 { echo -ag syntax: twitchfollow <nick> <#channel> | return }
if $exists(temp.txt) { .remove temp.txt }
sockclose twitchfollow
sockopen -e twitchfollow api.twitch.tv 443
sockmark twitchfollow $1 $2
}
on *:sockopen:twitchfollow: {
if ($sockerr) {
echo -ag problem encountered, pls try again
}
else {
tokenize 32 $sock($sockname).mark
sockwrite -n $sockname GET $+(/kraken/users/,$1,/follows/channels/,$2) HTTP/1.1
sockwrite -n $sockname Host: api.twitch.tv
sockwrite -n $sockname Accept: application/vnd.twitchtv.v2+json
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
}
on *:sockread:twitchfollow: {
if ($sockerr) {
echo -ag problem encountered, pls try again
}
else {
var %r
sockread %r
while %r { sockread %r }
sockread &r
while $bvar(&r,0) {
bwrite temp.txt -1 -1 &r
sockread &r
}
}
}
on *:sockclose:twitchfollow: {
if $exists(temp.txt) { run temp.txt }
else { echo -ag Error: $sock($sockname) unable to retrieve data.. }
}