shithub: gridchat

Download patch

ref: 917a1d503a424c5d753b28aea7c9c20416ede021
parent: 4ed833284a1ef29cf1957a0dd63191e84ef2b62e
author: grobe0ba <grobe0ba@tcp80.org>
date: Tue Aug 2 14:09:56 EDT 2022

personal changes

--- a/chat	Tue Aug  2 14:09:56 2022
+++ b/chat	Tue Aug  2 14:09:56 2022
@@ -11,7 +11,7 @@
 }
 
 fn close{
-	echo PART $name from $channel >>/n/$chatsrv/$channel
+#	echo PART $name from $channel >>/n/$chatsrv/$channel
 	@{echo kill>/proc/$catkill/ctl}
 }
 
@@ -28,8 +28,15 @@
 	shutdown
 }
 
+fn clear{
+	awk 'BEGIN{
+		for(i = 0; i < '$1'; i++)
+			printf "\x08"
+	}'
+}
+
 channel=chat
-chatsrv=chat
+chatsrv=gchat
 while (~ $1 -*){
 	switch($1){
 	case -n
@@ -38,9 +45,6 @@
 	case -j
 		channel = $2
 		shift 2
-	case -s
-		chatsrv = $2
-		shift 2
 	case *
 		echo bad flag $1 '-n NICK -j CHANNEL'
 		shift
@@ -48,9 +52,9 @@
 }
 if(! ~ $1 '')
 	chatsrv=$1
-if(! test -e /n/$chatsrv/ctl)
+if(! test -e /n/$chatsrv/chat)
 	mount /srv/$chatsrv /n/$chatsrv
-if(! test -e /n/$chatsrv/ctl){
+if(! test -e /n/$chatsrv/chat){
 	echo 'no chat service named $chatsrv found' >[1=2]
 	exit no.chat
 }
@@ -58,30 +62,27 @@
 echo '		-- hubchat 0.2 --'
 helpmessage
 sleep 2
-while(~ $#name 0){
-	echo 'please enter a chat name:'
-	name=`{read}
-}
-echo JOIN $name to $channel >>/n/$chatsrv/$channel
+#while(~ $#name 0){
+#	echo 'please enter a chat name:'
+#	name=`{read}
+#}
+name=be0ba
+#echo JOIN $name to $channel >>/n/$chatsrv/$channel
 
-$home/bin/$objtype/chat-fmt </n/$chatsrv/$channel &
+chat-fmt </n/$chatsrv/$channel &
 catkill=$apid
 
 while(talk=`{read}){
+	clear `{echo $talk | wc -r}
 	switch($talk(1)){
 	case /q
 		shutdown
 	case /n
-		if(! ~ $talk(2) ''){
-			echo nick $name ' -> ' $talk(2) >>/n/$chatsrv/$channel
 			name=$talk(2)
-		}
-		if not
-			echo 'you need to provide a nick for /n NICK'
 	case /j
 		if (~ $talk(2) '')
 			echo must specify a channel to join
-		if not if(test -e /n/$chatsrv/$talk(2)){
+		if not if(test -e /n/chat/$talk(2)){
 			close
 			channel=$talk(2)
 			cat /n/$chatsrv/$channel &
@@ -105,7 +106,7 @@
 #		ts=`{echo '('^$ts(4)^')'}
 		if(! ~ $talk ''){
 			line=`{echo $name '→ ' $talk}
-			echo $line >>/n/$chatsrv/$channel
+			echo $line >>/n/$chatsrv/$channel &
 		}
 	}
 }