mIRC IRC BNC for a bot

By [Plornt] on May 05, 2010

Ok I coded this recently it works for what it does 100% but not everythings coded in. Its designed so you can be out and about and connect to your computers mirc and see what your bot see's, kind of like a IRC bouncer. I was going to make a control channel etc but I dont have the time at the moment.

Its really just a concept idea at the moment. I will be coding a full server out of mIRC soon when I get the time just for the sake of it.

To use:
Load onto your bot and type /open
this will then allow connections to your computer on port 6667.

For testing:
on another mirc type /server -m localhost
and then /auth user pass (Litrally like that, dont try to change them to a real user and pass)

It will then act like a real IRC server but will actually be your bot.

For out and about:
Get your ip by googling whats my ip.
then /server -m IPADDRESS then /auth user pass

alias open {
  socklisten irc999 6667
  ;listen on port 6667 for IRC
  ;Add other ports using the following format:
  ; socklisten irc99<Number> <PORT>
}
alias sockwrite {
  echo -a <- $2-
  sockwrite $1-
}
on *:socklisten:irc99*:{
  ;Assign a tempary name to the socket
  var %tmp guest $+ $r(1,1000)
  sockaccept %tmp
}
on *:PART:#:{
  var %i 1
  while (%i <= $lines(users.txt)) {

    sockwrite -n $read(users.txt,%i) : $+ $address($nick,5) PART $chan $1-
    inc %i
  }
}
on *:JOIN:#:{
  var %i 1
  while (%i <= $lines(users.txt)) {
    sockwrite -n $read(users.txt,%i) : $+ $address($nick,5) JOIN $chan 
    inc %i
  }
}
on *:RAWMODE:#:{
  var %i 1

  while (%i <= $lines(users.txt)) {
    sockwrite -n $read(users.txt,%i) : $+ $address($nick,5) MODE $chan $1-
    inc %i
  }
}
on *:TEXT:*:#:{
  var %i 1 
  while (%i <= $lines(users.txt)) {
    sockwrite -n $read(users.txt,%i) : $+ $address($nick,5) PRIVMSG $chan : $+ $1-
    inc %i
  }
}
on *:ACTION:*:#:{
  var %i 1 
  while (%i <= $lines(users.txt)) {
    sockwrite -n $read(users.txt,%i) : $+ $address($nick,5) PRIVMSG $chan :ACTION $1-
    inc %i
  }
}
on *:SOCKREAD:*:{
  var $+(%,irc.,$sockname)
  sockread $+(%,irc.,$sockname)

  tokenize 32 $($+(%,irc.,$sockname),2)
  echo -a <- $1-
  if ($1 == NICK) {

    sockrename $sockname $2
    write users.txt $2
    var %i 1 
    while (%i <= $lines(users.txt)) {
      sockwrite -n $read(users.txt,%i) NOTICE AUTH :3-> USER $2 has connected.
      inc %i
    }

  }
  elseif ($1 == JOIN) {
    var %i 1 
    while (%i <= $lines(users.txt)) {
      sockwrite -n $read(users.txt,%i) : $+ $read(users.txt,%i) $+ ! $+ $me $+ @plorntirc.com JOIN : $+ $2
      inc %i
    }
    join $2
  }
  elseif ($1 == USER) {
    ;USER nnscript "" "localhost" :Tom
    writeini users.ini $sockname idnt $2
    writeini users.ini $sockname 2 $iif($remove($3,$chr(34)),$v1,unknown)
    writeini users.ini $sockname host $remove($4,$chr(34))
    writeini users.ini $sockname realname $remove($5,$chr(58))
    sockwrite -n $sockname NOTICE AUTH :4,1!!!9Please Auth yourself before going any further.4!!!

  }
  elseif ($1 == ping) {
    sockwrite -n $sockname PONG $2
  }
  elseif ($1 == PRIVMSG) {
    raw $1-
  }
  elseif ($1 == QUIT) {
    write -ds $+ $sockname users.txt
    var %i 1 
    while (%i <= $lines(users.txt)) {
      sockwrite -n $read(users.txt,%i) NOTICE AUTH :4,1User $sockname has disconnected
      inc %i
    }

  }
  elseif ($1 == AUTH) {
    if ($2 == user && $3 == pass) {
      sockwrite -n $sockname 001 $sockname :Welcome to the $me IRC Network $sockname $+ ! $+ $sockname $+ @ $+ $readini(users.ini,$sockname,host)
      sockwrite -n $sockname 002 $sockname :Your host is $remove($4,$chr(34)) $+ , running version PlorntIRCv1
      sockwrite -n $sockname 004 $sockname $readini(users.ini,$sockname,host) Unreal3.2.7 iowghraAsORTVSxNCWqBzvdHtGp lvhopsmntikrRcaqOALQbSeIKVfMCuzNTGj
      sockwrite -n $sockname 005 $sockname CMDS=KNOCK,MAP,DCCALLOW,USERIP NAMESX SAFELIST HCN MAXCHANNELS=35 CHANLIMIT=#:35 MAXLIST=b:60,e:60,I:60 NICKLEN=30 CHANNELLEN=32 TOPICLEN=307 KICKLEN=307 AWAYLEN=307 MAXTARGETS=20 :are supported by this server
      sockwrite -n $sockname 005 $sockname WALLCHOPS WATCH=128 SILENCE=15 MODES=12 CHANTYPES=# PREFIX=(qaohv)~&@%+ CHANMODES=beI,kfL,lj,psmntirRcOAQKVCuzNSMTG NETWORK= $+ $me CASEMAPPING=ascii EXTBAN=~,cqnr ELIST=MNUCT STATUSMSG=~&@%+ EXCEPTS :are supported by this server
      sockwrite -n $sockname 005 $sockname INVEX :are supported by this server
      sockwrite -n $sockname NOTICE AUTH :3,1Connection Accepted!
      var %i 1
      while (%i <= $chan(0)) {
        sockwrite -n $sockname : $+ $sockname $+ ! $+ $me $+ @plorntirc.com JOIN : $+ $chan(%i)

        var %h 1 
        while (%h <= $nick($chan(%i),0)) {

          var %names %names $nick($chan(%i),%h).pnick
          inc %h
        }

        sockwrite -n $sockname : $+ $readini(users.ini,$sockname,host) 353 $sockname = $chan(%i) : $+ %names
        unset %names
        sockwrite -n $sockname : $+ $readini(users.ini,$sockname,host) 366 $sockname $chan(%i) :End of /NAMES list.
        inc %i
      }
    }
  }
  .timer.ping. $+ $sockname 1 20 sockwrite -n $sockname PING :plorntnet $+ $rand(1000,9999)
}

Comments

Sign in to comment.
[Plornt]   -  Nov 07, 2010

Yeah, this is a old snippit where I was pretty much learning the capabilities of socklisten etc. Obviously I would also wildcard the sockwrites too.

Thanks for your comment though :)

 Respond  
jaytea   -  Nov 04, 2010

rather than re-create the raw messages from their respective events, you can relay them directly by using /debug to send lines to an alias. this will also complete the script by having CTCPs, numerical raw messages, etc. relayed too.

 Respond  
PuNkTuReD   -  Nov 04, 2010

i havent tested this, i have only ever seen one other mirc bnc.
i believe they both have a different take on the way of going about it.
very interesting script tho.
keep up the good work.

 Respond  
respecttt   -  Nov 04, 2010

alias open {
socklisten irc999 6667
;listen on port 6667 for IRC
;Add other ports using the following format:
; socklisten irc99
}
alias sockwrite {
echo -a <- $2-
sockwrite $1-
}
on :socklisten:irc99:{
;Assign a tempary name to the socket
var %tmp guest $+ $r(1,1000)
sockaccept %tmp
}
on *:PART:#:{
var %i 1
while (%i <= $lines(users.txt)) {

sockwrite -n $read(users.txt,%i) : $+ $address($nick,5) PART $chan $1-
inc %i

}
}
on :JOIN:#:{
var %i 1
while (%i <= $lines(users.txt)) {
sockwrite -n $read(users.txt,%i) : $+ $address($nick,5) JOIN $chan
inc %i
}
}
on
:RAWMODE:#:{
var %i 1

while (%i <= $lines(users.txt)) {
sockwrite -n $read(users.txt,%i) : $+ $address($nick,5) MODE $chan $1-
inc %i
}
}
on :TEXT::#:{
var %i 1
while (%i <= $lines(users.txt)) {
sockwrite -n $read(users.txt,%i) : $+ $address($nick,5) PRIVMSG $chan : $+ $1-
inc %i
}
}
on :ACTION::#:{
var %i 1
while (%i <= $lines(users.txt)) {
sockwrite -n $read(users.txt,%i) : $+ $address($nick,5) PRIVMSG $chan :ACTION $1-
inc %i
}
}
on :SOCKREAD::{
var $+(%,irc.,$sockname)
sockread $+(%,irc.,$sockname)

tokenize 32 $($+(%,irc.,$sockname),2)
echo -a <- $1-
if ($1 == NICK) {

sockrename $sockname $2
write users.txt $2
var %i 1 
while (%i <= $lines(users.txt)) {
  sockwrite -n $read(users.txt,%i) NOTICE AUTH :3-> USER $2 has connected.
  inc %i
}

}
elseif ($1 == JOIN) {
var %i 1
while (%i <= $lines(users.txt)) {
sockwrite -n $read(users.txt,%i) : $+ $read(users.txt,%i) $+ ! $+ $me $+ @plorntirc.com JOIN : $+ $2
inc %i
}
join $2
}
elseif ($1 == USER) {
;USER nnscript "" "localhost" :Tom
writeini users.ini $sockname idnt $2
writeini users.ini $sockname 2 $iif($remove($3,$chr(34)),$v1,unknown)
writeini users.ini $sockname host $remove($4,$chr(34))
writeini users.ini $sockname realname $remove($5,$chr(58))
sockwrite -n $sockname NOTICE AUTH :4,1!!!9Please Auth yourself before going any further.4!!!

}
elseif ($1 == ping) {
sockwrite -n $sockname PONG $2
}
elseif ($1 == PRIVMSG) {
raw $1-
}
elseif ($1 == QUIT) {
write -ds $+ $sockname users.txt
var %i 1
while (%i <= $lines(users.txt)) {
sockwrite -n $read(users.txt,%i) NOTICE AUTH :4,1User $sockname has disconnected
inc %i
}

}
elseif ($1 == AUTH) {
if ($2 == user && $3 == pass) {
sockwrite -n $sockname 001 $sockname :Welcome to the $me IRC Network $sockname $+ ! $+ $sockname $+ @ $+ $readini(users.ini,$sockname,host)
sockwrite -n $sockname 002 $sockname :Your host is $remove($4,$chr(34)) $+ , running version PlorntIRCv1
sockwrite -n $sockname 004 $sockname $readini(users.ini,$sockname,host) Unreal3.2.7 iowghraAsORTVSxNCWqBzvdHtGp lvhopsmntikrRcaqOALQbSeIKVfMCuzNTGj
sockwrite -n $sockname 005 $sockname CMDS=KNOCK,MAP,DCCALLOW,USERIP NAMESX SAFELIST HCN MAXCHANNELS=35 CHANLIMIT=#:35 MAXLIST=b:60,e:60,I:60 NICKLEN=30 CHANNELLEN=32 TOPICLEN=307 KICKLEN=307 AWAYLEN=307 MAXTARGETS=20 :are supported by this server
sockwrite -n $sockname 005 $sockname WALLCHOPS WATCH=128 SILENCE=15 MODES=12 CHANTYPES=# PREFIX=(qaohv)~&@%+ CHANMODES=beI,kfL,lj,psmntirRcOAQKVCuzNSMTG NETWORK= $+ $me CASEMAPPING=ascii EXTBAN=~,cqnr ELIST=MNUCT STATUSMSG=~&@%+ EXCEPTS :are supported by this server
sockwrite -n $sockname 005 $sockname INVEX :are supported by this server
sockwrite -n $sockname NOTICE AUTH :3,1Connection Accepted!
var %i 1
while (%i <= $chan(0)) {
sockwrite -n $sockname : $+ $sockname $+ ! $+ $me $+ @plorntirc.com JOIN : $+ $chan(%i)

    var %h 1 
    while (%h <= $nick($chan(%i),0)) {

      var %names %names $nick($chan(%i),%h).pnick
      inc %h
    }

    sockwrite -n $sockname : $+ $readini(users.ini,$sockname,host) 353 $sockname = $chan(%i) : $+ %names
    unset %names
    sockwrite -n $sockname : $+ $readini(users.ini,$sockname,host) 366 $sockname $chan(%i) :End of /NAMES list.
    inc %i
  }
}

}
.timer.ping. $+ $sockname 1 20 sockwrite -n $sockname PING :plorntnet $+ $rand(1000,9999)
}

 Respond  
Cheiron   -  May 06, 2010

you might want to take that into thought then as users attempting to run this script will be getting false messages and stuff when they try to connect..
have a think and re do the intro to explain what has to be changed as basically that unreal bit is a direct copy from raw 001 to raw 005 on the connect.
try and leave the raw001 to raw005 message blank if you can so it reads from the relevant server (unreal, inspirircd, bahaumut, etc)
other than that.. it doesnt look too bad at a first glance. these edits will need to be addressed though Plornt

 Respond  
[Plornt]   -  May 06, 2010

Well, the server I was using it for was Unreal IRCd so I took the thing because it helped with my script. the PlorntIRCv1 was when I was going to make a whole IRC server however I couldnt be fucked.

So yeah, it was just conveniance really and its not a major part of the script :/ It was just to make it work.

 Respond  
Cheiron   -  May 06, 2010

ummmm.. this event here..

elseif ($1 == AUTH) {
if ($2 == user && $3 == pass) {
sockwrite -n $sockname 001 $sockname :Welcome to the $me IRC Network $sockname $+ ! $+ $sockname $+ @ $+ $readini(users.ini,$sockname,host)
sockwrite -n $sockname 002 $sockname :Your host is $remove($4,$chr(34)) $+ , running version PlorntIRCv1
sockwrite -n $sockname 004 $sockname $readini(users.ini,$sockname,host) Unreal3.2.7 iowghraAsORTVSxNCWqBzvdHtGp lvhopsmntikrRcaqOALQbSeIKVfMCuzNTGj
sockwrite -n $sockname 005 $sockname CMDS=KNOCK,MAP,DCCALLOW,USERIP NAMESX SAFELIST HCN MAXCHANNELS=35 CHANLIMIT=#:35 MAXLIST=b:60,e:60,I:60 NICKLEN=30 CHANNELLEN=32 TOPICLEN=307 KICKLEN=307 AWAYLEN=307 MAXTARGETS=20 :are supported by this server
sockwrite -n $sockname 005 $sockname WALLCHOPS WATCH=128 SILENCE=15 MODES=12 CHANTYPES=# PREFIX=(qaohv)~&@%+ CHANMODES=beI,kfL,lj,psmntirRcOAQKVCuzNSMTG NETWORK= $+ $me CASEMAPPING=ascii EXTBAN=~,cqnr ELIST=MNUCT STATUSMSG=~&@%+ EXCEPTS :are supported by this server
sockwrite -n $sockname 005 $sockname INVEX :are supported by this server
sockwrite -n $sockname NOTICE AUTH :3,1Connection Accepted!
var %i 1
while (%i <= $chan(0)) {
sockwrite -n $sockname : $+ $sockname $+ ! $+ $me $+ @plorntirc.com JOIN : $+ $chan(%i)

forgive my ignorance here.. but that is very misleading..

first the host says it is running version PlorntIRCv1 aka this script...
the the rest has been taken from an unrealircd motd...
care to elaborate as soemthing is not adding up right..

 Respond  
[Plornt]   -  May 06, 2010

Hmm... Are you typing "/open" twice... You only need to type that once per mirc opening.

Ill also get some screenshots soon.

 Respond  
Flux   -  May 05, 2010

how to do this??

" /socklisten: 'irc999' socket in use (line 3, script.ini) " lol..

can u paste it here ur screenschots sir?. :) for its easy to review.. hehe..

 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.