Exemplo n.º 1
0
        public async Task GetHouseAddress(string qr = "")
        {
            if (CanRunTipCommands)
            {
                var houseAddr = QTCommands.GetAccountAddress(Context.Guild.CurrentUser.Id);

                if (qr.ToLower() == "qr")
                {
                    QRCodeGenerator qrgen  = new QRCodeGenerator();
                    QRCodeData      data   = qrgen.CreateQrCode($"{houseAddr}", QRCodeGenerator.ECCLevel.Q);
                    var             qrcode = new Base64QRCode(data);

                    byte[] bytes = Convert.FromBase64String(qrcode.GetGraphic(4, Color.White, Color.FromArgb(54, 57, 62), null));

                    MemoryStream ms = new MemoryStream(bytes);
                    await Context.Channel.SendFileAsync(ms, "qraddr.png", $"`The house deposit address is {houseAddr}`");
                }
                else
                {
                    EmbedBuilder b = new EmbedBuilder();
                    b.WithTitle(Context.Guild.CurrentUser.Username);
                    b.AddField("Address", houseAddr);
                    b.AddField("Developer", "Yokomoko");
                    //b.AddField("Developer Donations", "MVT2AJDK7CYTtWo5fX9u48eQT5ynWPyFFd");
                    b.WithColor(Discord.Color.Blue);
                    b.WithFooter("Payments to these addresses will help fund hosting, and support giveaway events.");
                    await ReplyAsync("", false, b);
                }
            }
            else
            {
                await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel");
            }
        }
Exemplo n.º 2
0
 public async Task DonateAsync(decimal amount, string pot)
 {
     if (QTCommands.CheckBalance(Context.User.Id, amount))
     {
         if (pot.Contains("dev"))
         {
             var resp = QTCommands.Withdraw(Context.User.Id, "FWN1qdiRrymSR6jbpbanLYqZpjkEaZouHN", amount);
             if (string.IsNullOrEmpty(resp.Error))
             {
                 await ReplyAsync($"Donation successful! The {Preferences.BaseCurrency} Team thanks you! Transaction: {Preferences.ExplorerPrefix}{resp.Result}{Preferences.ExplorerSuffix}");
             }
         }
         else if (pot.Contains("market"))
         {
             var resp = QTCommands.Withdraw(Context.User.Id, "FqkPKgvb2jFv6GdVphgyVY2iFPcHHi3dx7", amount);
             if (string.IsNullOrEmpty(resp.Error))
             {
                 await ReplyAsync($"Donation successful! The {Preferences.BaseCurrency} Team thanks you! Transaction: {Preferences.ExplorerPrefix}{resp.Result}{Preferences.ExplorerSuffix}");
             }
         }
         else
         {
             await ReplyAsync($"No Donation Fund found for {pot}! Options: `dev`, `marketing`");
         }
     }
     else
     {
         await ReplyAsync("Not enough balance!");
     }
 }
Exemplo n.º 3
0
        public async Task Tip(string amount, SocketUser user)
        {
            if (CanRunTipCommands)
            {
                if (decimal.TryParse(amount, out var decAmount))
                {
                    if (decAmount < MinimumTipValue)
                    {
                        await ReplyAsync($"Minimum tip amount is {MinimumTipValue}");

                        return;
                    }

                    if (QTCommands.CheckBalance(Context.User.Id, decAmount))
                    {
                        QTCommands.SendTip(Context.User.Id, user.Id, decAmount);
                        await ReplyAsync($"{Context.User.Mention} tipped {user.Username} {amount} {Preferences.BaseCurrency}");
                    }
                    else
                    {
                        await ReplyAsync("You do not have enough balance to tip that much!");
                    }
                }
            }
            else
            {
                await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel");
            }
        }
Exemplo n.º 4
0
 public async Task WithdrawAsync(string address)
 {
     if (CanRunTipCommands)
     {
         if (address.StartsWith("F") || address.StartsWith("3") || address.StartsWith("grs1"))
         {
             var resp = QTCommands.Withdraw(Context.User.Id, address);
             if (string.IsNullOrEmpty(resp.Error))
             {
                 await ReplyAsync($"Withdrawn successfully! Transaction: {Preferences.ExplorerPrefix}{resp.Result}{Preferences.ExplorerSuffix}");
             }
             else
             {
                 await ReplyAsync(resp.Error);
             }
         }
         else
         {
             await ReplyAsync("Invalid Address");
         }
     }
     else
     {
         await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel");
     }
 }
Exemplo n.º 5
0
        public async Task GetAddressAsync(string addr = "")
        {
            if (CanRunTipCommands)
            {
                var result = QTCommands.GetAddress(Context.User.Id);
                if (addr == "qr")
                {
                    QRCodeGenerator qrgen = new QRCodeGenerator();

                    QRCodeData data   = qrgen.CreateQrCode($"{result}", QRCodeGenerator.ECCLevel.Q);
                    var        qrcode = new Base64QRCode(data);

                    byte[]       bytes = Convert.FromBase64String(qrcode.GetGraphic(4, Color.White, Color.FromArgb(54, 57, 62)));
                    MemoryStream ms    = new MemoryStream(bytes);
                    await Context.Channel.SendFileAsync(ms, "qraddr.png", $"`Your deposit address is {result}`");
                }
                else
                {
                    var b = new EmbedBuilder();
                    b.WithDescription($"Your deposit address is: **{result}**");
                    b.WithFooter(Preferences.FooterText);
                    await ReplyAsync("", false, b);
                }
            }
            else
            {
                await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel");
            }
        }
Exemplo n.º 6
0
 public async Task GetBalanceAsync()
 {
     if (CanRunTipCommands)
     {
         var result = QTCommands.GetBalance(Context.User.Id);
         await ReplyAsync($"Your balance is {result.Result} {Preferences.BaseCurrency}");
     }
     else
     {
         await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel");
     }
 }
Exemplo n.º 7
0
        private void FantasyTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            var embed          = FantasyPortfolioModule.GetLeaderboardEmbed();
            var winner         = FantasyPortfolioModule.GetWinner();
            var additionalText = "";

            TimeSpan span = (Round.CurrentRoundEnd - DateTime.Now);

            if (Round.CurrentRoundEnd <= DateTime.Now)
            {
                Console.WriteLine($"Round {Round.CurrentRoundEnd} Finished. Winner: {winner.UserId}");
                using (var context = new FantasyPortfolio_DBEntities()) {
                    if (context.Leaderboards.Any(d => d.RoundId == Round.CurrentRound))
                    {
                        if (FantasyPortfolioModule.PrizePool > 0)
                        {
                            additionalText = $"Congratulations <@{winner.UserId}>! You have won the fantasy portfolio and won {FantasyPortfolioModule.PrizePool} {Preferences.BaseCurrency}";
                            QTCommands.SendTip(_client.CurrentUser.Id, ulong.Parse(winner.UserId), FantasyPortfolioModule.PrizePool);
                        }
                        else
                        {
                            additionalText = $"Congratulations <@{winner.UserId}>! You have won the fantasy portfolio! There was no prize.";
                        }
                    }
                    else
                    {
                        embed.WithDescription("Round has finished! There were no participants in this round, so nobody wins!");
                    }
                    Round round = new Round {
                        RoundEnds = DateTime.Now.AddDays(Round.RoundDurationDays)
                    };
                    context.Rounds.Add(round);
                    context.SaveChanges();
                }
            }
            else if (span.TotalMilliseconds < fantasyTickerTimer.Interval)
            {
                //Set next interval to 5000ms after the round ends
                fantasyTimer.Interval = span.TotalMilliseconds + 5000;
                Console.WriteLine("Next fantasy interval set to 5 seconds");
            }
            else
            {
                // Set the next interval to 2 hours
                fantasyTickerTimer.Interval = 7200000;
                Console.WriteLine("Next fantasy interval set to 2 hours");
            }
            _client.GetGuild(Settings.Default.GuildId).GetTextChannel(Settings.Default.FantasyChannel).SendMessageAsync(additionalText, false, embed);
        }
Exemplo n.º 8
0
 public async Task DonateAsync(decimal amount)
 {
     if (QTCommands.CheckBalance(Context.User.Id, amount))
     {
         var resp = QTCommands.Withdraw(Context.User.Id, "FWN1qdiRrymSR6jbpbanLYqZpjkEaZouHN", amount);
         if (string.IsNullOrEmpty(resp.Error))
         {
             await ReplyAsync($"Donation successful! The {Preferences.BaseCurrency} Team thanks you! Transaction: {Preferences.ExplorerPrefix}{resp.Result}{Preferences.ExplorerSuffix}");
         }
     }
     else
     {
         await ReplyAsync("Not enough balance!");
     }
 }
Exemplo n.º 9
0
 private string SendRain(SocketUser fromUser, List <SocketGuildUser> tipUsers, decimal amount)
 {
     if (QTCommands.CheckBalance(fromUser.Id, amount))
     {
         if (amount / tipUsers.Count < (decimal)0.01)
         {
             return($"Rain amount must be at least 0.01 {Preferences.BaseCurrency} per person");
         }
         foreach (var person in tipUsers)
         {
             QTCommands.SendTip(Context.User.Id, person.Id, Math.Round(amount / tipUsers.Count, 7));
         }
         var mentionList = new List <string>();
         foreach (var users in tipUsers)
         {
             mentionList.Add($"{DiscordClientNew._client.GetUser(users.Id).Mention}");
         }
         return($"{fromUser.Mention} made it rain :cloud_rain:! Congratulations to {(mentionList.Count == 2 ? string.Join(" and ", mentionList) : string.Join(", ", mentionList))} who {(mentionList.Count > 1 ? "have" : "has")} been awarded {Math.Round(amount / mentionList.Count, 7)} {Preferences.BaseCurrency} {(mentionList.Count > 1 ? "each" : "")}");
     }
     return("You do not have enough balance to perform this rain");
 }
Exemplo n.º 10
0
        public async Task GetHouseBalance()
        {
            if (CanRunTipCommands)
            {
                var balanceString = QTCommands.GetBalance(DiscordClientNew._client.CurrentUser.Id).Result;

                if (decimal.TryParse(balanceString, NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint, CultureInfo.CreateSpecificCulture("en-GB"), out var balance))
                {
                    balance = balance - FantasyPortfolioModule.PrizePool;
                    await ReplyAsync($"The house balance is at {balance} {Preferences.BaseCurrency}");
                }
                else
                {
                    await ReplyAsync("Error getting house balance");
                }
            }
            else
            {
                await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel");
            }
        }
Exemplo n.º 11
0
 public async Task Join()
 {
     if (FantasyPortfolioModule.EntryFee == 0 || QTCommands.CheckBalance(Context.User.Id, FantasyPortfolioModule.EntryFee))
     {
         if (FantasyPortfolioModule.EntryFee > 0)
         {
             QTCommands.SendTip(Context.User.Id, DiscordClientNew._client.CurrentUser.Id, FantasyPortfolioModule.EntryFee);
         }
         if (Portfolio.Join(Context.User.Id.ToString()))
         {
             await ReplyAsync($"You have joined round {Round.CurrentRound}. An entry fee of {FantasyPortfolioModule.EntryFee} {Preferences.BaseCurrency} has been taken.");
         }
         else
         {
             await ReplyAsync("You have already joined this round!");
         }
     }
     else
     {
         await ReplyAsync($"You do not have the required entry fee of {FantasyPortfolioModule.EntryFee} {Preferences.BaseCurrency}. Please send some {Preferences.BaseCurrency} to your tipping account and try again.");
     }
 }
Exemplo n.º 12
0
        public async Task WithdrawAsync(string address, decimal amount)
        {
            if (CanRunTipCommands)
            {
                if (address.StartsWith("F") || address.StartsWith("3") || address.StartsWith("grs1"))
                {
                    if (QTCommands.CheckBalance(Context.User.Id, amount))
                    {
                        if (amount <= QTCommands.MinimumWithdraw)
                        {
                            await ReplyAsync($"Minimum Withdrawal: {QTCommands.MinimumWithdraw:N8}");

                            return;
                        }
                        var resp = QTCommands.Withdraw(Context.User.Id, address, amount);
                        if (string.IsNullOrEmpty(resp.Error))
                        {
                            await ReplyAsync($"Withdrawn successfully! Transaction: {Preferences.ExplorerPrefix}{resp.Result}{Preferences.ExplorerSuffix}");
                        }
                        else
                        {
                            await ReplyAsync(resp.Error);
                        }
                    }
                    else
                    {
                        await ReplyAsync("Not enough balance!");
                    }
                }
                else
                {
                    await ReplyAsync("Invalid Address");
                }
            }
            else
            {
                await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel");
            }
        }
Exemplo n.º 13
0
        public async Task ListInactive()
        {
            if (Context.User.Id == 354270799684829185)
            {
                var accounts = QTCommands.ListAccounts();

                var sb = new StringBuilder();
                sb.Append("");
                foreach (var r in accounts)
                {
                    if (!string.IsNullOrEmpty(r.Key))
                    {
                        if (ulong.TryParse(r.Key, out ulong userId))
                        {
                            if (Context.Guild.Users.All(d => d.Id != userId) && r.Value > 0)
                            {
                                sb.AppendLine($"{r.Key} - {r.Value}");
                            }
                        }
                    }
                }
                await ReplyAsync(sb.ToString());
            }
        }
Exemplo n.º 14
0
        public async Task ShowInactiveFunds()
        {
            if (Context.User.Id == 354270799684829185)
            {
                var accounts = QTCommands.ListAccounts();

                decimal inactiveTotal = 0;

                foreach (var r in accounts)
                {
                    if (!string.IsNullOrEmpty(r.Key))
                    {
                        if (ulong.TryParse(r.Key, out ulong userId))
                        {
                            if (Context.Guild.Users.All(d => d.Id != userId))
                            {
                                inactiveTotal += r.Value;
                            }
                        }
                    }
                }
                await ReplyAsync($"Total held by left members: {inactiveTotal:N8} {Preferences.BaseCurrency}");
            }
        }
Exemplo n.º 15
0
        public async Task RockPaperScissorsGame(string rps, string amount)
        {
            if (CanRunTipCommands)
            {
                if (Enum.TryParse(rps.ToLower(), out RockPaperScissors userDecision))
                {
                    if (decimal.TryParse(amount, out var betAmount))
                    {
                        if (QTCommands.CheckBalance(Context.User.Id, betAmount))
                        {
                            if (betAmount < MinBetAmount)
                            {
                                await ReplyAsync($"Minimum bet {MinBetAmount} {Preferences.BaseCurrency}");

                                return;
                            }

                            decimal balance          = 0;
                            var     houseBalanceCall = QTCommands.GetBalance(Context.Client.CurrentUser.Id).Result;
                            decimal.TryParse(houseBalanceCall, out balance);

                            decimal maxBet = balance / 10;

                            if (betAmount > maxBet)
                            {
                                await ReplyAsync($"Maximum bet exceeded. Max: {maxBet} {Preferences.BaseCurrency}");

                                return;
                            }

                            var rewardValue = betAmount * (decimal)BetWin;
                            if (QTCommands.CheckBalance(DiscordClientNew._client.CurrentUser.Id, rewardValue + FantasyPortfolioModule.PrizePool))
                            {
                                QTCommands.SendTip(Context.User.Id, DiscordClientNew._client.CurrentUser.Id, betAmount);
                                try {
                                    var botDecision = (RockPaperScissors)RandomInteger(0, 3);

                                    var embed = new EmbedBuilder();

                                    string message = "";

                                    var userOutcome = new Outcome();

                                    switch (botDecision)
                                    {
                                    case RockPaperScissors.rock: {
                                        switch (userDecision)
                                        {
                                        case RockPaperScissors.rock:
                                            userOutcome = Outcome.draw;
                                            break;

                                        case RockPaperScissors.paper:
                                            userOutcome = Outcome.win;
                                            break;

                                        case RockPaperScissors.scissors:
                                            userOutcome = Outcome.lose;
                                            break;
                                        }
                                        break;
                                    }

                                    case RockPaperScissors.paper: {
                                        switch (userDecision)
                                        {
                                        case RockPaperScissors.rock:
                                            userOutcome = Outcome.lose;
                                            break;

                                        case RockPaperScissors.paper:
                                            userOutcome = Outcome.draw;
                                            break;

                                        case RockPaperScissors.scissors:
                                            userOutcome = Outcome.win;
                                            break;
                                        }
                                        break;
                                    }

                                    case RockPaperScissors.scissors: {
                                        switch (userDecision)
                                        {
                                        case RockPaperScissors.rock:
                                            userOutcome = Outcome.win;
                                            break;

                                        case RockPaperScissors.paper:
                                            userOutcome = Outcome.lose;
                                            break;

                                        case RockPaperScissors.scissors:
                                            userOutcome = Outcome.draw;
                                            break;
                                        }
                                        break;
                                    }
                                    }

                                    switch (userOutcome)
                                    {
                                    case Outcome.win:
                                        QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, rewardValue);
                                        embed.AddInlineField("Outcome", $"Bot opted for {botDecision.ToString()} whereas you opted for {userDecision.ToString()}");
                                        embed.AddInlineField("Prize", $"{rewardValue} {Preferences.BaseCurrency}");
                                        embed.AddInlineField("Profit", $"{(rewardValue - betAmount)} {Preferences.BaseCurrency}");
                                        embed.WithColor(Discord.Color.Green);
                                        message = $"You won! Congratulations {Context.User.Mention}!";
                                        break;

                                    case Outcome.draw:
                                        QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, betAmount);
                                        embed.AddInlineField("Outcome", $"Bot opted for {botDecision.ToString()} whereas you opted for {userDecision.ToString()}");
                                        embed.WithColor(Discord.Color.Gold);
                                        message = "It was a draw! Bet refunded";
                                        break;

                                    case Outcome.lose:
                                        QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, betAmount);
                                        embed.AddInlineField("Outcome", $"Bot opted for {botDecision.ToString()} whereas you opted for {userDecision.ToString()}");
                                        embed.AddInlineField("Prize", $"{rewardValue} {Preferences.BaseCurrency}");
                                        embed.AddInlineField("Profit", $"{(rewardValue - betAmount)} {Preferences.BaseCurrency}");
                                        embed.WithColor(Discord.Color.Red);
                                        message = "Unlucky! You lose! Bot won";
                                        break;
                                    }
                                    embed.WithFooter(Preferences.FooterText);
                                    await ReplyAsync(message, false, embed);

                                    Console.WriteLine($"{Context.User.Id} ({Context.User.Username}) opted for {userDecision} and bot opted for {botDecision}");
                                }
                                catch (Exception e) {
                                    Console.WriteLine(e.Message);
                                    QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, betAmount);
                                    await ReplyAsync("Sorry something went wrong. You have been refunded your bet.");
                                }
                            }
                            else
                            {
                                await ReplyAsync("Sorry, the bot is too poor to reward you if you won :(");
                            }
                        }
                        else
                        {
                            await ReplyAsync("You do not have enough balance to perform this action");
                        }
                    }
                }
            }
            else
            {
                await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel");
            }
        }
Exemplo n.º 16
0
        public async Task Flip(string side, string amount)
        {
            if (CanRunTipCommands)
            {
                if (Enum.TryParse(side.ToLower(), out CoinSide coinSide))
                {
                    if (decimal.TryParse(amount, out var betAmount))
                    {
                        if (QTCommands.CheckBalance(Context.User.Id, betAmount))
                        {
                            if (betAmount < MinBetAmount)
                            {
                                await ReplyAsync($"Minimum bet {MinBetAmount} {Preferences.BaseCurrency}");

                                return;
                            }

                            decimal balance          = 0;
                            var     houseBalanceCall = QTCommands.GetBalance(Context.Client.CurrentUser.Id).Result;
                            decimal.TryParse(houseBalanceCall, out balance);

                            decimal maxBet = balance / 10;

                            if (betAmount > maxBet)
                            {
                                await ReplyAsync($"Maximum bet exceeded. Max: {maxBet} {Preferences.BaseCurrency}");

                                return;
                            }

                            var rewardValue = betAmount * (decimal)BetWin;
                            if (QTCommands.CheckBalance(Context.Client.CurrentUser.Id, rewardValue + FantasyPortfolioModule.PrizePool))
                            {
                                QTCommands.SendTip(Context.User.Id, Context.Client.CurrentUser.Id, betAmount);
                                try {
                                    var coin = (CoinSide)RandomInteger(0, 2);
                                    //var coin = (CoinSide)Generator.Next(0, 2);

                                    var embed = new EmbedBuilder();

                                    string message;

                                    if (coin == coinSide)
                                    {
                                        QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, rewardValue);
                                        embed.AddInlineField("Flipped", FirstCharToUpper(coin.ToString()));
                                        embed.AddInlineField("Prize", $"{rewardValue} {Preferences.BaseCurrency}");
                                        embed.AddInlineField("Profit", $"{(rewardValue - betAmount)} {Preferences.BaseCurrency}");
                                        embed.WithColor(Discord.Color.Green);
                                        message = $"You won! Congratulations {Context.User.Mention}!";
                                    }
                                    else
                                    {
                                        embed.AddInlineField("Flipped", FirstCharToUpper(coin.ToString()));
                                        embed.AddInlineField("Lost", $"{betAmount} {Preferences.BaseCurrency}");
                                        embed.WithColor(Discord.Color.Red);
                                        message = $"Unlucky {Context.User.Mention}, you lost :(";
                                    }
                                    embed.WithFooter(Preferences.FooterText);
                                    await ReplyAsync(message, false, embed);

                                    using (var context = new FantasyPortfolio_DBEntities()) {
                                        var result = new FlipResults();
                                        result.DateTime   = DateTime.Now;
                                        result.UserId     = Context.User.Id.ToString();
                                        result.FlipResult = (byte)coin;
                                        result.UserFlip   = (byte)coinSide;
                                        result.FlipValue  = betAmount;
                                        context.FlipResults.Add(result);
                                        context.SaveChanges();
                                    }

                                    Console.WriteLine($"{Context.User.Id} ({Context.User.Username}) bet on {side} and flipped {coin}");
                                }
                                catch (Exception e) {
                                    Console.WriteLine(e.Message);
                                    QTCommands.SendTip(DiscordClientNew._client.CurrentUser.Id, Context.User.Id, betAmount);
                                    await ReplyAsync("Sorry something went wrong. You have been refunded your bet.");
                                }
                            }
                            else
                            {
                                await ReplyAsync("Sorry, the bot is too poor to reward you if you won :(");
                            }
                        }
                        else
                        {
                            await ReplyAsync("You do not have enough balance to perform this action");
                        }
                    }
                }
            }
            else
            {
                await ReplyAsync($"Please use the <#{Preferences.TipBotChannel}> channel");
            }
        }