mIRCB - mIRC Bouncer

By TMFKSOFT on Nov 30, 2011

I probably should post this in the Scripts section but it means uploading the script and its pretty uselsss to do that.

Its a 294 lined script, it allows you to use your mIRC like a BNC and is the start of me creating my own mIRC ZNC.

There are tonnes of bugs and debugging dont want to turn off, you cant join channels on connect and must part all before joining.

For now load it in a mIRC you dont use for general use.

Im fixing those bugs!

Fill in the config Vars and type /start

Leave comments below!

If you are in a network remember to portforward.

; mIRCB Alpha v1.0
; By Thomas Edwards (TMFKSOFT)

; CAUTION: This script is still VERY buggy.
;          Don't blame me about bugs, I will fix them
;          when I find a solution.
;          Report ALL bugs to http://bugs.ilkotech.co.uk/
;          Select the project "mIRCB alpha" and fill in all fields.

; Limitations: Only one client can be handled at a time.
; Commands: /start /stop

; PM '~mIRCB' to control via client.
; ~mIRCB client commands:
; DISCONNECT = Disconnect from IRC and close mIRCB
; RECONNECT = Reconnect to IRC
; AWAYNICK <nick> = Set away NICK
; HELP = Show this help.

; Before you start, joining channels dont work.
; Just leave %channels as it is let your client or services do what you need.

alias start {

  ; This is a config block.
  ; Modify all to your pleasing.
  ; DO NOT leave anything blank!!!

  ; IRC Server Info
  set %addr irc.ilkotech.co.uk
  set %port 6667

  ; User info
  set %nick MainNick
  set %awaynick MainNick[Away]
  set %realname Amazing Realname
  set %username something

  ; Channels to auto join [MAY NOT WORK]
  set %channels #0,0

  ; Password for mIRCB server. It is used with the main IRC server too.
  ; Its a good idea to use your irc pass so when mIRCB connects you auto
  ; identify for your nick!

  set %pass myamazingpassword

  ; Crap out RAW IRC and info notifications?
  ; For general mIRC set to 0 for an untouched mIRC or just connecting set 1

  set %debug 1
  ;The debug var is checked all the time.

  ;======================================================;
  ; DO NOT EDIT BELOW THIS LINE IF YOU WANT TO LIVE!     ;
  ;======================================================;
  set %connected 0
  ; Connect to IRC Server
  echo 4[mIRCB] Connecting to IRCD.
  sockopen ircd %addr %port

  ; Listen for the user.
  echo 4[mIRCB] Opening listening socket.
  socklisten user.listen 1337
}
on 1:sockopen:ircd:{
  sockwrite $sockname NICK %nick $+ $crlf
  sockwrite $sockname PASS %pass $+ $crlf
  sockwrite $sockname USER %username "" " $+ %addr $+ " : $+ %realname $+ $crlf

  if ($sock(user).status != $null) {
    sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ Connected to %addr $+ : $+ %port $+ $crlf
  }

}
on 1:sockread:ircd:{
  var %read
  sockread %read
  if (%debug) {  
    echo 3[IRCD] %read
  }
  tokenize 32 %read

  if ($1 == PING) {
    sockwrite $sockname PONG $2- $+ $crlf
  }
  if ($2 == 001) {
    if (%debug) {
      echo 3CONNECTED!
    }
  }
  if ($2 == NICK) {
    set %nick $remove($3,:)
    if (%debug) {
      echo 3[IRCD] Nick changed.
    }
  }
  if ($2 == KILL) {
    if ($3 == %nick || $3 == %awaynick) {
      if (%debug) {
        echo 4[IRCD] 4Bouncer Terminated
      }
      if ($sock(user).status != $null) {
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ Disconnected from %addr $+ : $+ %port reconnecting. $+ $crlf
      }

      sockclose $sockname      
      sockopen ircd %addr %port
    }

  }

  if ($sock(user).status != $null) {
    sockwrite user %read $+ $crlf
  }
  else {
    if (%debug) {
      echo 4[mIRCB] No User connected.
    }
  }
}
on 1:socklisten:user.listen:{
  if ($sock(user).status == $null) {
    if (%debug) {    
      echo 7[USER] User connected.
    }
    set %connected 0
    set %verify 0
    sockaccept user
  }
  else {
    if (%debug) {
      echo 7[USER]4 Refusing 2nd connection. Already connected.
    }
  }
}

on 1:sockread:user:{
  var %read
  sockread %read
  tokenize 32 %read

  if ($1 == PASS) {
    if ($2 == %pass) {
      set %verify 1      
      sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ Password accepted. Welcome %nick $+ $crlf
      if ($sock(ircd).status != $null) {
        sockwrite ircd JOIN %channels $+ $crlf
        sockwrite ircd AWAY $+ $crlf
      }

    }
    else {
      if (%debug) {
        echo 7[USER]4 Bad Password $2
      }
      set %verify 0
      sockclose user
      HALT
    }
  }
  else {
    if (%verify == 0) {
      if (%debug) {
        echo 7[USER]4 No Password
      }
      set %verify 0
      sockclose user
      HALT
    }
  }

  if ($1 == PRIVMSG) {
    if ($2 == ~MIRCB) {
      var %text $remove($3-,:)
      tokenize 32 %text
      if ($1 == disconnect) {
        sockwrite ircd QUIT :mIRCB Quitting $+ $crlf
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ Disconnected from %addr $+ : $+ %port $+ $crlf
        stop 
      }
      else if ($1 == reconnect) {
        sockwrite ircd QUIT :mIRCB Quitting $+ $crlf
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ Reconnecting to %addr $+ : $+ %port $+ $crlf
        sockclose ircd
        sockopen ircd %addr %port
      }
      else if ($1 == awaynick) {
        if ($2 == $null) {
          sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ Away nick cannot be empty. $+ $crlf
        }
        else {
          sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ Away nick changed to $+(',$2,') $+ $crlf
          set %awaynick $2
        }
      }
      else if ($1 == help) {
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ mIRCB Help $+ $crlf
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ =============================== $+ $crlf
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ DISCONNECT = Close mIRCB, same as /stop $+ $crlf
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ RECONNECT = Reconnect to IRC $+ $crlf
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ AWAYNICK = Set your away nick. $+ $crlf
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ =============================== $+ $crlf
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ mIRCB by Thomas Edwards (TMFKSOFT) 2011 $+ $crlf
      }
      else {
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ Unknown command $+ $crlf
      }

      halt
    }
  }

  if ($1 == USER) {
    sockwrite $sockname :mircb.server NICK %nick $+ $crlf
    sockwrite $sockname :mircb.server 001 %nick :Welcome to the mIRCB IRC Network $+(%nick,!,%usernamem,@,$sock($sockname).saddr) $+ $crlf

    if ($sock(ircd).status == $null) {
      if ($sock(user).status != $null) {
        sockwrite user :~mIRCB!mircb@mircb.server privmsg %nick : $+ Connecting to %addr $+ : $+ %port $+ $crlf
      }
      sockopen ircd %addr %port
    }
    else {
      sockwrite ircd NICK %nick $+ $crlf
      sockwrite ircd motd $+ $crlf
      sockwrite IRCD JOIN %channels $+ $crlf
      sockwrite $sockname JOIN %channels $+ $crlf
      set %connected 1
    }
    HALT
  }
  else if ($1 == NICK) {
    if (%connected == 1) {
      if (%debug) {
        echo 7[USER] Nick Attempting nick change to %nick
      }
      sockwrite ircd $1- $+ $crlf
    }
  }
  else if ($1 == QUIT) {
    sockwrite ircd AWAY :mIRCB auto away. $asctime(HH:nn dd/mm/yyyy) $+ $crlf
    set %connected 0
    if ($sock(ircd).status != $null) {    
      sockwrite ircd NICK %awaynick $+ $crlf
    }
    if (%debug) {
      echo 7[USER] User Disconnected
    }
    sockclose $sockname
  }
  else {
    if ($sock(ircd).status != $null) {    
      sockwrite ircd $1- $+ $crlf
    }
  }
  if (%debug) {
    echo 7[USER] %read
  }
}
on 1:sockclose:user:{
  set %connected 0
  set %verify 0
  if ($sock(ircd).status != $null) {
    sockwrite ircd NICK %awaynick $+ $crlf
    sockwrite ircd AWAY :mIRCB auto away. $asctime(HH:nn dd/mm/yyyy) $+ $crlf

  }
  if (%debug) {
    echo 7[USER] User Disconnected
  }
}
on 1:sockclose:ircd:{
  if ($sock(user).status != $null) {
    sockwrite user :~mIRCB!mircb@mircb.ilkotech.co.uk privmsg %nick : $+ Disconnected from %addr $+ : $+ %port reconnecting. $+ $crlf
  }     
  sockopen ircd %addr %port
}
alias stop {
  if ($sock(user).status != $null) {
    echo 4[mIRCB] Closed user socket.
    sockclose user
  }  
  if ($sock(user.listen).status != $null) {
    echo 4[mIRCB] Closed listen socket.
    sockclose user.listen
  }  
  if ($sock(ircd).status != $null) {
    echo 4[mIRCB] Closed IRCD socket.
    sockclose ircd
  } 
}

Comments

Sign in to comment.
Clark2016   -  Sep 13, 2016

So if this is kind of a bouncer, will it still remain connected even if we shut down our computer???

 Respond  
IllogicTC   -  Feb 03, 2012

Used to operate a sorter system with a computer using Win2000 Server. Worked great. Easy interface, of course, and uptime never caused an issue. They did a yearly purge and reset just to be sure, and that was about it.

 Respond  
  -  Feb 02, 2012

Great idea, great work/starting point. I like it. hope to see further work done.

as for windows servers, I can tell you all day long I set up servers, Windows and Linux Boxes/ VPSs and both have there pros and cons.

 Respond  
blackvenomm666   -  Feb 01, 2012

<3 windows

 Respond  
Sorasyn   -  Feb 01, 2012

Xpl0reR: Why so cynical? It seems as if your comments are targeted for disagreement. In any case, I for one like the snippet.

 Respond  
SplitFire   -  Feb 01, 2012

You have no idea what windows server is capable of :p

 Respond  
xplo   -  Dec 06, 2011

windows server.. eww what a waste of disc space.

 Respond  
Frenetic   -  Dec 01, 2011

Jaytea said:> Xpl0reR, what makes you think this can only be used by the very same machine hosting the script? it's simply BNC software coded in mIRC script, with uses on par with any other similarly featured BNC.

You're right, they could host mIRC on a windows server and use it like so.

 Respond  
TMFKSOFT   -  Dec 01, 2011

Xpl0reR:
Its orignal creation was to allow me to use my mobile phone and keep my host, for the simple reason it helps with opering secuirty and also EggDrop, I'd rather keep my home host recognised on my bot rather than adding extra hosts that i may never use again. Also its useful in the same vain as what jaytea said.

Thanks to everyone for commenting :)

 Respond  
jaytea   -  Nov 30, 2011

Xpl0reR, what makes you think this can only be used by the very same machine hosting the script? it's simply BNC software coded in mIRC script, with uses on par with any other similarly featured BNC.

i made myself a similar script once for my work client once (on a client i actually used, so the 'ircd' socket in this snippet was actually a series of mIRC handled connections) so that i could IRC from home on the same connections.

 Respond  
Dodge   -  Nov 30, 2011

right idea, wrong line.

 Respond  
IllogicTC   -  Nov 30, 2011

I'm kinda with Xpl0reR on this one. It's a great and original concept, but would really not offer the true "bouncing."

 Respond  
xplo   -  Nov 30, 2011

this is completely useless... your client is your bouncer. you are evading the principal reason why someone would use a bouncer...
Nice coding, it completely works, i see your talent.. the thing is.. its not usefull... at all.

a Bouncer is to keep you alive in case your client crashes, or to protect yourself from ddos attacks. witch even now, your client will be the one receiving it (if happening)

3/10 (not usefull)
+Like (Great idea)

 Respond  
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.