telegram

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TeleConfig

type TeleConfig struct {
	// Token is the OAuth token for pushing messages.
	Token string `json:"Token"`

	// SubChannels is the list of channels for posting messages.
	//
	// Each channel must start with an `@` symbol. For example: @astra_alert
	SubChannels []string `json:"SubChannels"`

	// MessageQueueSize specifies the message queue size.
	MessageQueueSize int `json:"MessageQueueSize"`

	// EnabledMessageTypes specifies which message types are allowed to be posted.
	EnabledMessageTypes map[string]bool `json:"EnabledMessageTypes"`
}

TeleConfig consists of configurations of the TeleHook.

func DefaultConfig

func DefaultConfig() TeleConfig

func (TeleConfig) IsValid

func (cfg TeleConfig) IsValid() (bool, error)

IsValid checks if the current TeleConfig is valid.

type TeleHook

type TeleHook struct {
	*tgbotapi.BotAPI
	// contains filtered or unexported fields
}

TeleHook implements a Telegram webhook for pushing messages.

func NewTeleHook

func NewTeleHook(cfg TeleConfig, log logger.Logger) (*TeleHook, error)

NewTeleHook creates a new TeleHook with the given TeleConfig.

func (*TeleHook) Alert

func (t *TeleHook) Alert(msg interface{}) error

Alert pushes the given alert message to the TeleHook.

func (*TeleHook) Error

func (t *TeleHook) Error(msg interface{}) error

Error pushes the given error message to the TeleHook.

func (*TeleHook) Info

func (t *TeleHook) Info(msg interface{}) error

Info pushes the given information message to the TeleHook.

func (*TeleHook) Ping

func (t *TeleHook) Ping() error

Ping checks if the remote Tele service is alive.

func (*TeleHook) Start

func (t *TeleHook) Start() error

Start starts the TeleHook.

func (*TeleHook) Stop

func (t *TeleHook) Stop()

Stop stops the TeleHook.

Jump to

Keyboard shortcuts

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