A Go client for Mattermost's webhooks API.
Branch: master
Clone or download
Latest commit af136e3 Jan 10, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example Update main.go Dec 22, 2018
.gitignore add gitignore Aug 9, 2018
LICENSE Initial commit Jul 12, 2018
README.md add go report card Jan 10, 2019
matterhook.go Update matterhook.go Aug 9, 2018
matterhook_test.go add test for send method and refactoring code Dec 22, 2018
message.go add test for send method and refactoring code Dec 22, 2018

README.md

Matterhook

Go Report Card

Simple Go client for Mattermost's WebHooks API.

Installation

$ go get -u https://github.com/nafisfaysal/matterhook

Usage

Basic text message

   webhookURL := "https://docs.mattermost.com/developer/webhooks-incoming.html"
   message := matterhook.Message{
      Text: "Hello MatterHook",
   }
   err := matterhook.Send(weebhokURL, message)
   if err != nil {
      fmt.Println(err)
   }

Send message with attachments

    webhookURL := "https://matterhook.com/3423knkldv323"
  
    var msg matterhook.Message
    
    attachment := matterhook.Attachment{
        Text:  "Attact Text",
        Title: "Attact Title",
        Fields: []matterhook.Field{
            {
                Title: "Attach field Title",
            },
        },
    }
    
    anotherAttachment := matterhook.Attachment{
        Text:       "Hello",
        Title:      "No title",
        AuthorName: "nafis",
        AuthorIcon: "give author icon",
        Fields: []matterhook.Field{
            {
                Title: "Filed Title",
                Value: "Some value",
                Short: true,
            },
        },
    }
    
    msg.AddAttachments([]matterhook.Attachment{attachment, anotherAttachment})
    
    err := matterhook.Send(webhookURL, msg)
    if err != nil {
        fmt.Println(err)
    }

Contribution

If you are interested to make the package better please send pull requests or create an issue so that others can fix.

License

The matterhook is an open-source software licensed under the MIT License.