mIRC Home    About    Download    Register    News    Help

Print Thread
#163094 26/10/06 02:39 PM
Joined: Jun 2006
Posts: 79
B
Babel fish
OP Offline
Babel fish
B
Joined: Jun 2006
Posts: 79
Code:
 
ctcp !@*:*:#: { if ($nick isreg #) { .signal -n a # $nick | haltdef } } 
on !@*:ctcpreply:*: { if ($nick isreg #) && ($me isop #) { .signal -n b # $nick | haltdef } } 
on ^!@*:text:*:#: { if ($nick isreg #) { .signal -n c # $nick $1- | haltdef } } 
on ^!@*:action:*:#: { if ($nick isreg #) { .signal -n c # $nick $1- | haltdef } } 
on ^!@*:notice:*:#: { if ($nick isreg #) { .signal -n c # $nick $1- | haltdef } } 
on *:signal:*: {
  $iif($signal == a,.signal -n d $1-2 ctcp)) 
  $iif($signal == b,.signal -n d $1-2 ctcpreply)) 
  if ($signal == c) { 
    $iif($regex($3-,/[[:cntrl:]]/g) > 49,.signal -n d $1-2 codes))
    $iif($regex($3-,/[[:upper:]]/gS) > 49,.signal -n d $1-2 caps)) 
    $iif($regex($3-,/\d/gS) > 49,.signal -n d $1-2 number)) 
    $iif($regex($3-,/[[:punct:]]/gS) > 49,.signal -n d $1-2 symbol))
    $iif($regex($3-,/[ $chr(174) ]/gS) > 49,.signal -n d $1-2 ascii))
    $iif($regex($3-,/[ $chr(160) ]/gS) > 49,.signal -n d $1-2 blur)) 
    $iif($regex($3-,/./gS) > 199,.signal -n d $1-2 lenght))
    $iif($regex($remove($3-,$chr(40),$chr(41)),/(?:^|(\40|\240))((http+(:|s:)\/\/\S*)|((www\.{1})+(.*)+(\.{1})+(\w{2,3})\S*)|#[^\40]\S*)/Si),.signal -n d $1-2 advertise))
    $iif($regex($3-,/\b([censored]||suck|[censored]|bitch|dick)\b/Si),.signal -n d $1-2 swear))
    .hinc -u5m row $+($1,$2) 1 
    if ($hget(row,$+($1,$2)) > 4) { .signal -n d $1-2 lines }
    hinc -u5m rep [ $+ [ $1 ] $+ [ $2 ] ] $hash($remove($3-,$chr(160),$chr(32)),32) 1 
    if ($hget(rep [ $+ [ $1 ] $+ [ $2 ] ],$hash($remove($3-,$chr(160),$chr(32)),32)) > 2) { .signal -n d $1-2 repeat }
  } 
  if ($signal == d) { 
    if ($2 ison $1) { 
      .hinc -mu20 d y  
      if ($hget(d,y) < 22) { !kick $1 $2 $3 }
  }
}

 


I need chan protection with fast detect and kick. Now i just wanna ask few question how can i modify codes above works more faster. I dont mind if the codes looks complicated as long as its can works faster. The questions is refer to the codes above wink

1. Is it using to many "|" makes my codes works slower?
eg:
if bla bla
if bla2 bla2

better than

if bla bla | if bla la

2. Which one is better ?
a.
if bla bla

b.
$iif bla bla

3. if $iif .. is it makes it one line is better ?
eg:
$iif bla bla,$iif bla2 bla2

4. Is that haldef is better using on event either than halt?

5. Signal is better than using aliases

6. What is the best way to detect only a letter .. $regex ?
eg:
[ $chr(160 ]

7. Which is better(faster)
a.
if $regex bla bla
b.
hadd a b
$hget a b $regex bla bla
c.
var %dll = $scriptdiraircdll.dll $regex bla
if +flood

8. What is better using on kick limit
a.
%n < 0 halt
%n >= 22 halt
b. isnum (0-21)

last
- What should i edit codes above for overall. Hopefully with an example.

I think thats all for now. Sorry if im asking stupid question. I will greatfull if many ppl give some comment/answer. Thanks

#163095 26/10/06 10:28 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I need chan protection with fast detect and kick. Now i just wanna ask few question how can i modify codes above works more faster. I dont mind if the codes looks complicated as long as its can works faster. The questions is refer to the codes above wink

1. using seperate lines is slightly faster
2. using IF is slightly faster
3. n/a $IIF is not better
4. /HALT terminates the event script & stops the defualt mirc action, while /HALTDEF stops the defualt mirc action, ie: the script keeps running to its code end.
5. Signal -n is nearly the same as an alias call, some identifiers are lost/changed when using a signal, event limitations are lost (such as no use of $input)
6. sorry i suck at regex on a guess i think its \xA0
7. a. if $regex bla bla (answer based on the fact each of the options contain the regex and this is the sortest surounding code)
8. b. isnum (0-21) and/or !isnum (0-21) halt
9.
Code:
ctcp !@*:*:#: { if ($nick isreg #) { haltdef | .signal -n d # $nick ctcp } } 
;
;on !@*:ctcpreply:*: { if ($nick isreg #) &amp;&amp; ($me isop #) { haltdef | .signal -n d # $nick ctcpreply } } 
;^ remarked out becuase i dont beleive there is a # value in ctcpreplies as it is not channel specific, if im wrong un remark it. but since your comparing $me isop i dont think it is!
;
on ^!@*:text:*:#: { if ($nick isreg #) { haltdef | .signal -n c # $nick $1- } } 
on ^!@*:action:*:#: { if ($nick isreg #) { haltdef | .signal -n c # $nick $1- | haltdef } } 
on ^!@*:notice:*:#: { if ($nick isreg #) { haltdef | .signal -n c # $nick $1- | haltdef } } 
 
;&lt;unneeded&gt; $iif($signal == a,.signal -n d $1-2 ctcp)) 
;&lt;unneeded&gt; $iif($signal == b,.signal -n d $1-2 ctcpreply)) 
on *:signal:c: {
  if ($regex($3-,/[[:cntrl:]]/g) &gt; 49) { .signal -n d $1-2 codes }
  if ($regex($3-,/[[:upper:]]/gS) &gt; 49) { .signal -n d $1-2 caps }
  if ($regex($3-,/\d/gS) &gt; 49) { .signal -n d $1-2 number }
  if ($regex($3-,/[[:punct:]]/gS) &gt; 49) { .signal -n d $1-2 symbol }
  if ($regex($3-,/[ $chr(174) ]/gS) &gt; 49) { .signal -n d $1-2 ascii }
  if ($regex($3-,/[ $chr(160) ]/gS) &gt; 49) { .signal -n d $1-2 blur }
  if ($regex($3-,/./gS) &gt; 199) { .signal -n d $1-2 lenght }
  if ($regex($remove($3-,$chr(40),$chr(41)),/(?:^|(\40|\240))((http+(:|s:)\/\/\S*)|((www\.{1})+(.*)+(\.{1})+(\w{2,3})\S*)|#[^\40]\S*)/Si)) { .signal -n d $1-2 advertise }
  if ($regex($3-,/\b([censored]||suck|[censored]|bitch|dick)\b/Si)) { .signal -n d $1-2 swear }
  .hinc -u5m row $+($1,$2) 1 
  if ($hget(row,$+($1,$2)) &gt; 4) { .signal -n d $1-2 lines }
  ;
  ;hinc -u5m $+(rep,$1,$2) $hash($remove($3-,$chr(160),$chr(32)),32) 1 
  ;if ($hget($+(rep,$1,$2),$hash($remove($3-,$chr(160),$chr(32)),32)) &gt; 2) { .signal -n d $1-2 repeat }
  ;^ i corrected this then had a closer read of what it did, and think this likely to be eating huge amounts of ram and needed rerwiting.
  ;^ Creating multiple hashtables one each based named "REP&lt;channel&gt;&lt;nick&gt;" must be eating ram like crazy
  ;
  var %itemname = $+($2,@,$1,@,$hash($remove($3-,$chr(160),$chr(32)),32)
  hinc -u5m repeatHASH %itemname 1 
  if ($hget(repeatHASH,%itemname) &gt; 2) { .signal -n d $1-2 repeat }
} 
on *:signal:d: {
  if ($2 ison $1) {
    ;^ since ctcpreplies have been remarked out becuase they have no channel info this makes no sence, as the event calling must have the nick on channel
    ;^ i have left it in however as you may need to adjust your other code to deal with the ctcpreplies
    ;
    ;
    ;PS: i dont actually really understand what this codes doing as it doesnt seem to make overly high sence "kick the nick of the 23rd+ ctcp/ctcpreply(or one of the others) , if in 20 seconds" ?
    ;
    ;
    .hinc -mu20 d y  
    if ($hget(d,y) &lt; 22) { !kick $1 $2 $3 }
  }
}


* code untested *

Last edited by DaveC; 26/10/06 10:36 PM.
#163096 26/10/06 11:25 PM
Joined: Jun 2006
Posts: 79
B
Babel fish
OP Offline
Babel fish
B
Joined: Jun 2006
Posts: 79
DaveC what is \xA0 actually? I dont get it clear.

The reason why i use < 22 in 20secs because i want to prevent from excess flood. Thanks Davec wink .. I hope other hand will give some comment/answer too.

Ah one more. Refer to Davec answer, should i replace < 22 with isnum (0-21) ? wink

#163097 28/10/06 07:16 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
$chr(160) 160 is A0 (hex value) hex values are often displayed with a leading 0x becuase 0x99 = 153 (decimal)


Link Copied to Clipboard