The DarkPaladin — File Browser

TheDarkPaladinv2.0.7 / TheDarkPaladinv2.0.7 / multi-irc.mrc

multi-irc.mrc — 19.33 KB — Download this file

on *:LOAD: { socklisten ident 113 }
menu menubar {
  Multiple Server Connection: {
    echo -a 2,11Please wait, reading server list from servers.ini
    dialog -m MultiServ MultiServ
  } 
}

alias sname { return $left($1-,$calc($pos($1-,SERVER:,1) - 1)) }
alias shost {
  var %server.host $mid($1-,$calc($pos($1-,SERVER:,1) + 7),$len($1-))
  return $gettok($left(%server.host,$calc($pos(%server.host,GROUP:,1) - 1)),1,58) $gettok($gettok($left(%server.host,$calc($pos(%server.host,GROUP:,1) - 1)),2,58) ,1,44)
}

dialog MultiServ {
  title "Multiple Server Connection"
  size -1 -1 430 200
  text "Server:", 400, 5 5 50 15
  combo 1, 5 20 300 180, edit vsbar
  text "Nick:", 401, 315 50 45 15
  edit "", 2, 345 47 80 20, autohs
  text "Ident:", 402, 315 75 45 15
  edit "", 3, 345 72 80 20
  button "Connect",500, 330 160 80 30, DEFAULT
  button "",499, -10 -10 1 1, OK
}

on *:DIALOG:MultiServ:INIT:*: { 
  did -b MultiServ 500
  set %selectedserver n0
  var %ticks $ticks
  var %start 0
  :start
  var %cur n $+ %start
  var %server.ini $readini servers.ini servers %cur
  if (%server.ini == $null) {
    did -c MultiServ 1 1
    halt 
  }
  did -a MultiServ 1 $sname(%server.ini)  
  inc %start
  goto start
}

on *:DIALOG:MultiServ:*:*: { 
  if ($did(MultiServ,2) != $null) && ($did(MultiServ,3) != $null) && ($did(MultiServ,1) != $null) { did -e MultiServ 500 }
  else { did -b MultiServ 500 }
  if ($did == 500) { 
    set %server.sel $readini servers.ini servers %selectedserver
    set  %server $shost(%server.sel)
    if ($sname(%server.sel) != $did(MultiServ,1)) { set %server $did(MultiServ,1) }
    set %socket.name Multi [ $+ [ $rand(1000,9999) ] ]
    set %socket.nick $did(MultiServ,2)
    set %socket.ident $did(MultiServ,3)
    sockopen %socket.name %server 6667
    dialog -k MultiServ
    unset %SelectedServer
  }
  if ($did == 1) && ($devent == sclick) {  set %SelectedServer n $+ $calc($did(Multiserv,1).sel - 1) }
}


on *:SOCKOPEN:multi*: {
  window -aek @ $+ $sockname
  titlebar @ $+ $sockname 
  set %login. [ $+ [ $sockname ] ] no
  ;  socklisten ident 113
}

on *:SOCKREAD:ident*: {
  sockread %ident
  if (%ident) sockwrite -n $sockname $gettok(%ident,1,32) $+ , 6667 : USERID : UNIX : %socket.ident
  ;  if (%ident) sockwrite -n $sockname $gettok(%ident,1,32) $+ , 6667 : USERID : UNIX : Gehad
}
on *:SOCKLISTEN:ident: sockaccept ident $+ $ticks

on *:SOCKREAD:multi*:{ 
  if (%login. [ $+ [ $sockname ] ] ) {
    sockwrite -n $sockname user %socket.ident Test1 Test2 : Psionic's Socket-Server script Version 1.1
    sockwrite -n $sockname nick %socket.nick
    sockmark $sockname %socket.nick
    unset %nick
    unset %login. [ $+ [ $sockname ] ]
  }
  var %temp
  if ($sockerr > 0) {
    echo -a 0,12Error number $sockerr on socket $sock(multi)
    return 
  }
  :nextread 
  sockread %temp 
  if ($sockbr == 0) { return }
  if (%temp) { FilterSocket [ @ [ $+ [ $sockname ] ] ] %temp }
  goto nextread 
} 

on *:CLOSE:@multi*: { 
  sockwrite -n $right($target,-1) quit :Leaving - Psionic's Multi-IRC Script for mIRC
  sockclose $right($target,-1) 
  close -@* $+ $right($target,-1)  $+ *
}
on *:CLOSE:@#*-Multi*: { sockwrite -n $gettok($target,2,45) part $right($gettok($target,1,45),-1) }
on *:CLOSE:@Chat-*:  { sockclose $right($active,-1) }

on *:INPUT:@: { 
  haltdef
  if (@Msg:* iswm $active) { 
    echo $active < $+ %socket.nick $+ > $1-
    sockwrite -n $gettok($active,2,58) privmsg $gettok($active,3,58) : $+ $1-
  }
  if (@Multi isin $active) {
    if ($1 == /join) { 
      sockwrite -n $right($active,-1) $right($1-,-1)
      sockwrite -n $right($active,-1) mode $2
      window -keaSl11 @ $+ $2 $+ - $+ $right($active,-1) 
      halt 
    }
    if ($1 == /quit) { 
      sockwrite -n $right($active,-1) QUIT :Psionic's Multi-IRC client Script
      halt
    }
    sockwrite -n $right($active,-1) $1-
  }
  if (@#* iswm $active) {
    if (/msg == $1) {
      echo $active 10* $+ $$2 $+ * $$3-
      sockwrite -n $gettok($active,2,45) privmsg $$2 : $+ $$3-
      halt
    }
    if (/me == $1) { 
      echo $active  $+ $colour(action) $+ * $sock($gettok($active,2,45)).mark $2-
      sockwrite -n $gettok($active,2,45)  privmsg $gettok($right($active,-1),1,45) :ACTION $$2- $+ 
      halt
    }
    if ($1 == /join) { 
      sockwrite -n $gettok($active,2,45) $right($1-,-1)
      sockwrite -n $gettok($active,2,45) mode $2
      window -keaSl11 @ $+ $2 $+ - $+ $right($active,-1) 
      halt 
    }
    else {
      var %opnick @ $+ $1
      var %vnick + $+ $1
      if ($fline($active,$1,1,1)) || ($fline($active,%opnick,1,1)) || ($fline($active,%vnick,1,1))  {
        echo $active < $+ $sock($gettok($active,2,45)).mark $+ > 3* $+ 10 $+ $$1 $+ 3* $2-
        sockwrite -n $gettok($active,2,45) privmsg $gettok($right($active,-1),1,45) : $+ 3* $+ 10 $+ $$1 $+ 3* $2-
      }
      else {
        echo $active < $+ $sock($gettok($active,2,45)).mark $+ > $1-
        sockwrite -n $gettok($active,2,45) privmsg $gettok($right($active,-1),1,45) : $+ $1-
      }
    }
  }
  if (@Chat-* iswm $active) {
    echo $active < $+ %socket.nick $+ > $1-
    sockwrite -n $right($active,-1) $1-
  }
  halt
}



alias FilterSocket {
  var %socket.nick $sock($sockname).mark
  var %window @ $+ $4 $+ - $+ $sockname
  if ($left($4,1) == :) { 
    var %window @ $+ $right($4,-1) $+ - $+ $sockname
  }
  if ($window(%window)) {
    if ($3 == MODE) { 
      echo %window 3*** $right($gettok($2,1,33),-1) sets mode $5- 

      ; sockwrite -n $sockname names $4
    }
    elseif ($3 == JOIN) {
      if ($left($4,1) == :) {
        echo %window  $+ $colour(join) $+ *** $right($gettok($2,1,33),-1) has joined $right($4,-1)
      }
      else {
        echo %window  $+ $colour(join) $+ *** $right($gettok($2,1,33),-1) has joined $4
      }
      aline -l %window $right($gettok($2,1,33),-1)
    }
    elseif ($3 == PART) {
      echo %window  $+ $colour(join) $+ *** $right($gettok($2,1,33),-1) has left $4 ( $+ $right($5-,-1) $+ )
      if ($fline(%window,$right($gettok($2,1,33),-1),1,1)) dline -l %window $fline(%window,$right($gettok($2,1,33),-1),1,1)
      if ($fline(%window,+ $+ $right($gettok($2,1,33),-1),1,1)) dline -l %window $fline(%window,+ $+ $right($gettok($2,1,33),-1),1,1)
      if ($fline(%window,@ $+ $right($gettok($2,1,33),-1),1,1)) dline -l %window $fline(%window,@ $+ $right($gettok($2,1,33),-1),1,1)
    }
    elseif ($3 == KICK) { 
      echo %window 3*** $right($gettok($2,1,33),-1) has kicked $5 ( $+ $right($6-,-1) $+ )
      dline -l %window $fline(%window,$5,1,1)
    }
    elseif ($3 == PRIVMSG) {
      if (ACTION * iswm $right($5-,-1)) { echo %window  $+ $colour(action) $+ * $right($gettok($2,1,33),-1) $left($6-,-1) }
      else { echo %window < $+ $right($gettok($2,1,33),-1) $+ > $right($5-,-1) }
    }
    elseif ($3 == NOTICE) {
      echo %window < $+ $right($gettok($2,1,33),-1) $+ > $right($5-,-1)
    }
  }
  else {
    if ($3 == NICK) {
      var %nick $gettok($right($2,-1),1,33)
      var %address $gettok($2,2,33)
      var %newnick $right($4,-1)
      if (%nick == %socket.nick) { 
        sockmark $sockname
        sockmark $sockname %newnick 
      }
      var %start 1
      var %end $window(0)
      :start
      if ($window(%start) == @ $+ $sockname) {
        echo $window(%start) 3*** %nick ( $+ %address $+ ) has changed nick to %newnick
      }
      if ($left($window(%start),2) == @#) && ($gettok($window(%start),2,45) == $sockname) {
        if ($fline($window(%start),%nick,1,1)) {
          echo $window(%start) 3*** %nick has changed nick to %newnick
          dline -l $window(%start) $fline($window(%start),%nick,1,1)
          aline -l $window(%start) %newnick
        }
      }
      inc %start
      if (%start <= %end) { goto start }
      halt
    }
    if ($3 isnum) {
      echo $$1 11,1 RAW $3 2 $5- 
      if ($3 == 353) { 

        var %window @ $+ $6 $+ - $+ $sockname
        var %start 1
        var %end $numtok($7-,32)
        var %nicks $right($7-,-1)
        var %nicknum 1- $+ $line(%window,0,1)
        if (%names. [ $+ [ $sockname ] ]) {
          dline -l %window %nicknum
          unset %names. [ $+ [ $sockname ] ]
        }
        :start
        if ($fline(%window,$gettok(%nicks,%start,32),1,1)) goto skip
        aline -l %window $gettok(%nicks,%start,32) 
        :skip
        inc %start
        if (%start <= %end) { goto start }
      }
      if ($3 == 366) { set %names. [ $+ [ $sockname ] ] yes }
      if ($3 == 332) { 
        if ($dialog(Channel)) {
          did -a Channel 10 $7-
          set %channel.topic $7-
          halt
        }
        var %window @ $+ $5 $+ - $+ $sockname
        titlebar %window $7-
        echo %window 3*** Topic is " $+ $7- $+ 3"
      }
      if ($3 == 333) {
        if ($dialog(Channel)) halt
        var %window @ $+ $5 $+ - $+ $sockname
        echo %window 3*** Topic set by $6 on $asctime($7, mmmm dd - hh:nn:ss)
      } 
      if ($3 == 328) {
        var %window @ $+ $5 $+ - $+ $sockname
        echo %window 3*** Web site: $right($6-,-1)
      }
      if ($3 == 324) { 
        var %window @ $+ $5 $+ - $+ $sockname
        if ($dialog(Channel)) {
          if (i isin $6) did -c Channel 1
          if (l isin $6) did -c Channel 2
          if (p isin $6) did -c Channel 3
          if (s isin $6) did -c Channel 4
          if (k isin $6) did -c Channel 5
          if (m isin $6) did -c Channel 6
          if (n isin $6) did -c Channel 7
          if (t isin $6) did -c Channel 8
          else { did -e Channel 10 | did -e Channel 401 }
          if (l isin $6) && (k isin $6) { did -a Channel 9 $7 | did -a Channel 11 $8 }
          if (l isin $6) && (k !isin $6) { did -a Channel 9 $7  }
          if (l !isin $6) && (k isin $6) { did -a Channel 11 $7 }
          halt
        }
        echo %window 3*** Channel modes are $6-
      }
      if ($3 == 367) {
        if ($dialog(Channel)) {
          did -a Channel 20 $6 ( $+ $gettok($7,1,33) on $asctime($ctime,dddd) at $time($ctime) $+ )
        }
      }
      halt
    }
    elseif ($3 == PRIVMSG) {
      if (DCC CHAT * iswm $right($5-,-1)) {
        echo $$1  $+ $colour(ctcp) $+ ** $right($gettok($2,1,33),-1) is trying to DCC CHAT you ( $+ $longip($8) $+ )
        set %Chat- $+ $right($gettok($2,1,33),-1) $longip($8)
        .timer 1 0 ChatFrom $right($gettok($2,1,33),-1) $longip($8) $left($9,-1)
        halt
      }
      elseif ($chr(1) isin $right($5,-1)) {
        echo -a 4[ $+ $gettok($right($2,-1),1,33) $right($5,-2) $+ $chr(93) $left($6-,-1)
        if ($right($5,-2) == VERSION) {
          sockwrite -n $right($$1,-1) notice $gettok($right($2,-1),1,33) $chr(1) $+ $right($5,-2) $+ $chr(1) :Reply %multirc.version
        }
      }
      else {
        var %window @Msg: $+ $sockname $+ : $+ $right($gettok($2,1,33),-1))
        if ($Window(%window) == $Null) {
          window -nke @Msg: $+ $sockname $+ : $+ $right($gettok($2,1,33),-1)
        }
        if (ACTION * iswm $right($5-,-1)) { echo @Msg: $+ $sockname $+ : $+ $right($gettok($2,1,33),-1)  $+ $colour(action) $+ * $right($gettok($2,1,33),-1) $left($6-,-1) | halt }
        echo @Msg: $+ $sockname $+ : $+ $right($gettok($2,1,33),-1) < $+ $right($gettok($2,1,33),-1) $+ > $right($5-,-1) 
      }
      halt
    }
    elseif ($2 == ERROR) { 
      echo $$1 3*** $right($3-,-1)
      halt
    }
    elseif ($3 == NOTICE) {
      echo $$1  $+ $colour(notice) - $+ $right($gettok($2,1,33),-1) $+ - $right($5-,-1)
      halt
    }
    elseif ($3 == QUIT) {
      var %nick $gettok($right($2,-1),1,33)
      var %address $gettok($right($2,-1),2,33)
      var %quitmsg $right($4-,-1)
      var %start 1
      var %end $window(0)
      :start
      if ($window(%start) == @ $+ $sockname) {
        echo $window(%start) 3*** %nick ( $+ %address $+ ) has quit IRC. ( $+ %quitmsg $+ )
      }
      if ($left($window(%start),2) == @#) && ($gettok($window(%start),2,45) == $sockname) {
        if ($fline($window(%start),%nick,1,1)) {
          dline -l $window(%start) $fline($window(%start),%nick,1,1)
          echo $window(%start) 3*** %nick has quit IRC. ( $+ %quitmsg $+ )
        }
      }
      inc %start
      if (%start <= %end) { goto start }
      halt
    }
    if ($2 == PING) { 
      echo $$1 3PING? PONG! 
      sockwrite -n $right($$1,-1) pong $right($3,-1)
    }
    else {
      echo $$1 $2-
    }
  }
}

alias ChatFrom {
  if ($AcceptChat($$1,$$2)) {
    sockopen Chat- $+ $$1 %Chat- [ $+ [ $$1 ] ] $$3
    echo -a sockopen -n Chat- $+ $$1 %Chat- [ $+ [ $$1 ] ] $$3
  }
}
alias AcceptChat {
  return $$?!="Dcc chat from $$1 ( $+ $$2 $+ )"
}
on *:SOCKOPEN:Chat-*: { 
  window -ake @ $+ $sockname
  sockwrite -n $sockname 100 %dcc.nick
  echo @ $+ $sockname 4* DCC Link established...
  echo @ $+ $sockname 4-
}
on *:SOCKCLOSE:Chat-*: {
  echo @ $+ $sockname 4* DCC Link terminated...
}

on *:SOCKREAD:Chat-*: {
  var %temp
  if ($sockerr > 0) {
    return 
  }
  :nextread 
  sockread %temp 
  if ($sockbr == 0) {
    return 
  }
  if (%temp) { 
    echo @ $+ $sockname < $+ $gettok($sockname,2,45) $+ > %temp
  }
  goto nextread 
}

menu @Multi* {
  Quit: { 
    sockwrite -n $right($active,-1) quit :Leaving - Psionic's Multi-IRC Script for mIRC
    sockclose $right($active,-1) 
    close -@* $+ $right($active,-1)  $+ *
  }
}

menu @#* {
  dclick: { 
    if ($InWindow) { mserv_channel } 
    else { window -kae @Msg: $+ $gettok($active,2,45) $+ : $+ $remove($sline($active,1),@,+) }
  }
}
menu @#* {
  ;Main Channel settings
  $iif($InWindow,Channel Settings): mserv_channel

  ;Nicklist
  $iif($NotInWindow,Query) { window -kae @Msg: $+ $gettok($active,2,45) $+ : $+ $remove($$1,@,+) }
  ;  $iif($NotInWindow,DCC Chat) { InitiateChat $$1 }
  -
  $iif($NotInWindow,Control)
  .$iif($NotInWindow,Op) : sockwrite -n $gettok($right($active,-1),2,45) mode $gettok($right($active,-1),1,45) +o $$1
  .$iif($NotInWindow,Deop): sockwrite -n $gettok($right($active,-1),2,45) mode $gettok($right($active,-1),1,45) -o $$1
  .$iif($NotInWindow,Voice) : sockwrite -n $gettok($right($active,-1),2,45) mode $gettok($right($active,-1),1,45) +v $$1
  .$iif($NotInWindow,Devoice): sockwrite -n $gettok($right($active,-1),2,45) mode $gettok($right($active,-1),1,45) -v $$1
  .$iif($NotInWindow,Kick) : sockwrite -n $gettok($right($active,-1),2,45) kick $gettok($right($active,-1),1,45) $$1
  .$iif($NotInWindow,Kick (why)): sockwrite -n $gettok($right($active,-1),2,45) kick $gettok($right($active,-1),1,45) $$1 : $+ $$?="Why kick?"
  .$iif($NotInWindow,Kick/Ban) : {
    sockwrite -n $gettok($right($active,-1),2,45) kick $gettok($right($active,-1),1,45) $$1
    sockwrite -n $gettok($right($active,-1),2,45) mode $gettok($right($active,-1),1,45) +b $$1
  }
  .$iif($NotInWindow,Ban): sockwrite -n $gettok($right($active,-1),2,45) mode $gettok($right($active,-1),1,45) +b $$1
  .$iif($NotInWindow,Unban): sockwrite -n $gettok($right($active,-1),2,45) mode $gettok($right($active,-1),1,45) -b $$?="What to unban?"
}

alias InWindow {
  if ($mouse.x) return $true
  return $false
}
alias NotInWindow {
  if ($mouse.x) return $false
  return $true
}

alias InitiateChat {
  .enable #dnscheck
  set %chat.nick $$1
  set %port $rand(2000,5000)
  set %socket $gettok($active,2,45)  
  dns $$1
}

#dnscheck off
;on *:DNS: { 
;  set %IP $iaddress
;  sockopen Chat- $+ %chat.nick %ip %port
;  sockwrite -n %socket privmsg %chat.nick : $+ DCC CHAT chat $longip($ip) %port $+ 
;  socklisten temp.dccchat %port
;}
;on *:SOCKLISTEN:temp.dccchat: { 
;  sockaccept ChatDCC
;  sockwrite -n ChatDCC 100 $nick
;}


#dnscheck end
alias mserv_channel {
  echo -a 3*** Retreiving $right($gettok($active,1,45),-1) info...
  var %opnick @ $+ %socket.nick
  set %ch.set.op $line($active,$fline($active,%opnick,1,1),1)
  set %ch.sock $gettok($active,2,45)
  set %ch.set $right($gettok($active,1,45),-1)
  dialog -m Channel Channel
}

dialog channel {
  title "Channel settings"
  size -1 -1 400 257
  button "&Apply Changes",400,175 225 85 25, default
  button "&Unban",401,265 225 55 25
  button "&Close",402,325 225 55 25, CANCEL
  button "", 500, -10 -10 1 1, OK
  text "",100,5 5 395 15, center
  text "Topic:",101, 10 27 35 15
  edit "",10, 45 24 350 22, autohs 
  box "Channel Modes:",490, 5 55 163 195 
  check "&Invite Only",1, 15 70 80 20
  check "&Limit to:",2, 15 90 55 20
  edit "",9,72 91 45 20
  check "&Private",3, 15 110 55 20
  check "&Secret",4, 15 130 55 20
  check "&Key:",5, 15 150 40 20
  edit "",11,60 151 80 20
  check "&Moderated",6, 15 170 80 20
  check "&No external messages",7, 15 190 123 20
  check "Only ops change &topic",8, 15 210 125 20
  text "Channel ban list",99, 175 60 200 15, center
  list 20, 175 75 215 155, vsbar extsel
}

on *:DIALOG:Channel:INIT:*: { 
  sockwrite -n $gettok($right($active,-1),2,45) mode $gettok($right($active,-1),1,45) -b
  sockwrite -n $gettok($right($active,-1),2,45) mode $gettok($right($active,-1),1,45)
  sockwrite -n $gettok($right($active,-1),2,45) topic $gettok($right($active,-1),1,45)
  if (%ch.set.op == $null) {
    did -b Channel 1
    did -b Channel 2
    did -b Channel 3
    did -b Channel 4
    did -b Channel 5
    did -b Channel 6
    did -b Channel 7
    did -b Channel 8
    did -b Channel 9
    did -b Channel 10
    did -b Channel 11
    did -b Channel 401
    did -b Channel 400
    did -ra Channel 100 You are not an op in this channel
  }
  else { did -ra Channel 100 You are an op, and may change these settings. }
}
on *:DIALOG:Channel:*:*: {
  if ($did == 20) && ($devent == dclick) {
    ShowBanInfo $did(Channel,20,$did(Channel,20).sel)
  }
  if ($did == 401) { 
    var %start 1
    var %end $did(Channel,20,0).sel
    :start
    sockwrite -n %ch.sock mode %ch.set -b $gettok($did(Channel,20,$did(Channel,20,%start).sel),1,32)
    inc %start
    if (%start <= %end) { goto start }
  }
  if ($did == 400) { 
    if ($did(Channel,10) != %channel.topic) {
      sockwrite -n %ch.sock topic $did(Channel,10)
    }      
    var %+modes +
    var %-modes -
    if ($did(Channel,1).state == 1) { %+modes = %+modes $+ i }
    else { %-modes = %-modes $+ i }
    if ($did(Channel,2).state == 1) { %+modes = %+modes $+ l }
    else { %-modes = %-modes $+ l }
    if ($did(Channel,3).state == 1) { %+modes = %+modes $+ p }
    else { %-modes = %-modes $+ p }
    if ($did(Channel,4).state == 1) { %+modes = %+modes $+ s }
    else { %-modes = %-modes $+ s }
    if ($did(Channel,6).state == 1) { %+modes = %+modes $+ m }
    else { %-modes = %-modes $+ m }
    if ($did(Channel,7).state == 1) { %+modes = %+modes $+ n }
    else { %-modes = %-modes $+ n }
    if ($did(Channel,8).state == 1) { %+modes = %+modes $+ t }
    else { %-modes = %-modes $+ t }
    if ($did(Channel,5).state == 1) { %+modes = %+modes $+ k }
    else { %-modes = %-modes $+ k  }
    sockwrite -n %ch.sock mode %ch.set %+modes $did(Channel,9) $did(Channel,11)
    sockwrite -n %ch.sock mode %ch.set %-modes $did(Channel,9) $did(Channel,11)
  }
}

alias ShowBanInfo {
  dialog -m Popup Popup
  did -ra Popup 1 $1 was set by $right($2,-1) $left($3-,-1)
} 
dialog popup {
  title "Popup Info"
  size -1 -1 500 55
  text "",1,0 0 500 35
  button "&Close",2, 0 30 500 20,cancel
}
on *:DIALOG:popup:init:*: {
  dialog -f popup 1
}