notify

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TELEGRAM = "telegram"
	DISCORD  = "discord"
	SMTP     = "smtp"
)
View Source
const (
	/**
		Gmail SMTP Server
	**/
	SMTPServer = "smtp.gmail.com"
)

Variables

This section is empty.

Functions

func GetTgBot

func GetTgBot(option TgBotOption) *tgbotapi.BotAPI

GetTgBot get an instance of tgBot

func SendMessageDiscord

func SendMessageDiscord(discordClient DiscordClient, message string) error

SendMessageDiscord send msg to discord

func SendMessageSMTP

func SendMessageSMTP(sender *Sender, message string)

SendMessageSMTP send msg to SMTP

func SendMessageTG

func SendMessageTG(bot *tgbotapi.BotAPI, id int64, message string) error

SendMessageTG send msg to telegram

Types

type Author

type Author struct {
	Name    string `json:"name,omitempty"`
	URL     string `json:"url,omitempty"`
	IconURL string `json:"icon_url,omitempty"`
}

Author ...

type DiscordClient

type DiscordClient interface {
	// PostMessage ...
	PostMessage(ctx context.Context, message string) error
}

func NewDiscordClient

func NewDiscordClient(options DiscordClientOptions) (DiscordClient, error)

NewDiscordClient create an instance of discord client

type DiscordClientOptions

type DiscordClientOptions struct {

	// ServerHook url to use
	ServerHook string

	HttpClient *http.Client
}

DiscordClientOptions ...

type Embed

type Embed struct {
	Author      Author `json:"author,omitempty"`
	Title       string `json:"title,omitempty"`
	URL         string `json:"url,omitempty"`
	Description string `json:"description,omitempty"`
	Color       int64  `json:"color,omitempty"`
}

Embed object that define the structure of our msg

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

type Notifier

type Notifier interface {
	SendNotification(data interface{}) error
}

Notifier ...

type PayloadWebHookDiscord

type PayloadWebHookDiscord struct {
	Username  string  `json:"username,omitempty"`
	AvatarURL string  `json:"avatar_url,omitempty"`
	Content   string  `json:"content,omitempty"`
	Embeds    []Embed `json:"embeds,omitempty"`
}

PayloadWebHookDiscord general payload to make request to discord Hook

func (*PayloadWebHookDiscord) ToReader

func (p *PayloadWebHookDiscord) ToReader() *strings.Reader

type Sender

type Sender struct {
	// User ...
	User string
	// Password
	Password string
}

Sender object it`s used to send SMTP request

func NewSender

func NewSender(Username, Password string) Sender

NewSender constructor

func (Sender) SendMail

func (sender Sender) SendMail(Dest []string, Subject, bodyMessage string)

SendMail send mail to an array of dst

func (Sender) WriteEmail

func (sender Sender) WriteEmail(dest []string, contentType, subject, bodyMessage string) string

WriteEmail an email

func (*Sender) WriteHTMLEmail

func (sender *Sender) WriteHTMLEmail(dest []string, subject, bodyMessage string) string

WriteHTMLEmail ...

func (*Sender) WritePlainEmail

func (sender *Sender) WritePlainEmail(dest []string, subject, bodyMessage string) string

WritePlainEmail ...

type TgBotOption

type TgBotOption struct {
	Debug bool
	Token string
}

TgBotOption object options for telegram service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL