[final result in comments]
Ive been doodling with link protection for a while since the ones posted here dont work for me on twitch.tv. They seem inconsistent and although the code looks good, it doesnt always do what its supposed to do.
So, i decided to write my very first script from scratch (so please bare with me :P) I'm sure there's someone who can tell me how to merge the 'domain pods' into a single pod for a cleaner look, but for now, im after a way to implement a strike system. (higher punishment for more links posted).
So far the code looks like this
on *:text:!linkson:#: {
if ($nick isop #) {
if (%links) { msg $chan Link protection is already active }
else {
msg $chan Link protection activated
set %links On
}
}
}
on *:text:!linksoff:#: {
if ($nick isop #) {
if (%links) {
msg $chan Link protection deactivated
unset %links On
}
else { msg $chan Link protection is already disabled. }
}
}
on *:text:*.com*:#: {
if ($nick isop #) { return }
if ($istok(%permit,$nick,32)) { return }
if (%links) {
msg $chan /timeout $nick 10
msg $chan please ask permission before posting a link, $nick [Link] [Warning]
}
}
on *:text:*.net*:#: {
if ($nick isop #) { return }
if ($istok(%permit,$nick,32)) { return }
if (%links) {
msg $chan /timeout $nick 10
msg $chan please ask permission before posting a link, $nick [Link] [Warning]
}
}
on *:text:*.nl*:#: {
if ($nick isop #) { return }
if ($istok(%permit,$nick,32)) { return }
if (%links) {
msg $chan /timeout $nick 10
msg $chan please ask permission before posting a link, $nick [Link] [Warning]
}
}
on *:text:*.tv*:#: {
if ($nick isop #) { return }
if ($istok(%permit,$nick,32)) { return }
if (%links) {
msg $chan /timeout $nick 10
msg $chan please ask permission before posting a link, $nick [Link] [Warning]
}
}
on *:text:*http://*:#: {
if ($nick isop #) { return }
if ($istok(%permit,$nick,32)) { return }
if (%links) {
msg $chan /timeout $nick 10
msg $chan please ask permission before posting a link, $nick [Link] [Warning]
}
}
on *:text:*www.*:#: {
if ($nick isop #) { return }
if ($istok(%permit,$nick,32)) { return }
if (%links) {
msg $chan /timeout $nick 10
msg $chan please ask permission before posting a link, $nick [Link] [Warning]
}
}
on *:text:!permit*:#: {
if ($nick isop #) {
if (%links) {
set -u30 %permit $addtok(%permit,$2,32)
msg $chan You have 30 seconds to post a link, $nick
}
}
}
Now, ive tried implementing the following into the pods. But it always seems to pick the first 'if' instead of responding according to the set variable and therefor banning someone for a day immediately instead of going through the chain first. Can anyone tell me what im doing wrong here?:
on *:text:*.com*:#: {
if ($nick isop #) { return }
if ($istok(%permit,$nick,32)) { return }
if (%links) {
if (%repeat. $+ $nick) {
msg $chan Third time, come back tomorrow, $nick [Link] [Ban]
unset %repeat. $+ $nick On
msg $chan /timeout $nick 86400
}
elseif (%links. $+ $nick) {
msg $chan post another link and you will be banned, $nick [Link] [Timeout]
unset %links. $+ $nick On
msg $chan /timeout &nick
set -u86400 %repeat. $+ $nick On
}
else {
msg $chan /timeout $nick 10
msg $chan please ask permission before posting a link, $nick [Link] [Warning]
set -u86400 %links. $+ $nick On
}
}
}
If im being too vague, my apologies. The language barrier is strong in this one :P Thank you for your time either way!
Okay i drove myself nuts with the variables so i decided to do it differently. Used userlevels to check wheter or not someone has posted before and it's working pretty well. Also merged the domain 'pods' into one paragraph for a cleaner look and merged the toggle on/off function into a single event. Starting to look like something now
on *:text:!links*:#: {
if ($nick isop #) {
if ($2 == on) {
if (%links) {
msg # Link protection is already enabled
return
}
else {
msg # Link protection enabled
set %links On
return
}
}
if ($2 == off) {
if (%links) {
msg # Link protection disabled
unset %links on
return
}
else {
msg # Link protection is already disabled
return
}
}
else { msg # ' $+ $2 $+ ' is not a valid function. use '!links on' to enable link protection and '!links off' to disable it again. }
}
}
on *:text:!permit*:#: {
if ($nick isop #) {
if (%links) {
set -u30 %permit $addtok(%permit,$2,32)
msg $chan You have 30 seconds to post a link, $2
}
}
}
on +201:text:*:#: {
if ($nick isop #) { return }
if ($istok(%permit,$nick,32)) { return }
if (%links) {
if (*www.* iswm $1- || *http://* iswm $1- || *.com* iswm $1- || *.tv* iswm $1- || *.nl* iswm $1- || *.sh* iswm $1- || *.net* iswm $1- || *.me* iswm $1-) {
.ruser 201 $nick
msg # /timeout $nick 86400
msg # That was your 3rd link. Try again tomorrow, $nick [Link] [24h]
return
}
}
}
on +200:text:*:#: {
if ($nick isop #) { return }
if ($istok(%permit,$nick,32)) { return }
if (%links) {
if (*www.* iswm $1- || *http://* iswm $1- || *.com* iswm $1- || *.tv* iswm $1- || *.nl* iswm $1- || *.sh* iswm $1- || *.net* iswm $1- || *.me* iswm $1-) {
.ruser 200 $nick | .auser 201 $nick | .timermsg 1 3600 .ruser 201 $nick
msg # /timeout $nick
msg # No links without permission, $nick $+ ! [Link] [Timeout]
return
}
}
}
on *:text:*:#: {
if ($nick isop #) { return }
if ($nick == PUT CASTER HERE) { return }
if ($istok(%permit,$nick,32)) { return }
if (%links) {
if (*www.* iswm $1- || *http://* iswm $1- || *.com* iswm $1- || *.tv* iswm $1- || *.nl* iswm $1- || *.sh* iswm $1- || *.net* iswm $1- || *.me* iswm $1-) {
msg $chan /timeout $nick 10
msg $chan Please ask permission before posting a link, $nick [Link] [Warning]
.auser 200 $nick | .timermsg 1 3600 .ruser 200 $nick
return
}
}
}
**It will check for perms first, if someone has no permission/is not OP it will proceed to check for links. If links are detected it will timeout the sender and give them a higher userlevel. The higher userlevel, the higher punishment. (1 link gets you userlevel 200 and a purge. 2 links get you userlevel 201 and a 10 minute timeout, the third link gets you a 24h ban and resets the userlevel) In the last paragraph you'll notice i have added an extra check for the caster. I did this because it takes Twitch IRC some time for it to send out modes and the last thing you want is have your bot try to time a caster for posting links in his own channel :P
Pretty proud of my first doodle. I think this is about the best i can get it without diving head first into regex, which i dont know aaaanything about. If you have any suggestions to make it better, or if i overlooked something, please let me know ^_^
A very interesting set up. how has it been working for you?