home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / chat / 12 / 12.exe / SYSTEM / telnet.mrc < prev    next >
Encoding:
Text File  |  2000-02-16  |  12.9 KB  |  323 lines

  1. ;%%%%%%%%%%%%%%%%%%%%%%%%
  2. ;script iTelnet Daemon
  3. ;version 7.20
  4. ;author Quietust
  5. ;email quietust@ircN.org
  6. ;url http://www.ircN.org
  7. ;%%%%%%%%%%%%%%%%%%%%%%%%
  8. on 1:START {
  9.   sockclose telnet
  10.   if ($portfree(%telnetport)) socklisten telnet %telnetport
  11.   else iecho Warning! Unable to open $hc(Telnet daemon) on port $hc(%telnetport) $+ !
  12. }
  13. on 1:SOCKLISTEN:telnet {
  14.   set %i 0
  15.   :start
  16.   inc %i
  17.   if ($sock($addtok(telnet,%i,46)) == $null) sockaccept $addtok(telnet,%i,46)
  18.   else goto start
  19.   sockwrite -n $addtok(telnet,%i,46) $crlf $+ $crlf $+ $me ( $+ $strip(%iver) (c)1998 The Quietust) $+ $crlf $+ $crlf $+ Please enter your nickname.
  20.   pl.fbc n *** Incoming connection from $sock($addtok(telnet,%i,46)).ip
  21. }
  22. on 1:SOCKREAD:telnet.* {
  23.   if ($sockerr > 0) return
  24.   sockread %pl.parse
  25.   if ($sockbr == 0) return
  26.   tel.login $sockname $backspace(%pl.parse)
  27. }
  28. alias tel.login {
  29.   if ($gettok($1,2,46) isnum) {
  30.     if ($gettok($1,3,46)) {
  31.       if ($2 === $password($gettok($1,3,46))) {
  32.         sockwrite $1 $crlf
  33.         sockrename $1 $deltok($1,2,46)
  34.         .timer 1 0 tel.login $deltok($1,2,46) .
  35.       }
  36.       else {
  37.         sockwrite -n $1 Negative on that, Houston.
  38.         sockclose $1
  39.       }
  40.     }
  41.     elseif ($password($2)) {
  42.       if (($sock($addtok(telnet.*,$2,46))) || ($sock($addtok(telnet,$2,46)))) {
  43.         sockwrite -n $1 Error! You are already connected at the interface menu!
  44.         sockclose $1
  45.       }
  46.       else {
  47.         sockwrite -n $1 $crlf $+ Enter your password.
  48.         sockrename $1 $addtok($1,$2,46)
  49.       }
  50.     }
  51.     elseif ($usrhost($2)) {
  52.       sockwrite -n $1 You have no password set.
  53.       sockclose $1
  54.     }
  55.     else {
  56.       sockwrite -n $1 You have no access.
  57.       sockclose $1
  58.     }
  59.   }
  60.   elseif ((%partyline == on) && ($2 == partyline) && ($chkflag($gettok($1,2,46),$null,p))) {
  61.     if ($sock($puttok($1,partyline,1,46))) {
  62.       sockwrite -n $1 You are already connected using that interface!
  63.       .timer 1 0 tel.login $1 .
  64.     }
  65.     else {
  66.       sockrename $1 $puttok($1,partyline,1,46)
  67.       pl.login $puttok($1,partyline,1,46)
  68.     }
  69.   }
  70.   elseif ((%rcontrol == on) && ($2 == remote) && ($chkflag($gettok($1,2,46),$null,r))) {
  71.     if ($sock($puttok($1,remote,1,46))) {
  72.       sockwrite -n $1 You are already connected using that interface!
  73.       .timer 1 0 tel.login $1 .
  74.     }
  75.     else {
  76.       sockrename $1 $puttok($1,remote,1,46)
  77.       rc.login $puttok($1,remote,1,46)
  78.     }
  79.   }
  80.   elseif ($2 == quit) {
  81.     sockwrite -n $1 Goodbye...
  82.     sockclose $1
  83.   }
  84.   elseif ($2 == .) sockwrite -n $1 Available interfaces: $iif((%partyline == on) && $chkflag($gettok($1,2,46),$null,p),partyline) $iif((%rcontrol == on) && $chkflag($gettok($1,2,46),$null,r),remote) quit $+ $crlf $+ Enter interface to use.
  85.   elseif ($2) {
  86.     sockwrite -n $1 Invalid interface!
  87.     .timer 1 0 tel.login $1 .
  88.   }
  89. }
  90. on 1:SOCKREAD:partyline.* {
  91.   if ($sockerr > 0) return
  92.   sockread %pl.parse
  93.   if ($sockbr == 0) return
  94.   if ($backspace(%pl.parse) != $null) pl.parse $sockname $ifmatch
  95. }
  96. alias pl.parse {
  97.   if ((($chkflag($gettok($1,2,46),*,m)) || ($chkflag($gettok($1,2,46),$null,n))) && ($left($2,1) == ,)) pl.fbc m - $+ $gettok($1,2,46) $+ - $getright($2-)
  98.   elseif (($pl.var($gettok($1,2,46),channel) == $null) || ($left($2,1) == .)) {
  99.     set %tmp.pl.parse $iif($left($2,1) == .,$getright($2),$2)
  100.     if ($isalias($addtok(partyline,%tmp.pl.parse,46))) {
  101.       $addtok(partyline,%tmp.pl.parse,46) $1-
  102.       set %tmp.pl.parse $iif($left($2,1) == .,$getright($2),$2)
  103.       if ($result == -2) sockwrite -n $1 You have chat turned off.
  104.       elseif ($result == -1) {
  105.         if ($pl.var($gettok($1,2,46),channel) != $null) sockwrite -n $1 What? Try '.help'
  106.         else sockwrite -n $1 What? Try 'help'
  107.       }
  108.       elseif ($result == 0) return
  109.       elseif ($result == 1) pl.fbc m $chr(35) $+ $gettok($1,2,46) $+ $chr(35) %tmp.pl.parse $3-
  110.       elseif ($result == 2) pl.fbc m $chr(35) $+ $gettok($1,2,46) $+ $chr(35) %tmp.pl.parse (something)
  111.       elseif ($result == 3) pl.fbc m $chr(35) $+ $gettok($1,2,46) $+ $chr(35) %tmp.pl.parse $3 (something)
  112.       elseif ($result isnum) pl.fbc m $chr(35) $+ $gettok($1,2,46) $+ $chr(35) %tmp.pl.parse $3- [ $+ [ $result ] ] (something)
  113.       else partyline.boot partyline. $+ $gettok(%owner,1,44) .boot $gettok($1,2,46) Command ' $+ %tmp.pl.parse $+ ' returned invalid value!
  114.     }
  115.     elseif ($pl.var($gettok($1,2,46),channel) != $null) sockwrite -n $1 What? Try '.help'
  116.     else sockwrite -n $1 What? Try 'help'
  117.   }
  118.   elseif ($pl.var($gettok($1,2,46),channel) != $null) {
  119.     partyline.say $1 .say $2-
  120.     if ($result == -2) sockwrite -n $1 You have chat turned off.
  121.   }
  122. }
  123. alias pl.login {
  124.   sockwrite -n $1 $crlf $+ Connected to $me $+ , running $strip(%iver) (c) 1999 The Quietust $+ $crlf
  125.   qplay -f $td(cmotd.txt) sockwrite -n $1
  126.   sockwrite -n $1 $crlf $+ Commands start with '.' (like '.quit' or '.help') $+ $crlf $+ Everything else goes out to the party line. $+ $crlf
  127.   sockmark $1 on off - - $ctime 0
  128.   pl.bc $1 *** $gettok($1,2,46) joined the party line.
  129. }
  130. alias pl.chkowner {
  131.   set %i 0
  132.   :start
  133.   inc %i
  134.   if ($gettok(%owner,%i,44)) {
  135.     set %tmp.pl.chkowner +
  136.     if ($chkflag($gettok(%owner,%i,44),$null,n) == $false) set %tmp.pl.chkowner %tmp.pl.chkowner $+ n
  137.     if ($chkflag($gettok(%owner,%i,44),$null,m) == $false) set %tmp.pl.chkowner %tmp.pl.chkowner $+ m
  138.     if ($chkflag($gettok(%owner,%i,44),$null,p) == $false) set %tmp.pl.chkowner %tmp.pl.chkowner $+ p
  139.     if (%tmp.pl.chkowner != +) chattr $gettok(%owner,%i,44) %tmp.pl.chkowner
  140.     goto start
  141.   }
  142. }
  143. alias pl.set {
  144.   if ($2 == echo) sockmark $addtok(partyline,$1,46) $3 $gettok($sock($addtok(partyline,$1,46)).mark,2-,32)
  145.   elseif ($2 == timestamp) sockmark $addtok(partyline,$1,46) $gettok($sock($addtok(partyline,$1,46)).mark,1,32) $3 $gettok($sock($addtok(partyline,$1,46)).mark,3-,32)
  146.   elseif ($2 == consolechannel) sockmark $addtok(partyline,$1,46) $gettok($sock($addtok(partyline,$1,46)).mark,1-2,32) $3 $gettok($sock($addtok(partyline,$1,46)).mark,4-,32)
  147.   elseif ($2 == consolemode) sockmark $addtok(partyline,$1,46) $gettok($sock($addtok(partyline,$1,46)).mark,1-3,32) $3 $gettok($sock($addtok(partyline,$1,46)).mark,5-,32)
  148.   elseif ($2 == idle) sockmark $addtok(partyline,$1,46) $gettok($sock($addtok(partyline,$1,46)).mark,1-4,32) $3 $gettok($sock($addtok(partyline,$1,46)).mark,6-,32)
  149.   elseif ($2 == channel) sockmark $addtok(partyline,$1,46) $gettok($sock($addtok(partyline,$1,46)).mark,1-5,32) $3 $gettok($sock($addtok(partyline,$1,46)).mark,7-,32)
  150.   elseif ($2 == away) sockmark $addtok(partyline,$1,46) $gettok($sock($addtok(partyline,$1,46)).mark,1-6,32) $3-
  151. }
  152. alias pl.var {
  153.   if ($2 == echo) return $gettok($sock($addtok(partyline,$1,46)).mark,1,32)
  154.   elseif ($2 == timestamp) return $gettok($sock($addtok(partyline,$1,46)).mark,2,32)
  155.   elseif ($2 == consolechannel) return $gettok($sock($addtok(partyline,$1,46)).mark,3,32)
  156.   elseif ($2 == consolemode) return $gettok($sock($addtok(partyline,$1,46)).mark,4,32)
  157.   elseif ($2 == idle) return $gettok($sock($addtok(partyline,$1,46)).mark,5,32)
  158.   elseif ($2 == channel) return $gettok($sock($addtok(partyline,$1,46)).mark,6,32)
  159.   elseif ($2 == away) return $gettok($sock($addtok(partyline,$1,46)).mark,7-,32)
  160. }
  161. alias pl.unset {
  162.   if ($2 == channel) sockmark $addtok(partyline,$1,46) $gettok($sock($addtok(partyline,$1,46)).mark,1-5,32) - $gettok($sock($addtok(partyline,$1,46)).mark,7-,32)
  163.   elseif ($2 == away) sockmark $addtok(partyline,$1,46) $gettok($sock($addtok(partyline,$1,46)).mark,1-6,32)
  164. }
  165. alias pl.clr sockmark $addtok(partyline,$1,46)
  166. alias pl.bc {
  167.   set %i 0
  168.   :start
  169.   inc %i
  170.   set %dcnick $gettok($sock(partyline.*,%i),2,46)
  171.   if (%dcnick) {
  172.     if ($pl.var(%dcnick,channel) != $null) {
  173.       if (($gettok($1,2,46) == %dcnick) && ($pl.var(%dcnick,echo) == off)) goto start
  174.       if ($pl.var(%dcnick,channel) == $pl.var($gettok($1,2,46),channel)) {
  175.         if ($pl.var(%dcnick,timestamp) == on) sockwrite -n $addtok(partyline,%dcnick,46) $timestamp $2-
  176.         else sockwrite -n $addtok(partyline,%dcnick,46) $2-
  177.       }
  178.     }
  179.     goto start
  180.   }
  181. }
  182. alias pl.fbc {
  183.   set %i 0
  184.   :start
  185.   inc %i
  186.   set %dcnick $gettok($sock(partyline.*,%i),2,46)
  187.   if (%dcnick) {
  188.     if ($chkflag(%dcnick,*,$1)) {
  189.       if ($pl.var(%dcnick,timestamp) == on) sockwrite -n $addtok(partyline,%dcnick,46) $timestamp $2-
  190.       else sockwrite -n $addtok(partyline,%dcnick,46) $2-
  191.     }
  192.     goto start
  193.   }
  194. }
  195. alias partychat telnet $ip $sock(telnet).port
  196. alias pl.whom {
  197.   set %pl.tmp $flags($1)
  198.   if (n isincs %pl.tmp) return * $+ $1
  199.   if (m isincs %pl.tmp) return + $+ $1
  200.   if (o isincs %pl.tmp) return @ $+ $1
  201.   if ($chkflag($1,$pl.var($1,consolechannel),o)) return @ $+ $1
  202.   return $1
  203. }
  204. on 1:SOCKCLOSE:partyline.* {
  205.   if ($pl.var($gettok($sockname,2,46),channel) != $null) {
  206.     pl.bc $sockname *** $gettok($sockname,2,46) lost dcc link.
  207.     pl.clr $gettok($sockname,2,46)
  208.   }
  209. }
  210. on 1:CHAT:.partyline {
  211.   qctcp $nick DCC CHAT chat $longip($ip) %telnetport
  212.   close -c $nick
  213. }
  214. alias pl.checkflags {
  215.   set %tmp.pl.checkflags $addtok(partyline,$1,46)
  216.   if ($sock(%tmp.pl.checkflags)) {
  217.     if ((x !isin $2) && (x isin $3)) {
  218.       sockwrite -n %tmp.pl.checkflags -+- POOF! -+-
  219.       sockwrite -n %tmp.pl.checkflags You now have file area access.
  220.     }
  221.     if ((m !isin $2) && (m isin $3)) {
  222.       sockwrite -n %tmp.pl.checkflags *** POOF! ***
  223.       sockwrite -n %tmp.pl.checkflags You are now a master.
  224.     }
  225.     if ((n !isin $2) && (n isin $3)) {
  226.       sockwrite -n %tmp.pl.checkflags @@@ POOF! @@@
  227.       sockwrite -n %tmp.pl.checkflags You are now an OWNER.
  228.     }
  229.     if ((r !isin $2) && (r isin $3)) {
  230.       sockwrite -n %tmp.pl.checkflags ### POOF! ###
  231.       sockwrite -n %tmp.pl.checkflags You now have REMOTE CONTROL access.
  232.     }
  233.     if ((r isin $2) && (r !isin $3)) {
  234.       sockwrite -n %tmp.pl.checkflags ### POOF! ###
  235.       sockwrite -n %tmp.pl.checkflags You no longer have remote control access.
  236.     }
  237.     if ((n isin $2) && (n !isin $3)) {
  238.       sockwrite -n %tmp.pl.checkflags @@@ POOF! @@@
  239.       sockwrite -n %tmp.pl.checkflags You are no longer an owner.
  240.     }
  241.     if ((m isin $2) && (m !isin $3)) {
  242.       sockwrite -n %tmp.pl.checkflags *** POOF! ***
  243.       sockwrite -n %tmp.pl.checkflags You are no longer a master.
  244.     }
  245.     if ((x isin $2) && (x !isin $3)) {
  246.       sockwrite -n %tmp.pl.checkflags -+- POOF! -+-
  247.       sockwrite -n %tmp.pl.checkflags You no longer have file area access.
  248.     }
  249.     if ((p isin $2) && (p !isin $3)) {
  250.       sockwrite -n %tmp.pl.checkflags -*- POOF! -*-
  251.       sockwrite -n %tmp.pl.checkflags You no longer have party line access.
  252.       .timer 1 0 partyline.boot partyline. $+ $gettok(%owner,1,44) .boot $1 User no longer has party line access.
  253.     }
  254.   }
  255.   set %tmp.pl.checkflags $addtok(remote,$1,46)
  256.   if ($sock(%tmp.pl.checkflags)) {
  257.     if ((r isin $2) && (r !isin $3)) {
  258.       sockwrite -n %tmp.pl.checkflags ### POOF! ###
  259.       sockwrite -n %tmp.pl.checkflags You no longer have remote control access.
  260.       if ($sock($addtok(telnet,$1,46))) sockclose %tmp.pl.checkflags
  261.       else {
  262.         sockwrite -n %tmp.pl.checkflags Returning to interface menu...
  263.         sockrename %tmp.pl.checkflags $addtok(telnet,$1,46)
  264.         tel.login $addtok(telnet,$1,46) .
  265.       }
  266.     }
  267.   }
  268. }
  269. on 1:SOCKREAD:su.* {
  270.   if ($sockerr > 0) return
  271.   sockread %su.parse
  272.   if ($sockbr == 0) return
  273.   pl.su $sockname $backspace(%su.parse)
  274. }
  275. alias pl.su {
  276.   if ($2 === $password($gettok($1,2,46))) {
  277.     sockwrite $1 $crlf
  278.     sockrename $1 $addtok(partyline,$gettok($1,2,46),46)
  279.     pl.login $addtok(partyline,$gettok($1,2,46),46)
  280.   }
  281.   else {
  282.     sockwrite -n $1 Negative on that, Houston.
  283.     sockrename $1 $addtok(partyline,$gettok($1,3,46),46)
  284.     pl.login $addtok(partyline,$gettok($1,3,46),46)
  285.   }
  286. }
  287. on 1:SOCKREAD:remote.* {
  288.   if ($sockerr > 0) return
  289.   sockread %rc.parse
  290.   if ($sockbr == 0) return
  291.   rc.parse $sockname $backspace(%rc.parse)
  292. }
  293. alias rc.login {
  294.   iecho Remote control interface with $gettok($1,2,46) initialized.
  295.   sockwrite -n $1 Remote control interface initiated. $+ $crlf $+ Type ".return" to return to the interface menu.
  296. }
  297. alias rc.parse {
  298.   if ($2 == .return) {
  299.     sockwrite -n $1 Remote control interface terminated.
  300.     if ($sock($puttok($1,telnet,1,46))) sockclose $1
  301.     else {
  302.       sockwrite -n $1 Returning to interface menu...
  303.       sockrename $1 $puttok($1,telnet,1,46)
  304.       tel.login $puttok($1,telnet,1,46) .
  305.     }
  306.     iecho Remote control interface with $gettok($1,2,46) terminated.
  307.   }
  308.   else $2-
  309. }
  310. alias rc.relay {
  311.   set %rc.txt $1-
  312.   if ($gettok(%rc.txt,1,32) isnum) set %rc.txt $deltok(%rc.txt,1,32)
  313.   if ($left($gettok(%rc.txt,1,32),1) == -) set %rc.txt $deltok(%rc.txt,1,32)
  314.   sockwrite -n remote.* %rc.txt
  315. }
  316. on 1:SOCKCLOSE:remote.* {
  317.   .timer 1 0 iecho Remote control interface with $gettok($sockname,2,46) terminated.
  318. }
  319. on 1:CHAT:.remote {
  320.   qctcp $nick DCC CHAT chat $longip($ip) %telnetport
  321.   close -c $nick
  322. }
  323.