mIRC Home    About    Download    Register    News    Help

Print Thread
#257215 22/03/16 07:06 AM
Joined: Mar 2016
Posts: 21
P
pykolas Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2016
Posts: 21
So I want to make script which counts words in twitch chat. For example, I turn bot on, he starts to count spam and everyone spams word "twitch". So bot counts every "twitch" word and stores number somewhere. after 10s when there is no new "twitch" word, bot turns off and writes down how much words was spammed and resets smile I am new to mirc, I am looking how to code, but to make this one is to hard for me, and this would help me to better understand how mirc works smile

Last edited by pykolas; 22/03/16 07:08 AM.
pykolas #257217 22/03/16 09:26 PM
Joined: Oct 2015
Posts: 112
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Well, I wrote this during my stream today, but you already knew that. :P

Code:
ON $*:TEXT:/!counter (((start|end)$)|words\s)/iS:%mychan: {
  IF ($nick isop $chan) {
    IF ($2 == start) {
      IF (!%Counter_Active) {
        SET %Counter_Active On
        MSG $chan $nick $+ , the spam counter script is now active.
      }
      ELSE MSG $chan $nick $+ , the spam counter script is already active in the channel. FailFish
    }
    ELSEIF (($2 == words) && ($3)) {
      VAR %x = 1
      UNSET %Counter_Words
      WHILE ($0 >= %x) {
        SET %Counter_Words %Counter_Words $ [ $+ [ $calc(%x + 2) ] ]
        INC %x
      }
      MSG $chan The spam counter words to match have been set to: %Counter_Words
    }
    ELSEIF (($2 == end) && (%Counter_Active)) counter_end
  }
}

ON *:TEXT:*:%mychan: {
  IF (%Counter_Active) {
    VAR %x = 1
    WHILE ($numtok(%Counter_Words,32) >= %x) {
      IF ($count($1-,$gettok(%Counter_Words,%x,32)) > 0) {
        INC %Counter_Word_ [ $+ [ $gettok(%Counter_Words,%x,32) ] ] $count($1-,$gettok(%Counter_Words,%x,32))
        .TIMER.COUNTER 1 10 counter_end
      }
      INC %x
    }
  }
}

alias -l counter_end {
  UNSET %Counter_Active
  VAR %x = 1
  WHILE ($numtok(%Counter_Words,32) >= %x) {
    IF ($($+(%,Counter_Word_,$gettok(%Counter_Words,%x,32)),2)) {
      VAR %Counter_Matches %Counter_Matches $gettok(%Counter_Words,%x,32): $chr(40) $+ $($+(%,Counter_Word_,$gettok(%Counter_Words,%x,32)),2) $+ $chr(41) -
      IF ($($+(%,Counter_Word_,$gettok(%Counter_Words,%x,32)),2) > $($+(%,counter.record.,$gettok(%Counter_Words,%x,32)),2)) {
        WRITE -l1 counter_record_ $+ $gettok(%Counter_Words,%x,32) $+ .txt The most $gettok(%Counter_Words,%x,32) was spammed on stream was $($+(%,Counter_Word_,$gettok(%Counter_Words,%x,32)),2) times on $asctime(mmm d yyyy)
        SET %counter.record. [ $+ [ $gettok(%Counter_Words,%x,32) ] ] $($+(%,Counter_Word_,$gettok(%Counter_Words,%x,32)),2)
        VAR %NewRecords %NewRecords New Spam Record! $gettok(%Counter_Words,%x,32) $chr(40) $+ $($+(%,Counter_Word_,$gettok(%Counter_Words,%x,32)),2) $+ $chr(41) -
      }
    }
    INC %x
  }
  IF (%Counter_Matches) {
    MSG %mychan Spam Counter has matched the following: $left(%Counter_Matches,-1)
    IF (%NewRecords) MSG %mychan $left(%NewRecords,-1)
  }
  ELSE MSG %mychan Spam Counter did not match anything!
  UNSET %Counter_Word_*
}

You can replace %mychan with #yourchannelname.

Blas #257222 23/03/16 05:59 AM
Joined: Mar 2016
Posts: 21
P
pykolas Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2016
Posts: 21
what 32 stands for in "%Counter_Words,32" ?

pykolas #257225 23/03/16 05:28 PM
Joined: Oct 2015
Posts: 112
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Originally Posted By: pykolas
what 32 stands for in "%Counter_Words,32" ?

It just means that all tokens in %Counter_Words are separated by a SPACE. See Chr Values.


Link Copied to Clipboard