# default.src

# Default Command Shell for Synchronet Version 2.00a+

# $Id: default.src,v 1.22 2018/10/22 05:23:10 rswindell Exp $

# @format.tab-size 8, @format.use-tabs true

###############################################################################
# This shell is an imitation of the Version 1c command set/structure	      #
#									      #
# It also serves as an example of a complex command shell using the Baja      #
# command shell language						      #
#									      #
###############################################################################

# Tips:
#
#	Tabstops should be set to 8 to view/edit this file
#	If your editor does not support control characters,
#		use \1 for Ctrl-A codes
#	All lines starting with # are considered comments and are ignored
#	Left margins (indents) are not relevant and used only for clarity
#	Almost everything is not case sensitive with the exception of @-codes

################################# Begins Here #################################

!include sbbsdefs.inc

# Set return point for main menu commands (via end_cmd)
cmd_home

# Display TEXT\MENU\MAIN.* if not in expert mode
compare_user_misc UM_EXPERT
if_false
	cls
	menu main
	end_if

# Update node status
node_action node_main
async

inc_main_cmds

compare_ars RIP
if_true
	getlines
	end_if

# Display main Prompt
print "\1-\1c\r\nț \1b\1hMain \1n\1cț \1h"
compare_ars exempt T
if_true
	print "@TUSED@"
else
	print "@TLEFT@"
	end_if
print " \1n\1c[\1h@GN@\1n\1c] @GRP@\1\\ [\1h@SN@\1n\1c] @SUB@: \1n"

# Get key (with / extended commands allowed)
compare_user_misc UM_COLDKEYS
if_false
	getkeye
else
	getstrupr 60
	endif

# Do nothing for control keys and space
cmdkey ^@
	end_cmd
cmdkey ^M
	end_cmd
cmdkey ^S
	end_cmd
 cmdkey  "
	end_cmd

# Write command to log file
logkey_comma

# Hitting number changes current sub-board
cmdkey digit
	compare_user_misc UM_COLDKEYS
	if_false
		ungetkey
		end_if
	msg_get_sub_num
	end_cmd

# Hitting /number changes current group
cmdkey edigit
	compare_user_misc UM_COLDKEYS
	if_false
		ungetkey
	else
		shift_str 1
		end_if
	msg_get_grp_num
	end_cmd

# Show the key hit
compare_user_misc UM_COLDKEYS
if_false
	printkey
	endif

# Next sub-board
cmdkey ^^
	msg_subboard_up
	end_cmd
cmdkey >
	msg_subboard_up
	end_cmd
cmdkey }
	msg_subboard_up
	end_cmd
cmdkey )
	msg_subboard_up
	end_cmd
cmdkey +
	msg_subboard_up
	end_cmd
cmdkey =
	msg_subboard_up
	end_cmd

# Previous sub-board
cmdkey ^J
	msg_subboard_down
	end_cmd
cmdkey <
	msg_subboard_down
	end_cmd
cmdkey {
	msg_subboard_down
	end_cmd
cmdkey (
	msg_subboard_down
	end_cmd
cmdkey -
	msg_subboard_down
	end_cmd

# Next group
cmdkey ^F
	msg_group_up
	end_cmd
cmdkey ]
	msg_group_up
	end_cmd

# Previous group
cmdkey ^]
	msg_group_down
	end_cmd
cmdkey [
	msg_group_down
	end_cmd

# String commands start with a semicolon
cmdkey ;
	compare_user_misc UM_COLDKEYS
	if_true
		shift_str 1
	else
		getstrupr 40
		end_if
	exec_bin "str_cmds %s"
	end_cmd

cmdkey T
	chkfile "%zmenu/tmessage.*"
	if_true
		menu tmessage
		end_if
        call file_transfers
        end_cmd

compare_user_misc UM_COLDKEYS
if_false
	crlf
	end_if
pause_reset

# Menu
cmdkey ?
	compare_user_misc UM_expert
	if_true
		menu main
		end_if
	end_cmd

# Sysop Menu
compare_ars SYSOP or EXEMPT Q or I or N
if_true
	cmdkey !
		menu sysmain
		end_cmd
	end_if

# Commands

cmdkey A
	auto_message
	end_cmd
cmdkey /A
	compare_ars ANSI and not GUEST
	if_false
		print "\r\nSorry, only regular users with ANSI terminals can do that.\r\n"
	else
		print "Selecting your avatar..."
		exec_bin avatar_chooser
		# an alternative approach (uses the configured xtrn/door):
		# exec_xtrn avatchoo
		end_if
	end_cmd

cmdkey B
	print "\r\n\1c\1hBrowse/New Message Scan\r\n"
	msg_browse_scan
	end_cmd

cmdkey C
	exec_bin chat_sec
	end_cmd

cmdkey D
	user_defaults
	end_cmd

cmdkey E
	exec_bin email_sec
	end_cmd

cmdkey F
	print "\r\n\1c\1hFind Text in Messages\r\n"
	msg_find_text
	end_cmd

cmdkey /F
	msg_find_text_all
	end_cmd

cmdkey G
	text_file_section
	end_cmd

cmdkey I
	call main_info
	end_cmd

cmdkey J
	msg_select_area
	end_cmd

cmdkey /L
	nodelist_all
	end_cmd

cmdkey M
	minute_bank
	end_cmd

cmdkey N
	print "\r\n\1c\1hNew Message Scan\r\n"
	msg_new_scan
	end_cmd

cmdkey /N
	msg_new_scan_all
	end_cmd

cmdkey O
	file_download_batch
	if_true
		end_cmd
                end_if
	logoff
	end_cmd

cmdkey /O
	file_download_batch
	if_true
		end_cmd
                end_if
	logoff_fast
	end_cmd

cmdkey P
	msg_post
	end_cmd

cmdkey /P
	exec_bin postpoll
	end_cmd

cmdkey Q
	msg_qwk
	end_cmd

cmdkey R
	msg_read
	end_cmd

cmdkey S
	print "\r\n\1c\1hScan for Messages Posted to You\r\n"
	msg_your_scan
	end_cmd

cmdkey /S
	msg_your_scan_all
	end_cmd

cmdkey U
	print "\r\n\1c\1hList Users\r\n"
	mnemonics "\r\n~Logons Today, ~Sub-board, or ~All: "
	getcmd LSA\r

	cmdkey L
		userlist_logons
		end_cmd
	cmdkey S
		userlist_sub
		end_cmd
	cmdkey A
		userlist_all
		end_cmd

	# fall-through for CR, Ctrl-C, etc
	end_cmd

cmdkey /U
	userlist_all
	end_cmd

cmdkey V
    exec_bin scanpolls
    end_cmd

cmdkey /V
    exec_bin scanpolls all
    end_cmd

cmdkey X
	exec_bin xtrn_sec
	end_cmd

cmdkey Z
	print "\r\n\1c\1hContinuous New Message Scan\r\n"
	msg_cont_scan
	end_cmd

cmdkey /Z
	msg_cont_scan_all
	end_cmd

cmdkey *
	msg_show_subboards
	end_cmd

cmdkey /*
	msg_show_groups
	end_cmd

cmdkey &
	call main_cfg
	end_cmd

cmdkey #
	print "\r\n\1c\1hType the actual number, not the symbol.\r\n"
	end_cmd

cmdkey /#
	print "\r\n\1c\1hType the actual number, not the symbol.\r\n"
        end_cmd

# fall through
print "\r\n\1c\1hUnrecognized command."
compare_user_misc UM_expert
if_true
	print " Hit '\1i?\1n\1c\1h' for a menu."
	end_if
crlf
end_cmd

# shouldn't hit next line
print "Problem in command shell."
pause
hangup
return

############################ Main Info Section	###############################

:main_info
cmd_home
compare_user_misc UM_expert
if_false
	menu maininfo
	end_if
async
print "\r\n\1y\1hInfo: \1n"
getcmd ?QISVY\r
logkey

cmdkey ?
	compare_user_misc UM_expert
	if_true
		menu maininfo
		end_if
	end_cmd

cmdkey I
	info_system
	end_cmd

cmdkey S
	info_subboard
	end_cmd

cmdkey Y
	info_user
	end_cmd

cmdkey V
	info_version
	end_cmd

cmdkey Q
	cmd_pop
	return
	end_cmd

cmd_pop
return

########################### Main Config Section  ##############################

:main_cfg

compare_user_misc UM_expert
if_false
	menu maincfg
	end_if
async
print "\r\n\1y\1hConfig: \1n"
getcmd ?QNPIS\r
logkey

cmdkey ?
	compare_user_misc UM_expert
	if_true
		menu maincfg
		end_if
	goto main_cfg
	end_cmd

cmdkey N
	msg_new_scan_cfg
	return
	end_cmd

cmdkey S
	msg_your_scan_cfg
	return
	end_cmd

cmdkey P
	msg_ptrs_cfg
	return
	end_cmd

cmdkey I
	msg_ptrs_reinit
	return
	end_cmd

return


########################### File Transfer Section #############################

:file_transfers

compare_ars file_cmds=0
if_true
	compare_user_misc UM_ask_nscan
	if_true
		crlf
		crlf
		yes_no "Search all libraries for new files"
		if_true
			file_new_scan_all
			end_if
		end_if
	end_if

cmd_home

compare_user_misc UM_expert
if_false
	cls
	menu transfer
	end_if

# Update node status
node_action node_xfer
async

inc_file_cmds

# Display main Prompt
print "\1-\1c\r\nț \1b\1hFile \1n\1cț \1h"
compare_ars exempt T
if_true
	print "@TUSED@"
else
	print "@TLEFT@"
	end_if
print " \1n\1c(\1h@LN@\1n\1c) @LIB@\1\\ (\1h@DN@\1n\1c) @DIR@: \1n"

# Get key (with / extended commands allowed)
compare_user_misc UM_COLDKEYS
if_false
	getkeye
else
	getstrupr 60
        endif

compare_ars RIP
if_true
	getlines
	end_if

# Do nothing for control keys and space
cmdkey ^@
	end_cmd
cmdkey ^M
	end_cmd
cmdkey ^S
	end_cmd
 cmdkey  "
	end_cmd

# Write command to log file
logkey_comma

# Hitting number changes current sub-board
cmdkey digit
	compare_user_misc UM_COLDKEYS
	if_false
		ungetkey
                end_if
	file_get_dir_num
	end_cmd

# Hitting /number changes current group
cmdkey edigit
	compare_user_misc UM_COLDKEYS
	if_false
		ungetkey
	else
		shift_str 1
                end_if
	file_get_lib_num
	end_cmd

# Show the key hit
compare_user_misc UM_COLDKEYS
if_false
	printkey
        endif

# Next directory
cmdkey ^^
	file_directory_up
	end_cmd
cmdkey >
	file_directory_up
	end_cmd
cmdkey }
	file_directory_up
	end_cmd
cmdkey )
	file_directory_up
	end_cmd
cmdkey +
	file_directory_up
	end_cmd
cmdkey =
	file_directory_up
	end_cmd

# Previous directory
cmdkey ^J
	file_directory_down
	end_cmd
cmdkey <
	file_directory_down
	end_cmd
cmdkey {
	file_directory_down
	end_cmd
cmdkey (
	file_directory_down
	end_cmd
cmdkey -
	file_directory_down
	end_cmd

# Next library
cmdkey ^F
	file_library_up
	end_cmd
cmdkey ]
	file_library_up
	end_cmd

# Previous library
cmdkey ^]
	file_library_down
	end_cmd
cmdkey [
	file_library_down
	end_cmd

# String commands start with a semicolon
cmdkey ;
	compare_user_misc UM_COLDKEYS
	if_true
		shift_str 1
	else
                getstrupr 40
		end_if
	exec_bin "str_cmds %s"
	end_cmd

cmdkey Q
        cmd_pop
        return
        end_cmd

compare_user_misc UM_COLDKEYS
if_false
	crlf
	end_if
pause_reset

# Menu
cmdkey ?
	compare_user_misc UM_expert
	if_true
		menu transfer
		end_if
	end_cmd

# Sysop Menu
compare_ars SYSOP
if_true
	cmdkey !
		menu sysxfer
		end_cmd
	end_if

# Commands

cmdkey B
	file_batch_section
	end_cmd

cmdkey C
	exec_bin chat_sec
	end_cmd

cmdkey D
	print "\r\n\1c\1hDownload File(s)\r\n"
	file_download_batch
	if_true
		end_cmd
		end_if
	getfilespec
	if_true
		file_download
		end_if
	end_cmd

cmdkey /D
	print "\r\n\1c\1hDownload File(s) from User(s)\r\n"
	file_download_user
	end_cmd

cmdkey E
	print "\r\n\1c\1hList Extended File Information\r\n"
	getfilespec
	if_true
		file_list_extended
		end_if
	end_cmd

cmdkey F
	print "\r\n\1c\1hFind Text in File Descriptions (no wildcards)\r\n"
	file_find_text
	end_cmd

cmdkey /F
	file_find_text_all
        end_cmd

cmdkey I
	call file_info
	end_cmd

cmdkey J
	file_select_area
	end_cmd

cmdkey L
	setstr *.*
	file_list
	end_cmd

cmdkey /L
	nodelist_all
	end_cmd

cmdkey N
	print "\r\n\1c\1hNew File Scan\r\n"
	file_new_scan
	end_cmd

cmdkey /N
	file_new_scan_all
	end_cmd

cmdkey O
	file_download_batch
	if_true
		end_cmd
                end_if
	logoff
	end_cmd

cmdkey /O
	file_download_batch
	if_true
		end_cmd
                end_if
	logoff_fast
        end_cmd

cmdkey R
	print "\r\n\1c\1hRemove/Edit File(s)\r\n"
	getfilespec
	if_true
		file_remove
		end_if
	end_cmd

cmdkey S
	print "\r\n\1c\1hSearch for Filename(s)\r\n"
	file_find_name
	end_cmd

cmdkey /S
	file_find_name_all
	end_cmd

cmdkey T
	file_temp_section
	end_cmd

cmdkey U
	print "\r\n\1c\1hUpload File\r\n"
	chkfile "%zmenu/upload.*"
	if_true
		menu upload
		end_if
	file_upload
	end_cmd

cmdkey /U
	print "\r\n\1c\1hUpload File to User\r\n"
	file_upload_user
	end_cmd

cmdkey V
	print "\r\n\1c\1hView File(s)\r\n"
	getfilespec
	if_true
		file_view
		end_if
	end_cmd

cmdkey Z
	print "\r\n\1c\1hUpload File to Sysop\r\n"
	file_upload_sysop
	end_cmd

cmdkey *
	file_show_directories
	end_cmd

cmdkey /*
	file_show_libraries
	end_cmd

cmdkey &
	:xfercfg
	compare_user_misc UM_expert
	if_false
		menu xfercfg
		end_if
	async
	print "\r\n\1y\1hConfig: \1n"
	getcmd ?QBEP\r
	logkey

	cmdkey ?
		compare_user_misc UM_expert
		if_true
			menu xfercfg
			end_if
		goto xfercfg
		end_cmd

	cmdkey P
		file_ptrs_cfg
		end_cmd

	cmdkey B
                crlf
		toggle_user_misc UM_BATCHFLAG
                compare_user_misc UM_BATCHFLAG
                print "Batch flagging in file listings is now: \1h"
                if_true
                    print "ON"
                else
                    print "OFF"
                    end_if
                crlf
		end_cmd
    
	cmdkey E
                crlf
		toggle_user_misc UM_EXTDESC
                compare_user_misc UM_EXTDESC
                print "Extended file description display is now: \1h"
                if_true
                    print "ON"
                else
                    print "OFF"
                    end_if
                crlf
                end_cmd
	end_cmd

cmdkey #
	print "\r\n\1c\1hType the actual number, not the symbol.\r\n"
	end_cmd

cmdkey /#
	print "\r\n\1c\1hType the actual number, not the symbol.\r\n"
        end_cmd

# fall through
print "\r\n\1c\1hUnrecognized command."
compare_user_misc UM_expert
if_true
	print " Hit '\1i?\1n\1c\1h' for a menu."
	end_if
crlf
end_cmd

# shouldn't hit next line
print "Problem in command shell."
pause
hangup

############################ File Info Section	###############################

:file_info
cmd_home
compare_user_misc UM_expert
if_false
	menu xferinfo
	end_if
async
print "\r\n\1y\1hInfo: \1n"
getcmd ?TYDUQ\r
logkey

cmdkey ?
	compare_user_misc UM_expert
	if_true
		menu xferinfo
		end_if
	end_cmd

cmdkey T
	info_xfer_policy
	end_cmd

cmdkey Y
	info_user
	end_cmd

cmdkey D
	info_directory
	end_cmd

cmdkey U
	userlist_dir
	end_cmd

cmdkey Q
	cmd_pop
	return
	end_cmd

cmd_pop
return

#end of DEFAULT.SRC
