mIRC Home    About    Download    Register    News    Help

Print Thread
#255732 16/11/15 05:28 AM
Joined: Nov 2015
Posts: 3
R
RivenPB Offline OP
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Nov 2015
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

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Code:
on *:text:*:#:{
  if ($regex($1-,/word/giS)) {
    inc %count $v1
  }
}


You'll have to escape special characters.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2015
Posts: 3
R
RivenPB Offline OP
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Nov 2015
Posts: 3
Does this count it if the emote is used multiple times in the same line?

Joined: May 2015
Posts: 133
K
Vogon poet
Offline
Vogon poet
K
Joined: May 2015
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
}

Last edited by keyeslol; 17/11/15 06:01 PM.

twitter @keyeslol
Joined: Nov 2015
Posts: 3
R
RivenPB Offline OP
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Nov 2015
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

Last edited by RivenPB; 18/11/15 04:11 AM.
Joined: May 2015
Posts: 133
K
Vogon poet
Offline
Vogon poet
K
Joined: May 2015
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.

Last edited by keyeslol; 18/11/15 05:39 AM.

twitter @keyeslol
Joined: May 2015
Posts: 133
K
Vogon poet
Offline
Vogon poet
K
Joined: May 2015
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
Joined: Aug 2003
Posts: 325
W
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
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.


Link Copied to Clipboard