A dead simple Go library for sending notifications to various messaging services.

notify logo

GitHub tag (latest SemVer) Go Report Card Codacy Badge Maintainability FOSSA Status go.dev reference

A dead simple Go library for sending notifications to various messaging services.

About

Notify arose from my own need for one of my api server running in production to be able to notify me when, for example, an error occurred. The library is kept as simple as possible to allow a quick integration and easy usage.

Disclaimer

Any misuse of this library is your own liability and responsibility and cannot be attributed to the authors of this library. See license for more.

Spamming through the use of this library may get you permanently banned on most supported platforms.

Install

go get -u github.com/nikoksr/notify

Example usage

// The notifier we're gonna send our messages to
notifier := notify.New()

// Create a telegram service. Ignoring error for demo simplicity
telegramService, _ := telegram.New("your_telegram_api_token")

// Passing a telegram chat id as receiver for our messages.
// Basically where should our message be sent to?
telegramService.AddReceivers("-1234567890")

// Tell our notifier to use the telegram service. You can repeat the above process
// for as many services as you like and just tell the notifier to use them.
// Its kinda like using middlewares for api servers.
notifier.UseService(telegramService)

// Send a test message
_ = notifier.Send(
	"Message Subject/Title",
	"The actual message. Hello, you awesome gophers! :)",
)

Supported services

  • Discord
  • Email
  • Microsoft Teams
  • Slack
  • Telegram
  • Pushbullet

Roadmap

  • Add tests (see #1)
  • Add more notification services

Credits

Author

Niko Köser

Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

License

FOSSA Status

Owner
Niko Köser
software engineer by day, software engineer by night.
Niko Köser
Comments
  • Community question: How to test external services?

    Community question: How to test external services?

    Hi, dear reader,

    notify is currently untested and I'd love to change that but I'll be straight up honest with you, I don't know how you test a library that's so dependent on external services. Like, do you create test/pseudo accounts/bots on all supported platforms and use the real api-tokens while testing? Do you actually make calls to the external services to verify the lib is working or can this be solved by mocking?

    Feedback and PRs would be really appreciated! Hope you enjoy the library and have a nice day! :)

  • Add plaintext toggle

    Add plaintext toggle

    Description

    Adding a toggle, that makes it possible to send E-Mails as unformatted Plain text.

    Motivation and Context

    I want to send E-Mails as unformatted Plain Text. Right now the mail service sends out e-mails as HTML only.

    How Has This Been Tested?

    • Tested locally using implementation.
    • Added some tests to ensure fields are set correctly.

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [x] My code follows the code style of this project.
    • [ ] I have updated the documentation accordingly.
    • [x] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
  • feat: add bark service

    feat: add bark service

    Description

    add Bark service

    Motivation and Context

    add new service

    How Has This Been Tested?

    package main
    
    import (
    	"context"
    
    	"github.com/nikoksr/notify"
    	"github.com/nikoksr/notify/service/bark"
    )
    
    func main() {
    	var device = "your bark key"
    	// Create a bark service. `device key` is generated when you install the application
    	barkService := bark.New(device, bark.DefaultServer)
    
    	// Tell our notifier to use the bark service. You can repeat the above process
    	// for as many services as you like and just tell the notifier to use them.
    	notify.UseServices(barkService)
    
    	// Send a test message.
    	_ = notify.Send(
    		context.Background(),
    		"Subject/Title",
    		"The actual message - Hello, you awesome gophers! :)",
    	)
    }
    
    

    bark-screenshoot

    Screenshots / Output (if appropriate):

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] I have updated the documentation accordingly.
    • [ ] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
  • feat(service): Add Mattermost

    feat(service): Add Mattermost

    Description

    Adds a notifier service for Mattermost

    Motivation and Context

    • Mattermost is an opensource alternative to slack. Mattermost has great community, supports various of tools integration, and also most of the features are FREE!
    • Small teams can get great benefit from this messaging/collaboration service.

    This addresses the issue https://github.com/nikoksr/notify/issues/422

    How Has This Been Tested?

    I tested this in 2 steps:

    • Basic unit tests using mocks.
    • Manual testing has been performed as well.

    NOTE: make fmt introduced small change in mock_matrix_client.go file imports.

    Screenshots / Output (if appropriate):

    image This is output from several runs.

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] I have updated the documentation accordingly.
    • [x] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
  • feat(service): Add matrix service

    feat(service): Add matrix service

    Description

    Adds a notifier service for Matrix

    Motivation and Context

    This addresses #283 partially. I decided to split up the Matrix and Signal PRs as tey are two features in one ticket.

    Matrix is an open standard and communication protocl for real-time communication.

    How Has This Been Tested?

    I tested this in 2 steps:

    • Basic unit tests using mocks
    • Manual testing has been performed as well

    Screenshots / Output (if appropriate):

    image This is output from several runs.

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] I have updated the documentation accordingly.
    • [x] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
  • feat(service): Add Instagram service

    feat(service): Add Instagram service

    Add support for Instagram service.

    I would be happy to add unit tests, but I skimmed through #1 and it seems like the decision on testing is still pending.

  • feat(service): Add Viber

    feat(service): Add Viber

    Description

    Implement Viber service to solve #114

    Motivation and Context

    • This PR is to solve #114

    How Has This Been Tested?

    • Unit Test image

    • End-to-end testing image

    Screenshots / Output (if appropriate):

    • Screenshot End to end testing The script that is used can be seen in the README with some modifications to change dummy values. image

    • Unit Test image

    • All Test Results There is a failure in syslog service but it's not related with this PR, maybe we can solve it in different PR? image

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] I have updated the documentation accordingly.
    • [x] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
  • feat: Add specific recevier support

    feat: Add specific recevier support

    Describe the solution you'd like The ability send message to specific recevier

    telegramService, _ := telegram.New("your_telegram_api_token")
    notify.UseServices(telegramService)
    
    fooReceiver := telegram.Receiver(-1234567890)
    barReceiver := telegram.Receiver(-0987654321)
    
    // Send a message to fooReceiver .
    _ = notify.To(fooReceiver).Send(
    	context.Background(),
    	"Hello",
    	"The message to fooReceiver",
    )
    // Send another message to barReceiver 
    _ = notify.To(fooReceiver).Send(
    	context.Background(),
    	"Hello",
    	"The message to barReceiver",
    )
    
  • feat(service): Add Viber service

    feat(service): Add Viber service

    Is your feature request related to a problem? Please describe.

    Missing support for Viber.

    Describe the solution you'd like

    Implement a notification service and use existing services such as WhatsApp as a guide for implementation. At the time writing this, mileusna/viber seems to be the best client library for our service.

  • refactor: Better error handling in Send function

    refactor: Better error handling in Send function

    Is your feature request related to a problem? Please describe.

    Presently when sending a notification, an error in sending to one receiver will cause stop all further messages. It would be nice if the service first attempted to notify to all other recievers.

    package main
    
    import (
        "github.com/nikoksr/notify"
        "github.com/nikoksr/notify/service/slack"
    )
    
    func main() {
    
        notifier := notify.New()
    
        // Provide your Slack OAuth Access Token
        slackService := slack.New("OAUTH_TOKEN")
    
        slackService.AddReceivers([]string{"INVALID_CHANNEL",  "VALID_CHANNEL"})
    
        notifier.UseService(slackService)
    
        // This will error on the first reciever ("INVALID_CHANNEL")
        // and the "VALID_CHANNEL" will never receive a message
        _ = notifier.Send(
            "Hello :wave:\n",
            "I am a bot written in Go!",
        )
    }
    

    Describe the solution you'd like

    Either collate the errors and return them after all recievers have been attempted (i.e. add the errors to a slice), or find a more elegant way to collate meta-errors.

    Pseudocode:

    func ... Send(subject, message string) error {
    	
         sendErrors := make([]string, 0, 0)
    
         for ... {
          
             if err != nil {
                sendErrors = append(sendErrors, errors.Wrapf(err, ...).Error())
                }
          }
          // This has the advantage of being "nil" in the case of no errors
          // but is perhaps inelegant / overly verbose
          if sendErrors != nil {
    	  return errors.New(strings.Join(sendErrors, "\n"))
          }
          return nil
    }
    

    Describe alternatives you've considered

    If errors are all expected to be of the same type, perhaps better to just collate the channel ids? I believe a similar field exists for all services.

  • fix(deps): update module github.com/sendgrid/sendgrid-go to v3.12.0+incompatible

    fix(deps): update module github.com/sendgrid/sendgrid-go to v3.12.0+incompatible

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/sendgrid/sendgrid-go | require | minor | v3.11.1+incompatible -> v3.12.0+incompatible |


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox. ⚠ Warning: custom changes will be lost.

    This PR has been generated by Mend Renovate. View repository job log here.

  • feat(service): Add Google Chat Service

    feat(service): Add Google Chat Service

    Fixes issue #459

    Description

    Implements Google Chat Service integration.

    Motivation and Context

    This PR solves Issue #459

    How Has This Been Tested?

    Decent unit test coverage

    gocov test | gocov report
    ok      github.com/nikoksr/notify/service/googlechat    0.384s  coverage: 85.2% of statements
    
    github.com/nikoksr/notify/service/googlechat/mock_create_call.go                 newMockCreateCall               100.00% (4/4)
    github.com/nikoksr/notify/service/googlechat/mock_spaces_message_creator.go      newMockSpacesMessageCreator     100.00% (4/4)
    github.com/nikoksr/notify/service/googlechat/mock_create_call.go                 @55:12                          100.00% (1/1)
    github.com/nikoksr/notify/service/googlechat/mock_spaces_message_creator.go      @41:12                          100.00% (1/1)
    github.com/nikoksr/notify/service/googlechat/googlechat.go                       Service.AddReceivers            100.00% (1/1)
    github.com/nikoksr/notify/service/googlechat/googlechat.go                       Service.Send                    88.89% (8/9)
    github.com/nikoksr/notify/service/googlechat/mock_spaces_message_creator.go      mockSpacesMessageCreator.Create 85.71% (6/7)
    github.com/nikoksr/notify/service/googlechat/mock_create_call.go                 mockCreateCall.Do               81.25% (13/16)
    github.com/nikoksr/notify/service/googlechat/googlechat.go                       newMessageCreator               80.00% (4/5)
    github.com/nikoksr/notify/service/googlechat/googlechat.go                       New                             80.00% (4/5)
    github.com/nikoksr/notify/service/googlechat/googlechat.go                       messageCreator.Create           0.00% (0/1)
    github.com/nikoksr/notify/service/googlechat                                     ------------------------------- 85.19% (46/54)
    
    Total Coverage: 85.19% (46/54)
    

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] I have updated the documentation accordingly.
    • [x] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
  • Who uses Notify?

    Who uses Notify?

    Hello fellow Notify users!

    We are the maintainers of the open source project Notify and we would love to know more about our community of users. If you are using Notify in your projects or at work, we would greatly appreciate it if you could share with us a brief description of how you are using it and any feedback you may have. This will help us understand the impact of our project and guide our future development efforts.

    Thank you in advance for your contribution and happy holidays!

  • fix(deps): update module github.com/atc0005/go-teams-notify/v2 to v2.7.0

    fix(deps): update module github.com/atc0005/go-teams-notify/v2 to v2.7.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | github.com/atc0005/go-teams-notify/v2 | require | minor | v2.6.1 -> v2.7.0 |


    Release Notes

    atc0005/go-teams-notify

    v2.7.0

    Compare Source

    Added
    • (GH-134) Allow setting user agent, fallback to project-specific default value
    • (GH-135) Allow overriding default http.Client
    • (GH-157) Add Adaptive Card message format support
    • (GH-169) Added YAML en(de)coding support to MessageCard
    Changed
    • Dependencies
      • github.com/stretchr/testify
        • v1.7.0 to v1.8.1
    • (GH-154) Deprecate API interface, expose underlying "Teams" client
    • (GH-183) Update Makefile and GitHub Actions Workflows
    • (GH-190) Refactor GitHub Actions workflows to import logic
    Fixed
    • (GH-166) Update lintinstall Makefile recipe
    • (GH-184) Apply Go 1.19 specific doc comments linting fixes
    • (GH-176) ./send_test.go:238:8: second argument to errors.As should not be *error
    • (GH-179) Wrong json key name for URL (uses uri instead)

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

  • feat(service): Add Gotify

    feat(service): Add Gotify

    Description

    Adds support for Gotify.

    Motivation and Context

    Closes #455

    How Has This Been Tested?

    Unit tests are included.

    Screenshots / Output (if appropriate):

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] I have updated the documentation accordingly.
    • [x] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
  • feat(service): Add Ntfy

    feat(service): Add Ntfy

    Description

    Motivation and Context

    There was feature request created in issue to add Ntfy service https://github.com/nikoksr/notify/issues/461

    How Has This Been Tested?

    Test program included in readme.md file

    Screenshots / Output (if appropriate):

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] I have updated the documentation accordingly.
    • [ ] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
Simple-messaging - Brokerless messaging. Pub/Sub. Producer/Consumer. Pure Go. No C.

Simple Messaging Simple messaging for pub/sub and producer/consumer. Pure Go! Usage Request-Response Producer: consumerAddr, err := net.ResolveTCPAddr

Jan 20, 2022
Github-notifications - Small script to alert me when I have notifications on Github. I use it in my Polybar conf

Github notification polybar widget This tool is meant to be used with Polybar, in order to let the user know when they have notifications on Github. R

Jan 26, 2022
Sending line notifications using a binary, docker or Drone CI.
Sending line notifications using a binary, docker or Drone CI.

drone-line Sending line notifications using a binary, docker or Drone CI. Register Line BOT API Trial Please refer to LINE Business Center. Feature Se

Sep 27, 2022
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps.
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps.

Beaver A Real Time Messaging Server. Beaver is a real-time messaging server. With beaver you can easily build scalable in-app notifications, realtime

Jan 1, 2023
ntfy is a super simple pub-sub notification service. It allows you to send desktop notifications via scripts.

ntfy ntfy (pronounce: notify) is a super simple pub-sub notification service. It allows you to send desktop and (soon) phone notifications via scripts

Jan 9, 2023
A simple microservice which accepts incoming notifications
A simple microservice which accepts incoming notifications

Notifier A simple microservice which accepts incoming notifications, and questions and redirects them to notification sinks such as Telegram, Email et

May 21, 2022
Go client library SDK for Ably realtime messaging service

Ably Go A Go client library for www.ably.io, the realtime messaging service. Installation ~ $ go get -u github.com/ably/ably-go/ably Feature support T

Dec 2, 2022
Abstraction layer for simple rabbitMQ connection, messaging and administration
Abstraction layer for simple rabbitMQ connection, messaging and administration

Jazz Abstraction layer for quick and simple rabbitMQ connection, messaging and administration. Inspired by Jazz Jackrabbit and his eternal hatred towa

Dec 12, 2022
⚡ HTTP/2 Apple Push Notification Service (APNs) push provider for Go — Send push notifications to iOS, tvOS, Safari and OSX apps, using the APNs HTTP/2 protocol.

APNS/2 APNS/2 is a go package designed for simple, flexible and fast Apple Push Notifications on iOS, OSX and Safari using the new HTTP/2 Push provide

Jan 1, 2023
Package notify provides an implementation of the Gnome DBus Notifications Specification.

go-notify Package notify provides an implementation of the Gnome DBus Notifications Specification. Examples Display a simple notification. ntf := noti

Dec 27, 2022
Send slack notifications using Github action

Slack notification This is a simple Slack notification action which runs using a Bot token. Example Action A simple example on how to use this action:

Aug 9, 2021
Golang tool to send notifications to LINE app
Golang tool to send notifications to LINE app

Golang tool to send notifications to LINE app

Nov 9, 2022
Bark is an iOS App which allows you to push customed notifications to your iPhone.
Bark is an iOS App which allows you to push customed notifications to your iPhone.

Bark is an iOS App which allows you to push customed notifications to your iPhone.

Jan 3, 2023
graylog-golang is a full implementation for sending messages in GELF (Graylog Extended Log Format) from Go (Golang) to Graylog

graylog-golang is a full implementation for sending messages in GELF (Graylog Extended Log Format) from Go (Golang) to Graylog

Dec 5, 2022
API for sending sms through the connected modem using golang

SMS sender API API for making SMS sending from modem, by sending post request to route Request for Send SMS url method 127.0.0.1:8000/api/v1/send-mode

Nov 5, 2021
Scalable real-time messaging server in language-agnostic way
Scalable real-time messaging server in language-agnostic way

Centrifugo is a scalable real-time messaging server in language-agnostic way. Centrifugo works in conjunction with application backend written in any

Jan 2, 2023
websocket based messaging server written in golang

Guble Messaging Server Guble is a simple user-facing messaging and data replication server written in Go. Overview Guble is in an early state (release

Oct 19, 2022
Golang client for NATS, the cloud native messaging system.

NATS - Go Client A Go client for the NATS messaging system. Installation # Go client go get github.com/nats-io/nats.go/ # Server go get github.com/na

Jan 5, 2023
A realtime distributed messaging platform
A realtime distributed messaging platform

Source: https://github.com/nsqio/nsq Issues: https://github.com/nsqio/nsq/issues Mailing List: [email protected] IRC: #nsq on freenode Docs:

Dec 29, 2022