mIRC Homepage
Posted By: powerade661 Help with viewer count script - 18/05/15 07:11 AM
So my current script grabs viewers that are only in the chat. What I am trying to do is exclude the count if there are certain users in the chat such as bots. Is it possible to do this?

Like if $nick == potatobot {return}
elseif $nick == anotherbot basically it doesn't count these usernames and they aren't added into the count along with the current channel.
An example of this would be if $nick == #

These are just examples of what I am trying to do. Any help with this would be much appreciated.

Code:
on *:text:!viewerupdate:#: {
  msg # Viewer update has been started
  .timer.update 0 1800 msg # Current viewers in chat -> $nick(#,0) 



}
on *:text:!viewerupdate off:#: {
  msg # Viewer update has been stopped
  .timer.update off
}

Posted By: splinny Re: Help with viewer count script - 18/05/15 07:27 AM
As i remember, timer will return $nick(#,0) NOT updated, it will always be same (as when timer started). You need to make an alias, where $nick(#,0) is used, and timer will use this alias, so $nick(#,0) will be real-time updated.
And to exclude some nicks, you can make "%exNicks botnick1 yournick botnick2" and use $istok(%exnicks,$nick(#,%x),32).
Posted By: powerade661 Re: Help with viewer count script - 18/05/15 07:33 AM
I have no idea how to do that. So is it only updating if it's not on a timer?
Posted By: splinny Re: Help with viewer count script - 18/05/15 08:08 AM
Type in your mIRC editbox: //timer 10 1 echo -ag $time
Same with $nick(#,0).
Posted By: Loki12583 Re: Help with viewer count script - 18/05/15 12:45 PM
You don't need an alias, you can use $!nick(#,0) in a timer to prevent the immediate evaluation.
Posted By: powerade661 Re: Help with viewer count script - 18/05/15 03:22 PM
So how would I code this exactly, I am not the best at lining up brackets.

Would it be this instead?

How do I make it so that the current channel is excluded?

Is it "%exNicks #" for the current channel?

Code:
on *:text:!viewerupdate:#: {
  msg # Viewer update has been started
  .timer.update 0 1800 msg # Current viewers in chat ->  
$!nick(#,0)
%exNicks wizebot zacbot # $istok(%exnicks,$nick(#,%x),32)

}
on *:text:!viewerupdate off:#: {
  msg # Viewer update has been stopped
  .timer.update off
}

Posted By: powerade661 Re: Help with viewer count script - 18/05/15 04:07 PM
When I use $!nick(#,0) it doesn't return the number, it returns this There are $nick(#,0) viewers in the chat.
Posted By: splinny Re: Help with viewer count script - 18/05/15 04:10 PM
Use double "/".
Posted By: powerade661 Re: Help with viewer count script - 18/05/15 04:16 PM
Double / where? //$!nick(#,0) there?
Posted By: powerade661 Re: Help with viewer count script - 18/05/15 05:13 PM
This isn't working.. I have no idea what I am doing, please help

Code:
On *:text:!viewers:#:{
  %exNicks $wizebot $zacbot661 $chan $nightbot
  $istok(%exnicks,$nick(#,%x),32)
  msg # There are $nick(#,0) viewers in the chat. Take note, this does not exclude bots. 

}

Posted By: OrFeAsGr Re: Help with viewer count script - 21/05/15 12:42 PM
Hi there smile
Code:
on *:text:*:#: {
  if ($strip($1) == !viewerupdate) {
    if ($strip($2) == $null) {
      msg $chan Viewer Update Has Been Started 
      .timer.update 0 1800 sayviewers $chan zacbot661 nightbot wizebot
    }
    if ($strip($2) == off) {
      msg $chan Viewer Update has been stopped
      .timer.update off
    }
  }
}

alias sayviewers {
  set %viewers $nick($1,0)
  var %v = 1
  while (%v <= $nick($1,0)) {
    if ($istok($2-,$nick($1,%v),32)) {
      dec %viewers 1
    }
    inc %v
  }
  msg $1 %viewers
}

i tested this and it works exactly as you want it smile
If you want to exclude more nicks add them after the sayviewers $chan
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 01:01 AM
I am not sure if I am doing something wrong but I did !viewerupdate and it shows me the message "viewer update has been started" but I am not seeing the viewers being displayed.

I even lowered the timer to 0 30 and it still hasn't displayed anything frown
Posted By: OrFeAsGr Re: Help with viewer count script - 23/05/15 01:08 AM
Hey! Have you changed anything else? Maybe you accidentaly removed $chan after the sayviewers and the script cant send the msg to the channel.
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 01:20 AM
Apparently I couldn't predict 30 minutes from 30 seconds. It works lol Thanks for the help man. Is it possible to have it say Current viewers -> <number here> Also another question, are you good with sockets? I am trying to make it display followers and viewers. I am a huge newbie when it comes to sockets but I really want to learn how to do them. And I have tried looking at the justin.tv API but it is very confusing.
Posted By: OrFeAsGr Re: Help with viewer count script - 23/05/15 01:38 AM
Yeah just change the text after "msg $1" in the alias. %viewers is the number of viewers/users on channel , you can place it where ever you want in the msg.
I have done some work with sockets lately but im not so good at it yet.
I have seen some snippets in Hawkee though while trying to help a user.
I think this should work:
http://hawkee.com/snippet/16083/
Or this:
http://hawkee.com/snippet/16083/
smile
Np!
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 01:41 AM
No I was talking about the follower count. Like Followers: 434 Viewers: 6. Is this possible?
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 02:48 AM
The current script isn't working now... -_-

Code:
on *:text:*:#: {
  if ($strip($1) == !viewerupdate) {
    if ($strip($2) == $null) {
      msg $chan Viewer Update Has Been Started 
      .timer.update 0 1800 sayviewers $chan zacbot661 nightbot wizebot
    }
    if ($strip($2) == off) {
      msg $chan Viewer Update has been stopped
      .timer.update off
    }
  }
}

alias sayviewers {
  set %viewers $nick($1,0)
  var %v = 1
  while (%v <= $nick($1,0)) {
    if ($istok($2-,$nick($1,%v),32)) {
      dec %viewers 1
    }
    inc %v
  }
  msg  $1 Viewers -> %viewers
}
Posted By: Belhifet Re: Help with viewer count script - 23/05/15 02:49 AM
Sure its possible. You need a json parser which a resident froggy has made.

Its kinda advanced scripting and obviously you aren't going to understand whats going on when you make it. It would really be best if you built on your knowledge instead of jumping into something you aren't quite ready for. Also this script kinda displays something thats already on the screen so its not all that important. --I guess this only applies if you are interested in learning msl..heh.


anyway using the json parser of froggiesomething

Code:
alias followcount {
  JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $1
  return $json(followcount, followers)
}
on *:text:!viewers:#:{
msg # $followcount($chan) people following and w/e you want.
}


Posted By: powerade661 Re: Help with viewer count script - 23/05/15 03:02 AM
Thank you so much! I definitely appreciate your time. smile
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 03:18 AM
Weird. It's saying insufficient parameters.
Posted By: westor Re: Help with viewer count script - 23/05/15 11:58 AM
Originally Posted By: powerade661
Weird. It's saying insufficient parameters.


Try change the line of the above code to : $followcount($mid($chan,2))
Posted By: Nillen Re: Help with viewer count script - 23/05/15 12:25 PM
Remove the # tag from the #channel. The url would become https://api.twitch.tv/kraken/channels/#channel instead of https://api.twitch.tv/kraken/channels/channel

Changes to the code:
Code:
alias followcount {
  JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $1
  return $json(followcount, followers)
}
on *:text:!viewers:#:{
msg # $followcount($mid($chan,2)) people following and w/e you want.
}


type " /help $mid " for further understanding, but essentially it takes the 2nd letter (c) from $chan (#channel) and everything behind it and makes it (channel)
Posted By: FroggieDaFrog Re: Help with viewer count script - 23/05/15 04:34 PM
Posting since no one has linked my JSON parser yet.

(Geez people, if you are going to talk about it, give the link so users don't have to jump all over the board looking for it :P )

Also:
Code:
on *:text:!viewers:#:{
  JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $mid(#, 2-)
  msg # $json(followcount, followers) people following and w/e you want.
}
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 06:53 PM
Thank you so much Froggie! Last question, you will see exactly what I am trying to do once you look at the code. Thank you guys for all of your help. I could not have done this without you. Also in this code, is it possible to make it to when the streamer leaves, it is turned off? would you do

on !*:PART:$chan:{
.timer.update off

Code:
on *:text:*:#: {
  if ($strip($1) == !viewerupdate) {
    if ($strip($2) == $null) {
      msg $chan Viewer Update Has Been Started 
      .timer.update 0 10 sayviewers $chan zacbot661 nightbot wizebot
    }
    if ($strip($2) == off) {
      msg $chan Viewer Update has been stopped
      .timer.update off
    }
  }
}

alias sayviewers {
  set %viewers $nick($1,0)
  var %v = 1
  while (%v <= $nick($1,0)) {
    if ($istok($2-,$nick($1,%v),32)) {
      dec %viewers 1
    }
    inc %v
  }

  JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $mid(#, 2-)
  msg followers -> # $json(followcount, followers) $1 Viewers -> %viewers

}



Posted By: splinny Re: Help with viewer count script - 23/05/15 07:23 PM
Use json for https://api.twitch.tv/kraken/streams/ $+ %streamer_name - returns error when offline.
Posted By: OrFeAsGr Re: Help with viewer count script - 23/05/15 07:30 PM
Yeah you got that right, just add it to the remote.
Although it's not nessecary i would do it this way
Code:
on *:part:#: {
if ($timer(.update)) {
.timer.update off
}
}

Added an if which checks if the timer is active, in order to avoid error messages.
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 07:32 PM
So I would put this below the rest of the code? So this just checks if the timer is off? Or does it also check if it's on? I don't really understand what you have done here.
Also I had to exclude my channel otherwise it would count me as a viewer. It's not excluding $chan frown Also is it possible to exclude the # and just put the channel name?
Posted By: OrFeAsGr Re: Help with viewer count script - 23/05/15 07:50 PM
It checks if the timer is on and if it is it does /timer.update off
Yes smile just put it under the rest of the code and yes you can replace # with your channel
Code:
on *:part:#channel: {
if ($timer(.update)) {
.timer.update off
}
}

wink this will only work for #channel ,replace #channel with the channel you want it to work for
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 07:53 PM
It won't work for any channel? on*:part $chan ? That doesn't work for all channels? If one channels leave it disables the timer for that channel?
Posted By: OrFeAsGr Re: Help with viewer count script - 23/05/15 08:08 PM
The whole script is made so that it sends the msg to the channel where you gave the command !viewerupdate .
Now, do you want the timer to stop when someone parts that channel ?
If so, use this code instead:
Code:
on *:text:*:#: {
  if ($strip($1) == !viewerupdate) {
    if ($strip($2) == $null) {
set %viewerschan $chan
      msg $chan Viewer Update Has Been Started 
      .timer.update 0 10 sayviewers $chan zacbot661 nightbot wizebot
    }
    if ($strip($2) == off) {
      msg $chan Viewer Update has been stopped
      .timer.update off
    }
  }
}

alias sayviewers {
  set %viewers $nick($1,0)
  var %v = 1
  while (%v <= $nick($1,0)) {
    if ($istok($2-,$nick($1,%v),32)) {
      dec %viewers 1
    }
    inc %v
  }
  JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $mid(#, 2-)
  msg followers -> # $json(followcount, followers) $1 Viewers -> %viewers
}

on *:part:#: {
if ($chan == %viewerschan) {
if ($timer(.update)) {
.timer.update off
}
}
}

Example:
If you start the timer in #test , if someone parts from #test the timer will be stopped.
If someone parts #blabla the timer wont stop smile
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 08:14 PM
I want to make it so that if the streamer leaves the timer stops.

I thought that is what $chan was. Am I missing something? I was able to remove the # by doing $remove(#,$chr(35)) the only issue now is uppercasing the first letter for the channel. So in order to get it for the stream channel I would have to do on *:part:#channel for each individual streamer?
Posted By: OrFeAsGr Re: Help with viewer count script - 23/05/15 08:33 PM
the last code i gave you will stop the timer if someone parts the channel smile
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 08:34 PM
But is that if anyone parts the channel? Or just the streamer, the timer stops? Sorry I am being so meticulous. Wait a second

if ($chan == %viewerschan) { that's how it knows if the streamer parted? Am I wrong or right?
Posted By: westor Re: Help with viewer count script - 23/05/15 08:40 PM
Originally Posted By: powerade661
But is that if anyone parts the channel? Or just the streamer, the timer stops? Sorry I am being so meticulous. Wait a second

if ($chan == %viewerschan) { that's how it knows if the streamer parted? Am I wrong or right?


@powerade661, if you pay attention what does @OrFeaSGr saying you will be able to understand..
Posted By: powerade661 Re: Help with viewer count script - 23/05/15 08:43 PM
I see it now, sorry OrFeAsGr.
Posted By: powerade661 Re: Help with viewer count script - 24/05/15 12:15 AM
Do I have to close the JSONopen? It doesn't update the followers in other channels. It worked for one channel and then another, and then it stayed with one channel and it won't update anymore. frown I have no idea what is going on.

Code:
on *:text:*:#: {
  if ($strip($1) == !viewerstatus) {
    if ($strip($2) == $null) {
      sayviewers $chan zacbot661 nightbot wizebot coolkid661

    }
  }
}

alias sayviewers {
  set %viewers $nick($1,0)
  var %v = 1
  while (%v <= $nick($1,0)) {
    if ($istok($2-,$nick($1,%v),32)) {
      dec %viewers 1
    }
    inc %v
  }

  JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $mid(#, 2-)
  msg # Stream status for $remove(#,$chr(35)) Followers: # $json(followcount, followers) Viewers: %viewers
}
Posted By: powerade661 Re: Help with viewer count script - 24/05/15 02:55 AM
Guys I do apologize. The computer I was hosting the bot on was very slow and I just figured out why it wasn't working very well. One core was slower than the other and after making changes, the script works very efficiently. Thanks for your time and patience with me.
Posted By: powerade661 Re: Help with viewer count script - 24/05/15 03:43 AM
It's not putting the message in the chat, only through TMI. Any ideas? It only updates the followers if I restart mIRC. -_- This is so confusing.

Code:
on *:text:*:#: {
  if ($strip($1) == !viewerupdate) {
    if ($strip($2) == $null) {
set %viewerschan $chan
      msg $chan Viewer Update Has Been Started 
      .timer.update 0 60 sayviewers $chan intellibot_v2.0 nightbot wizebot
    }
    if ($strip($2) == off) {
      msg $chan Viewer Update has been stopped
      .timer.update off
    }
  }
}

alias sayviewers {
  set %viewers $nick($1,0)
  var %v = 1
  while (%v <= $nick($1,0)) {
    if ($istok($2-,$nick($1,%v),32)) {
      dec %viewers 1
    }
    inc %v
  }
  JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $mid(#, 2-)
  msg # Stream update, followers: $json(followcount, followers) Viewers: %viewers
}

on *:part:#: {
if ($chan == %viewerschan) {
if ($timer(.update)) {
.timer.update off
}
}
}
Posted By: powerade661 Re: Help with viewer count script - 24/05/15 07:34 PM
Does anyone have any idea why this is happening? It's still not placing the message in the chat and it's not updating the follower count unless I restart mIRC. Also I am thinking the timer is stopping if someone leaves the stream, instead of the streamer.
Posted By: FroggieDaFrog Re: Help with viewer count script - 24/05/15 07:35 PM
change msg # to msg $1 in sayviewers

and because I'm a nice person with a nack for mSL:
Code:
on $*:text:/^!viewerupdate(\s|$)/Si:#: {
  if ($2 == off && $timer(FollowerUpdate $+ $cid $+ #)) {
    $+(.timerFollowerUpdate,$cid,#) off
  }
  elseif ($0 == 1) {
    msg $chan Viewer Update Has Been Started 
    $+(.timerFollowerUpdate,$cid,#) 0 60 sayviewers $chan intellibot_v2.0 nightbot wizebot
  }
}

on *:part:#: {
  if ($mid(#, 2-) == $nick && $timer(FollowerUpdate $+ $cid $+ #)) {
    $+(.timer,$v1) off
  }
}

alias sayviewers {
  var %i = 1, %viewers = 0
  while (%i <= $nick($1, 0)) {
    if (!$istok($2-, $nick($1, %i), 32)) {
      inc %viewers
    }
    inc %v
  }
  JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $mid($1, 2-)
  msg $1 Stream update, followers: $json(followcount, followers) Viewers: %viewers
}
Posted By: powerade661 Re: Help with viewer count script - 24/05/15 07:39 PM
Where it is msg # under the JSONOpen? Change that to $1?
Posted By: FroggieDaFrog Re: Help with viewer count script - 24/05/15 07:45 PM
I added a fixed script to my previous post smile
Posted By: powerade661 Re: Help with viewer count script - 24/05/15 09:55 PM
It's still not displaying the message. I waited an hour. frown
Posted By: FroggieDaFrog Re: Help with viewer count script - 24/05/15 10:58 PM
Are you trying to get this to trigger using the same client its running on?
Posted By: powerade661 Re: Help with viewer count script - 25/05/15 01:40 AM
I went to my chat and typed !viewerupdate it says "viewer update has been started" and then it doesn't display any message after 60 seconds in my chat.
Posted By: powerade661 Re: Help with viewer count script - 25/05/15 05:15 AM
Every time I do !viewerupdate, mIRC becomes completely unresponsive. It didn't do this with the other script, I don't understand what is going on. I even moved mIRC to another computer and still the same results. Please help frown Currently this is the only script that works, but it doesn't display the follower count.


Code:
on *:text:*:#: {
  if ($strip($1) == !viewerupdate) {
    if ($strip($2) == $null) {
set %viewerschan $chan
      msg $chan Viewer Update Has Been Started 
      .timer.update 0 60 sayviewers $chan intellibot_v2.0 nightbot wizebot
    }
    if ($strip($2) == off) {
      msg $chan Viewer Update has been stopped
      .timer.update off
    }
  }
}

alias sayviewers {
  set %viewers $nick($1,0)
  var %v = 1
  while (%v <= $nick($1,0)) {
    if ($istok($2-,$nick($1,%v),32)) {
      dec %viewers 1
    }
    inc %v
  }
  JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $mid(#, 2-)
  msg $1 Stream update for $remove(#,$chr(35)) followers: $json(followcount, followers) Viewers: %viewers
}

on *:part:#: {
if ($chan == %viewerschan) {
if ($timer(.update)) {
.timer.update off
}
}
}




This script displays the follower count.

Code:

on *:text:*:#: {
  if ($strip($1) == !streamstatus) {
    if ($strip($2) == $null) {
      sayviewers $chan vector_bot nightbot wizebot

    }
  }
}

alias sayviewers {
  set %viewers $nick($1,0)
  var %v = 1
  while (%v <= $nick($1,0)) {
    if ($istok($2-,$nick($1,%v),32)) {
      dec %viewers 1
    }
    inc %v
    }
  JSONOpen -ud followcount https://api.twitch.tv/kraken/channels/ $+ $mid(#, 2-)
  msg $1 Stream status for $remove(#,$chr(35)) followers: $json(followcount, followers) Viewers: %viewers
}


Posted By: powerade661 Re: Help with viewer count script - 25/05/15 11:01 AM
I have been trying to figure out this all night. I have came to the conclusion (is this possible) when I execute the command without the timer, it is parsing JSON, but when I do it through the timer, it is only displaying the message without parsing JSON. Could this be the case, does anyone have any idea? The current script works and stops when the streamer leaves. It's just the follower count that doesn't work.
Posted By: FroggieDaFrog Re: Help with viewer count script - 25/05/15 12:56 PM
I had a few typo's in my script.

Here's an update:
Code:
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 # intellibot_v2.0 nightbot wizebot
  }
}
on *:part:#: {
  if (!$istwitch) { return }
  if ($mid(#, 2-) == $nick && $timer(FollowerUpdate $+ $cid $+ #)) {
    $+(.timer, $v1) off
  }
}
alias sayviewers {
  if (!$istwitch) { return }
  var %i = 1, %v = 0
  while (%i <= $nick($1, 0)) {
    if (!$istok($2-, $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)


And here is the output:
Posted By: powerade661 Re: Help with viewer count script - 25/05/15 07:45 PM
Thank you so much! It works great! I appreciate your time and patience with me. Have a good day!
Posted By: powerade661 Re: Help with viewer count script - 25/05/15 10:29 PM
Quick question, how would I increase the time to 30 minutes instead of 60 seconds? Would I put it place of where ever 1 60 are?
Posted By: FroggieDaFrog Re: Help with viewer count script - 25/05/15 10:54 PM
replace the 60 with the number of SECONDS. so instead of
Code:
timer... 1 60 ...


you'd have the following for 30 minutes
Code:
timer... 1 1800 ...
Posted By: powerade661 Re: Help with viewer count script - 25/05/15 11:02 PM
It's not updating the follower count, I still have to restart mIRC in order to get it to update. Also it's not the excluding the channel. frown
Posted By: powerade661 Re: Help with viewer count script - 25/05/15 11:52 PM
Well never mind, it's not updating the follower count even when I restart mIRC anymore.
Posted By: powerade661 Re: Help with viewer count script - 26/05/15 07:04 AM
Update, I have to restart the computer in order for it to update now. Is there anyway to refresh this so I don't have to restart the computer?
Posted By: FroggieDaFrog Re: Help with viewer count script - 26/05/15 01:28 PM
as far as I've tested, it should continue to update unless it encounters an error. To restart the update process, use !viewerupdate again

Just to make sure, you do have the json parser from my signature installed aswell, correct?
Posted By: powerade661 Re: Help with viewer count script - 26/05/15 04:00 PM
How do I install that? No I don't.
Posted By: powerade661 Re: Help with viewer count script - 26/05/15 04:02 PM
Never mind, I just installed it. Testing it now.
Posted By: powerade661 Re: Help with viewer count script - 26/05/15 04:17 PM
Just to make sure I am installing this correctly, I go to file, then new and copy and paste the JSON parser into there correct?
Posted By: powerade661 Re: Help with viewer count script - 26/05/15 05:16 PM
Ok the script works but it is still not excluding the channel. It still counts the channel as a viewer. I installed the JSON parser and everything works as it should, it updates and everything.
Posted By: FroggieDaFrog Re: Help with viewer count script - 26/05/15 06:15 PM
so you want to ignore both a list of bots, and the streamer?


If that is the case:
Code:
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 # intellibot_v2.0 nightbot wizebot
  }
}
on *:part:#: {
  if (!$istwitch) { return }
  if ($mid(#, 2-) == $nick && $timer(FollowerUpdate $+ $cid $+ #)) {
    $+(.timer, $v1) 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)
Posted By: powerade661 Re: Help with viewer count script - 26/05/15 10:08 PM
I have tested it, and now it's not stopping the timer if the streamer leaves. Any ideas? Everything else is working fine.
Posted By: powerade661 Re: Help with viewer count script - 26/05/15 10:25 PM
How long should I wait for it to update. Does anyone know?
Posted By: powerade661 Re: Help with viewer count script - 27/05/15 08:19 PM
Ok so the update is, it works for a while and then it will just stay with one channel and it won't grab the data from the API. I have tried allowing mIRC through the firewall private and public, I didn't really want to turn off my firewall, but I did just to test and it still did the same thing. I don't really know what's going on. Would anyone recommend I reinstall windows and start over from scratch? That's literally the only thing I haven't tried. The timer also doesn't stop when the streamer leaves. Any help with this would be much appreciated. I have tried everything.
Posted By: Loki12583 Re: Help with viewer count script - 27/05/15 09:29 PM
If you tried everything you'd be able to identify the point of failure. Reinstalling mIRC, let alone Windows, would have no effect.
Posted By: powerade661 Re: Help with viewer count script - 27/05/15 10:09 PM
Let me rephrase that. I have tired everything that I know how to do.
Posted By: powerade661 Re: Help with viewer count script - 27/05/15 10:22 PM
Also the reason why I said should I reinstall windows is because when I moved the program over to another computer it allocated over 4GB of RAM. But when I moved it to the computer it was on before, it only allocated 1.12GB of RAM. I am thinking there could be an issue with the operating system. The application is very unresponsive most of the time as well.
Posted By: powerade661 Re: Help with viewer count script - 28/05/15 07:41 AM
Any ideas as to why it's not stopping the timer when the streamer leaves?
Posted By: powerade661 Re: Help with viewer count script - 28/05/15 09:27 AM
Never mind I figured it out. Here is the fixed code for anyone wondering.

Code:
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)
© mIRC Discussion Forums