Skip to content
MSN

I need a real pro's opinion on this code.

A TG007 community discussion started by CreepingDeth101™.

Discussion 11 posts
Page 1 of 1
Open
Topic #967 · 11 published posts · 655 views

Ok, this is for anyone way better at MSN scripting than I (darn near everyone). Does this look like it'll work? It's For A "Show Respect" Script That I Intend To Eventually Release If It Seems Like A Useful One, Might Be Able To Be Modified For Regular IRC usage as well. Anyone that helps me here of course will receive credit for doing so. "Revisions By so on and so forth". I know I could have done it with user levels but I'm obsessed with using txt files. I used custom identifiers to simplify the bulk of the code (as you can see it's prolly a good idea).

 

$res.ifoffend($1-) looks up the restricted words file to see if any of the words is in the text and if so returns true, else returns false

 

$offender($$ial($nick $+ *,1).addr).exists returns true if they already said somethign offensive

 

$offender($$ial($nick $+ *,1).addr).count returns the number of offenses

 

The on join will check to see if the user's in the disrespectful list and if so ban them, however if it's the script itself then it'll check the whole room for the addresses of everyone, and if on the list and the script is owner ban them and kick them cos these people are offenders 10x or more. and yes this is with vincula 4.9.

 

the on text checks if it's offensive by reading the list, reads the restricted file and determines whether or not they're on it, if so how much, and will warn/kick accordingly.

 

Thanks to anyone who lends a hand.

 

;
;identifiers
;

res.ifoffend { 
 var %curword 1
 var %retval $false
 var %look.in $1
 while (%curword <= $lines(restricted.txt)) { 
   if ($read(restricted.txt,%curword) isin %look.in) { 
     %retval = $true
     /break
   }
  /inc %curword
 }
 return %retval
}

offender { 
 var %retval
 if ($prop == exists) { 
   %retval = $false
   if ($read(offenders.txt,w,* $+ $1 $+ *) { 
     %retval = $true
     /break
   }
 }
 if ($prop == count) { 
   %retval = $gettok($read(offenders.txt,w,* $+ $1 $+ *),2,126)
 }
 return %retval
}

;
;text check
;

on *:TEXT:**:#:{ 
 if ($res.ifoffend($1-) == $true) { 
   if ($offender($$ial($nick $+ *,1).addr).exists == $true) { 
     if ($offender($$ial($nick $+ *,1).addr).count = 1) { 
       /write -l $+ $readn offenders.txt $$ial($nick $+ *,1).addr $+ ~ $+ $calc($offender($$ial($nick $+ *,1).addr).count + 1)
       /msg $comchan($me,1) Hey $nick This Is Your Second Warning, No Slurs Or Disrespectful Comments.  I MEAN IT! :@
     }
     elseif ($offender($$ial($nick $+ *,1).addr).count = 2) { 
       /write -l $+ $readn offenders.txt $$ial($nick $+ *,1).addr $+ ~ $+ $calc($offender($$ial($nick $+ *,1).addr).count + 1)
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr $calc(1440 * 2)
       /kick $comchan($me,1) $nick Show Some Respect! [Access Ban Set For 48 Hours]
     }
     elseif ($offender($$ial($nick $+ *,1).addr).count >= 3) && ($offender($$ial($nick $+ *,1).addr).count < 10){ 
       /write -l $+ $readn offenders.txt $$ial($nick $+ *,1).addr $+ ~ $+ $calc($offender($$ial($nick $+ *,1).addr).count + 1)
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr $calc(1440 * 7)
       /kick $comchan($me,1) $nick OK It Seems That The 48 Hours I Gave You Wasn't Enough.  Let's Try A Week Now.  [Access Ban Set For 1 Week]
     }
     elseif ($offender($$ial($nick $+ *,1).addr).count = 10){ 
       /write -l $+ $readn offenders.txt $$ial($nick $+ *,1).addr $+ ~ $+ $calc($offender($$ial($nick $+ *,1).addr).count + 1)
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr $calc(1440 * 7)
       /kick $comchan($me,1) $nick OK It Seems That The 48 Hours I Gave You Wasn't Enough.  Let's Try A Week Now.  [Access Ban Set For 1 Week]
     }
     if ($offender($$ial($nick $+ *,1).addr).count > 10){ 
       /write -l $+ $readn offenders.txt $$ial($nick $+ *,1).addr $+ ~ $+ $calc($offender($$ial($nick $+ *,1).addr).count + 1)
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr 0
       /kick $comchan($me,1) $nick Looks Like You Can't Listen [Access Ban Set Indefinitely]
     }
   else { 
     /write offenders.txt $$ial($nick $+ *,1).addr $+ ~ $+ 1
     /msg $comchan($me,1) Ok $nick I'm Telling You Now...No Slurs, Slur-ish Or Disrespectful Remarks, In Any Fashion.  It's Rude.
   }
 }
}

;
;Join Check
;

on *:JOIN:#:{ 
 if ($nick != $me) &&{ 
   if ($offender($$ial($nick $+ *,1).addr).exists == $true) { 
     if ($offender($$ial($nick $+ *,1).addr).count > 10) {
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr 0
       /kick $comchan($me,1) $nick You've Been A Pain [You'll Never Be Alowed In Here Again]
     }
   }
 }
 elseif ($nick == $me) && ($me isowner $chan) { 
   var %i = 0 
   var %nicks = "" 
   :nextnick
   inc %i 
   if ($nick($chan,%i) == $me) { 
     inc %i 
   }
   if ($offender($$ial($nick($chan,%i) $+ *,1).addr).exists == $true) { 
     if ($offender($$ial($nick($chan,%i) $+ *,1).addr).count > 10) { 
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr 0
       /kick $comchan($me,1) $nick You've Been A Pain [You'll Never Be Alowed In Here Again]
     }
   goto nextnick 
   }
 }
}

i advise against using

if ($read(offenders.txt,w,* $+ $1 $+ *) { 

 

sometimes it does stop by itself, with no convincing reason (though the code is correct)

i had to switch my admin/gold/brown AOP lists, including Banlist to INI files to recover the future bugs that might show up

 

For me, ini files are easier to handle and a bit faster in reading, besides; ini lists are better if yr intending to make ur list with a room scanner.

 

u can use this as a text filter ;

on *:TEXT:*:#:{  
var %i = 1   
while ($gettok($1-,%i,32)) {  
  if ($read(remote\BadWord.txt,w,$ifmatch) == $ifmatch) {  
    $TestDeWord
    break   
}   
  inc %i 
}  
}

alias TestDeWord {
if (%reacti0n == warn) {
  msg # $replace(%warnmessage,<nick>,$nick)
}
elseif (%reacti0n == kick) {
  if (%deny == on) {
    access # add deny $address($nick,1) %denytime
    kick # $nick $replace(%kickmessage,<nick>,$nick) (Access ban set for %denytime minutes)
  }
  else {
    kick # $nick $replace(%kickmessage,<nick>,$nick)
  }
}
else { halt }
}

 

modify it as desired to go with ur script

 

 

hope i wuz useful somehow O_o

Edited Jul 24, 2004 5:35 PM by [::X-System::]

on me:*:join:#:hop #

I was thinking on using an ini file, but I'm wondering one thing and hating another....wondering how to convert the code (hating because I have much to learn about ini reading and writing) Thanks for the advise. I'm gonna start work on the new code and let me know what you think. crap I didn't even think of the huge lag that a txt file would cause if it got big.

 

i seem to remember though something about ini files only being able to be 64kb or something. maybe it's vb rules I'm not sure.

 

thanks again System

thats from my AOP

on *:join:#:{
if ($nick != $me) {
  if ($readini(aOP.ini,adminaop,$address($nick,1)) != $null) {
    /msg $chan Found (AdmInAop) $nick Logged as: $gettok($readini(aOP.ini,adminaop,$$address($nick,1)),1,32) Reason: $gettok($readini(aOP.ini,adminaop,$$address($nick,1)),2-,32)
  }
}
}

 

for a profanity commiter 4 example, it might look like this ;

on *:join:#:{
if ($nick != $me) {
;user is kick only listed
  if ($readini(BadBehavior.ini,kick,$address($nick,1)) != $null) {
/kick # $nick You have been listed as a bad user, seeya.
  }
;user is ban/kick listed
elseif ($readini(BadBehavior.ini,ban,$address($nick,1)) != $null) {
/access # add deny $ial($nick).addr <ban time here>
/kick # $nick You have been listed as a bad user, seeya. (Banned for <time> minutes.
}
}

Edited Jul 24, 2004 5:42 PM by [::X-System::]

on me:*:join:#:hop #

If the -n switch is specified, mIRC will attempt to write to the .ini file even if it is larger than 64k.

 

eg /writeini -n test.ini <section> <item> <value>

My code does NOT have bugs. It just develops random features.

well heck that doesn't seem so bad. as for the access thing though I prefer the sockwrite method (even though I still have no clue how to use it in a customized manner) cos it makes me look better at scripting. lol_sign.gif

 

 

oh yeah and ozzy I looked it up in the help file right after I posted that...read exactly that. well heck I'm happy that I actually remembered something from over a year ago when I scripted constantly. Now I barely touch the stuff wacko.gif

Edited Jul 24, 2004 5:47 PM by CreepingDeth101â„¢

Ok, system I've incorporated the ini idea and the way you used on text but to make it simpler on the adjustment process all I did was adjust the $res.ifoffend identifier to what you used there and made a couple minor adjustments. was way easier than I thought after I thought it wasn't so bad. Thanks again for all of your help. lol my script already has a bad list but ehh...I wanted it automated. I'm too lazy to click once or twice. dialog will be added, it's them darn listbox loadbuf's, they always trick me around.

 

How's it look now (just fixed for INI's, thats all, nothing else is new)???

 

res.ifoffend { 
 var %i = 1   
 var %retval $false
 while ($gettok($1-,%i,32)) {  
   if ($read(restricted.txt,w,$ifmatch) == $ifmatch) {  
     %retval = $true
     break   
   }   
   inc %i 
 }  
 return %retval
}

offender { 
 var %retval
 if ($prop == exists) { 
   %retval = $false
   if ($readini(offenders.ini,Offenders,$1) { 
     %retval = $true
   }
 }
 if ($prop == count) { 
   %retval = $readini(offenders.ini,Offenders,$1)
 }
 return %retval
}

;
;text check
;

on *:TEXT:**:#:{ 
 if ($res.ifoffend($1-,$comchan($me,1),$nick) == $true) { 
   if ($offender($$ial($nick $+ *,1).addr).exists == $true) { 
     if ($offender($$ial($nick $+ *,1).addr).count = 1) { 
       /writeini -n offenders.ini Offenders $$ial($nick $+ *,1).addr $calc($offender($$ial($nick $+ *,1).addr).count + 1)
       /msg $comchan($me,1) Hey $nick This Is Your Second Warning, No Slurs Or Disrespectful Comments.  I MEAN IT! :@
     }
     elseif ($offender($$ial($nick $+ *,1).addr).count = 2) { 
       /writeini -n offenders.ini $$ial($nick $+ *,1).addr $calc($offender($$ial($nick $+ *,1).addr).count + 1)
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr 1440
       /kick $comchan($me,1) $nick Show Some Respect! [Access Ban Set For 24 Hours]
     }
     elseif ($offender($$ial($nick $+ *,1).addr).count >= 3) && ($offender($$ial($nick $+ *,1).addr).count < 10){ 
       /writeini -n offenders.ini $$ial($nick $+ *,1).addr $calc($offender($$ial($nick $+ *,1).addr).count + 1)
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr $calc(1440 * 7)
       /kick $comchan($me,1) $nick OK It Seems That The 48 Hours I Gave You Wasn't Enough.  Let's Try A Week Now.  [Access Ban Set For 1 Week]
     }
     elseif ($offender($$ial($nick $+ *,1).addr).count = 10){ 
       /writeini -n offenders.ini $$ial($nick $+ *,1).addr $calc($offender($$ial($nick $+ *,1).addr).count + 1)
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr $calc(1440 * 7)
       /kick $comchan($me,1) $nick OK It Seems That The 48 Hours I Gave You Wasn't Enough.  Let's Try A Week Now.  [Access Ban Set For 1 Week]
     }
     if ($offender($$ial($nick $+ *,1).addr).count > 10){ 
       /writeini -n offenders.ini $$ial($nick $+ *,1).addr $calc($offender($$ial($nick $+ *,1).addr).count + 1)
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr 0
       /kick $comchan($me,1) $nick Looks Like You Can't Listen [Access Ban Set Indefinitely]
     }
   else { 
     /writeini -n offenders.ini $$ial($nick $+ *,1).addr 1
     /msg $comchan($me,1) Ok $nick I'm Telling You Now...No Slurs, Slur-ish Or Disrespectful Remarks, In Any Fashion.  It's Rude.
   }
 }
}

;
;Join Check
;

on *:JOIN:#:{ 
 if ($nick != $me) &&{ 
   if ($offender($$ial($nick $+ *,1).addr).exists == $true) { 
     if ($offender($$ial($nick $+ *,1).addr).count > 10) {
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr 0
       /kick $comchan($me,1) $nick You've Been A Pain [You'll Never Be Alowed In Here Again]
     }
   }
 }
 elseif ($nick == $me) && ($me isowner $chan) { 
   var %i = 0 
   var %nicks = "" 
   :nextnick
   inc %i 
   if ($nick($chan,%i) == $me) { 
     inc %i 
   }
   if ($offender($$ial($nick($chan,%i) $+ *,1).addr).exists == $true) { 
     if ($offender($$ial($nick($chan,%i) $+ *,1).addr).count > 10) { 
       .sockwrite -tn msn.server. $+ $cid ACCESS $msn.get($cid,fullroom) ADD DENY $$ial($nick $+ *,1).addr 0
       /kick $comchan($me,1) $nick You've Been A Pain [You'll Never Be Alowed In Here Again]
     }
   goto nextnick 
   }
 }
}

for the ini files is there any way I can count how many items are in a section?? I've found no method thusfar.

$ini(<file>,<section>,0) gives the number of items in a section

bfush.PNG

yeah I found out shortly after. I tend to do that, thanks for help though. I'm gonna do some testing and then see if it works. This script however will exempt no one from being able to send messages of racial/derogative slurring. You gotta add you're own words though as certain people have different ideas on if say for instance "cracker" is a racial slur, etc, I think so but I couldn't find a way to make em deleteable.

i wud better use;

$address($nick,1) in the /writeini & /readini

on me:*:join:#:hop #