Example #1
0
 //ShipPlayer
 //public Dictionary<ulong, ShipPlayer> shipPlayers;
 public ShipHandler(MainHandler MainHandler)
 {
     this.MainHandler = MainHandler;
     ships            = new Dictionary <string, IShip>();
     ready            = false;
     //shipPlayers = new Dictionary<ulong, ShipPlayer>();
 }
Example #2
0
        public void Process(Message msg)
        {
            //if (UpdateTime.AddMilliseconds(HelloLimit) < DateTime.Now && LastHello.AddMilliseconds(HelloLimit) < DateTime.Now)
            //{
            //    LastHello = DateTime.Now;
            //    SendTextMessage(TextGeneration.Messages.Hello()).Wait();
            //}
            Worker.TelegramApi.SendChatActionAsync(msg.Chat.Id, Telegram.Bot.Types.Enums.ChatAction.Typing).Wait();
            if (msg.Type == Telegram.Bot.Types.Enums.MessageType.TextMessage)
            {
                Worker.GeneralApi.Send(msg.Date, msg.Text, msg.Chat.Id.ToString(), msg.Chat.Username, Worker.BotInfo.Username).Wait();
            }

            if (UpdateTime.AddMilliseconds(TimeLimit) < DateTime.Now)
            {
                ExitAll();
            }
            if (HandlersStack.Count > 0)
            {
                var handled = HandlersStack.Peek().Process(msg);
                UpdateTime = DateTime.Now;
                return;
            }
            MainHandler.Process(msg);
        }
Example #3
0
        public async Task RunAsync()
        {
            Discord = new DiscordSocketClient(new DiscordSocketConfig()
            {
                LogLevel = LogSeverity.Info
            });

            Discord.Log += (message) =>
            {
                Console.WriteLine(message);
                return(Task.CompletedTask);
            };
            Discord.Ready += () =>
            {
                Console.WriteLine("Connected!");
                return(Task.CompletedTask);
            };

            var services = new ServiceCollection();

            services.AddSingleton(Discord);
            services.AddPaginator(Discord);

            MainHandler = new MainHandler(Discord, services.BuildServiceProvider());
            await MainHandler.InitializeEarlyAsync();

            await Discord.LoginAsync(TokenType.Bot, "...");

            await Discord.StartAsync();

            await Task.Delay(-1);
        }
Example #4
0
 public void Exit(CommandHandler tgCmdHandler, bool pulse = true)
 {
     lock (HandlersStack)
     {
         if (HandlersStack.Contains(tgCmdHandler))
         {
             while (HandlersStack.Count > 0)
             {
                 var last = HandlersStack.Pop();
                 UpdateTime = DateTime.Now;
                 if (last == tgCmdHandler)
                 {
                     break;
                 }
             }
             if (pulse)
             {
                 if (HandlersStack.Count > 0)
                 {
                     HandlersStack.Peek().Attach();
                 }
                 else
                 {
                     MainHandler.Attach();
                 }
             }
         }
     }
 }
Example #5
0
        public static void Main(string[] args)
        {
            if (AttachConsole(ATTACH_PARENT_PROCESS))
            {
                ParentConsoleAvailble = true;
            }

            if (args.Contains("/nogui"))
            {
                var mh = new MainHandler(new List <ILibrary>()
                {
                    new Draw.Libs.Draw(null, null),
                    new IO(),
                    new Lp()
                });
                var a = args.ToList();
                a.Remove("/nogui");
                mh.Main(a.ToArray());
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new HiddenContext(args));
            }
        }
Example #6
0
 public DCB(MainHandler MainHandler, JObject o)
 {
     this.MainHandler = MainHandler;
     ship             = o;
     ship_max         = null;
     search           = null;
 }
Example #7
0
 public AirCarrier(MainHandler MainHandler, JObject o)
 {
     this.MainHandler = MainHandler;
     ship             = o;
     shipMax          = null;
     cv = null;
 }
Example #8
0
 public TextHandler(MainHandler MainHandler)
 {
     this.MainHandler = MainHandler;
     interferenceTime = swearTimer = null;
     swear            = null;
     focus            = null;
 }
Example #9
0
        public MainWindow()
        {
            InitializeComponent();

            _viewModel  = new MainWindowViewModel();
            DataContext = _viewModel;

            _mainHandler = new MainHandler(this);
        }
Example #10
0
 public MayaCommandContext(IDiscordClient client, MainHandler handler, IUserMessage msg)
 {
     Client      = client;
     Guild       = (msg.Channel as IGuildChannel)?.Guild;
     Channel     = msg.Channel;
     User        = msg.Author;
     Message     = msg;
     MainHandler = handler;
 }
Example #11
0
        public void AddFirstHandler(MainHandler handler)
        {
            if (_actionHandler != null)
            {
                handler.Next = _actionHandler;
            }

            _actionHandler = handler;
        }
Example #12
0
 /// <summary>
 /// this method is used to reset the table, the changes, and the sql handler so they can be used.
 /// </summary>
 private void ClearOptions()
 {
     tblLay.Controls.Clear();
     tblLay.RowStyles.Clear();
     tblLay.ColumnStyles.Clear();
     tblLay.ColumnCount = 1;
     tblLay.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
     changes.Clear();
     MainHandler.Reset();
 }
Example #13
0
        public async Task InitializeAsync(MainHandler MainHandler, IServiceProvider services)
        {
            this.MainHandler = MainHandler;
            client           = (DiscordSocketClient)services.GetService(typeof(DiscordSocketClient));
            commands         = new CommandService();
            this.services    = services;

            commands.AddTypeReader <Nullable <int> >(new NullableTypeReader <int>(int.TryParse));
            await commands.AddModulesAsync(Assembly.GetEntryAssembly());

            client.MessageReceived += HandleCommand;
        }
 // this makes sure that this object is the only object of this kind unless we load a scene with the same script than this will be replaced
 void Awake()
 {
     if (mainHandler == null)
     {
         DontDestroyOnLoad(this);
         mainHandler = this;
     }
     else if (mainHandler != null)
     {
         Destroy(gameObject);
     }
 }
Example #15
0
 public GuildHandler(MainHandler MainHandler, SocketGuild Guild)
 {
     this.MainHandler   = MainHandler;
     this.Guild         = Guild;
     ConfigHandler      = new ConfigHandler(this);
     DatabaseHandler    = new DatabaseHandler(this);
     IgnoreHandler      = new IgnoreHandler(this);
     MusicHandler       = new MusicHandler(this);
     PersonalityHandler = new PersonalityHandler(this);
     TitleHandler       = new TitleHandler(this);
     TagHandler         = new TagHandler(this);
 }
        public void Main()
        {
            Handler register = new RegisterHandler();
            Handler login    = new LoginHandler();
            Handler main     = new MainHandler();
            Handler settings = new SettingsHandler();

            register.succeedWith(login);
            login.succeedWith(main);
            main.succeedWith(settings);

            register.check(state);
        }
Example #17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            EngineNS.CIPlatform.Instance.InitAndroid(this.Assets);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            mHandler = new MainHandler();

            mGameView = FindViewById <Android.Views.SurfaceView>(Resource.Id.surfaceView);
            mGameView.Holder.AddCallback(this);
        }
Example #18
0
        public async Task InitializeAsync(MainHandler MainHandler, IServiceProvider services)
        {
            _mainHandler = MainHandler;
            _client      = (DiscordSocketClient)services.GetService(typeof(DiscordSocketClient));
            _commands    = new CommandService();
            _services    = services;

            await _commands.AddModulesAsync(Assembly.GetEntryAssembly());

            _commands.Log += Log;

            _client.MessageReceived += HandleCommand;
            _client.MessageUpdated  += HandleUpdate;
        }
Example #19
0
        public async Task RunAsync()
        {
            if (!Directory.Exists("Temp"))
            {
                Directory.CreateDirectory("Temp");
            }
            var files = Directory.GetFiles("Temp");

            foreach (string f in files)
            {
                File.Delete(f);
            }

            Discord = new DiscordSocketClient(new DiscordSocketConfig()
            {
                LogLevel         = LogSeverity.Info,
                MessageCacheSize = 100
            });

            Discord.Log += (message) =>
            {
                Console.WriteLine($"{message.ToString()}");
                return(Task.CompletedTask);
            };
            Discord.Ready += async() =>
            {
                Console.WriteLine("Connected!");
                await Discord.SetGameAsync(null);

                await MainHandler.InitializeLaterAsync();
            };

            var services = new ServiceCollection();

            services.AddSingleton(Discord);
            services.AddPaginator(Discord);

            MainHandler             = new MainHandler(Discord);
            Discord.GuildAvailable += MainHandler.InitializeGuild;
            Discord.JoinedGuild    += MainHandler.InitializeGuild;
            Discord.LeftGuild      += MainHandler.RemoveGuild;
            await MainHandler.InitializeEarlyAsync(services.BuildServiceProvider());

            await Discord.LoginAsync(TokenType.Bot, "NDE0NDA1ODE0NDIyNjAxNzMw.DWnHCA.8q5kLh_HYBQzrQtrQ_-s85UEWSE");

            await Discord.StartAsync();

            await Task.Delay(-1);
        }
Example #20
0
        /// <summary>
        /// this constructor is used to set up not only the UI elements, but also set up the SQL options (such as providers),
        /// as well as gather the providers for the UI,
        /// </summary>
        public SQLCopierForm()
        {
            InitializeComponent();
            MainHandler.SetUp(Changes);
            string log = "Application Started, With ";

            foreach (var key in MainHandler.GetProviders())
            {
                comboBox1.Items.Add(key);
                comboBox2.Items.Add(key);
                log += key + ",";
            }
            comboBox1.SelectedIndex = comboBox2.SelectedIndex = 0;
            MainHandler.LogMessage(log.TrimEnd(',') + " as data providers");
        }
Example #21
0
        static void Main(string[] args)
        {
            try
            {
                Log4net.InitiateLog();

                ApplicationConfig.LoadIni();

                MainHandler.Start();
            }
            catch (Exception ex)
            {
                Log4net.log.ErrorFormat("Error: {0}", ex);
                Utility.ClearAll();
            }
        }
Example #22
0
 public void AddLastHandler(MainHandler handler)
 {
     if (_actionHandler == null)
     {
         _actionHandler = handler;
     }
     else
     {
         var prev = _actionHandler;
         while (prev.Next != null)
         {
             prev = prev.Next;
         }
         prev.Next = handler;
     }
 }
Example #23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            EngineNS.CIPlatform.Instance.InitAndroid(this, this.Assets);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            mHandler = new MainHandler();

            mGameView = FindViewById <Android.Views.SurfaceView>(Resource.Id.surfaceView);
            mGameView.Holder.AddCallback(this);
            //var pm = (PowerManager)this.GetSystemService(Context.PowerService);
            //mWakeLock = pm.NewWakeLock(WakeLockFlags.ScreenDim | WakeLockFlags.OnAfterRelease, "BatMan");
            //mWakeLock.Acquire();
        }
Example #24
0
        public Manager()
        {
            InitializeComponent();
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (DispatcherOperationCallback) delegate(object o)
            {
                mainHandler = new MainHandler();
                listView_clients.ItemsSource = mainHandler.GetClients();
                mainHandler.StartServer();
                return(null);
            }, null);

            DispatcherTimer timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
            {
                tb_Clock.Text = DateTime.Now.ToString("HH:mm:ss");
                ShowDetails();
            }, this.Dispatcher);
        }
Example #25
0
 public override void Process(Message msg)
 {
     if (AuthHandler.CheckAuth(msg.Chat.Id))
     {
         if (HandlersStack.Count > 0)
         {
             HandlersStack.Peek().Process(msg);
         }
         else
         {
             MainHandler.Process(msg);
         }
     }
     else
     {
         AuthHandler.Process(msg);
     }
 }
Example #26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.main);
            findview();
            savelist          = new  Collection <string>();
            webView1          = new WebView(this);
            mSharedPreference = GetSharedPreferences(Constant.Com_Fra, FileCreationMode.WorldWriteable);
            myfunslist        = new List <MyImageButton>();
            mainhandler       = new MainHandler(this);
            showwebviewfirst();
            showfunsold();
            GetNewinfo getnew = new GetNewinfo();

            getnew.context = this;
            getnew.Start();

            // Create your application here
        }
Example #27
0
        public async Task Start()
        {
            DataBases = new DataBases();
            await DataBases.Open();

            Console.WriteLine("Starting up...");

            await Keys.LoadAPIKeys();

            mHandler = new MainHandler();
            mHandler.Start();

            NetworkHandler = new NetworkHandler(1994);
            NetworkHandler.Start();

            DiscordClient = new DiscordClient(NetworkHandler);

            Console.WriteLine($"{DesignFunctions.Time.GetTime()} Server started [ {NetworkHandler.tcpListener.LocalEndpoint.ToString()} ]");

            await Task.Delay(-1);
        }
Example #28
0
        public void RemoveHandler(MainHandler handler)
        {
            var         current = _actionHandler;
            MainHandler prev    = null;

            while (current != null && current != handler)
            {
                prev    = current;
                current = current.Next;
            }

            if (current != null)
            {
                if (prev == null)
                {
                    _actionHandler = current.Next;
                }
                else
                {
                    prev.Next = current.Next;
                }
            }
        }
Example #29
0
        public async Task MainAsync()
        {
            _client = new DiscordSocketClient(new DiscordSocketConfig()
            {
                AlwaysDownloadUsers = true
            });

            _config = BuildConfig();

            var services = ConfigureServices();

            services.GetRequiredService <LogService>();
            await services.GetRequiredService <CommandHandlingService>().InitializeAsync(services);

            // IoC pls D:
            MainHandler = new MainHandler(_client, new DarkOrbitService());
            await _client.SetGameAsync(null);

            await _client.LoginAsync(TokenType.Bot, _config["token"]);

            await _client.StartAsync();

            await Task.Delay(-1);
        }
Example #30
0
 public ExceptionHandler(MainHandler MainHandler)
 {
     this.MainHandler = MainHandler;
 }