Start() private method

private Start ( ) : void
return void
コード例 #1
0
        static void Main(string[] args)
        {
            string configPath = "/saiyanbot.cfg";

            if (args.Length > 0)
            {
                if (args[0] == "-c" || args[0] == "--config")
                {
                    if (args.Length < 2)
                    {
                        Console.WriteLine($"Invalid value after flag \"{args[0]}\"");
                        return;
                    }

                    configPath = args[1];
                }
                else if (args[0] == "-h" || args[0] == "--help")
                {
                    Console.WriteLine("Options:");
                    Console.WriteLine("    -c  --config: Specify a different configuration file directory");
                    Console.WriteLine("    -h  --help:   Show this info");
                }
            }

            Config conf = Config.ParseConfig(Config.LoadConfigFile(File.GetDirectory(Assembly.GetExecutingAssembly.Location) + configPath));

            Bot bot = new Bot(conf);

            bot.Start();
        }
コード例 #2
0
        public Form1()
        {
            InitializeComponent();

            this.timer          = new System.Windows.Forms.Timer();
            this.timer.Interval = 1;
            this.timer.Tick    += Timer_Tick;

            map = new Map(24, 24, 55, 40, this);

            this.tank  = new Tank(new Point(8, 16), map, this.ClientRectangle);
            this.bots  = new List <Bot>();
            tank.Color = Color.Black;

            Task.Run(() =>
            {
                for (int i = 0; i < 1; i++)
                {
                    Bot bot   = new Bot(this.ClientRectangle, tank, map);
                    bot.Color = Color.Red;
                    bot.Start();
                    this.bots.Add(bot);
                }
            });

            this.DoubleBuffered = true;
        }
コード例 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (BotList.Count == 0)
            {
                MessageBox.Show("No Bots Added!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (IsStarted)
            {
                MessageBox.Show("Already Started!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Program.botRunning = true;

            Invoke(new Action(() =>
            {
                int Amount = BotList.Count;
                foreach (Thread Bot in BotList)
                {
                    Bot.Start();
                }
                PreventSleepMode.ToggleSleepMode(true);
                MessageBox.Show($"{Amount} Bots have been started!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                IsStarted = true;
            }));
        }
コード例 #4
0
        static void Main(string[] args)
        {
//#if Linux
//        Console.WriteLine("Built on Linux!");
//#elif OSX
//        Console.WriteLine("Built on macOS!");
//#elif Windows
//        Console.WriteLine("Built in Windows!");
//#endif

            var logger = Diagnostics.EventLogger.GetLogger();
            var config = Configuration.Config.Load(Strings.ConfigFileName);

            if (config == null)
            {
                logger.Error($"Failed to load config {Strings.ConfigFileName}.");
                return;
            }

            var bot = new Bot(config);

            bot.Start();

            System.Diagnostics.Process.GetCurrentProcess().WaitForExit();
        }
コード例 #5
0
 private void BotStartMenuItem_Click(object sender, RoutedEventArgs e)
 {
     lock (Bot)
     {
         Bot.Start();
     }
 }
コード例 #6
0
        public void RunnerStartsWithBotWhenStartingBot()
        {
            Bot bot = new Bot(api_client_mock.Object, bot_runner_mock.Object);

            bot.Start();

            bot_runner_mock.Verify(runner => runner.Start(bot));
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: kurilchik/Pilot_Project
        static void Main(string[] args)
        {
            Bot bot = new Bot();

            bot.Start();
            bot.OrderPizza();
            bot.Delivery();
        }
コード例 #8
0
 // TODO: Rename Button
 private void button1_Click(object sender, EventArgs e)
 {
     rbtechbot.LogMessage    += LogMessage;
     rbtechbot.OnChatMessage += Bot_ChatMessage;
     rbtechbot.OnUserJoin    += Bot_ChatUserJoin;
     rbtechbot.OnUserPart    += Bot_ChatUserPart;
     rbtechbot.Start();
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: llenroc/CryptoTickerBot
        public static void Main( )
        {
            Console.Title = Settings.Instance.ApplicationName;
            Logger.Info($"Started {Settings.Instance.ApplicationName}");
            var ctb = new Bot( );

            ctb.Start( );
            Thread.Sleep(int.MaxValue);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: olegstabr/ScrapbookBot
        private static async Task Main(string[] args)
        {
            var bot = new Bot();
            await bot.GetTokenFromFileAsync("/home/linuxoid/Desktop/token scrapbook");

            await bot.Start();

            Console.ReadLine();
            bot.Stop();
        }
コード例 #11
0
ファイル: MainWindow.cs プロジェクト: wawah/BinanceBot-2
        private void Trade()
        {
            btnStartStop.Text = "Stop";

            _bot.Start(Program.Settings);

            _bot.Strategy.Started += Strategy_Started;
            _bot.Strategy.TradeListItemHandled += Strategy_Handled;
            _bot.Strategy.OrderSucceeded       += Strategy_OrderSuccess;
            _bot.Strategy.Completed            += Strategy_Completed;
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: LlamaNL/RoboLlama
 private static void Main()
 {
     #if !DEBUG
     var filestream = new FileStream("exception.log", FileMode.Create);
     var streamwriter = new StreamWriter(filestream) {AutoFlush = true};
     Console.SetError(streamwriter);
     ConsoleDecorator.SetToConsole();
     #endif
     var bot = new Bot();
     bot.Start();
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: AlexTruba/BpmBot
        static void Main(string[] args)
        {
            using (var timer = new Timer(2000))
            {
                Bot bot = new Bot();
                timer.Elapsed += async(sender, e) => await bot.Start();

                timer.Disposed += (sender, e) => bot.Dispose();
                timer.Start();
                Console.ReadKey();
            }
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: GoodGamesTeam/Jubi
        static void Main(string[] args)
        {
            var bot = new Bot(
                "config.ini",
                new SiteProvider[] { new VKontakteProvider(), new TelegramProvider() },
                new ExecutorInformation
            {
                Namespace = "Jubi.ConsoleApp.Executors",
                Assembly  = Assembly.GetExecutingAssembly()
            });

            bot.Start();
        }
コード例 #15
0
 private void StartScriptButton_Click(object sender, RoutedEventArgs e)
 {
     lock (Bot)
     {
         if (Bot.Running == BotClient.State.Stopped)
         {
             Bot.Start();
         }
         else if (Bot.Running == BotClient.State.Started || Bot.Running == BotClient.State.Paused)
         {
             Bot.Pause();
         }
     }
 }
コード例 #16
0
        // event. Click sur le boutton 'RunBotBtn'
        private void RunBotBtn_Click(object sender, EventArgs e)
        {
            switch (RunBotBtn.Text)
            {
            case "Démarrer":
                if (GamePanel.Controls.Contains(SelectWindowGroupBox))
                {
                    MessageBox.Show("Veuillez intégrer une fenêtre du jeu !", App.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (TrajetBotComboBox.Items.Count == 0 || TrajetBotComboBox.SelectedIndex == -1)
                {
                    MessageBox.Show("Veuillez spécifier un trajet pour le bot !", App.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (FightIAComboBox.Items.Count == 0 || FightIAComboBox.SelectedIndex == -1)
                {
                    MessageBox.Show("Veuillez spécifier une IA de combat pour le bot !", App.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (GoBanqueCheckGroupBox.Checked && BanqueTrajetComboBox.SelectedIndex == -1)
                {
                    MessageBox.Show("Veuillez ajouter le trajet de la banque dans l'onglet Métier !", App.Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    // Trajet
                    Trajet TrajetBot = new Trajet(((ComboBoxItem)TrajetBotComboBox.SelectedItem).Value.ToString());
                    TrajetBot.Repeat = RepeatTrajetBotCheckBox.Checked;
                    // Metier
                    Job Job = new Job((int)CollectTimeNumericUpDown.Value * 1000);     // conversion en milliseconde
                    if (Job.GoBanque.Enabled = GoBanqueCheckGroupBox.Checked)
                    {
                        Job.GoBanque.Trajet = new Trajet(((ComboBoxItem)BanqueTrajetComboBox.SelectedItem).Value.ToString());
                    }
                    // Combat
                    Fight Fight = new Fight(new IA(((ComboBoxItem)FightIAComboBox.SelectedItem).Value.ToString()));

                    Bot = new Bot(this, Log, TrajetBot, Job, Fight, BotTimer, BotStopWatch, RunBotBtn, PauseBotBtn, BotStatePictureBox, MinimapPictureBox, GamePanel, GameProcess.MainWindowHandle, PodProgressBar);
                    Bot.Start();
                }
                break;

            case "Arrêter":
                Bot.Stop();
                break;
            }
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: darknessOfficial/VK-Bot
        static void Main(string[] args)
        {
            //Создание параметров для бота.
            var settings = new BotSettings()
            {
                GroupId   = groupVkId,
                Messenger = MessengerPlatform.Vkontakte,
                VKToken   = vkTokenGroup
            };
            //Создание экзмпляра класса бота.
            IBot bot = new Bot(settings, new NoCommand());

            //Установка команд.
            bot.SetCommands(new StartCommand(),
                            new ShowCommand(),
                            new Services(),
                            new Portfolio(),
                            new Information(),
                            new Сontacts(),
                            new Printing(),
                            new Promotion(),
                            new Polygraphy(),
                            new SpecialServices(),
                            new BannerPrinting(),
                            new FilmPrinting(),
                            new Signboards(),
                            new LightBoxes(),
                            new AutoBranding(),
                            new PortableStructures(),
                            new StandsAndSigns(),
                            new VolumetricLetters(),
                            new Booklets(),
                            new Calendars(),
                            new Leaflets(),
                            new Postcards(),
                            new BusinessCards(),
                            new Design(),
                            new MillingWork(),
                            new PlatformRental());

            //Установка сервисов.
            //bot.SetServices(new CounterService());

            //Запуск бота
            bot.Start();

            //Чтобы консоль тупо не закрылась))
            Console.ReadLine();
        }
コード例 #18
0
ファイル: BotManager.cs プロジェクト: lythm/orb3d
            public bool StartBots()
            {
                FBotList = new List<Bot>(FBotDesc.Count);
                for (int i = 0; i < FBotDesc.Count; ++i)
                {
                    Bot bot = new Bot(this, FBotDesc, i);
                    FBotList.Add(bot);
                    bot.Start();
                }

                AppContext.WriteLog("Bot["+FBotDesc.Name+"] started.");
                FBotDesc.Running = true;

                return true;
            }
コード例 #19
0
 private void FlatButton_startStopClick(object sender, EventArgs e)
 {
     if (bot.IsWorking())
     {
         bot.Stop();
         flatButton_startStop.Text      = "Start";
         flatButton_startStop.BaseColor = Color.FromArgb(255, 35, 168, 109);
     }
     else
     {
         bot.Start();
         flatButton_startStop.Text      = "Stop";
         flatButton_startStop.BaseColor = Color.FromArgb(255, 168, 35, 35);
     }
 }
コード例 #20
0
ファイル: Program.cs プロジェクト: wawah/BinanceBot-2
        private static void Main(string[] args)
        {
            Settings = Bot.LoadSettings();

            // Error handling
            if (string.IsNullOrEmpty(Settings.APIKey))
            {
                Console.Write("Enter Binance API Key: ");
                Settings.APIKey = Console.ReadLine();

                Console.Write("Enter Binance Secret Key: ");
                Settings.SecretKey = Console.ReadLine();
            }

            // Choose Bot mode
            foreach (BotMode bm in Enum.GetValues(typeof(BotMode)))
            {
                Console.WriteLine($"{bm.GetIndex()} for {bm.GetDescription()}");
            }
            Console.Write("Choose Bot mode: ");

            int intMode;

            int.TryParse(Console.ReadLine(), out intMode);
            Settings.BotMode = (BotMode)intMode;

            Bot.SaveSettings(Settings);

            // Error handling - Bot mode specific
            switch (Settings.BotMode)
            {
            case BotMode.FixedProfit:
                if (Settings.DailyProfitTarget <= 0)
                {
                    Console.WriteLine("Daily Profit Target must be greater than zero!");
                    Console.ReadLine();
                    return;
                }
                break;
            }

            Bot myBot = new Bot(Program.Settings);

            myBot.Start(Program.Settings);
            Console.WriteLine($"{Settings.BotMode.GetDescription()} Bot started...");

            Console.ReadLine();
        }
コード例 #21
0
ファイル: Form1.cs プロジェクト: stvn1337/sBot
        public void BotBuddha(int i)
        {
            if (this.pictureBox2.InvokeRequired)
            {
                SetBotCallback p = new SetBotCallback(BotBuddha);
                this.Invoke(p, new object[] { i });
            }
            else
            {
                switch (i)
                {
                case 0:
                    try
                    {
                        pictureBox1.Image = Properties.Resources.supreme_box_logo___1;
                    }
                    catch (Exception) { }

                    pictureBox2.Image = Properties.Resources.robot_hands___down;

                    Bot.Stop();

                    Randomizer.Change(Timeout.Infinite, Timeout.Infinite);
                    Block = false;
                    break;

                case 1:
                    pictureBox2.Image = Properties.Resources.robot_gif;

                    Bot.Start();

                    Randomizer.Change(0, 3000);
                    Block = true;
                    break;

                case 2:
                    pictureBox2.Image = Properties.Resources.robot_hands___up;
                    break;

                case 3:
                    pictureBox2.Image = Properties.Resources.robot_gif;
                    pictureBox2.Refresh();
                    break;
                }
            }

            EmptyWorkingSet(Process.GetCurrentProcess().Handle);
        }
コード例 #22
0
        private static void drawMainMenu()
        {
            Console.Clear();
            drawDuck();

            if (currentBotMode == BotMode.None)
            {
                drawModeSelection();
            }
            else if (canLoad)
            {
                configManager.RefreshConfig();
                quaverManager.ConfigManager.RefreshConfig();

                var map = quaverManager.QuaverBase.GameplayScreen.CurrentMap;

                var  mods       = quaverManager.QuaverBase.GameplayScreen.Ruleset.ScoreProcessor.CurrentMods;
                bool flipInputs = currentBotMode == BotMode.UserReplay && (Mods)Math.Abs(replay.Mods - mods) == Mods.Mirror;

                if (currentBotMode == BotMode.AutoplayReplay)
                {
                    replay = Replay.GenerateAutoplayReplay(map);
                }

                Console.WriteLine($"\n\n~ Playing{(currentBotMode == BotMode.UserReplay ? $" {replay.PlayerName}'s replay on" : string.Empty)} {map.Artist} - {map.Title} [{map.DifficultyName}] by {map.Creator}");

                bot.Start(replay, flipInputs);
            }
            else
            {
                Console.WriteLine("\n\n~ Waiting for player...");
                Console.WriteLine("\n~ Press ESC to change mode.");

                while (!canLoad && !Console.KeyAvailable)
                {
                    Thread.Sleep(150);
                }

                if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)
                {
                    currentBotMode = BotMode.None;
                }
            }

            drawMainMenu();
        }
コード例 #23
0
        private void btnBotStart_Click(object sender, EventArgs e)
        {
            if (Bot.CurrentBot == null)
            {
                return;
            }

            if (Bot.Start())
            {
                btnBotStart.Enabled = false;
                btnBotStop.Enabled  = true;

                cbBots.Enabled         = false;
                btnBotSettings.Enabled = false;
                cbBrains.Enabled       = false;
            }
        }
コード例 #24
0
        public void BotHandlesAnUpdateMessage()
        {
            ApiClient api_client = new ApiClient(API_TOKEN, http_client_stub);
            BotRunner bot_runner = new BotRunner();
            Bot       bot        = new Bot(api_client, bot_runner);

            bot.InstallUpdateHandler(new HelloTestHandler());

            bot.Start();

            InjectUpdate(TEST_HELLO_MESSAGE);

            Thread.Sleep(millisecondsTimeout: 200);
            bot.Stop();

            Assert.AreEqual("Hello John", SentMessage().text);
            Assert.AreEqual(344365009, SentMessage().chat_id);
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: wawah/BinanceBot-2
        private static void Main(string[] args)
        {
            decimal fiatValue           = 20000m;
            int     hydraFactorMin      = 10;
            int     hydraFactorMax      = 20;
            decimal priceChangePercMin  = 1;
            decimal priceChangePercMax  = 4;
            decimal priceChangePercIncr = 1;

            // BotOptimiser 20000 10 20 1.0 4.0
            if (args.Length == 6)
            {
                decimal.TryParse(args[0], out fiatValue);
                int.TryParse(args[1], out hydraFactorMin);
                int.TryParse(args[2], out hydraFactorMax);
                decimal.TryParse(args[3], out priceChangePercMin);
                decimal.TryParse(args[4], out priceChangePercMax);
                decimal.TryParse(args[5], out priceChangePercIncr);
            }

            for (int hydraFactor = hydraFactorMin; hydraFactor <= hydraFactorMax; hydraFactor++)
            {
                for (decimal priceChangePercDown = priceChangePercMin; priceChangePercDown <= priceChangePercMax; priceChangePercDown += priceChangePercIncr)
                {
                    for (decimal priceChangePercUp = priceChangePercMin; priceChangePercUp <= priceChangePercMax; priceChangePercUp += priceChangePercIncr)
                    {
                        Settings settings = new Settings()
                        {
                            CoinPair    = new CoinPair("BTC", "USDT", 6),
                            HydraFactor = hydraFactor,
                            PriceChangePercentageDown = priceChangePercDown,
                            PriceChangePercentageUp   = priceChangePercUp,
                            BotMode       = BotMode.FixedPriceChange,
                            InvestmentMax = 0
                        };

                        Bot myBot = new Bot(settings);
                        myBot.Start();
                    }
                }
            }

            Console.ReadLine();
        }
コード例 #26
0
        static void Main(string[] args)
        {
            var strategy = GetStrategyParam(args);

            var answers = ReadFile(args);
            var bot     = new Bot(answers, strategy);

            bot.Start();

            string message = "";

            do
            {
                Console.Write("[Я] ");
                message = Console.ReadLine();

                bot.ProcessComand(message);
            } while (message != "exit");
        }
コード例 #27
0
 private void tClock_Elapsed(object sender, ElapsedEventArgs e)
 {
     //tClock.Stop();
     try
     {
         TimeSpan ts = (DateTime.Now - lstUpdate);
         if (ts.TotalMinutes > 60)
         {
             lstUpdate = DateTime.Now;
             b         = new Bot();
             b.Start(user, pwd);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     //tClock.Start();
 }
コード例 #28
0
        static void Main(string[] args)
        {
            Console.CancelKeyPress += ProcessExit;

            try
            {
                _app = Application.GetInstance();
                _db  = _app.DbContext;

                _app.Log("Launching JMS");

                _bots = new List <Bot>();
                var servers = _db.Servers.GetAll();

                foreach (var server in servers)
                {
                    server.Chans = _db.Chans.GetListFromServerId(server.Id);
                    var bot = new Bot(server);

                    _bots.Add(bot);

                    _app.Log("Starting bot on {0} server...", server.Name);

                    bot.Start();
                }

                _app.Print("Running...");

                while (IsBotsRunning)
                {
                    Thread.Sleep(2000);
                }
            }
            catch (Exception ex)
            {
                _app.Log(ex.Message);
            }
            finally
            {
                Exit();
            }
        }
コード例 #29
0
ファイル: Program.cs プロジェクト: Fooxboy/CCDPlanetHelperBot
        static void Main(string[] args)
        {
            Console.WriteLine("Запуск бота...");

            var botSettings = new BotSettings();

            botSettings.GroupId   = 202349916;
            botSettings.Messenger = MessengerPlatform.Vkontakte;
            botSettings.VKToken   = "e7980081cccad8d0df1ce342355da76e6e0d8de37509d76fb08ff1f065823dc19e5f4ed7f4578314cc772";

            var command = new Commands.UnknownCommand();

            var bot = new Bot(botSettings, command);

            bot.SetCommands(new StartCommand(), new ReminderCommand(), new CalcCommand(),
                            new CourseCommand(), new CourceSetCommand(), new AddAdminCommand(),
                            new RemoveAdminCommand(), new ListAdminsCommand(), new AdvertisementCommand(),
                            new ExcecuteCommand(), new AdvertisementAddCommand(), new RemoveAdsCommand(),
                            new MailingCommand(), new UnsubscribeCommand(), new SubscribeCommand(),
                            new ReportCommand(), new ReportReply(), new ReportListCommand(),
                            new AddCarCommand(), new CarListCommand(), new RemoveCarCommand(),
                            new HelpCommand(), new ChangelogCommand(), new ChangelogEditCommand(),
                            new BindsCommand(), new BindsSetCommand(), new MenuCommand(),
                            new SettingsCommand(), new AdvertisementMenu(), new AdminMenuCommand(),
                            new SearchMenuCommand(), new CatalogCommand(), new AdsFilterCommand(),
                            new ShowRoomCommand(), new TestPhoto(), new CarInfoCommand(),
                            new AddTuningCommand(), new TuningSetCommand(), new AddTargetCommand(),
                            new TargetCommand(), new TargetEditCommand(), new SearchCommand(),
                            new ShowAdCommand(), new AddTagCommand(), new RemoveTagCommand(),
                            new RemoveTuningCommand(), new RemindersCommand(), new RemoveReminderCommand());


            var logger = bot.GetLogger();

            logger.Trace("Инициализация статик контента...");
            StaticContent.UsersCommand     = new Dictionary <long, string>();
            StaticContent.SelectUserServer = new Dictionary <long, int>();
            StaticContent.AddCarInfo       = new Dictionary <long, long>();
            bot.Start();
            Console.ReadLine();
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: Olfi01/WhoAmIBotReloaded
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                var waitHandle      = args[0];
                var eventWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset, waitHandle);
                eventWaitHandle.Set();
                // give old program time to shut down
                Thread.Sleep(1000);
            }

            DB = new WhoAmIDBContainer(Settings.DbConnectionString);

            Redis = new RedisClient(Settings.RedisHost, Settings.RedisPort, db: Settings.RedisDb);

            Bot = new Bot(Settings.BotToken, args.Length < 1);
            Bot.Api.OnUpdate += UpdateHandler.OnUpdate;
            Bot.Start();
            Console.Title = $"WhoAmIBotReloaded - {Bot.Username} ({Bot.Id}) - Version {Assembly.GetExecutingAssembly().GetName().Version}";

            //UpdateListenerThread = new Thread(ListenForUpdates);
            //UpdateListenerThread.Start();
            ListenForUpdates();

            ShutdownHandle.WaitOne();

            // send the cleaner to clean up the execution directory
            ProcessStartInfo psi = new ProcessStartInfo
            {
                FileName         = Settings.CleanerPath,
                WorkingDirectory = Path.Combine(Environment.CurrentDirectory, ".."),
                Arguments        = Environment.CurrentDirectory
            };
            Process cleaner = new Process {
                StartInfo = psi
            };

            cleaner.Start();
            Environment.Exit(0);
        }
コード例 #31
0
        public ActionResult OnGet()
        {
            TwitchBotConfiguration botConfiguration = new TwitchBotConfiguration()
            {
                Channel    = _appConfiguration["TwitchConfiguration:ChannelName"],
                UserName   = _appConfiguration["TwitchConfiguration:BotUserName"],
                OAuthToken = _appConfiguration["TwitchConfiguration:OAuthToken"]
            };

            try
            {
                if (_bot.isConnected == false)
                {
                    _bot.Start(botConfiguration).GetAwaiter().GetResult();
                    _bot.isConnected = true;
                }
            }
            catch
            {
                Console.WriteLine("Could not start bot, check your credentials!");
                return(RedirectToPage("Index", new { error = "Could not start bot, check your credentials!" }));
            }
            return(Page());
        }
コード例 #32
0
        public override void Init()
        {
            base.Init();

            if (CommandRegex == null)
            {
                CommandRegex = @"^!(.+)$";
            }

            if (CommandTimeoutMilliseconds == null)
            {
                CommandTimeoutMilliseconds = 60000;
            }

            if (Token == null || Token == "CHANGE_ME")
            {
                Token = "CHANGE_ME";
                Logger.Fatal("Token is not set, bot cannot start. Set the token manually in the database.");
                return;
            }

            Gateway.DetailedLogging = true;

            Bot = new Bot(Token, Intents.All);
            Bot.Start();

            Bot.OnMessage += async(_, message) =>
            {
                if (message.Author != Bot.User)
                {
                    await OnMessage(message);
                }
            };

            Logger.Info($"Started '{Bot.User.Username}#{Bot.User.Discriminator}'.");
        }