mIRC Home    About    Download    Register    News    Help

Print Thread
#127618 15/08/05 08:05 AM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
$+(Good,$chr(32),$iif($gettok($time,1,58) < 12,morning,$iif($gettok($time,1,58) < 17,afternoon,evening)))

What ever :tongue:

Ppl am wondering how can i make an addon that makes many ppl chats privatly via socket with many option. all i want to know is the ideas to make this kind of addon. thats all and sorry for my english.

#127619 15/08/05 08:09 AM
Joined: Jun 2005
Posts: 30
_
Ameglian cow
Offline
Ameglian cow
_
Joined: Jun 2005
Posts: 30
Man, I really should learn sockets. There seems to be alot of need for socket scripting help. Oh, and your english wasn't all that bad. If you hadn't said anything I would have just thought you were tired and lazy. :tongue: :tongue:

~mike~

#127620 15/08/05 12:44 PM
Joined: Aug 2005
Posts: 128
S
Vogon poet
Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
/help Sockets
You have to make a server and a client, with your own protocol.
I don't know what suggestions to give you, i've made a chat like that and i still have it, here's the source if you're interested
Code:
alias irc_chat { window -aek0 @irc | background @irc 5 }
on 1:sockopen:irc:{
  if ($sockerr &gt; 0) { irc_wr 7Cannot connect to server. :((( | halt }
  irc_wr 7Connected.
  bset &amp;proto 1 5
  bset &amp;proto 2 9
  bset &amp;proto 3 25
  bset &amp;proto 4 38
  bset &amp;proto 5 1
  bset &amp;proto 6 20
  bset &amp;proto 7 50
  sockwrite -n irc &amp;proto
}
on 1:sockread:irc:{
  sockread %data
  tokenize 32 %data
  if ($1 === NICK) irc_wr 12Use 7/nick 12to set your nickname.
  elseif ($1 === PRINT) irc_wr $2-
  elseif ($1 === JOIN) irc_wr 12 $+ $2 $+  7has joined the chat.
  elseif ($1 === PART) irc_wr 12 $+ $2 $+  7has left the chat.
  elseif ($1 === CHGNICK) irc_wr 12 $+ $2 $+  7is now known as12 $3 $+ .
  elseif ($1 === MSG) aline @irc 12&lt;4 $+ $2 $+ 12&gt; 7 $+ $3- $+ 
}
alias irc_wr {
  if ($window(@irc)) aline @irc 9*** $1-
}
on 1:input:@irc:{
  if ($1 == /conn) {
    if (!$2) { irc_wr 12Syntax: /conn &lt;ip&gt; | halt }
    if ($sock(irc)) irc_wr 12Already connected to a server Use /quit first.
    else { sockopen irc $2 5238 | irc_wr 7Connecting to 12 $+ $2 $+ ... }
  }
  elseif ($1 == /quit) {
    if ($sock(irc)) {
      sockclose irc
      irc_wr 4Disconnected.
    }
    else irc_wr 4Not connected.
    haltdef
  }
  elseif ($1 == /nick) { sockwrite -n irc NICK $2 | haltdef }
  elseif ($mid($1,1,1) == /) irc_wr 12 $+ $1 $+ : Unknown command.
  else {
    if ($sock(irc)) sockwrite -n irc MSG $1-
    else irc_wr 12Not connected.
  }
}
alias irc_server {
  if ($sock(ircserver)) echo -a Server already opened.
  else socklisten ircserver 5238
}
on 1:socklisten:ircserver:{
  var %sockid = ircserver- $+ $ticks $+ - $+ $r(1000,9999)
  sockaccept %sockid
  sockmark %sockid proto
}
on 1:sockread:ircserver-*:{
  sockread &amp;data
  var %data = $remove($bvar(&amp;data,1-).text,$cr,$lf)
  tokenize 32 %data
  var %status = $gettok($sock($sockname).mark,1,32)
  var %nick = $gettok($sock($sockname).mark,2,32)
  if (%status == proto) {
    ;if ($bvar(&amp;data,1-) != 5 9 25 38 1 20 50) { sockwrite -n $sockname PRINT 12Invalid protocol. Disconnecting... | sockclose $sockname }
    if (0) haltdef
    else { sockmark $sockname nick | sockwrite -n $sockname NICK }
    halt
  }
  if (%status == nick) {
    if ($1 != NICK) { sockwrite -n $sockname PRINT 12Register first. }
    elseif ($inuse($2)) sockwrite -n $sockname PRINT 12Nickname in use.
    else {
      if ($len($2) &gt; 12) || (!$regex($2,/^[-a-zA-Z0-9^_`]+$/)) sockwrite -n $sockname PRINT Invalid nick.
      else { sockmark $sockname conn $2 | sockwrite -n $sockname PRINT 12Welcome. | ircserv_massmsg JOIN $2 }
    }
  }
  if (%status == conn) {
    if ($1 === NICK) {
      if ($len($2) &gt; 12) || (!$regex($2,/^[-a-zA-Z0-9^_`]+$/)) sockwrite -n $sockname PRINT Invalid nick.
      elseif (%nick == $2) haltdef
      elseif ($inuse($2)) sockwrite -n $sockname PRINT 12Nickname in use.
      else { sockwrite -n $sockname CHGNICK %nick $2 | sockmark $sockname conn $2 }
    }
    if ($1 === MSG) {
      if ($len($2-) &gt; 500) sockwrite -n $sockname PRINT 12Line too long.
      elseif ($2 == LUSERS) {
        sockwrite -n $sockname MSG ULIST Users list:
        var %i = 1
        while ($sock(ircserver-*,%i)) {
          var %s = $gettok($sock($ifmatch).mark,1,32)
          var %n = $gettok($sock($ifmatch).mark,2,32)
          var %a = $ifmatch
          if (%s == conn) sockwrite -n $sockname MSG ULIST %n $iif($3 == sock,%a)
          inc %i
        }
        sockwrite -n $sockname MSG ULIST $str(-,12)
      }
      else ircserv_massmsg MSG %nick $2-
    }
  }
}
on 1:sockclose:ircserver-*:if ($gettok($sock($sockname).mark,1,32)) ircserv_massmsg PART $gettok($sock($sockname).mark,2,32)
alias inuse {
  var %i = 1
  while ($gettok($sock(ircserver-*,%i).mark,2,32)) {
    var %nick = $ifmatch
    if (%nick == $1) return 1
    inc %i
  }
  return 0
}
alias ircserv_massmsg {
  var %i = 1
  while ($sock(ircserver-*,%i)) {
    var %b = $sock($ifmatch).mark
    var %s = $ifmatch
    if ($gettok(%b,1,32) == conn) sockwrite -n %s $1- 
    inc %i
  }
}



Link Copied to Clipboard