示例#1
0
        public async Task Say(BotMessage message)
        {
            if (string.IsNullOrEmpty(message.ChatHub?.Id))
            {
                throw new MissingChannelException("When calling the Say() method, the message parameter must have its ChatHub property set.");
            }

            var client = _connectionFactory.CreateChatClient();

            //This uses manual fillout. Lets simplify things shall we?
            //await client.PostMessage(SlackKey, message.ChatHub.Id, message.Text, message.Attachments);

            //By passing the message directly we can more easily control fields.
            await client.PostMessage(SlackKey, message);
        }
        public async Task Say(BotMessage message)
        {
            if (string.IsNullOrEmpty(message.ChatHub?.Id))
            {
                throw new MissingChannelException("When calling the Say() method, the message parameter must have its ChatHub property set.");
            }

            var client = _connectionFactory.CreateChatClient();
            await client.PostMessage(SlackKey, message.ChatHub.Id, message.Text, message.Attachments);
        }
示例#3
0
        public async Task <SlackMessagePosted> Say(BotMessage message)
        {
            if (string.IsNullOrEmpty(message.ChatHub?.Id))
            {
                throw new MissingChannelException("When calling the Say() method, the message parameter must have its ChatHub property set.");
            }

            var client   = _connectionFactory.CreateChatClient();
            var response = await client.PostMessage(SlackKey, message.ChatHub.Id, message.Text, message.Attachments);

            if (response == null)
            {
                return(null);
            }
            return(new SlackMessagePosted()
            {
                TimeStamp = response.TimeStamp, Channel = response.Channel, Message = response.Message
            });
        }