; when mIRC starts
on *:START:{
; create a hashtable
hmake twitchEmotes 200
; load twitch emotes into the hashtable using numbers as the keys
; and each line of the file as the values
hload -n twitchemotes emotes.txt
}
; on text in a channel I am op in
on @*:TEXT:*:#:{
; check to make sure the user IS NOT an channel mod
if ($nick !isop #) {
; store the input line
set -eu0 %emoteCountLine $1-
; store the emote count, giving it a default value of 0
set -eu0 %emoteCount 0
; search the hashtable's 'data' for any wildcard-matching items
; in the table that match text. For each found, call /countEmotes
noop $hfind(twitchEmotes, $1-, 0, W, countEmotes $1-).data
; if the emotecount is equal-to or greater than 5, send message and timeout user
if (%emoteCount >= 5) {
msg # Stop spamming emotes, $nick $+ !
msg # .timeout $nick 120
}
; cleanup the variables
unset %emoteCount, %emoteCountLine
}
}
alias -l countEmotes {
; get the 'data' portion of the found match
var %emote = $hget(TwitchEmotes, $1-)
; remove the surrounding *'s
%emote = $left($right(%emote, -1), -1)
; turn the emote into a regex pattern
%emote = /(?<=^| ) $+ $right($left($hget(twitchEmotes, $1-), -1),-1) $+ (?= |$)/g
; call the $regex and increase %emoteCount by the number of matches it finds
inc %emoteCount $regex(%emoteCountLine, %emote)
}