コード例 #1
0
        private static ILocalisable <string> GetString(ILocalisable <EmbedBuilder> embed)
        {
            return(new DynamicString(tr =>
            {
                var localised = embed.Localise(tr);
                var blocks = new List <string>();
                if (localised.Author != null)
                {
                    blocks.Add($"{localised.Author?.Name}\n{localised.Author?.Url}".Trim());
                }
                if (localised.Title != null)
                {
                    blocks.Add($"**{localised.Title}**".Trim());
                }
                if (localised.Description != null)
                {
                    blocks.Add(localised.Description.Trim());
                }
                if (localised.ThumbnailUrl != null)
                {
                    blocks.Add($"Thumbnail: {localised.ThumbnailUrl}".Trim());
                }
                foreach (var field in localised.Fields)
                {
                    blocks.Add($"**{field.Name.Trim()}**\n{field.Value.ToString().Trim()}");
                }
                if (localised.ImageUrl != null)
                {
                    blocks.Add(localised.ImageUrl.Trim());
                }
                blocks.Add(string.Join(" | ", new object[] { localised.Footer?.Text, localised.Timestamp }.Where(v => !string.IsNullOrWhiteSpace(v?.ToString()))).Trim());

                return string.Join("\n---------\n", blocks.Where(b => !string.IsNullOrWhiteSpace(b)).ToArray());
            }));
        }
コード例 #2
0
        /// <summary>
        /// Localise the control
        /// </summary>
        public void Localise()
        {
            ILocalisable localisable = _visualisation as ILocalisable;

            if (localisable != null)
            {
                localisable.Localise();
            }
        }
コード例 #3
0
 private ILocalisable <string> ValueViewer(ILocalisable <string> baseValue)
 => new DynamicString(tr =>
 {
     var x = baseValue?.Localise(tr);
     if (string.IsNullOrWhiteSpace(x))
     {
         return(((LocalisedString)SettingText.NOTSET).Localise(tr));
     }
     return(x);
 });
コード例 #4
0
 public LocalisedAuthorBuilder WithUrl(ILocalisable <string> url)
 {
     Url = url;
     return(this);
 }
コード例 #5
0
ファイル: Command.cs プロジェクト: MildanWorld/Titanbot
 protected ValueTask <IUserMessage> ReplyAsync(string key, ReplyType replyType, ILocalisable <EmbedBuilder> embedable, params object[] values)
 => ReplyAsync(key, replyType, Embedable.FromEmbed(embedable), values);
コード例 #6
0
        private bool TrySet(ICommandContext context, IEntity <ulong> entity, TAccept value, out ILocalisable <string> error)
        {
            error = Validator(context, value);
            if (error != null)
            {
                return(false);
            }

            Editor(entity, s => Setter(s, Converter(context, value)));
            return(true);
        }
コード例 #7
0
 ISettingEditorCollection ISettingEditorCollection.WithDescription(ILocalisable <string> description)
 => WithDescription(description);
コード例 #8
0
 public ISettingEditorCollection <TSetting> WithDescription(ILocalisable <string> description)
 {
     Description = description;
     return(this);
 }
コード例 #9
0
 public LocalisedFieldBuilder WithName(ILocalisable <string> name)
 {
     Name = name;
     return(this);
 }
コード例 #10
0
 public static Embedable FromEmbed(ILocalisable <EmbedBuilder> embed, Func <ILocalisable <EmbedBuilder>, ILocalisable <string> > stringFormat)
 => embed == null ? null : new Embedable(embed, stringFormat);
コード例 #11
0
 public static Embedable FromEmbed(ILocalisable <EmbedBuilder> embed)
 => FromEmbed(embed, GetString);
コード例 #12
0
 private Embedable(ILocalisable <EmbedBuilder> value, Func <ILocalisable <EmbedBuilder>, ILocalisable <string> > stringFormat)
 {
     Builder         = value;
     StringFormatter = stringFormat;
 }
コード例 #13
0
 private async void ReplyAsync(ICommandContext context, ILocalisable <string> message)
 => await context.Replier.Reply(context.Channel, context.Author).WithMessage(message).SendAsync();
コード例 #14
0
ファイル: ReplyContext.cs プロジェクト: MildanWorld/Titanbot
 public IReplyContext WithMessage(ILocalisable <string> message)
 {
     Message = message;
     return(this);
 }
コード例 #15
0
 public LocalisedFooterBuilder WithText(ILocalisable <string> text)
 {
     Text = text;
     return(this);
 }
コード例 #16
0
ファイル: ModifyContext.cs プロジェクト: MildanWorld/Titanbot
 public IModifyContext ChangeEmbedable(ILocalisable <EmbedBuilder> embedable)
 => ChangeEmbedable(Commands.Embedable.FromEmbed(embedable));
コード例 #17
0
 public LocalisedFooterBuilder WithIconUrl(ILocalisable <string> iconUrl)
 {
     IconUrl = iconUrl;
     return(this);
 }
コード例 #18
0
ファイル: ModifyContext.cs プロジェクト: MildanWorld/Titanbot
 public IModifyContext ChangeMessage(ILocalisable <string> message)
 {
     Text = message;
     return(this);
 }
コード例 #19
0
 public LocalisedFieldBuilder WithValue(ILocalisable <string> value)
 {
     Value = value;
     return(this);
 }
コード例 #20
0
ファイル: Command.cs プロジェクト: MildanWorld/Titanbot
 protected ValueTask <IUserMessage> ReplyAsync(ILocalisable <string> message, IEmbedable embedable)
 => Reply().WithMessage(message).WithEmbedable(embedable).SendAsync();
コード例 #21
0
 public ISettingEditorCollection <TSetting> WithNotes(ILocalisable <string> notes)
 {
     Notes = notes;
     return(this);
 }
コード例 #22
0
ファイル: Command.cs プロジェクト: MildanWorld/Titanbot
 protected ValueTask <IUserMessage> ReplyAsync(string key, ILocalisable <EmbedBuilder> embedable)
 => ReplyAsync(key, Embedable.FromEmbed(embedable));
コード例 #23
0
 ISettingEditorCollection ISettingEditorCollection.WithNotes(ILocalisable <string> notes)
 => WithNotes(notes);
コード例 #24
0
 public bool TrySet(ICommandContext context, IEntity <ulong> entity, object value, out ILocalisable <string> error)
 => TrySet(context, entity, (TAccept)value, out error);