IRC connections using sockets

By Daveoh on Mar 08, 2008

Automatically creates and maintains multiple socket connections to multiple IRC servers. The script should be added to to create more automated commands. Currently it returns PING replies from the server to maintain the connection and automatically joins a channel on connection.

Requires good knowledge of raw commands and decent knowledge of scripting in general.
Typing into a connection will send raw commands.
/writeall - Can be used to send raw commands to all connections.
/ircconnect [N] - Opens N new connections (N optional).

alias ircconnect {
  sockopen irc irc.quakenet.org 6667
  if ($1 isnum 2-) {
    var %i = $int($1) - 1
    while (%i) {
      .timer 1 %i sockopen irc irc.quakenet.org 6667
      dec %i
    }
  }
}
on *:SOCKOPEN:irc:{
  var %i = $calc($sock(irc*,0))
  sockrename irc irc $+ %i
  window -e @irc $+ %i
  echo @irc $+ %i $sockname : Connected to server.
  sockwrite -n irc $+ %i NICK DaveohTest $+ %i $+ $crlf $+ USER ident "" "irc.quakenet.org" :Daveoh
  echo @irc $+ %i -> NICK DaveohTest $+ %i
  echo @irc $+ %i -> USER ident "" "irc.quakenet.org" :Daveoh
}
on *:SOCKREAD:irc*:{
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) return
  tokenize 32 %temp
  if (%temp == $null) %temp = -
  echo @ $+ $sockname <- %temp
  if (PING == $1 && $2) {
    ;PING reply
    sockwrite -n $sockname PONG $2
    echo @ $+ $sockname -> PONG $2
  }
  elseif (001 == $2) {
    ;successfully connected to server
    sockwrite -n $sockname JOIN #Daveoh
    echo @ $+ $sockname -> JOIN #Daveoh
  }
  goto nextread
}
on *:SOCKCLOSE:irc*:{
  echo @ $+ $sockname $sockname : Lost connection.
}
on *:INPUT:@irc*:{
  if (/* !iswm $1) {
    sockwrite -n $right($active,-1) $1-
    echo @ $+ $right($active,-1) -> $1-
  }
}
alias writeall {
  var %i = 1
  while ($sock(irc*,%i)) {
    sockwrite -n $v1 $1-
    echo @ $+ $v1 -> $1-
    inc %i
  }
}
on *:CLOSE:@:{
  if ($sock($right($target,-1))) { .timer 1 0 window -e $target $chr(124) echo -s Reopened IRC connection window $target }
}

Comments

Sign in to comment.
Noutrious   -  May 10, 2008

Problem solved.

 Respond  
Daveoh   -  Apr 17, 2008

I don\'t know what server you\'re using.
You should debug a normal, stable connection to the server to see what\'s happening.
(woops, deleted comment :P)

 Respond  
Noutrious   -  Mar 20, 2008

Yeah, it works - i added things i needed and everything is almost fine till the \"Client exited\" thing - it means, when the nick idles in the chan throught the sockets, it gets Client exited quits pretty much, is it PING PONG related or anything else - i dont know.
Just curios about how to fix that.

 Respond  
Daveoh   -  Mar 18, 2008

I used it myself and it works for at least QuakeNet and similar servers.
If others require different commands, they need to be added. Knowledge of the IRC server and raw commands is needed.

 Respond  
Noutrious   -  Mar 18, 2008

As far as i tested, it is not tested, it gets Client exited pretty much - how to bugfix that?

 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.