예제 #1
0
        private static void LaunchBots(IEnumerable <OurBot> ourBots)
        {
            int total = ourBots.Count();
            int count = 0;

            foreach (var bot in ourBots)
            {
                LaunchBot(bot);
                count++;
                BotLaunched?.Invoke(null, new BotLaunchedArgs(bot, (double)count / total * 100));
            }
        }
예제 #2
0
        public static void RegisterNewBot(string token, int ownerId, string schemeName)
        {
            var bot = new OurBot()
            {
                TBot       = new TelegramBotClient(token),
                Token      = token,
                OwnerId    = ownerId,
                SchemeName = schemeName
            };

            bot.Owner = DBHelper.GetBotOwner(bot);
            SchemeBase.GetShemeFor(bot);  // initialize scheme and store texts
            using (var db = DBHelper.GetConnection())
            {
                db.Insert(bot);
            }
            LaunchBot(bot);
            BotLaunched?.Invoke(null, new BotLaunchedArgs(bot));
        }
예제 #3
0
        public static void Init()
        {
            Form = new MainForm();
            Form.OnLaunchAllButtonClick       += delegate(object sender, EventArgs e) { OnLaunchAllButtonClick?.Invoke(sender, null); };
            Form.OnClientsButtonClick         += delegate(object sender, EventArgs e) { OnClientsButtonClick?.Invoke(sender, null); };
            Form.OnStopAllButtonClick         += delegate(object sender, EventArgs e) { OnStopAllButtonClick?.Invoke(sender, null); };
            Form.OnLaunchContextMenuItemClick += delegate(object sender, LaunchSeveralBotsArgs e) { OnLaunchContextMenuItemClick?.Invoke(sender, e); };
            Form.OnStopContextMenuItemClick   += delegate(object sender, StopSeveralBotsArgs e) { OnStopContextMenuItemClick?.Invoke(sender, e); };
            Form.Show();

            DBHelper.CheckDB();

            BotController.BotLaunched += delegate(object sender, BotLaunchedArgs e) { BotLaunched?.Invoke(sender, e); };
            BotController.BotStopped  += delegate(object sender, BotStoppedArgs e) { BotStopped?.Invoke(sender, e); };
            BotController.BotChecked  += delegate(object sender, BotCheckedArgs e) { BotChecked?.Invoke(sender, e); };
            BotController.Init();

            ClientController.Init();

            Form.Hide();
            Form.ShowDialog();
        }