Back to Code Snippets / Powrót do Strzępów Kodu


; very ladny skrypt by gynvael.coldwind//vx

alias tlconn {
 if ( $0 == 0 ) {
   if ( %tlconn == A ) {
     echo -a %tllogo TL connection type is set to Active (don't-disconnect-after-reciving-define)
     echo -a %tllogo To set it to Disconnect-after-reciving-define type /tlconn B
     halt
   }
   echo -a %tllogo TL connection type is set to Disconnect (Disconnect-after-reciving-define)
   echo -a %tllogo To set it to don't-disconnect-after-reciving-define type /tlconn A
   halt
 }
 if ( $1 == A ) {
   set %tlconn A
   echo -a %tllogo Changed to A
   halt
 }

 if ( $1 == B ) {
   set %tlconn B
   echo -a %tllogo Changed to B
   halt
 }

 echo -a %tllogo Usage: /tlconn [A|B]

}

alias tl translate $1-

alias translate {
 if ( $0 != 1 ) {
   echo -a %tllogo Usage: /translate word
   echo -a %tllogo i.e. /translate cat
   halt
 }
 set %word_to_translate $1
 echo -a %tllogo Word to define: %word_to_translate
 if ( $sock(translator,0) == 0 )  {
   sockopen translator %trans_addr %trans_port
   halt
 }
 if ( %tlconn == A ) {
   sockwrite -tn translator define wn %word_to_translate
   halt
 }
 sockclose translator
 sockopen translator %trans_addr %trans_port
}

on *:load: {
 set %trans_addr dict.org
 set %trans_port 2628
 set %tllogo <7L>
 set %tlconn A
 echo -a %tllogo Some very nice script by gynvael/vx is now loaded
 echo -a %tllogo Usage: /translate word OR /tl word
}

on *:sockopen:translator:{
 if ( !$sock(translator) ) {
   echo -a %tllogo Couldn't connect to %trans_addr
   halt
 }
 sockwrite -tn translator define wn %word_to_translate
}

on *:sockread:translator:{
 if ($sockerr > 0) return
 :nextread
 sockread %temp
 if ($sockbr == 0) return
 if (%temp == $null) goto nextread
 if (%temp == . ) {
   if ( %tlconn == A ) goto nextread
   sockclose translator
   halt
 }
 var %ret = $left(%temp,3)
 if ( %ret == 552 ) {
   echo -a %tllogo No match
   goto nextread
 }

 if ( %ret == 250 ) {
   goto nextread
 }
 if ( %ret == 150 ) {
   goto nextread
 }
 if ( %ret == 151 ) {
   goto nextread
 }
 if ( %ret == 220 ) {
   goto nextread
 }

 echo -a %tllogo %temp
 goto nextread
}

Add a comment:

Nick:
URL (optional):
Math captcha: 7 ∗ 8 + 8 =