telegram

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Scheme = "telegram"
)

Scheme is the identifying part of this service's configuration URL

Variables

This section is empty.

Functions

func IsTokenValid

func IsTokenValid(token string) bool

IsTokenValid for use with telegram

Types

type Config

type Config struct {
	Token        string
	Preview      bool      `key:"preview" default:"Yes" desc:"If disabled, no web page preview will be displayed for URLs"`
	Notification bool      `key:"notification" default:"Yes" desc:"If disabled, sends message silently"`
	ParseMode    parseMode `key:"parsemode" default:"None" desc:"How the text message should be parsed"`
	Channels     []string  `key:"channels"`
}

Config for use within the telegram plugin

func (*Config) Enums

func (config *Config) Enums() map[string]types.EnumFormatter

Enums returns the fields that should use a corresponding EnumFormatter to Print/Parse their values

func (*Config) GetURL

func (config *Config) GetURL() *url.URL

GetURL returns a URL representation of it's current field values

func (*Config) SetURL

func (config *Config) SetURL(url *url.URL) error

SetURL updates a ServiceConfig from a URL representation of it's field values

type SendMessagePayload

type SendMessagePayload struct {
	Text                string `json:"text"`
	ID                  string `json:"chat_id"`
	ParseMode           string `json:"parse_mode,omitempty"`
	DisablePreview      bool   `json:"disable_web_page_preview"`
	DisableNotification bool   `json:"disable_notification"`
}

SendMessagePayload is the notification payload for the telegram notification service

type Service

type Service struct {
	standard.Standard
	// contains filtered or unexported fields
}

Service sends notifications to a given telegram chat

func (*Service) GetConfig

func (service *Service) GetConfig() *Config

GetConfig returns the Config for the service

func (*Service) Initialize

func (service *Service) Initialize(configURL *url.URL, logger *log.Logger) error

Initialize loads ServiceConfig from configURL and sets logger for this Service

func (*Service) Send

func (service *Service) Send(message string, params *types.Params) error

Send notification to Telegram

Jump to

Keyboard shortcuts

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