mIRC Home    About    Download    Register    News    Help

Print Thread
[Twitch] Commands running independently for users #253892 11/07/15 06:34 PM
Joined: Jul 2015
Posts: 5
J
Jadester Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
J
Joined: Jul 2015
Posts: 5
Hey there, I've been making a simple bot for counter strike streams that creates statistics of how many times the word "VAC" (the games anti-cheat) is spammed in a certain time frame. Here's the source.

Code:
on *:TEXT:>vacbot:#: {
  msg $chan Hello, I'm VAC Bot! I was developed by Jadester_ to see the exact number of VACs/second spammed in chat. For now, this bot is exclusive to Jadester_, but plans to be open soon!
}
on *:TEXT:>ping:#: {
  msg $chan Pong OMGScoots ? 
}
on *:text:*:#: {
  if ($1 == vac) { inc %vac.times }
  elseif ($1 == >vaccount) { msg $chan VAC has been been spammed %vac.times times in the last %pers.times seconds, or more precisely $calc(%vac.times / %pers.times) VACs/second. | .timerVac off | %vac.times = 0 | %pers.times = 0  }
  elseif ($1 == >vacstart) { %vac.times = 0 | %pers.times = 0 | .timerVac 0 1 inc %pers.times | .msg $chan VAC/second count started, type >vaccount for results $+ . }
  elseif ($1 == >debug) msg $chan vac: %vac.times pers: %pers.times $+ .
}


It's very simple and has silly work arounds to make it work with my knowledge of msl. I want to make this bot public, but the problem is if two users try to start the counter using the ">vacstart" command, the variables are overridden and can't handle two separate counts going on at once.

Is there a way to make it so two different users could run their own counts? Thanks!

Re: [Twitch] Commands running independently for users [Re: Jadester] #253893 11/07/15 06:40 PM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
Originally Posted By: Jadester
Is there a way to make it so two different users could run their own counts? Thanks!

Different - you mean for different streams?


Dont give a fish - teach to fish!
Re: [Twitch] Commands running independently for users [Re: splinny] #253894 11/07/15 06:52 PM
Joined: Jul 2015
Posts: 5
J
Jadester Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
J
Joined: Jul 2015
Posts: 5
No, sorry I should have been more clear! I mean in the same channel, if two people are trying to use the ">vacstart" in the same time frame it doesn't work properly.

Re: [Twitch] Commands running independently for users [Re: Jadester] #253895 11/07/15 07:00 PM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
1. Why not to use only last on-text event with
Code:
:*:#:
and check ">vacbot" and ">ping" there.
2.
Code:
results $+ .
and
Code:
OMGScoots ?
looks like a minor exterior errors.
3. About different - check (%vac.times > 0) or ($timer(vac)) for >vacstart - so it wont work more then once untill >vaccount.
4. Why do you need >vacstart? Check the same stuff for ($1 == vac) - so first "vac" will start all the stuff as >vacstart do.


Dont give a fish - teach to fish!
Re: [Twitch] Commands running independently for users [Re: splinny] #253896 11/07/15 07:05 PM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
5. Check for mod status and\or make flood-protection for commands.


Dont give a fish - teach to fish!
Re: [Twitch] Commands running independently for users [Re: splinny] #253897 11/07/15 07:52 PM
Joined: Jul 2015
Posts: 5
J
Jadester Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
J
Joined: Jul 2015
Posts: 5
Hey there, thanks for the reply. Yeah, It looks like for your 1 and 2 points I did have a couple errors, number 3 is needed though as twitch doesnt recognize it as an emote with the question mark directly after it smile

For your 3. point, this actually would help somewhat, but a different user could end someone elses vac/s count, and they still couldn't count two instances simultaneously.

And for 4, I dont want this timer running if anyone says VAC, only if i'm looking for the VAC/s in a certain time window.

Thanks!

Edit: Hadn't seen your 5th point. I want this bot to be open to EVERYONE, not just mods. Also the flood Idea could work, but still doesn't let me have multiple users using this
simultaneously.

Last edited by Jadester; 11/07/15 07:57 PM.
Re: [Twitch] Commands running independently for users [Re: Jadester] #253898 11/07/15 08:31 PM
Joined: Jul 2015
Posts: 5
J
Jadester Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
J
Joined: Jul 2015
Posts: 5
Okay, after some thought I think I have come to the decision that my original question is pretty much impossible. I've decided that I would use the suggestion @splinny gave me. Heres the edited source:
Code:
on *:TEXT:>vacstart:#: {
  if (%pers.times < 1) { %vac.times = 0 | %pers.times = 0 | .timerVac 0 1 inc %pers.times | .msg $chan VAC/second count started, type >vaccount for results. }
  else msg $chan A VAC count is already in progress. Type ">vaccount" to end current count and get results. 
}
on *:TEXT:>vacbot:#: {
  msg $chan Hello, I'm VAC Bot! I was developed by Jadester_ to see the exact number of VACs/second spammed in chat. For now, this bot is exclusive to Jadester_, but plans to be open soon! For now you can get the source code here and try it in your own channel! http://pastebin.com/XFA6Zu57 To use this bot type ">vacstart" to begin the count and ">vaccount" to end it and get results. 
}
on *:TEXT:>ping:#: {
  msg $chan Pong OMGScoots ? 
}
on *:TEXT:>vaccount:#: {
  if (%pers.times > 1) { msg $chan VAC has been been spammed %vac.times times in the last %pers.times seconds, or more precisely $calc(%vac.times / %pers.times) VACs/second. | .timerVac off | %vac.times = 0 | %pers.times = 0  } 
  else msg $chan A VAC count hasn't been started yet. Type ">vacstart" to begin the count, then type ">vaccount" to get results.
}
on *:text:vac:#: {
  inc %vac.times 
}
on *:text:>debug:#: {
  msg $chan vac: %vac.times pers: %pers.times $+ .
}

I decidied to give every command its own on text call, instead of an all call as it was previously. It makes the script longer but is easier for me to work with. In the end I'll probally end up making it restricted to my $user tag, but if I get an idea of how to make it work for a heavy amount of users I'll implement it.

Thanks all

Re: [Twitch] Commands running independently for users [Re: Jadester] #253899 11/07/15 08:41 PM
Joined: Jul 2015
Posts: 5
J
Jadester Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
J
Joined: Jul 2015
Posts: 5
Ooh, I found a way for it to run for 2 different users, 1 lane for OP's and 1 lane for viewers! Really proud of how this came out smile
Code:
on *:TEXT:>vacstart:#: {
  if (%pers.times < 1) && ($nick == jadester_) { %vac.times = 0 | %pers.times = 0 | .timerVac 0 1 inc %pers.times | .msg $chan VAC/second count started, type >vaccount for results. }
  elseif (%persg.times < 1) && ($nick != jadester_) { %vacg.times = 0 | %persg.times = 0 | .timergVac 0 1 inc %persg.times | .msg $chan Guest: VAC/second count started, type >vaccount for results. }  
  else msg $chan A VAC count is already in progress. Type ">vaccount" to end current count and get results. 
}
on *:TEXT:>vacbot:#: {
  msg $chan Hello, I'm VAC Bot! I was developed by Jadester_ to see the exact number of VACs/second spammed in chat. To use this bot type ">vacstart" to begin the count and ">vaccount" to end it and get results. You can also get the source code from VAC_Bot's channel title.
}
on *:TEXT:>ping:#: {
  msg $chan Pong OMGScoots ? 
}
on *:TEXT:>vaccount:#: {
  if (%pers.times > 1) && ($nick == jadester_) { msg $chan VAC has been been spammed %vac.times times in the last %pers.times seconds, or more precisely $calc(%vac.times / %pers.times) VACs/second. | .timerVac off | %vac.times = 0 | %pers.times = 0  } 
  elseif (%persg.times > 1) && ($nick != jadester_) { msg $chan Guest: VAC has been been spammed %vacg.times times in the last %persg.times seconds, or more precisely $calc(%vacg.times / %persg.times) VACs/second. | .timerVacg off | %vacg.times = 0 | %persg.times = 0  }
  else msg $chan A VAC count hasn't been started yet. Type ">vacstart" to begin the count, then type ">vaccount" to get results.
}
on *:text:vac:#: {
  inc %vac.times
  inc %vacg.times 
}
on *:text:>debug:#: {
  msg $chan vac: %vac.times pers: %pers.times vacg: %vacg.times persg: %persg.times $+ .
}
on *:text:>commands:#: {
  msg $chan VAC Bot's commands are: >vacbot, >vacstart, >vaccount, >ping, >commands and >debug.
}

Last edited by Jadester; 11/07/15 09:15 PM.