Need some help with a $read check/comparison

By Menteroth on Sep 17, 2013

the if-line timeouts fine if the banmask is the only thing said. but it doesn't work if there are words in front or after the banmask.
nor if it's inside a lot text like "wwwwwwwwwbanmaskzzzzzzzzzzz"

really bad at scripting from scratch. been looking through other codes and tried to put this together myself.

on 1:TEXT:*:#:{
; this if-line below is the one I do not get to work as I want. formerly used "==" instead of "isin" which
; didn't work either.
  if ($1- isin $read(bans- $+ $chan $+ .txt,w, $1-)) { .msg $chan .timeout $nick | echo # 14(00 $+ $time $+ 14) 10-11-15- 5min timeout on $nick }
  elseif ($1 == !addban) {
    if ($2- == $read(bans- $+ $chan $+ .txt,w, $2-)) { msg $chan banmask " $+ $2- $+ " is already added. }
    else { write bans- $+ $chan $+ .txt $2- | msg $chan banmask " $+ $2- $+ " added. }
  }
  elseif ($1 == !delban) {
    if ($2- != $read(bans- $+ $chan $+ .txt,w, $2-)) { msg $chan no such banmask " $+ $2- $+ ". }
    else { write -ds " $+ $2- $+ " bans- $+ $chan $+ .txt | msg $chan banmask " $+ $2- $+ " deleted. }
  }
}

Comments

Sign in to comment.
Farcrada   -  Sep 23, 2013
if ($1- isin $read(bans- $+ $chan $+ .txt,w, $1-))

That's not working seen as you (For some reason.) HAVE to use variables to make that work. Just like this one:

 echo # 14(00 $+ $time $+ 14) 10-11-15- 5min timeout on $nick

You also didn't define how long you want $nick to be timed out.

.msg $chan .timeout $nick |

In other words:

on 1:TEXT:*:#:{
  var %readbans bans- $+ $chan $+ .txt
  var %echotime 00 $+ $time $+ 14
  if ($1- isin $read(%readbans,w, $1-)) { .msg $chan .timeout $nick 10 | echo # 14(%echotime) 10-11-15- 5min timeout on $nick }
  elseif ($1 == !addban) {
    if ($2- == $read(%readbans,w, $2-)) { msg $chan banmask " $+ $2- $+ " is already added. }
    else { write %readbans $2- | msg $chan banmask " $+ $2- $+ " added. }
  }
  elseif ($1 == !delban) {
    if ($2- != $read(%readbans,w, $2-)) { msg $chan no such banmask " $+ $2- $+ ". }
    else { write -ds " $+ $2- $+ " %readbans | msg $chan banmask " $+ $2- $+ " deleted. }
  }
}

that ought to do the trick. Try it.

Menteroth  -  Sep 23, 2013

hello. thanks for the help. I will try this when I get the time and get back to you.
and for the timeout. I don't need to set time since the default is 5 minutes. this is a twitch.tv IRC-channel I'm using the script for. so that's fine. :)

and I don't need to change the !addban/!delban parts. they work as intended. I can add and remove several words banmasks.

Farcrada  -  Sep 23, 2013

You don't have to modify the !addban/!delban parts. This is just WAY easier when making modifycations. With some editing you could host this on multiple streams and once with just 1 script running. Don't get me wrong, but that's EXACTLY how Moobot, Nightbot Saucebot etc do their stuff. The have 1 script made to differ in options between streams. Now it's your tunr to figure out how and apply that. Then to become as famous as a bot like Moobot and Nightbot you'd have to pull some serious strings by some big-ass streams.

Menteroth  -  Sep 23, 2013

ah okay. then I understand. it probably won't be as big or nor do I really try for it. just fixing it for a small community channel which I stream on. I will try your correction later this evening if I get some time. thanks. :)

Menteroth  -  Oct 03, 2013

sorry for the late response. this doesn't work. the banmask doesn't trigger if it's in a text, only if it's said alone with no other text. commands still work as usual.

Sign in to comment

blackvenomm666   -  Sep 19, 2013

you could try switching it around and try using isin instead of ==

if ($read+ $chan $(bans- $+ .txt,w, $1-)) isin $1- ) { .msg $chan .timeout $nick | echo # 14(00 $+ $time $+ 14) 10-11-15- 5min timeout on $nick }
  elseif ($1 == !addban) {
blackvenomm666  -  Sep 19, 2013

now that i'm looking at it more you may need a while loop to cycle through everything said.

Menteroth  -  Sep 20, 2013

"isin" doesn't work either. I have no idea how loops work. as I stated above. I don't really script and I suck at it. :)

blackvenomm666  -  Sep 20, 2013

I'll help you out in a bit

Menteroth  -  Sep 21, 2013

thanks. it's no rush. I appreciate any help I can get.

blackvenomm666  -  Sep 22, 2013

i am not the best with while loops myself but i believe this should work

on 1:TEXT:*:#:{
  var %a = 1, %b = $lines(bans- $+ $chan $+ .txt)
  while (%a <= %b) {
    if ($read(bans- $+ $chan $+ .txt, %a) isin $1-) {
      .msg $chan .timeout $nick 
      echo # 14(00 $+ $time $+ 14) 10-11-15- 5min timeout on $nick 

      inc %a
    }
    inc %a
  }
  elseif ($1 == !addban) {
    if ($2 == $read(bans- $+ $chan $+ .txt,w, $2-)) { msg $chan banmask " $+ $2- $+ " is already added. }
    else { write bans- $+ $chan $+ .txt $2- | msg $chan banmask " $+ $2- $+ " added. }
  }
  elseif ($1 == !delban) {
    if ($2 != $read(bans- $+ $chan $+ .txt,w, $2-)) { msg $chan no such banmask " $+ $2- $+ ". }
    else { write -ds " $+ $2- $+ " bans- $+ $chan $+ .txt | msg $chan banmask " $+ $2- $+ " deleted. }
  }
}
Menteroth  -  Oct 03, 2013

sorrry for the late response. the banmask check works, if it's with other text or just alone but I can't add or delete banmasks. the commands doesn't work.

blackvenomm666  -  Oct 04, 2013
von 1:TEXT:*:#:{
  var %a = 1, %b = $lines(bans- $+ $chan $+ .txt)
  while (%a <= %b) {
    if ($read(bans- $+ $chan $+ .txt, %a) isin $1-) {
      .msg $chan .timeout $nick 
      echo # 14(00 $+ $time $+ 14) 10-11-15- 5min timeout on $nick 

      inc %a
    }

  elseif ($1 == !addban) {
    if ($2 == $read(bans- $+ $chan $+ .txt,w, $2-)) { msg $chan banmask " $+ $2- $+ " is already added. }
    else { write bans- $+ $chan $+ .txt $2- | msg $chan banmask " $+ $2- $+ " added. }
  }
  elseif ($1 == !delban) {
    if ($2 != $read(bans- $+ $chan $+ .txt,w, $2-)) { msg $chan no such banmask " $+ $2- $+ ". }
    else { write -ds " $+ $2- $+ " bans- $+ $chan $+ .txt | msg $chan banmask " $+ $2- $+ " deleted. }
  }
}
}   
Menteroth  -  Oct 05, 2013

thanks a lot. I will try this in a bit.

Menteroth  -  Oct 07, 2013

First thing I did was trying to add a banmask:

(10:22:15) (menteroth) !addban megamongo
(10:22:17) (mentbot) banmask "megamongo" added.
(10:22:17) (mentbot) banmask "megamongo" is already added.
(10:22:18) (mentbot) banmask "megamongo" is already added.
(10:22:18) (mentbot) banmask "megamongo" is already added.
(10:22:18) (mentbot) banmask "megamongo" is already added.
(10:22:18) (mentbot) banmask "megamongo" is already added.
(10:22:19) (mentbot) banmask "megamongo" is already added.
(10:22:19) (mentbot) banmask "megamongo" is already added.
(10:22:19) (mentbot) banmask "megamongo" is already added.
(10:22:19) (mentbot) banmask "megamongo" is already added.
(10:22:20) (mentbot) banmask "megamongo" is already added.
(10:22:20) (mentbot) banmask "megamongo" is already added.
(10:22:20) (mentbot) banmask "megamongo" is already added.
(10:22:21) (mentbot) banmask "megamongo" is already added.

like 20 times more of this segment until it disconnected for flooding.

Menteroth  -  Oct 07, 2013

same thing with !delban. floods.

and reading/comparing from text file doesn't work. if banmask is entered with other text: blabla banmask bla bla

blackvenomm666  -  Oct 07, 2013

What server can I find you on

Menteroth  -  Oct 07, 2013

I'm using twitch.tv's IRC server. you don't wanna test things there. 'cause if you flood there you can't talk for like 4 hours or something.

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.