Exemplo n.º 1
0
        private async Task SendMessages(Trade trade, VetMember sender, string message)
        {
            var senderIsOwner = trade.VetMemberId == sender.Id;

            var messageTargets =
                senderIsOwner ? DbContext.TradeMessages.AsQueryable().Where(c => c.TradeId == trade.Id).Select(c => c.VetMember).Distinct().ToArray()
                            : new[] { trade.VetMember };

            var dmMessage = $@"
メッセージ元:{trade.Title}
URL:{StaticSettings.SiteBaseUrl}Trades/Details?id={trade.Id}
差出人:{sender.Name}
{message}";

            Discord.EmbedBuilder builder = new Discord.EmbedBuilder();
            builder.WithTitle(trade.Title)
            .WithAuthor(sender.Name, sender.GetAvaterIconUrl(), sender.GetMemberPageUrl(StaticSettings.SiteBaseUrl))
            .WithUrl($"{StaticSettings.SiteBaseUrl}Trades/Details?id={trade.Id}")
            // .AddField("アクション", "メッセージがあります")
            .AddField("メッセージ内容", message);



            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }
Exemplo n.º 2
0
        private async Task SendMessages(Contract contract, VetMember sender, string message)
        {
            var stakeHolders = await GetStakeHolders(contract.Id);

            var trade = DbContext.Contracts.AsQueryable().Where(c => c.Id == contract.Id).Select(c => c.Trade).First();


            //            var dmMessage = $@"
            //メッセージ元:{trade.Title}
            //URL:https://vetcoin.azurewebsites.net/Trades/Contracts?contractId={contract.Id}
            //差出人:{sender.Name}
            //{message}";
            Discord.EmbedBuilder builder = new Discord.EmbedBuilder();
            builder.WithTitle(trade.Title)
            .WithAuthor(sender.Name, sender.GetAvaterIconUrl(), sender.GetMemberPageUrl(StaticSettings.SiteBaseUrl))
            .WithUrl($"https://vetcoin.azurewebsites.net/Trades/Contracts?contractId={contract.Id}")
            // .AddField("アクション", "メッセージがあります")
            .AddField("メッセージ内容", message);


            var messageTargets = stakeHolders.Where(c => c.Id != sender.Id).ToArray();


//#if DEBUG
//            messageTargets = new[] { sender };
//#endif

            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }
Exemplo n.º 3
0
        private async Task SalesNotification(UserContext userContext, Vender vender, VenderSale venderSale)
        {
            var builder = new Discord.EmbedBuilder();

            builder
            .WithTitle($"{vender.Title} 【購入】")
            .WithUrl($"{StaticSettings.SiteBaseUrl}Venders/Details?id={vender.Id}")
            .WithAuthor(
                userContext.CurrentUser.Name,
                userContext.CurrentUser.GetAvaterIconUrl(),
                userContext.CurrentUser.GetMemberPageUrl(StaticSettings.SiteBaseUrl)
                )
            .AddField("金額", $"{venderSale.Amount}{StaticSettings.CurrenryUnit}", false);

            if (!string.IsNullOrEmpty(venderSale.Message))
            {
                builder
                .AddField("メッセージ", venderSale.Message, false);
            }



            var messageTargets = new[] { vender.VetMember };
            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }
Exemplo n.º 4
0
        private async Task SendConfirmNotificationAsync(ExteralApplication app, VetMember user, ExteralApplicationPayment eap)
        {
            Discord.EmbedBuilder builder = new Discord.EmbedBuilder();

            builder.WithTitle($"{app.Name}:購入確認");
            builder.WithUrl(app.CallbackUrl + $"?id={eap.Id}");
            builder.WithAuthor(app.VetMember.Name, app.VetMember.GetAvaterIconUrl(), app.VetMember.GetMemberPageUrl(StaticSettings.SiteBaseUrl));
            builder.AddField("金額", eap.Amount);
            builder.WithDescription(eap.Description);
            builder.WithFooter("よろしければ、タイトルをクリックして購入処理をつづけてください");

            await CoreService.SendDirectMessage(new[] { user }, string.Empty, builder.Build());
        }
Exemplo n.º 5
0
        private void SendRaport()
        {
            var embed = new Discord.EmbedBuilder();

            embed.WithTitle($"Results of the battle in __**{this.attackedSystem}**__");
            embed.WithColor(new Discord.Color(255, 0, 0));
            embed.WithCurrentTimestamp();
            embed.AddField("Time of battle", $"From: {this.encounterStart.ToString("T")}\nTo: {this.lastNotification.ToString("T")}\nTotal: {this.GetEncounterTime().ToString(@"hh\:mm\:ss")}", false);
            embed.AddField("Statistics", $"Total number of characters attacking: {this.attackingPlayers.Count}\nTotal number of teams attacking: {this.attackingTeams.Count}\nNumber of messages: {this.totalMessageAmount}", false);
            embed.AddField("Players attacking", string.Join("\n", this.attackingPlayers.ToArray()), false);
            embed.AddField("Teams attacking", string.Join("\n", this.attackingTeams.ToArray()), false);
            _ = this.discordApi.EmbedObjectAsync(this.channelID, embed.Build(), true);
        }
Exemplo n.º 6
0
        private async Task DeliveryMessage(UserContext userContext, Vender vender, VenderSale venderSale)
        {
            var builder = new Discord.EmbedBuilder();

            builder
            .WithTitle($"{vender.Title} 【購入】")
            .WithUrl($"{StaticSettings.SiteBaseUrl}Venders/Details?id={vender.Id}")
            .WithAuthor(
                userContext.CurrentUser.Name,
                userContext.CurrentUser.GetAvaterIconUrl(),
                userContext.CurrentUser.GetMemberPageUrl(StaticSettings.SiteBaseUrl)
                )
            .AddField("金額", $"{venderSale.Amount}{StaticSettings.CurrenryUnit}", false);
            //.AddField("メッセージ", venderSale.Message, false);


            if (!string.IsNullOrEmpty(venderSale.Message))
            {
                builder
                .AddField("メッセージ", venderSale.Message, false);
            }

            //if (!string.IsNullOrEmpty(vender.DeliveryMessage))
            //{
            //    builder.WithDescription(vender.DeliveryMessage);
            //}
            //else
            //{
            //    builder.WithDescription("[配信メッセージが未設定です]");
            //}
            string message = null;

            if (!string.IsNullOrEmpty(vender.DeliveryMessage))
            {
                message = $@"販売者からのメッセージです
----------------------------
{vender.DeliveryMessage}";
            }
            else
            {
            }


            var messageTargets = new[] { userContext.CurrentUser };
            await CoreService.SendDirectMessage(messageTargets, message, builder.Build());


            await Task.Yield();
        }
Exemplo n.º 7
0
        private void userinfo(ServerMessage e, string m)
        {
            var user = Funcs.GetUserByMentionOrName(e.Server.Users, m);

            if (user != null)
            {
                var eb = new Discord.EmbedBuilder().WithAuthor("The Overbork", server.DC.CurrentUser.GetAvatarUrl()).WithCurrentTimestamp();
                eb.WithTitle(user.Nickname + "(" + user.Username + ")").WithDescription(user.Mention);
                eb.AddInlineField("Status", user.Status).AddInlineField("Joined", user.JoinedAt).AddInlineField("Hierarchy Position", user.Hierarchy).AddInlineField("Registered", user.CreatedAt);
                var embed = eb.Build();
                server.safeSendEmbed(e.Channel, embed);
            }
            else
            {
                server.safeSendMessage(e.Channel, "Could not find user: " + m);
            }
        }
Exemplo n.º 8
0
        public Discord.Embed getHelpMessageEmbed()
        {
            var eb = new Discord.EmbedBuilder().WithAuthor("The Overbork", server.DC.CurrentUser.GetAvatarUrl()).WithCurrentTimestamp();

            eb.WithTitle(name).WithDescription(helpmessage.getDescription()).AddInlineField("Format", helpmessage.getFormat()).AddInlineField("Permission Required", priv == PrivilegeLevel.Everyone ? "None" : "Bot Admin");
            var args = helpmessage.getArguments().SelectMany(x => x + "\n").ToArray();

            eb.AddField("Arguments", args.Length == 0 ? "None" : new String(args));

            /*            const int maxFieldSize = 1024;
             *          for (int i = 0; i < ((botInfo.Length + (maxFieldSize - 1)) / maxFieldSize); i++)
             *          {
             *              int remLen = botInfo.Length - i * maxFieldSize;
             *              int len = remLen < maxFieldSize ? remLen : maxFieldSize;
             *              eb = eb.AddField("help" + i, botInfo.Substring(i * maxFieldSize, len));
             *          }
             *          safeSendEmbed(e.Channel, eb.Build());*/
            return(eb.Build());
        }
Exemplo n.º 9
0
        //private async Task<VetMember[]> GetStakeHolders(int id)
        //{
        //    var contractMember = DbContext.Contracts.AsQueryable().Where(c => c.Id == id).Select(c => c.VetMember);
        //    var tradeMember = DbContext.Contracts.AsQueryable().Where(c => c.Id == id).Select(c => c.Trade.VetMember);
        //    var messageMembers = DbContext.TradeMessages.AsQueryable().Where(c => c.TradeId == id).Select(c => c.VetMember);

        //    var stakeHolders = contractMember.Concat(tradeMember).Concat(messageMembers).Distinct();


        //    return await stakeHolders.ToArrayAsync();
        //}

        private async Task SendMessages(Contract contract, VetMember sender, VetMember reciver, VetMember postUser)
        {
            //var stakeHolders = await GetStakeHolders(contract.Id);
            var trade = DbContext.Contracts.AsQueryable().Where(c => c.Id == contract.Id).Select(c => c.Trade).First();

            Discord.EmbedBuilder builder = new Discord.EmbedBuilder();
            builder.WithTitle(trade.Title)
            .WithAuthor(postUser.Name, postUser.GetAvaterIconUrl(), postUser.GetMemberPageUrl(StaticSettings.SiteBaseUrl))
            .WithUrl($"https://vetcoin.azurewebsites.net/Trades/Contracts?contractId={contract.Id}")
            .AddField("アクション", "作業完了通知")
            .AddField("メッセージ内容", @"作業完了したようです。
納品物などを確認して契約完了ボタンをおしてください");



            var messageTargets = new[] { sender };

            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }
Exemplo n.º 10
0
        private async Task SendMessages(Vender vender, VetMember sender, string message)
        {
            var senderIsOwner = vender.VetMemberId == sender.Id;

            var messageTargets =
                senderIsOwner ? DbContext.VenderMessages
                .AsQueryable()
                .Where(c => c.VenderId == vender.Id)
                .Select(c => c.VetMember).Distinct().ToArray()
                            : new[] { vender.VetMember };


            Discord.EmbedBuilder builder = new Discord.EmbedBuilder();
            builder.WithTitle($"{ vender.Title} 【メッセージ】")
            .WithAuthor(sender.Name, sender.GetAvaterIconUrl(), sender.GetMemberPageUrl(StaticSettings.SiteBaseUrl))
            .WithUrl($"{StaticSettings.SiteBaseUrl}Venders/Details?id={vender.Id}")
            .AddField("内容", message);

            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }
Exemplo n.º 11
0
        private async Task Notification(VetMember from, VetMember to, long amount, string message, long totalAmount)
        {
            var builder = new Discord.EmbedBuilder();

            builder
            .WithTitle($"{from.Name} から{amount}{StaticSettings.CurrenryUnit} 送金されました")
            .WithAuthor(
                from.Name,
                from.GetAvaterIconUrl(),
                from.GetMemberPageUrl(StaticSettings.SiteBaseUrl)
                )
            .AddField("金額", $"{amount}{StaticSettings.CurrenryUnit}", false)
            .AddField("残高", $"{totalAmount}{StaticSettings.CurrenryUnit}", false);

            if (!string.IsNullOrEmpty(message))
            {
                builder
                .AddField("メッセージ", message, false);
            }

            var messageTargets = new[] { to };
            await CoreService.SendDirectMessage(messageTargets, string.Empty, builder.Build());
        }