示例#1
0
文件: BotHost.cs 项目: wildbunny/MT
        private async Task StartBots()
        {
            foreach (var bot in Bots)
            {
                var tryCount = 0;
                while (true)
                {
                    if (tryCount >= 3)
                    {
                        break;
                    }
                    tryCount++;

                    var createUser = false;
                    try
                    {
                        await bot.Initialize(_settings.MTServerAddress, _settings.MTAuthorizationAddress, _settings.ActionScriptInterval, _settings.TransactionFrequencyMin, _settings.TransactionFrequencyMax);

                        break;
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == "Invalid username or password")
                        {
                            createUser = true;
                        }
                    }
                    if (createUser)
                    {
                        LogInfo("StartBots", $"Creating user: {bot.Email}");
                        try
                        {
                            await MtUserHelper.Registration(bot.Email, bot.Password, _settings.MTAuthorizationAddress);

                            LogInfo("StartBots", $"User {bot.Email} created successfully");
                            System.Threading.Thread.Sleep(1000);
                        }
                        catch (Exception ex01)
                        {
                            LogError("MtUserHelper.Registration", ex01);
                            break;
                        }
                    }
                }
            }
        }
示例#2
0
        private static async void RegisterUser()
        {
            Console.Write("Email: ");
            var email = Console.ReadLine();

            try
            {
                await MtUserHelper.EmailVerification(email, _settings.MTAuthorizationAddress);
            }
            catch (Exception ex)
            {
                LogError("MtUserHelper.EmailVerification", ex);
                return;
            }

            Console.Write("Password: ");
            var pass = Console.ReadLine();

            await MtUserHelper.Registration(email, pass, _settings.MTAuthorizationAddress);
        }