mIRC Home    About    Download    Register    News    Help

Topic Options
#255732 - 16/11/15 05:28 AM Twitch emote counter
RivenPB Offline
Self-satisified door

Registered: 16/11/15
Posts: 3
I'm new to mIRC and have been messing around with it for a couple days now and was wondering how I would go about making something that would count how many times a specific twitch emote is used (sort of like a kappa per minute counter but wouldn't be tied down by per minute, I would want it to continuously keep counting).

Cheers

Top
#255737 - 16/11/15 12:30 PM Re: Twitch emote counter [Re: RivenPB]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1264
Code:
on *:text:*:#:{
  if ($regex($1-,/word/giS)) {
    inc %count $v1
  }
}


You'll have to escape special characters.

Top
#255738 - 16/11/15 10:09 PM Re: Twitch emote counter [Re: Loki12583]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3496
Loc: France
I have to say, most of the time you give code, like not so easy for beginner to understand, and you give very little explanation if any. Here you give an on text event with a regex if statement and you say "you'll have to escape special characters". OP started by saying he is new to this, I'd say he has no idea what you are talking about.
I'm not saying regex are not a good solution here, but explaning a bit how they work in general etc would be a must here. Perhaps he wants them to be word only or something.
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#255741 - 17/11/15 04:19 AM Re: Twitch emote counter [Re: Loki12583]
RivenPB Offline
Self-satisified door

Registered: 16/11/15
Posts: 3
Does this count it if the emote is used multiple times in the same line?

Top
#255744 - 17/11/15 05:55 PM Re: Twitch emote counter [Re: RivenPB]
keyeslol Offline
Vogon poet

Registered: 15/05/15
Posts: 133
Yes it does.

To output, use the following:

Code:
on *:text:*:#:{
  if ($regex($1-,/word/giS)) {
    inc %count $v1
  }
  elseif ($1 == !count) {
    msg # word has been said %count times
  }
}


I also have another flavor, not using regex:

Code:
on *:text:*kappa*:*: {
  var %countkappa $wildtok($1-,*kappa*,0,32)

  if ($1 == !kappas) msg # kappa has been said %numkappa times

  else inc %numkappa %countkappa
}


Edited by keyeslol (17/11/15 06:01 PM)
_________________________
twitter @keyeslol

Top
#255755 - 18/11/15 03:30 AM Re: Twitch emote counter [Re: keyeslol]
RivenPB Offline
Self-satisified door

Registered: 16/11/15
Posts: 3
the second one makes more sense to me, although i'm reading up on regex i think once i read about it a bit more i'll more than likely use that laugh

Thanks

EDIT: also, how would i incorporate a cooldown into the first segment of code(the one with regex)? I have a basic cooldown snippet made I just can't seem to get it to work, i'd trying to get it to work on the second portion of the first segment where you can trigger a command to tell you how many times it's been used
Code:
if ((%floodcounter) || ($($+(%,floodcounter.,$nick),2))) { return }
  set -u30 %floodcounter On
  set -u40 %floodcounter. $+ $nick On


Edited by RivenPB (18/11/15 04:11 AM)

Top
#255756 - 18/11/15 05:07 AM Re: Twitch emote counter [Re: RivenPB]
keyeslol Offline
Vogon poet

Registered: 15/05/15
Posts: 133
Code:
on *:text:*:#:{
  if ((%floodcounter) || ($($+(%,floodcounter.,$nick),2))) { return }
  if ($regex($1-,/word/giS)) {
    set -u30 %floodcounter On
    set -u40 %floodcounter. $+ $nick On
    inc %count $v1
  }
  elseif ($1 == !count) {
    msg # word has been said %count times
  }
}

Just be sure what you want to do. With the above settings, it won't count it again for 30 seconds and 40 seconds per nick.


Edited by keyeslol (18/11/15 05:39 AM)
_________________________
twitter @keyeslol

Top
#255762 - 19/11/15 04:09 PM Re: Twitch emote counter [Re: keyeslol]
keyeslol Offline
Vogon poet

Registered: 15/05/15
Posts: 133
I realized i didn't answer your question correctly, the correct code should be:

Code:
on *:text:*:#:{
  if ($regex($1-,/word/giS)) {
    inc %count $v1
  }
  elseif ($1 == !count) {
    if ((%floodcounter) || ($($+(%,floodcounter.,$nick),2))) { return }
    set -u30 %floodcounter On
    set -u40 %floodcounter. $+ $nick On
    msg # word has been said %count times
  }
}
_________________________
twitter @keyeslol

Top
#255965 - 08/12/15 04:18 PM Re: Twitch emote counter [Re: RivenPB]
Wolfie Offline
Fjord artisan

Registered: 07/08/03
Posts: 325
Try this. When you connect, have this raw command executed:
Code:
RAW CAP REQ :twitch.tv/tags


Then in a parseline event, have it search for non blank emote use.
Code:
ON $*:PARSELINE:in:/^\S+;emotes=([^;]+);\S+ :\S+!\S+@\S+?(?:tmi|irc)\.twitch\.tv /i:{
  echo -tsg $regml(0) . $regml(1)
  var %emotes = $regex( $regml(1),/(\d+):([,\d-]+)/g)
  echo -tsg %emotes . $regml(0)
  while (%emotes) {
    var %count = $calc(%emotes * 2), %id = $calc(%count - 1)
    echo -tgs $scriptline :: %emotes : %id $regml(%id) > %count $regml(%count)
    INC -u50 [ [ $+(%,$me,.emotes.,$regml(%id)) ] ] $numtok($regml(%count),44)
    dec %emotes
  }
}

What this will do is set a variable named %(the nick being used as the bot).emotes.(emote id) and increment the value based on the number of times the emote was used. Variable unsets after 50 seconds (from the last time it's set).

For example, if the nick being used is ImmaBot and Kappa is used 3 times on one line and then 5 on the next line, the variable names and values would be as follows...
%ImmaBot.emotes.25 3
%ImmaBot.emotes.25 8


How it works is that it matches lines where emotes are actually being used, then it breaks that down into a grouping (emote id):(locations of the emotes) and then counts how many locations there are. Here's an example of it in action.

Code:
[11:13:11] <- @color=#8A2BE2;display-name=Wolfie713;emotes=25:0-4,30-34/166:6-13,21-28/354:15-19;subscriber=0;turbo=0;user-id=1;user-type=mod :Wolfie713!wolfie713@wolfie713.tmi.twitch.tv PRIVMSG #somechannel :Kappa Volcania 4Head Volcania Kappa


Notice this part of the line:
Code:
emotes=25:0-4,30-34/166:6-13,21-28/354:15-19

See the "25:0-4,30-34"? 25 is Kappa and 0-4,30-34 are the locations of the emote word, separated by commas. Count the number of tokens, in this instance, two. Each emote grouping is separated by a slash so we can see there are three different emotes used.

The little event script above has an echo command in it so it will echo the process to the status window, which makes it easy to test out to see it in action. Simply remove the echo lines and customize to your needs.

Top