lan Nomar avatar lan Nomar committed 4a19ea3

added connect/reconect.brc
renamed Config-IRC.brc to connect/irc-args-parse.brc

Comments (0)

Files changed (4)

Config-IRC.brc

-#!/usr/bin/env brc
- # This contraption, is as its name implies, a configuration setter
-ConF=$HOME^'/.config/irc.rc' ; { . $ConF } ; { . `{ module.brc std } }
-Menu=`{ awk '/fn/ { print $2 }' $ConF }
-flagfmt='s server,p port,k pass,u nick,f name'
-	echo `{ getflags $* } ; eval `{ getflags $* }
-Status=`{ getflags $* | awk -F'=' '/status/ {print $2}'} #dirty fix for $status
-
-if (~ ($Status $#*) usage) { echo 'Err: args
-' $flagfmt ; exit 1 }
-
-# i can take this whole area out if i made getflags use $Optional, and didnt define something that doesnt exist
-if (~ $#flagp 1) { Port=$flagp }
-if (~ $#flagk 1) { Pass=$flagk }
-if (~ $#flagu 1) { Nick=$flagu ; Name=$Nick ; Alias=$Nick }
-if (~ $#flagf 1) { Name=$flagf }
-if (~ $#flags 1) { Server=$flags ; Serv=$Server } else {
-  if (~ $#* 1) { Serv=$1 } else { . `{ module.brc ask } ; Serv=$Pick } }
-
-# Calls function, which contains the configuration.
-if (~ $#Serv 0) { echo 'Err: No Server specified' ; exit 0 } else {
- if (~ $Serv $Server) {} else { # in case of -s (flagS)
-  if (~ $Menu $Serv) { $Serv ; echo -n '
-Conf:	'$Serv } else { echo 'Err:	No Such Conf' ; exit 1 } } }
-
-# $Channels(Default) ; $channels(absolute $Channels) ; $Chans(string)
-channels=`{ for (i in $Channels) { if (!~ $i ['#&']^*) { echo '#'^$i } else { echo $i } } }
-Chans=`{ OFS channels , } # Appends commas
-
-echo '
-Server:	'$Server'
-Port:	'$Port'
-Nick:	'$Nick'		Name:	'$Name'
-Chans:	'$^Channels
-# wha about channels? (-c #Channels) # it corrupts getflags, and a lot of workarounds, just dont use it
-# you cant have an arg with #, 
-#if (~ $#flagc 1) { Channels=`{ echo $flagc | tr -s ' ' '\n'} } #
-#eval `{getflags $* | tr -d '#'} # Unfortunate...
-#if (~ $Status 'usage') { echo 'Err: args' ; exit 1 } if (~ $#* 2) { echo 'Err: too many args' $flagfmt ; exit 1 }
 ~ $#iiDir 0 && iiDir=$HOME'/.local/ii/'$Alias
 
 iiDir=$iiDir/Servers
-#{
-#  if (~ $#flags 1) {
-#	iiDir=$iiDir/$^flags
-#	rm -v $iiDir/in $iiDir/*/in
-#}	}
+ServDir=$^iiDir/$^Server
 
 run=ii
 
 		sleep $Sleep
 
 	if (!ps $iipid > /dev/null){
-		echo 'ii not running, exiting' ; exit 1
+		echo 'ii not running(crashed?), quiting' ; exit 1
 }	}
 
-#( settings )#
-	echo $iipid > $^iiDir/$Server^'/pid'
+#( settings )# -- Keep file with ii info
+	if (!~ $#iipid 0) {
+		echo $iipid	> $ServDir/pid
+		if (~ $#Serv 0) {	echo $run		> $ServDir/run
+			} else {		echo $0 $Serv	> $ServDir/run
+}	}
 
 if (!~ $Channels) { 
   for (chan in $Channels) {

connect/irc-args-parse.brc

+#!/usr/bin/env brc
+ # This contraption, is as its name implies, a configuration setter
+ConF=$HOME^'/.config/irc.rc' ; { . $ConF } ; { . `{ module.brc std } }
+Menu=`{ awk '/fn/ { print $2 }' $ConF }
+flagfmt='s server,p port,k pass,u nick,f name'
+	echo `{ getflags $* } ; eval `{ getflags $* }
+Status=`{ getflags $* | awk -F'=' '/status/ {print $2}'} #dirty fix for $status
+
+if (~ ($Status $#*) usage) { echo 'Err: args
+' $flagfmt ; exit 1 }
+
+# i can take this whole area out if i made getflags use $Optional, and didnt define something that doesnt exist
+if (~ $#flagp 1) { Port=$flagp }
+if (~ $#flagk 1) { Pass=$flagk }
+if (~ $#flagu 1) { Nick=$flagu ; Name=$Nick ; Alias=$Nick }
+if (~ $#flagf 1) { Name=$flagf }
+if (~ $#flags 1) { Server=$flags ; Serv=$Server } else {
+  if (~ $#* 1) { Serv=$1 } else { . `{ module.brc ask } ; Serv=$Pick } }
+
+# Calls function, which contains the configuration.
+if (~ $#Serv 0) { echo 'Err: No Server specified' ; exit 0 } else {
+ if (~ $Serv $Server) {} else { # in case of -s (flagS)
+  if (~ $Menu $Serv) { $Serv ; echo -n '
+Conf:	'$Serv } else { echo 'Err:	No Such Conf' ; exit 1 } } }
+
+# $Channels(Default) ; $channels(absolute $Channels) ; $Chans(string)
+channels=`{ for (i in $Channels) { if (!~ $i ['#&']^*) { echo '#'^$i } else { echo $i } } }
+Chans=`{ OFS channels , } # Appends commas
+
+echo '
+Server:	'$Server'
+Port:	'$Port'
+Nick:	'$Nick'		Name:	'$Name'
+Chans:	'$^Channels
+# wha about channels? (-c #Channels) # it corrupts getflags, and a lot of workarounds, just dont use it
+# you cant have an arg with #, 
+#if (~ $#flagc 1) { Channels=`{ echo $flagc | tr -s ' ' '\n'} } #
+#eval `{getflags $* | tr -d '#'} # Unfortunate...
+#if (~ $Status 'usage') { echo 'Err: args' ; exit 1 } if (~ $#* 2) { echo 'Err: too many args' $flagfmt ; exit 1 }

connect/reconect.brc

+#!/usr/bin/env brc
+
+#if (pid run) file exists, it will restart it
+
+fn testfile { *=$*^* ; if ( ~ $^* *^'*' ) { return 1 } else { return 0 } }
+
+while (true) {	sleep 60
+	for (* in $iiDir/Servers/*) {
+	if ( testfile $^*/pid && testfile $^*/run ) {
+		if (! ps `{ cat $^*/pid } > /dev/null ) {
+			cat $^*/run
+			eval `{ cat $^*/run }
+}	}	}	}
+
+	#if ( ~ test -e $^*/pid  &&  test -e $^*/run ) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.