public static void Main(string[] args) { //this method is just for some tests //TestConnectionStability(); //return; int cycle_cnt = 0; while (true) { cycle_cnt++; //Console.Clear(); Console.WriteLine("Cycle: " + cycle_cnt); Thread.CurrentThread.Name = "Main"; #region Settings string startupPath = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); if (File.Exists(startupPath + "\\settings.ini")) profile = new Ini(startupPath + "\\settings.ini"); else { logger.Trace("Did not find" + startupPath); } channel = (string)profile.GetValue("Main", "Channel"); nick = (string)profile.GetValue("Main", "Nick"); real = (string)profile.GetValue("Main", "Real"); #endregion #region IRC Setup irc = new IrcClient(); irc.SendDelay = 500; irc.ActiveChannelSyncing = true; irc.OnChannelMessage += new IrcEventHandler(OnChannelMessage); irc.OnQueryMessage += new IrcEventHandler(OnQueryMessage); irc.OnBan += new BanEventHandler(OnBanMessage); irc.OnError += new Meebey.SmartIrc4net.ErrorEventHandler(OnError); irc.OnPart += new PartEventHandler(irc_OnPart); irc.OnRawMessage += new IrcEventHandler(OnRawMessage); if (proactiveMode) { timer = new System.Timers.Timer(); timer.Elapsed += new System.Timers.ElapsedEventHandler(autoAnswering); } #endregion sl = new SortedList(); Console.WriteLine("**********************************************************"); Console.WriteLine("These are my settings: "); Console.WriteLine("Trying to connect to " + serverlist[0] + " on port " + port + " - joining channel: " + channel); Console.WriteLine("My nickname is: " + nick + " and my real name is: " + real); Console.WriteLine("**********************************************************"); try { irc.AutoRetry = true; irc.AutoReconnect = true; irc.Connect(serverlist, port); } catch (ConnectionException e) { logger.Trace("couldn't connect! Reason: " + e.Message); } try { // here we logon and register our nickname and so on irc.OnRawMessage += new IrcEventHandler(irc_OnRawMessage); irc.Login(nick, real); //load all channels irc.RfcList(""); Dictionary<string, int> chann = new Dictionary<string, int>(); // join the channel irc.RfcJoin(channel); irc.OnChannelAction += new ActionEventHandler(irc_OnChannelAction); #region Prelude Setup //initialize interface logger.Trace("Loading Prelude..."); pi = new PreLudeInterface(); //define path to mind file pi.loadedMind = "mind.mdu"; pi.avoidLearnByRepeating = true; pi.initializedAssociater = Mind.MatchingAlgorithm.Dice; //start your engine ... pi.initializeEngine(); logger.Trace("Prelude loaded and initialized..."); #endregion // spawn a new thread to read the stdin of the console, this we use // for reading IRC commands from the keyboard while the IRC connection // stays in its own thread new Thread(new ThreadStart(ReadCommands)).Start(); irc.Listen(); // when Listen() returns our IRC session is over, to be sure we call // disconnect manually irc.Disconnect(); } catch (ConnectionException) { logger.Trace("Connection exception"); pi.stopPreludeEngine(); } catch (Exception e) { logger.Trace("Error occurred! Message: " + e.Message); logger.Trace("Exception: " + e.StackTrace); pi.stopPreludeEngine(); } logger.Trace("Going to sleep"); System.Threading.Thread.Sleep(5 * 60000); logger.Trace("==========================================="); } }