telegram

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ServerURL      = "https://api.telegram.org"
	APIGetMe       = "/getMe"
	APISendMessage = "/sendMessage"
)

Telegram server api details

View Source
const (
	ParseModeText       = "Text"
	ParseModeMarkdownV2 = "MarkdownV2"
	ParseModeHTML       = "HTML"
)

Message types

View Source
const (
	PluginTelegram = "telegram"
)

Variables

This section is empty.

Functions

func New

telegram handler

Types

type Config

type Config struct {
	Token   string `json:"-"`
	ChatIDs []string
}

Config data for telegram client

type Message

type Message struct {
	ChatID                string `json:"chat_id"`
	Text                  string `json:"text"`
	ParseMode             string `json:"parse_mode"`
	DisableWebPagePreview bool   `json:"disable_web_page_preview"`
	DisableNotification   bool   `json:"disable_notification"`
	ReplyToMessageID      int    `json:"reply_to_message_id"`
}

Message struct

type Response

type Response struct {
	IsOK        bool                   `json:"ok"`
	Result      map[string]interface{} `json:"result"`
	ErrorCode   int                    `json:"error_code"`
	Description string                 `json:"description"`
}

Response struct

type TelegramClient

type TelegramClient struct {
	Config *Config
	// contains filtered or unexported fields
}

TelegramClient struct

func (*TelegramClient) Close

func (c *TelegramClient) Close() error

Close handler implementation

func (*TelegramClient) GetMe

func (c *TelegramClient) GetMe() (*User, error)

GetMe returns about the user profile

func (*TelegramClient) Name

func (p *TelegramClient) Name() string

func (*TelegramClient) Post

func (c *TelegramClient) Post(parameters map[string]interface{}) error

Post handler implementation

func (*TelegramClient) SendMessage

func (c *TelegramClient) SendMessage(message *Message) error

SendMessage func

func (*TelegramClient) Start

func (c *TelegramClient) Start() error

Start handler implementation

func (*TelegramClient) State

func (c *TelegramClient) State() *types.State

State implementation

type User

type User struct {
	ID           int    `json:"id"`
	IsBot        bool   `json:"is_bot"`
	FirstName    string `json:"first_name"`
	LastName     string `json:"last_name"`
	Username     string `json:"username"`
	LanguageCode string `json:"language_code"`
}

User struct

Jump to

Keyboard shortcuts

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