Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Pre-Initialization checks of the Program before continuing
- /// </summary>
- private static void SanityCheck ( )
- {
- ConnectedIrcNetworks = new Dictionary<string, Irc> ( );
- if ( File.Exists ( Settingsf ) )
- return;
- Trace.Warning ( "{0} does not exist; Creating new configuration...", Path.GetFileName ( Settingsf ) );
- var net = new Network
- {
- AuthenticationService = "NickServ",
- AutoConnect = true,
- Color = ConsoleColor.Green,
- Id = Guid.NewGuid ( ),
- Ident = Name,
- IdentifyOnConnect = true,
- LastKnownCode = ReplyCode.ErrUnknowncode,
- Nick = "BlizzetaZero",
- NickServPass = Global.GenerateKey( "Aa0", 42 ),
- Owner = "-Your Name Here-",
- Email = "johndoe@seriouslynotarealemail.com",
- QuitMessage = Irc.VersionReply,
- RealName = "BlizzetaZero",
- ServerHost = "coruscant.r-type.ca",
- ServerPassword = "",
- ServerPort = 6667,
- SetupChannel = "#blizzeta",
- SetupChannelKey = "",
- Ssl = false
- };
- Trace.Info ( "Default Settings are as follows" );
- Trace.Info ( "AuthenticationService = {0}", net.AuthenticationService );
- Trace.Info ( "AutoConnect = {0}", net.AutoConnect );
- Trace.Info ( "Color = {0}", net.Color );
- Trace.Info ( "ID = {0}", net.Id );
- Trace.Info ( "Ident = {0}", net.Ident );
- Trace.Info ( "IdentifyOnConnect = {0}", net.IdentifyOnConnect );
- Trace.Info ( "LastKnownCode = {0}", net.LastKnownCode );
- Trace.Info ( "Nick = {0}", net.Nick );
- Trace.Info ( "NickServPass = {0}", net.NickServPass );
- Trace.Info ( "Owner = {0}", net.Owner );
- Trace.Info ( "Email = {0}", net.Email );
- Trace.Info ( "QuitMessage = {0}", net.QuitMessage );
- Trace.Info ( "RealName = {0}", net.RealName );
- Trace.Info ( "ServerHost = {0}", net.ServerHost );
- Trace.Info ( "ServerPassword = {0}", net.ServerPassword );
- Trace.Info ( "ServerPort = {0}", net.ServerPort );
- Trace.Info ( "SetupChannel = {0}", net.SetupChannel );
- Trace.Info ( "SetupChannelKey = {0}", net.SetupChannelKey );
- Trace.Info ( "SSL = {0}", net.Ssl );
- Trace.Info ( "Press any key to Accept the new settings, or Escape to cancel..." );
- if ( Console.ReadKey ( true ).Key == ConsoleKey.Escape )
- Environment.Exit ( -1 );
- File.Create ( Settingsf ).Close ( );
- GlobalSettings = new Settings ( );
- GlobalSettings.Networks.Add ( net );
- SaveSettings ( );
- }
- /// <summary>
- /// Defines the entry point of the application.
- /// </summary>
- private static void Main ( )
- {
- StartUptime ( );
- BeanApi.InitializeGlobal ( );
- IrcQueue = new Queue< Irc >();
- ShowHeader ( );
- Console.Title = FullName;
- Console.WindowWidth += 60;
- Console.WindowHeight += 30;
- SanityCheck ( );
- LoadSettings ( );
- CoreCommands.IncludeBuiltInCommands ( GlobalSettings.SuppressIncludeMessage );
- SetCharSet ( Encoding.UTF8 );
- if ( GlobalSettings == null )
- {
- Trace.Error (
- "{0} encountered an error parsing your configuration file in path: {1} and cannot proceed.", Name,
- Settingsf );
- Console.ReadLine ( );
- Environment.Exit ( 0 );
- }
- foreach ( Network net in GlobalSettings.Networks.Where ( net => net.Id == Guid.Empty ) )
- {
- net.Id = Guid.NewGuid ( );
- RehashSettings( );
- }
- ( new Root( ) ).Execute( null, null, null, Permissions.Root, new object[] { "server", "connect", "*ALL*"} );
- while ( ConnectedIrcNetworks.Count > 0 )
- {
- // Wait forever until all connected irc networks are cleared
- }
- Console.WriteLine( "Press any key to exit {0}", FullName );
- Console.ReadKey ( true );
- Cleanup ( );
- }
- /// <summary>
- /// Load a new set of settings
- /// </summary>
- public static void LoadSettings ( )
- {
- Console.WriteLine( "Loading Settings..." );
- try
- {
- var r = new StreamReader ( Settingsf );
- string res = r.ReadToEnd ( );
- r.Close ( );
- GlobalSettings = JsonConvert.DeserializeObject< Settings >( res );
- }
- // File is Empty........
- catch ( Exception ex )
- {
- IrcReply.FormatMessage( string.Format("Error! Type: {0}", ex.Data) );
- }
- Console.WriteLine( "End Block" );
- }
- /* Output
- Bean Counter has been initialized!
- Blizzeta Zero 0.42.5721.26235 Beta
- Copyright (c) 2009, 2014 - 2015 Blizzardo1
- Built on 31-Aug-15 14:34:30
- Loading Settings...
- End Block
- Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
- at BlizzetaZero.Kernel.Program.Main() in F:\BreakerDev Suite 2012\Blizzeta Zero rev2\Blizzeta Zero rev2\Kernel\Program.cs:line 241
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement