Im trying to parse JSON returned from the Steam API but its spaced really weirdly and doesnt do the thing. Anyone happen to know a workaround? On the picture you'll see the difference between normal JSON and Steam's JSON. Ive uploaded the full json here: http://pastebin.com/raw.php?i=eSx1acN3
I have no idea what you want but from what i understand the code continues when it should not? try this maybe
on *:TEXT:!bop*:#: {
if ($nick isop #) {
if (!$2) {
msg # who i am going to bop
return
}
elseif ($2) && (!$3) {
msg # /timeout $2 1
return
}
elseif ($2) && ($3) {
msg # /timeout $2 $3
return
}
}
else (!$2) && (!$3) {
msg # /timeout $nick 5
msg # Oh you are not gonna abuse it.
return
}
}
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 ^_^
[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..
Wouldnt it be easier to click his name and press "purge"? You could get the BTTV browser plugin to avoid having to deal with scripts.
if you still want that purge command i would make it something like
on *:TEXT:!purge*:#: {
if ($nick isop $chan) {
msg $chan /timeout $2 1
msg $chan Purging $2
}
else {
msg $chan You dont have permission to use this command $nick
}
}
Edited some things, works now.