Пример #1
0
        public override void Stop(bool withError = false)
        {
            UserBot.UserBot.DiscordClient.LogoutAsync();
            this.userBot = null;

            base.Stop(withError);
        }
Пример #2
0
        public override bool Start()
        {
            bool OK = base.Start();

            if (!OK)
            {
                return(false);
            }

            string userToken = (string)Config["DiscordUserToken"].Value;

            if (string.IsNullOrEmpty(userToken))
            {
                mainWindow.AddLog(Client.LogType.Error, $"No token for the userbot found!");
                return(false);
            }
            else
            {
                userBot = new UserBot.UserBot(userToken);
            }

            Task.Run(async() => await userBot.Start());

            Task.Run(async() =>
            {
                while (UserBot.UserBot.DiscordClient == null)
                {
                    await Task.Delay(5);
                }

                UserBot.UserBot.DiscordClient.Log += discordClient_Log;

                while (UserBot.UserBot.Commands == null)
                {
                    await Task.Delay(5);
                }

                UserBot.UserBot.Commands.AutoToadParameterCallback += commands_AutoToadParameterCallback;

                mainWindow.AddLog(Client.LogType.Success, $"UserBot started successfully.");
            });

            this.trackRecognition = new TrackRecognition();
            mainWindow.AddLog(Client.LogType.Success, $"Track recognition engine started successfully.");

            this.recognitionEngine = new BinaryRecognition();
            mainWindow.AddLog(Client.LogType.Success, $"Binary recognition engine started successfully.");

            if (Convert.ToUInt64(Config["DefaultChannel"].Value) != 0)
            {
                channelId = Convert.ToUInt64(Config["DefaultChannel"].Value);
            }

            if (!(bool)Config["RequireManualStart"].Value && Convert.ToUInt64(Config["DefaultChannel"].Value) != 0)
            {
                mainWindow.AddLog(Client.LogType.Info, $"AutoToad started automatically.");
                isActivated = true;
            }
            else
            {
                mainWindow.AddLog(Client.LogType.Info, $"Waiting for manual activation of AutoToad.");
            }

            return(true);
        }