# include gnu.gpl, (*) 2000 Micha 'malekith' Moskal <malekith@topnet.pl>. 
# $Id: main,v 1.1 2000/08/27 18:32:51 malekith Exp $ 

proc info(string s)
{
	puts(window, "\e<info> " + s);
}

if (`$loaded` == "") {
	shash thame, command_help, num, plus, conf;
	ihash bools, colors;
	string loaded = "yes";
	int rehash = 0;

	string window;

	string home_host, nick, real_name;
	string main_script;
	
	home_host = "";
	nick = getenv_def("IRCNICK", getenv_def("USER", "someone"));
	real_name = getenv_def("IRCNAME", "31337");

	shash windows;

	if (exists(home_dir + "/s/main"))
		main_script = home_dir + "/s/main";
	else if (exists(data_dir + "/s/main"))
		main_script = data_dir + "/s/main";
	else
		info("cannot find main script !");
}  else
	rehash = 1;

proc load_s(string s)
{
	string x;
	
	if (exists(home_dir + "/s/" + s))
		x = home_dir + "/s/" + s;
	else if (exists(data_dir + "/s/" + s))
		x = data_dir + "/s/" + s;
	else {
		puts("", "!!! cannot load " + s);
		return;
	}

	source(x);
}

load_s("thame");
load_s("cmd");
load_s("parse");

bools{contrast_colors} = 0;
bools{copy_status} = 1;
bools{short_status_line} = 0;
bools{no_colors} = 0;
bools{no_cont} = 0;
bools{half_scroll} = 0;
bools{scroll_on_print} = 0;
bools{window_input_line} = 0;
bools{invisible} = 0;

# executed whenever a new interface connects to the bot
proc cc_client_connected()
{
	set_status_line($VERSION + " by malekith");
}

if (rehash)
	info("rehash done.");
else
	info("script loaded.");
