remoteChat — File Browser
remoteChatv0.26 / remoteChatv0.26 / rchat.mrc
rchat.mrc — 15.63 KB — Download this file
;*** RemoteChat v0.26b
;*** by Da' Kool Cat <kcat@thearmy.com> <http://kcat.cjb.net>
;-- All scripting contained in this file is copyright (©) 1998-99 by Da' Kool Cat (that's me)
;-- I've written all of this from scratch, with help from the mIRC help file too.
;-- If you rip this off and I find out, you'll regret it for a very long time.
;-- You can, as stated in the readme, use this in your script, but you must give me credit
;-- somewhere (like in the readme, or when it starts).
; Refer to readme.txt for all the commands available.
alias rChat.config { dialog -m rChat rChat }
alias rChat.remove {
if ($?!="Are you sure you want to remove rChat?") {
echo 2 -a Removing rChat variables...
unset %rChat.*
echo 2 -a If you had problems with rChat, please email me at kcat@thearmy.com and I'll attempt to fix the problem. Visit http://kcat.cjb.net for the latest rChat release.
echo 2 -a Unloading $script $+ ...
unload -rs $script
}
}
on 1:start:rChat.start
on 1:load: {
if ($version < 5.5) {
echo 4 -a rChat.mrc: You need atleast mIRC 5.5!!!
unload -rs rChat.mrc
; I don't really need this but...
halt
}
unset %rChat.*
set %rChat.port 4444
set %rChat.name rChat
set %rChat.motd $scriptdir $+ motd.txt
set %rChat.ver rChat v0.26b
set %rChat.welcome 1
set %rChat.console 1
rChat.config
rChat.adduser Console $rand(10000,90000)
writeini -n rChat.ini Console op 2
writeini -n rChat.ini Console users Console
}
dialog rChat {
title "Configuration"
size -1 -1 140 200
text "Partyline name:", 1, 4 8 95 13, left
edit "", 2, 80 5 57 21, left autohs
text "TCP Port:", 3, 4 33 55 13, left
edit "", 4, 52 29 60 21, left autohs
check "Show Welcome", 5, 4 56 100 13, left
check "Start w/Console", 6, 4 73 100 13, left
text "Console name:", 7, 4 94 70 13, left
edit "", 8, 76 90 63 21, left autohs
text "MOTD File:", 9, 4 126 60 13, left
button "Browse", 10, 80 121 55 20
edit "", 11, 2 143 137 22, left autohs
button "OK", 12, 15 170 55 23, default
button "Cancel", 13, 75 170 55 23, cancel
}
on 1:dialog:rChat:*:* {
if (($devent == sclick) && ($did == 12)) { rChat.config.set | dialog -c rChat }
if (($devent == sclick) && ($did == 10)) {
echo You shouldn't see this.
set %rChat.motd $dir="Select the motd file" %rChat.motd
if (%rChat.motd == $null) { set %rChat.motd $scriptdir $+ motd.txt }
did -a rChat 11 %rChat.motd
}
if ($devent == init) {
did -a rChat 2 %rChat.name
did -a rChat 4 %rChat.port
if (%rChat.welcome) { did -c rChat 5 } else { did -u rChat 5 }
if (%rChat.console) { did -c rChat 6 } else { did -u rChat 6 }
did -a rChat 8 %rChat.local.name
did -a rChat 11 %rChat.motd
did -f rChat 12
did -b rChat 7
did -b rChat 8
did -b rChat 10
}
}
alias rChat.config.set {
if ($did(rChat,11) == $null) { return 0 }
set %rChat.name $did(rChat,2)
set %rChat.port $did(rChat,4)
set %rChat.welcome $did(rChat,5).state
set %rChat.console $did(rChat,6).state
set %rChat.local.name $did(rChat,8)
set %rChat.motd $did(rChat,11)
}
on 1:socklisten:remotechat: {
set %rChat.tmp rChat $+ $rand(10000,20000)
sockaccept %rChat.tmp
;*** If they're being ignored, they're consider banned
if ( *!*@ $+ $sock(%rChat.tmp).ip isignore) {
rChat.msg Console Access denied from $sock($sockname).ip (Banned)
sockclose $sockname
goto end
}
;*** Prompt for username
sockwrite -n %rChat.tmp Connected to %rChat.name running %rChat.ver
sockwrite %rChat.tmp Enter username:
rChat.msg Console Connection from $sock($sockname).ip
:end
unset %rChat.tmp
}
;*** Being sent something...
on 1:sockread:rChat* {
sockread %rChat.temp
if (%rChat.temp == $null) goto end
sockwrite -n $sockname
set %rChat.1 $gettok(%rChat.temp,1,32)
if ($level(%rChat.1) == rChat) {
sockrename $sockname rpass: $+ %rChat.1
if ($rChat.status($rChat.user($sockname)) == Connected) {
sockwrite -n $sockname You are already connected.
sockclose $sockname
goto end
}
rChat.msg Console $rChat.user($sockname) logging in...
sockwrite $sockname Password required for $rChat.user($sockname) $+ :
goto end
}
else {
rChat.msg Console Access denied from $sock($sockname).ip (No access)
sockwrite -n $sockname Access Denied.
sockclose $sockname
goto end
}
:end
unset %rChat.temp
unset %rChat.1
}
on 1:sockread:rpass*: {
sockread %rChat.temp
if (%rChat.temp == $null) goto end
sockwrite -n $sockname
set %rChat.1 $hash($gettok(%rChat.temp,1,32),32)
set %rChat.passwd $readini -n rChat.ini $rChat.user($sockname) password
if (%rChat.1 != %rChat.passwd) {
rChat.msg Console Failed login attempt from $sock($sockname).ip for $rChat.user($sockname) (Bad password)
sockwrite -n $sockname Incorrect Password.
sockclose $sockname
goto end
}
if (%rChat.1 == %rChat.passwd) {
rChat.msg Console $rChat.user($sockname) logged in.
writeini -n rChat.ini $rChat.user($sockname) Status connected
set %rChat.tmp.line 0
:motd
inc %rChat.tmp.line
if (%rChat.tmp.line > $lines(%rChat.motd)) { goto next }
sockwrite -n $sockname $read -l $+ %rChat.tmp.line %rChat.motd
goto motd
:next
sockwrite -n $sockname -
sockwrite $sockname >
if ($rChat.op($rChat.user($sockname)) == 1) { set %rChat.users @ $+ $rChat.user($sockname) %rChat.users }
if ($rChat.op($rChat.user($sockname)) == 0) { set %rChat.users $rChat.user($sockname) %rChat.users }
if ($rChat.op($rChat.user($sockname)) != 2) { inc %rChat.users.num }
sockrename $sockname ruser: $+ $rChat.user($sockname)
if ($rChat.op($rChat.user($sockname)) != 2) { rChat.control *** $rChat.user($sockname) joined %rChat.name }
goto end
}
:end
unset %rChat.temp
unset %rChat.1
unset %rChat.tmp.line
unset %rChat.passwd
}
on 1:INPUT:@rChat {
if ($left($1,1) == /) { return }
rChat.input Console $1-
aline @rChat Â
halt
}
on 1:sockread:ruser*: {
sockread %rChat.tmp
if (%rChat.tmp == $null) goto end
rChat.input $sockname %rChat.tmp
if ($sockname != $null) { sockwrite $sockname > }
:end
unset %rChat.tmp
}
on 1:sockclose:ruser*: {
rChat.control *** $rChat.user($sockname) closed connection.
if ($rChat.op($rChat.user($sockname)) == 1) { set %rChat.users $remove(%rChat.users, @ $+ $rChat.user($sockname)) }
if ($rChat.op($rChat.user($sockname)) == 0) { set %rChat.users $remove(%rChat.users, $rChat.user($sockname)) }
dec %rChat.users.num
writeini -n rChat.ini $rChat.user($sockname) Status not-connected
}
alias rChat.input {
if ($left($2,1) == .) {
rChat.msg Console $timestamp $chr(164) $+ $rChat.user($1) $+ $chr(164) $2-
}
if ($2 == .help) {
rChat.msg $1 Available commands:
if ($rChat.op($rChat.user($1)) > 0) {
rChat.msg $1 .start (Console command) - Startup the partyline
rChat.msg $1 .stop (SUPERUSER ONLY) - Shutdown the partyline
rChat.msg $1 .adduser (SUPERUSER ONLY) - Creates a new user
rChat.msg $1 .op (SUPERUSER ONLY) - Gives op access to another user
rChat.msg $1 .boot (OPS ONLY) - Boots someone off the partyline
rChat.msg $1 .ban (OPS ONLY) - Boots and bans someone off the partyline
}
rChat.msg $1 .msg - Sends a private msg to another user
rChat.msg $1 .quit - Quits the partyline
rChat.msg $1 .pass - Change your password
rChat.msg $1 .whom - Shows all connected users
rChat.msg $1 .help - You've already done this
rChat.msg $1 There are currently %rChat.users.num users connected.
goto end
}
if ($2 == .start) {
if ($rChat.op($rChat.user($1)) == 2) {
rChat.start
goto end
}
rChat.msg $1 You don't have the power!
goto end
}
if ($2 == .stop) {
if ($rChat.op($rChat.user($1)) == 2) {
rChat.stop
goto end
}
rChat.msg $1 You don't have the power!
goto end
}
if ($2 == .adduser) {
if ($rChat.op($rChat.user($1)) == 2) {
if ($4 == $null) { rChat.msg $1 USAGE: .adduser <user> <passwd> | goto end }
if ($rChat.op($rChat.user($3)) != 2) {
rChat.adduser $3 $4
rChat.msg $1 Added $3 with the password as $4
}
else { rChat.msg $1 Can't replace a SUPERUSER! }
goto end
}
rChat.msg $1 You don't have the power!
goto end
}
if ($2 == .pass) {
if ($3 == $null) { rChat.msg $1 Yes but change your password to what?! | goto end }
rChat.chpass $1 $3
rChat.msg $1 Changed your password to $3
goto end
}
if ($2 == .op) {
if ($rChat.op($rChat.user($1)) == 2) {
if ($rChat.op($3) == $null) { rChat.msg $1 Who?! | goto end }
if ($rChat.op($3) == 0) {
writeini -n rChat.ini $3 op 1
rChat.msg $1 Gave op access to $3
if ($rChat.status($3) == Connected) {
rChat.msg ruser: $+ $3 you have been given the power! (OP)
rChat.control *** $3 has been given the power!
set %rChat.tmp @ $+ $3
set %rChat.users $replace(%rChat.users, $3, %rChat.tmp)
}
goto end
}
else rChat.msg $1 But they already have op status!
goto end
}
rChat.msg $1 You don't have the power!
goto end
}
if ($2 == .ban) {
if (($rChat.op($rChat.user($1)) > 0) && ($rChat.op($rChat.user($3)) != 2)) {
if ($rChat.status($3) == Connected) {
rChat.msg $3 You have been booted off the partyline by $rChat.user($1) ( $+ $4- $+ )
.ignore -k $sock(%rChat.tmp).ip
; Maybe deleting them is a little harsh...
; rChat.deluser $3
set %rChat.tmp @ $+ $3
if ($rChat.op($3) == 1) { set %rChat.users $remove(%rChat.users, %rChat.tmp) }
if ($rChat.op($3) == 0) { set %rChat.users $remove(%rChat.users, $3) }
dec %rChat.users.num
writeini -n rChat.ini $3 Status not-connected
sockclose ruser: $+ $3
rChat.control *** $rChat.user($1) banned $3 from %rChat.name ( $+ $4- $+ )
goto end
}
else {
rChat.msg $1 But they're not connected!
goto end
}
}
rChat.msg $1 You don't have the power!
goto end
}
if ($2 == .boot) {
if (($rChat.op($rChat.user($1)) > 0) && ($rChat.op($rChat.user($3)) != 2)) {
if ($rChat.status($3) == Connected) {
sockwrite -n ruser: $+ $3 You have been booted off the partyline by $rChat.user($1) ( $+ $4- $+ )
rChat.control *** $rChat.user($1) booted $3 off %rChat.name ( $+ $4- $+ )
set %rChat.tmp @ $+ $3
if ($rChat.op($3) == 1) { set %rChat.users $remove(%rChat.users, %rChat.tmp) }
if ($rChat.op($3) == 0) { set %rChat.users $remove(%rChat.users, $3) }
dec %rChat.users.num
writeini -n rChat.ini $3 Status not-connected
sockclose ruser: $+ $3
goto end
}
else {
rChat.msg $1 But they're not connected!
goto end
}
}
rChat.msg $1 You don't have the power!
goto end
}
if ($2 == .whom) {
rChat.msg $1 %rChat.users
rChat.msg $1 There are currently %rChat.users.num users connected.
goto end
}
if ($2 == .msg) {
if ($rChat.status($3) == Connected) {
rChat.msg $1 Message sent.
sockwrite -n ruser: $+ $3 ( $+ $rChat.user($1) $+ ) $4-
goto end
}
else {
rChat.msg $1 But they're not connected!
goto end
}
}
if ($2 == .quit) {
rChat.msg $1 Buh-bye!
rChat.control *** $rChat.user($1) quit %rChat.name
set %rChat.tmp @ $+ $rChat.user($1)
if ($rChat.op($rChat.user($1)) == 1) { set %rChat.users $remove(%rChat.users, %rChat.tmp) }
if ($rChat.op($rChat.user($1)) == 0) { set %rChat.users $remove(%rChat.users, $rChat.user($1)) }
if ($rChat.op($rChat.user($1)) != 2) { dec %rChat.users.num }
writeini -n rChat.ini $rChat.user($1) Status not-connected
sockclose $1
goto end
}
if ($left($2,1) != .) { rChat.control < $+ $rChat.user($1) $+ > $2- | goto end }
rChat.msg $1 Say again?
:end
unset %rChat.tmp
}
alias rChat.console {
if ($window(@rChat).state == $null) { window -ne +bs @rChat 100 50 600 350 }
if (%rChat.welcome) {
echo @rChat This is the main console screen of rChat.
echo @rChat You can do all commands with SUPERUSER access, unless you've changed it.
echo @rChat Users won't be able to see you in the .whom output, they can't message you unless you connect to yourself (which will probably fuck up /rChat.msg, but ohwell), and they don't know that you know you can see what they type (hehe).
echo @rChat Â
echo @rChat As a beta tester, please, by all means, email bugs, typos, suggestions, questions, whatever, to kcat@thearmy.com, it took me 5 months to figure out that closing a connection wasn't working properly...
}
;*** Even I get sick of it...
set %rChat.welcome 0
}
alias rChat.start {
if ($portfree(%rChat.port)) { socklisten remotechat %rChat.port }
set %rChat.users.num 0
unset %rChat.users
;*** Strange, I didn't even notice they were the same
if (%rChat.console) { rChat.console }
set %rChat.tmp.num 0
set %rChat.tmp $readini -n rChat.ini Console users
:loop
inc %rChat.tmp.num
set %rChat.tmp.user $gettok(%rChat.tmp,%rChat.tmp.num,32)
if (%rChat.tmp.user == $null) { goto end }
writeini -n rChat.ini %rChat.tmp.user Status not-connected
goto loop
:end
unset %rChat.tmp
unset %rChat.tmp.num
unset %rChat.tmp.user
}
alias rChat.stop {
rChat.control Shutting down partyline...
;*** TCP port
sockclose remotechat
;*** Username prompt
sockclose rChat*
;*** Password prompt
sockclose rpass*
;*** Connected users
sockclose ruser*
;*** Please note: I "could" reset the users and rChat.ini information, but this is
;*** already done in /rChat.start so I've decided not to...
;*** Only user left should be admin
rChat.control Partyline shutdown.
}
alias rChat.chpass {
if ($1 == $null) {
/echo 4 -a /rChat.chpass: usage /rChat.chpass <user> <password>
goto end
}
writeini -n rChat.ini $$1 password $hash($$2,32)
/echo 2 -a Changed $$1 $+ 's password to $$2
:end
}
alias rChat.adduser {
if (($1 == $null) || ($2 == $null)) {
/echo 4 -a /rChat.adduser: usage /rChat.adduser <user> <password>
goto end
}
.auser rChat $$1
writeini -n rChat.ini $$1 Status not-connected
writeini -n rChat.ini $$1 password $hash($$2,32)
writeini -n rChat.ini $$1 op 0
writeini -n rChat.ini Console users $readini -n rChat.ini Console users $1
/echo 2 -a Added $$1 to userlist with password as $$2
:end
}
alias rChat.deluser {
if ($1 == $null) {
/echo 4 -a /rChat.deluser: usage /rChat.deluser <user>
goto end
}
.ruser rChat $$1
remini rChat.ini $$1
set %rChat.tmp $readini -n rChat.ini Console users
writeini -n rChat.ini Console users $remove(%rChat.tmp, $$1)
/echo 2 -a Deleted $$1 from the partyline userlist
:end
unset %rChat.tmp
}
alias rChat.control {
if ($window(@rChat).state != $null) { echo @rChat $timestamp $1- }
if ($sock(ruser,1).ip != $null) { sockwrite -n ruser* $timestamp $1- }
}
alias rChat.op {
return $readini -n rChat.ini $$1 op
}
alias rChat.status {
return $readini -n rChat.ini $$1 status
}
alias rChat.user {
if ($$1 != Console) {
return $remove($$1,$left($$1,6))
}
else return Console
}
alias rChat.msg {
if ($rChat.user($$1) != Console) {
sockwrite -n $1 $2-
}
else if (($2 != $null) && ($window(@rChat).state != $null)) { echo @rChat $2- }
}