mIRC Homepage
Posted By: Thedelirious1 Twitch bot word count help - 22/01/15 07:15 AM
I've been looking for a way to have my bot to count and keep a running total of how times a certain word has been typed. I want to be able to add, edit and delete the words being counted along with the word count messages. Also, I also want the word count message to be spam protected and only display the word count message in a 10 second interval, just in case if the word was typed multiple times within the 10 second period. For example, if the word "test" was typed 15 times in the 10 second interval it would only display a message such as "The word test has been typed 15 times" instead of displaying 15 word count messages.

I basically want to combine these codes I found on the forum and add the spam protection.

Here
Code:
on *:text:*count*:#: {
  inc %count $countcs($1-,count)
}


and here
Code:
on *:text:!addcom *:#: {
  if ($nick isop #) {
    var %r = $read(# $+ commands.txt,ns,$2)
    if (%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) is already exist into the database! | return }
    write # $+ commands.txt $2-
    msg $chan /me + Command $2 has been added to the database!
  }
}
on *:text:!delcom *:#: {
  if ($nick isop #) {
    var %r = $read(# $+ commands.txt,ns,$2)
    if (!%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) does NOT exist into the database! | return }
    write -dl $+ $readn # $+ commands.txt
    msg $chan /me - Command $2- has been deleted from the database!
  }
}
on *:text:!editcom & *:#: {
  if ($nick isop #) {
    var %r = $read(# $+ commands.txt,ns,$2)
    if (!%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) does NOT exist into the database! | return }
    write -l $+ $readn # $+ commands.txt $2-
    msg $chan /me -> Command $2 has been updated!
  }
}
ON *:TEXT:*:#: {
  tokenize 32 $strip($1-,burci)
  if ($read(# $+ commands.txt, nts, $1)) {
    var %com = $v1
    var %com = $replace(%com,@user@,$iif($2,$2,?),@nick@,$nick,@target@,$target)
    if (-ul=mod == $gettok(%com,1,32)) && ($nick !isop $chan) { msg $chan  | return }
    msg $chan $iif(-ul=mod == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
  }
}


Maybe instead of addcom, editcom, and delcom it could be addcount, editcount, delcount to add and change the word and word count messages.

Thanks in advance.
Posted By: Belhifet Re: Twitch bot word count help - 22/01/15 07:48 AM
uhh

what about something like..

Code:
on *:text:*:#: {
  if ($nick isop $chan) && ($1 !count) {
    if ($2 == add) && ($3) { set %wordlist $addtok(%wordlist,$3,44) } 
    if ($2 == remove) && ($istok(%wordlist,$3, 44)) { set %wordlist $remtok(%wordlist,$3,44) }
  }
  var %i 1
  while (%i <= $0) {
    if ($istok(%wordlist, $($+($,%i),2), 44)) { inc %count. $+ $($+($,%i),2) }
    inc %i
  }
}
Posted By: Thedelirious1 Re: Twitch bot word count help - 22/01/15 10:35 AM
How could I incorporate the spam protection that this welcome script has?

Code:
on !*:JOIN:#:{
  set -e $+(%,ajwelcome.,$cid,#) $addtok($($+(%,ajwelcome.,$cid,#),2),$nick $+ $chr(44),32)
  if (!$timer($+(.ajw.,$cid,#))) { $+(.timer.ajw.,$cid,#) 1 10 ajwelcome # }
}
alias -l ajwelcome {
  if ($($+(%,ajwelcome.,$cid,$1),2)) {
    msg $1 Welcome to the stream $left($v1,-1) $+ !
    unset $+(%,ajwelcome.,$cid,$1)
  }
}


What I like about it is that is welcomes multiple people that have join in a repeating 10 second interval. What I want for this word counter is to display the word count message (ex.: "Testword has been used X times in chat.") at the end of the 10 second interval if it was used within that 10 second interval. If the word was not used I don't want any word count message displayed. But, if the word was used 5 times within the 10 second period I only want 1 message displaying the total count including the 5 most recent uses of the count word.
© mIRC Discussion Forums