mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2006
Posts: 39
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2006
Posts: 39
Code:
 
on ^!*:text:*:#: abc $1-
on ^!*:notice:*:#: abc  $1-
on ^!*:action:*:#: abc $1-

alias abc  {

  if ($nick !isreg $chan) || ($nick == $me) { goto end }

  .hinc -u15m newrow [ $+ [ # ] ] $address($nick,3) 1 

  if ($hget(newrow  [ $+ [ # ] ],$address($nick,3)) > 4) { $newkick(rowing) }  

  .hinc -u15m newrpt [ $+ [ # ] $+ [ $address($nick,3) ] ] $hash($remove($strip($1-),$chr(160),$chr(32)),32) 1 
  if ($hget(newrpt [ $+ [ # ] $+ [ $address($nick,3) ] ],$hash($remove($strip($1-),$chr(160),$chr(32)),32)) > 2) { $newkick(repeating) }
}
alias newkick {

  var %nick = $ial($address($nick,3)).nick

  if ($me isop #) {


      .kick # %nick $1-

    }

  }

}
;---------
on ^*:logon:*:{ .debug -inpt Nul DCCWorkaround }

alias -l DCCWorkaround {
  if ($regex($1, /^<- :([^!]*)![^@]*@[^ ]*\s*PRIVMSG\s*(\S*)\s*:\001\s*DCC\s*(SEND|RESUME).*"(?:[^" ]*\s){32}.*$/i)) {
    var %nick = $regml(1), %target = $regml(2)
    .ignore -u2 %nick
    if ($me isop %target) { 
      .inc -u5m %z 
      if (%z isnum 1-21) { .kick %target %nick | .banx %nick %target | .halt }
    } 
    else { .halt }
  }
}

alias -l banx {
  .hadd -mu5 bx $1  
  .timerban 1 3 mode $2 + $+ $str(b,$hget(bx,0).data) $hget(bx,1).item $hget(bx,2).item $hget(bx,3).item $hget(bx,4).item $hget(bx,5).item $hget(bx,6).item $hget(bx,7).item $hget(bx,8).item $hget(bx,9).item $hget(bx,10).item $hget(bx,11).item $hget(bx,12).item 
  .halt
}



Help me to shorten and make it more easier. Thanks

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Not shorter, as in number of lines, but here's a re-write that takes into account the fact that some identifiers, like $nick and $chan, don't always pass correctly to aliases.. also fixed up a few other small things, like the fact that you have a goto end, but no :end
Code:
on ^!*:text:*:#: abc $nick $chan $address($nick,3) $1-
on ^!*:notice:*:#: abc $nick $chan $address($nick,3) $1-
on ^!*:action:*:#: abc $nick $chan $address($nick,3) $1-

alias abc  {
  if $1 isreg $2 {
    .hinc -u15m newrow $+($2,$3)
    if ($hget(newrow,$+($2,$3)) > 4) { newkick $1 $2 rowing  }  
    .hinc -u15m newrpt $+($2,$address($1,3),$hash($remove($strip($4-),$chr(160),$chr(32)),32)) 
    if ($hget(newrpt,$+($2,$3),$hash($remove($strip($1-),$chr(160),$chr(32)),32)) > 2) {  newkick $1 $2 repeating  }
  }
  halt
}
alias newkick {
  if ($me isop $2) {
    .kick $2 $1 $3-
  }
  halt 
}
;---------
on ^*:logon:*:{ .debug -inpt Nul DCCWorkaround }

alias -l DCCWorkaround {
  if ($regex($1, /^<- :([^!]*)![^@]*@[^ ]*\s*PRIVMSG\s*(\S*)\s*:\001\s*DCC\s*(SEND|RESUME).*"(?:[^" ]*\s){32}.*$/i)) {
    var %nick = $regml(1), %target = $regml(2)
    .ignore -u2 %nick
    if ($me isop %target) { 
      .inc -u5m %z 
      if (%z isnum 1-21) { .kick %target %nick | .banx %nick %target }
    } 
  }
}
alias -l banx {
  .hadd -mu5 bx $1  
  var %a = 1, %b = $hget(bx,0)
  while %a <= %b {
    set %ban $addtok(%ban,$hget(bx,%a).item,32)
    if $numtok(%ban,32) == $modespl {
      .timerban 1 3 mode $2 $+(+,$str(b,$modespl)) %ban
      unset %ban
    }
    inc %a
  }
  if %ban {
    .timerban 1 3 mode $2 $+(+,$str(b,$modespl)) %ban
    unset %ban
  }
}


I didn't try to modify your regex as my knowledge in that area is next to nil, so someone else might be able to reduce/improve that.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
They *do* always pass correctly to aliases

If anything, using $1, $2, etc. makes the /abc alias harder to read, not easier-- though neither one makes the coder shorter, as requested.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yeah, as long as the alias is called from the event, it will have access to the same identifiers the event has access to.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard