GithubHelp home page GithubHelp logo

nikoksr / notify Goto Github PK

View Code? Open in Web Editor NEW
2.7K 20.0 201.0 1.89 MB

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

License: MIT License

Go 99.19% Makefile 0.81%
golang messaging telegram email discord slack microsoft-teams twitter pushbullet sendgrid

notify's Introduction

code related stuff image..

Hey GitHub ๐Ÿ‘‹, I'm Niko

A Gopher who is passionate about all things Cloud.

  • ๐Ÿค Iโ€™m looking for help with Notify

  • ๐Ÿ‘ฏ Iโ€™m looking to collaborate on Proji

  • ๐ŸŒฑ Iโ€™m currently learning to forecast the Cloud's weather.

  • ๐Ÿ“ซ How to reach me [email protected]

  • โค๏ธ Open-Source Software

Connect with me:

nikoksr nikoksr nikoksr

nikoksr

ย nikoksr

ย 

Stay awesome! ๐Ÿ˜Ž

notify's People

Contributors

chanioxaris avatar checkaayush avatar dependabot[bot] avatar doersa avatar gtourkas avatar himsngh avatar immanuelhume avatar janboll avatar joshm91 avatar karitham avatar kaviisuri avatar kha7iq avatar kodiakhq[bot] avatar krishanbhalla avatar mischala avatar moond4rk avatar nikoksr avatar onemedicine avatar panapol-p avatar pkwong4321 avatar prashanthpai avatar qwqcode avatar raphaelabrantes avatar renanbastos93 avatar renovate-bot avatar renovate[bot] avatar sarojwasti avatar shivuslr41 avatar svaloumas avatar yoelsusanto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notify's Issues

feat(service): Add Mattermost service

Describe the missing service. Please provide useful links.

Describe the solution you'd like
Users should be able to send messages/notifications via notify.

Potential libraries to use
official go driver -> https://github.com/mattermost/mattermost-server/blob/master/model/client4.go
reference -> https://github.com/containrrr/shoutrrr/tree/main/pkg/services/mattermost
API docs -> https://api.mattermost.com

[INTERFACES] maybe we can to use interfaces on project

I believe that we can create an interface to subscribe to all services. However, we will guarantee integrity in all methods.
e.g

type IServices interface{
        New() interface{}
        Send(string, string) error
}

type Telegram struct {
        IServices // is obrigatory to create methods New and Send
	client   *tgbotapi.BotAPI
	listener *tgbotapi.BotAPI
	chatIDs  []int64
}

func (t *Telegram) New() *Telegram {
	return &Telegram{}
}

func (t *Telegram) Send(param1, param2 string) error{
	return nill
}

see ya

feat(examples): Give more examples

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

Hi! There is a problem that I don't know how to use it when I ready to use the email service.

Describe the solution you'd like

So we can give the more examples or docs that make more people like me know how to use it. It's very helpful.

feat(service): Add Mailgun service

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

Missing support for the popular email service platform Mailgun.

Describe the solution you'd like

Implement a notification service like already exists for Telegram etc. At the time writing the official Golang SDK mailgun/mailgun-go seems to be our best option for implementing it.

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! :)

[BUG] Whatsapp service not usable anymore

Describe the bug

Regarding the official documentation of the Rhymen/go-whatsapp API

Warning
This package is not being actively maintained currently and will soon be unusuable as WhatsApp updates to multi-device. Please look at tulir/whatsmeow for a Go WhatsApp Web API that is actively maintained and supports WhatsApp multi-device.

And the issues opened on it (Rhymen/go-whatsapp#644 & Rhymen/go-whatsapp#651), it seems that this API is no more usable.

Is there a plan to integrate the one proposed (whatsmeow) into Notify in the future?

[Question]: What is pseudo service?

Sorry guys, but I didn't understand if you really need this file: [service/pseudo/pseudo.go](https://github.com/nikoksr/notify/blob/main/service/pseudo/pseudo.go)

How to use mail service

How to use mail service

Demo

func Service() {
	// Create a telegram service. Ignoring error for demo simplicity.
	mailService := mail.New("[email protected]", "smtp.163.com:465")
	mailService.AuthenticateSMTP("", "[email protected]", "xxxxxx", "smtp.163.com")
	mailService.AddReceivers("[email protected]")
	notify.UseServices(mailService)
	// Send a test message.
	err := notify.Send(
		context.Background(),
		"Subject/Title",
		"The actual message - Hello, you awesome gophers! :)",
	)
	if err != nil {
		log.Println(err)
	}
}

image

Roadmap for v1

List of features/changes we want to finish before releasing an official v1 version:

  • Add notify.MustSend method (#48)
  • Add context.Context to parameter list of notify.Send - Done (#51)
  • Set standards and add a review process for new service candidates (#24)
  • Add missing usage docs
  • Add tests for all services (#1)

Please note that this list is not final.

feat(service): Add Amazon SES service

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

Missing support for the popular Amazon service Simple Email Service (SES).

Describe the solution you'd like

Implement a notification service like already exists for Telegram etc. At the time writing the official Amazon Golang SDK aws/aws-sdk-go is the best option for implementing it.

Describe alternatives you've considered

What is the preferred package name for this service. Should i named it amazonses or is there any other suggestion?

[BUG] : multiple messages

My module:

package mess

import (
   "context"

   "github.com/nikoksr/notify"
   "github.com/nikoksr/notify/service/telegram"
)

func Telegram(message string) {
   telegramService, _ := telegram.New("mykey")
   telegramService.AddReceivers(1234)
   notify.UseServices(telegramService)
   _ = notify.Send(context.Background(), "", message)
}

My call in main.go:

package main

import (
        "mod/mess"
)

func main() {
        mess.Telegram("Wtf 1 !?")
        mess.Telegram("Wtf 2 !?")
        mess.Telegram("Wtf 3 !?")
}

Outputs:

Wtf 1 !?
Wtf 2 !?
Wtf 2 !?
Wtf 3 !?
Wtf 3 !?
Wtf 3 !?

Any ideas?

Feat - Go Mail

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

Describe the solution you'd like
It would be great to see the use of Go Mail used in this project. https://github.com/ainsleyclark/go-mail
I think this will add SparkPost, Postal and Postmark support for free with no external dependencies.

I've noticed the go.mod file is quite large and this maybe a great opportunity to make it smaller by using the Mail drivers in the package outlined. All drivers in the Go Mail package use the std lib http client.

Describe alternatives you've considered
N/A

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/setup-go v3
  • actions/checkout v3
  • actions/cache v3
  • codecov/codecov-action v3
  • actions/checkout v3
  • golangci/golangci-lint-action v3
.github/workflows/codeql-analysis.yml
  • actions/checkout v3
  • github/codeql-action v2
  • github/codeql-action v2
  • github/codeql-action v2
gomod
go.mod
  • go 1.19
  • github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f@c0650d8dff0f
  • github.com/Rhymen/go-whatsapp v0.1.1
  • github.com/RocketChat/Rocket.Chat.Go.SDK v0.0.0-20220811115547-6c7006b790b8@6c7006b790b8
  • github.com/atc0005/go-teams-notify/v2 v2.6.1
  • github.com/aws/aws-sdk-go-v2 v1.16.10
  • github.com/aws/aws-sdk-go-v2/config v1.16.0
  • github.com/aws/aws-sdk-go-v2/credentials v1.12.12
  • github.com/aws/aws-sdk-go-v2/service/ses v1.14.12
  • github.com/aws/aws-sdk-go-v2/service/sns v1.17.12
  • github.com/blinkbean/dingtalk v0.0.0-20210905093040-7d935c0f7e19@7d935c0f7e19
  • github.com/bwmarrin/discordgo v0.25.0
  • github.com/cschomburg/go-pushbullet v0.0.0-20171206132031-67759df45fbb@67759df45fbb
  • github.com/dghubble/go-twitter v0.0.0-20220716041154-837915ec2f79@837915ec2f79
  • github.com/dghubble/oauth1 v0.7.1
  • github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible
  • github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
  • github.com/line/line-bot-sdk-go v7.8.0+incompatible
  • github.com/mailgun/mailgun-go/v4 v4.8.1
  • github.com/pkg/errors v0.9.1
  • github.com/plivo/plivo-go/v7 v7.10.0
  • github.com/sendgrid/sendgrid-go v3.11.1+incompatible
  • github.com/silenceper/wechat/v2 v2.1.3
  • github.com/slack-go/slack v0.11.2
  • github.com/stretchr/testify v1.8.0
  • github.com/textmagic/textmagic-rest-go-v2/v2 v2.0.3361
  • github.com/utahta/go-linenotify v0.5.0
  • golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4@886fb9371eb4
  • github.com/appleboy/go-fcm v0.1.5
  • github.com/go-lark/lark v1.7.2
  • github.com/google/go-cmp v0.5.8
  • github.com/kevinburke/twilio-go v0.0.0-20220615032439-b0fe9b151b0e@b0fe9b151b0e

  • Check this box to trigger a request for Renovate to run again on this repository

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",
)

[BUG] service := service

Hiya. I'm digging into the source as I'm trying to figure out how to use notify, and came across this line in send.go that seems to have a pointless line of code at line 25:

		service := service

I can send a PR to clean up this and a few small things like comments, but just want to make sure this isn't doing something non-obvious...

refactor(send): Add context.Context to notify.Send method

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

Since notify.Send may basically send a message to a huge amount of receivers, the user might appreciate to have the ability to cancel long running send executions.

Describe the solution you'd like

To achieve this behavior we will add a context.Context to the parameters of notify.Send.

Current notify.Send signature:

func (n Notify) Send(subject, message string) error {
    ...
}

New notify.Send signature:

func (n Notify) Send(ctx context.Context, subject, message string) error {
    ...
}

This needs to be done for every services implementation of the send method. The respective implementations will then need to check if the context got cancelled.

Example implementation:

func (s SomeService) Send(ctx context.Context, subject, message string) error {
    
    ...

    for _, receiver := range s.receivers {
        select {
	    case <-ctx.Done():
	        return nil // Context got cancelled; just return
            default:
	        _, _ = t.client.Send(receiver, message)  
	    }
        }
    }	

    return nil
}

feat(service): Add Signal support

Is your feature request related to a problem? Please describe.
I'm using secure messengers - Signal and Matrix, I would like to have notifications there instead of have to use third, or fourth messenger.

Describe the solution you'd like
I would like to send notifications to unencrypted Matrix channels (I know the encrypted ones may not be possible) and/or to Signal groups.

Shoutrrr has support for Matrix: https://containrrr.dev/shoutrrr/v0.5/services/matrix/
Apprise has support for both Signal and Matrix: https://github.com/caronc/apprise

[BUG] Syslog test seems to fail under WSL

Describe the bug

There is an error in the Syslog test that causing error when running make test

To Reproduce

Steps to reproduce the behavior:

  1. Execute command make test

Expected behavior

Syslog test should be passed and all tests will be passed

Screenshots
image

System

  • OS: Ubuntu 20 on WSL 2.0
  • Go Version: 1.19
  • Library Version: [e.g. 0.19.2]

Additional context

Add any other context about the problem here.

feat(service): Add SendGrid service

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

Missing support for the popular email service platform SendGrid.

Describe the solution you'd like

Implement a notification service like already exists for Telegram etc. At the time writing the official Golang SDK sendgrid/sendgrid-go seems to be our best option for implementing it.

Describe alternatives you've considered

Should we place the implementation under the mail package with the following constructor mail.NewSendGrid(...) or into a new separate package sendgrid?

Community question: Is anyone interested in an UI for notify?

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

Hey guys,

first of all, thanks for the really unbelievable support and interest so far. I recently had the idea that
there might be interest in a UI for notify.

Describe the solution you'd like

My first thought was a TUI with an input field, a history and a list of platforms to which the messages are sent - kind of the interface of most messengers today.



Wow, great colors for dark mode, sorry for that

Here is a small sketch of it:

image

Please remember, I am definitely not a designer and this sketch is just about the basic layout to give you an idea of what I had in mind. Btw this note was created with penpot.

The green and red at the platform names indicate whether the communication was successful or not. Again, this is just an idea and not a final version, please leave your ideas for a better design in the comments if you are interested.

Feeback and your suggestions are very welcome.

An Examples Folder

Is your feature request related to a problem? Please describe.
As someone exploring a library or a contributor, it can be messy to create a sandbox project to test out the local version.

I'm not sure if this is worth maintaining, but I just wanted to propose the idea.

Describe the solution you'd like
An example folder, similar to how it's done in the webpush-go package can solve this easily.

The example folder may contain examples for each type service, with the required setup code.

refactor(send): Add MustSend method

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

As discussed here the error handling in notify.Send might not fit everybodys needs. There might be occasions where you want Notify to immediately stop sending the message to the other receivers in case the preceding receiver was not reachable. Maybe its a very crucial message and you need to make sure that it was send to all receivers successfully. On the other hand there might be occasions where you don't care if Notify might not be able to reach some of the receivers and you just want it to continue after not reaching a receiver.

Describe the solution you'd like

In addition to the current notify.Send method we will add the notify.MustSend method. notify.Send will keep its current behavior which is to keep sending messages even after an error occured but.. it will need to collate all errors into one (something like #22). Instead of joining these errors I'm rather thinking about adding a custom error type which holds an array of unreachable receivers. notify.MustSend on the other will return the first error right after it occurs, basically skipping all remaining receivers.

Example for new error:

type ErrSendToReceivers struct {
    Receivers []string
    Err            error
}

feat(service): Add GMail service

Describe the missing service. Please provide useful links.

Gmail is one of the mail providers that is used by many people. I think adding a Gmail service to notify will attract people to use more this library.

It will be possible to implement because GMail has an API to interact. See more details: https://developers.google.com/gmail/api/quickstart/go

Describe the solution you'd like

  • Add new service to send a notification via email using Gmail API

Potential libraries to use

ci(service): Set standards and add review process for external services that are candiates for integration

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

This is related to j-wil's comment in the discussion about the testing procedure for external services. We currently have no standards for external services that are integrated into notify, even though certain minimum requirements have of course been taken into account up to now.

Describe the solution you'd like

As suggested by @j-wil, we need some sort of review process for the libraries behind the services that are potentially to be integrated. I suggest that we keep creating issues in style of #5 to propose the integration of a new service and that in the comment section of this issue we discuss which candidate would be the best fit for notify.

Suggestions for possible criteria:

  • Has the library been published directly by the vendor/developer of the service in question?
  • Does the library work at all?
  • Is the library still being actively developed/maintained?
  • Is the library reasonably popular relative to the popularity of the overriding service? (This is a rather weak criterion, but could be helpful in case we are between two equal candidates).

Please suggest other criteria in the comments or critique the example criteria given if needed.

feat(service): Add workplace chat

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

Describe the solution you'd like
It would be great to support Workplace by Facebook. I'm not sure if this is in tandem with the ticket open re supporting Facebook. But I'm pretty sure the Workplace API allows the sending of messages very easily.

Many thanks.

Describe alternatives you've considered
N/A

Additional context
https://developers.facebook.com/docs/workplace/bots/

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.

Python?

Any current library like this for Python?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.