telegram

package
v0.0.0-...-b12c321 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Send basic messages over Telegram

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Telegram

type Telegram struct {
	Token  string `env:"TELEGRAM_TOKEN"`   // Telegram bot token
	ChatID int64  `env:"TELEGRAM_CHAT_ID"` // Default telegram chat ID (https://t.me/getidsbot)
}

Telegram endpoint

func Default

func Default() *Telegram

Default telegram configuration from env variables

TELEGRAM_TOKEN - mandatory, bot token (from @BotFather), panic if not set

func (Telegram) SendText

func (cfg Telegram) SendText(text string) error

Send basic text message to default chat ID (see SendTextToContext)

func (Telegram) SendTextContext

func (cfg Telegram) SendTextContext(ctx context.Context, text string) error

Send basic text message to default chat ID (see SendTextToContext)

func (Telegram) SendTextTo

func (cfg Telegram) SendTextTo(text string, chatId int64) error

Send basic text message to custom chat ID (see SendTextToContext)

func (Telegram) SendTextToContext

func (cfg Telegram) SendTextToContext(ctx context.Context, text string, chatId int64) error

Send basic text message to custom chat ID. Bot should have access to the chat, otherwise Bad Request will be raised

API: https://api.telegram.org/

Jump to

Keyboard shortcuts

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