Ejemplo n.º 1
0
        public static Slack.Message CreateSlackMessage(string header, IList <AttachmentField> fields, BotElement bot, string channel, string color)
        {
            if (header == null)
            {
                return(null);
            }

            var message = new Slack.Message()
            {
                Channel     = channel,
                Username    = bot.GetSetting("username"),
                Attachments = new[] {
                    new Attachment()
                    {
                        Fallback = header,
                        Pretext  = header,
                        Color    = color,
                        Fields   = fields
                    }
                }
            };

            if (!String.IsNullOrEmpty(bot.GetSetting("iconUrl")))
            {
                message.IconUrl = bot.GetSetting("iconUrl");
            }
            else if (!String.IsNullOrEmpty(bot.GetSetting("iconEmoji")))
            {
                message.IconEmoji = bot.GetSetting("iconEmoji");
            }

            return(message);
        }
Ejemplo n.º 2
0
        public static Slack.Message CreateSlackMessage(string header, IEnumerable<AttachmentField> fields, BotElement bot, string channel, string color)
        {
            if (header == null) return null;

            var message = new Slack.Message()
            {
                Channel = channel,
                Username = bot.GetSetting("username"),
                Attachments = new[] {
                    new Attachment() {
                        Fallback = header,
                        Pretext = header,
                        Color = color,
                        Fields = fields
                    }
                }
            };
            if (!String.IsNullOrEmpty(bot.GetSetting("iconUrl")))
                message.IconUrl = bot.GetSetting("iconUrl");
            else if (!String.IsNullOrEmpty(bot.GetSetting("iconEmoji")))
                message.IconEmoji = bot.GetSetting("iconEmoji");

            return message;
        }