on $*:text:/^!viewerupdate(\s|$)/Si:#: {
if (!$istwitch) { return }
if ($2- == off && $nick isop # && $timer(FollowerUpdate $+ $cid $+ #)) {
$+(.timerFollowerUpdate, $cid, #) off
msg # Viewer update has been stopped
}
elseif ($0 == 1) {
msg $chan Viewer Update Has Been Started
$+(.timerFollowerUpdate, $cid, #) 1 60 sayviewers # nightbot wizebot moobot
}
}
on *:part:#: {
if (!$istwitch) { return }
if ($mid(#, 2-) == $nick && $timer(FollowerUpdate $+ $cid $+ #)) {
$+(.timerFollowerUpdate, $cid, #) off
}
}
alias sayviewers {
if (!$istwitch) { return }
var %i = 1, %v = 0, %ignore = $mid($1-,2-)
while (%i <= $nick($1, 0)) {
if (!$istok(%ignore, $nick($1, %i), 32)) {
inc %v
}
inc %i
}
JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $mid($1, 2-)
msg $1 Stream update, followers: $json(followcount, followers) Viewers: %v
$+(.timerFollowerUpdate, $cid, $1) 1 60 sayviewers $1-
}
alias -l isTwitch return $iif($status == connected && $regex($server, /^(?:tmi|irc)\.twitch\.tv$/i), $true, $false)