.KEY HOST,GROUPS/K,HISTORY/K,STAMP/K,KILL/K,TO/K,PANIC/K,BATCH/K/N,BLIP/K/N,TRACE/K
;*
;*   Sample script to invoke nntp client and add news to uucp Newsbase
;*
;*  Mandatory parameter of name of news server; all other parameters have
;*  reasonable defaults (assuming you have a uulib:NewsGroups file).
;*
.def HOST news.demon.co.uk		;for Demon subscribers only !
.def GROUPS "UULIB:NewsGroups"		;file containing list of groups
.def HISTORY "AmiTCP:db/NewsHistory"	;file containing news history
.def STAMP "AmiTCP:db/NewsStamp"	;file containing date news last retrieved
.def KILL "AmiTCP:db/nntpKillFile"	;file containing kill instructions
.def BLIP 5				;frequency of display of blipmsg
.def TO "uuspool:NewsBatch"		;file to contain batched news
.def PANIC 3000000			;maximum size of pending news in T:
.def BATCH 3				;maximum number of requests batched to server
.def TRACE 5				;amount of information displayed (used to be 5)
.BRA {
.KET }

if NOT EXISTS {Groups}			;Check we have a Groups file
	echo "You must set up a '{Groups}' file, or give the name"
	echo "of another file containing the news groups you want"
	quit 10
endif

if NOT {Host} eq localhost
	if NOT {Host} eq $HostName
		if NOT {Host} eq $NodeName
			if NOT $Slip0State eq Online
				echo "NNTPTransfer: Not connected."
				quit 10
				endif
			endif
		endif
	endif
endif

echo "Pulling News..."

echo >t:nntpclient-Commands "NEWGROUPS t:nntp-NewGroups*NNEWNEWS {Groups} {to}"

failat 16				;nntpclient has done something at error level 10
Amitcp:bin/nntpclient <t:nntpclient-Commands {host} COMPLEX BATCH {batch} BLIP {blip} BLIPMSG "%5ld articles received" HISTORYFILE {history} STAMPFILE {stamp} TRACE {trace}
if $RC EQ 15
    wait 2
    echo "Trying ... "{HOST}
    amitcp:bin/nntptransfer {HOST}
    quit
endif
;type t:nntpclient-Commands 		;diagnostic - commented out
failat 15				;back to default
delete t:nntpclient-Commands QUIET	;don't want command file now

if exists t:nntp-NewGroups		;Got any new groups ?
	echo "{host} has the following new news groups:"
	echo
	type t:nntp-NewGroups		; Show new groups
	delete t:nntp-NewGroups	quiet	; and get rid of the file
endif

if exists {to}
	failat 30			;don't worry if we can't find GetPriority
	amitcp:bin/getpriority >nil:		;preserve the current priority in a local variable
	failat 20			;back to default
	changetaskpri -4		;postprocessing is a background task
;	rnews {to}			;postprocess news to uucp news base
;	failat 10				; because
;	delete {to} quiet		;get rid of the postprocessed file
	get >nil: Priority		;check that Priority local var. was set
	if not WARN
		changetaskpri $Priority ;re-instate the saved priority
	endif
else
	echo "Sorry, no news transferred"
endif
