public static IEnumerable <string> GetAliases(this SlackMessageOptions option) { var memberInfos = option.GetType().GetMember(option.ToString()); var attribute = memberInfos[0].GetCustomAttributes(typeof(AliasAttribute), false); return(((AliasAttribute)attribute.ElementAt(0)).Aliases); }
public virtual T InterpretMessage(SlashCommandPayload payload) { Guard.ThrowIfNull(payload.text); var splitText = SplitTextToParts(payload.text); if (payload.text.StartsWith(option.ToString().ToLower())) { splitText.First().IsUsed = true; } if (IsHelpRequest(splitText.Where(x => !x.IsUsed))) { return(new T { IsHelp = true }); } var message = new T { Date = ExtractDate(splitText), UserId = payload.user_id, UserName = payload.user_name }; ExtractInto(message, splitText); if (splitText.Any(x => !x.IsUsed)) { message.ErrorMessage = $"Not sure how to interpret '{splitText.Where(x => !x.IsUsed).Select(x => x.Text).Join(" ")}'"; } return(message); }