Exemplo n.º 1
0
        public RainService(ILoggerFactory loggerFactory, DiscordSocketClient discord, WalletService walletService, IConfiguration config)
        {
            _logger        = loggerFactory.CreateLogger("rain");
            _discord       = discord;
            _walletService = walletService;
            _config        = config;

            _random        = new Random();
            _checkInterval = new TimeSpan(0, 0, Convert.ToInt32(config["rainCheckIntervalS"]));
            _announceDelay = new TimeSpan(0, 0, Convert.ToInt32(config["rainAnnounceDelayS"]));
            _registerDelay = new TimeSpan(0, 0, Convert.ToInt32(config["rainRegisterDelayS"]));
            _checkCanellationTokenSource = new CancellationTokenSource();
            _wallets           = new ConcurrentDictionary <SocketUser, TurtleWallet>();
            _requiredReactions = new ConcurrentDictionary <ulong, Emote>();

            _guildId   = 388915017187328002;
            _channelId = Convert.ToUInt64(config["rainChannelId"]);

            // The rain service has to be started explicitly (with ``!rain start``)
            State            = RainServiceState.Stopped;
            BalanceThreshold = Convert.ToInt64(config["rainBalanceThreshold"]);
            ReactionEmotes   = new List <Emote>();

            _discord.MessageReceived += MessageReceived;
        }
Exemplo n.º 2
0
        public RainService(ILoggerFactory loggerFactory, DiscordSocketClient discord, WalletService walletService, ConfigModule config)
        {
            _logger        = loggerFactory.CreateLogger("rain");
            _discord       = discord;
            _walletService = walletService;
            _config        = config;

            _random = new Random();

            TimeSpan TimspanConverter(object value) => TimeSpan.FromSeconds(Convert.ToDouble(value));

            _checkInterval.Converter = TimspanConverter;
            _announceDelay.Converter = TimspanConverter;
            _registerDelay.Converter = TimspanConverter;

            _checkCanellationTokenSource = new CancellationTokenSource();
            _wallets           = new ConcurrentDictionary <SocketUser, TurtleWallet>();
            _requiredReactions = new ConcurrentDictionary <ulong, Emote>();

            _guildId   = 388915017187328002;
            _channelId = Convert.ToUInt64(config["rainChannelId"]);

            // The rain service has to be started explicitly (with ``!rain start``)
            State = RainServiceState.Stopped;

            config.AddBinding(_balanceThreshold, "threshold");
            config.AddBinding(_checkInterval, "check");
            config.AddBinding(_announceDelay, "announce");
            config.AddBinding(_registerDelay, "register");

            _discord.MessageReceived += MessageReceived;
        }
Exemplo n.º 3
0
        public static async Task <TurtleWallet> FromString(WalletService walletService, string address)
        {
            if (!address.StartsWith("TRTL"))
            {
                return(null);
            }
            if (address.Length != 99)
            {
                return(null);
            }
            if (!await walletService.CheckAddress(address))
            {
                return(null);
            }

            return(new TurtleWallet(address));
        }