Example #1
0
        public async Task <TurtleWallet> GetFirstAddress()
        {
            JObject response = await SendRPCRequest("getAddresses");

            string firstAddress = (string)response["result"]["addresses"][0];

            return(await TurtleWallet.FromString(this, firstAddress));
        }
Example #2
0
        private async Task MessageReceived(SocketMessage rawMessage)
        {
            // Ignore system messages and messages from bots and exiled users
            if (!(rawMessage is SocketUserMessage message))
            {
                return;
            }
            if (message.Source != MessageSource.User)
            {
                return;
            }
            if (!(message.Channel is SocketDMChannel))
            {
                return;
            }
            var guildUser = _guildUsers.FirstOrDefault(u => u.Id == message.Author.Id);

            if (guildUser == null || guildUser.RoleIds.Contains(_exiledRoleId))
            {
                return;
            }

            var address = message.ToString();

            _logger.LogInformation(message.Author.Username + ": " + address);

            if (State != RainServiceState.AcceptingRegistrations)
            {
                if (State == RainServiceState.BalanceExceeded)
                {
                    //await rawMessage.Author.SendMessageAsync("You are too early, little turtle, please wait for the registration!");
                    return;
                }
                //await rawMessage.Author.SendMessageAsync("Huh, it doesn't look like it is raining soon...");
                return;
            }

            if (_wallets.ContainsKey(message.Author))
            {
                //await rawMessage.Author.SendMessageAsync("You are already registered, little turtle.");
                return;
            }

            var wallet = await TurtleWallet.FromString(_walletService, address);

            if (wallet == null)
            {
                //await rawMessage.Author.SendMessageAsync("Your wallet address is malformed, little turtle.");
                return;
            }

            _wallets[message.Author] = wallet;
            _requiredReactions[message.Author.Id] = _reactionEmotes.RandomElement(_random);

            await message.Author.SendMessageAsync($"React to the announcement message with {_requiredReactions[message.Author.Id]} (and **ONLY** with {_requiredReactions[message.Author.Id]}) to catch some shells!");
        }