telegram

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 11 Imported by: 0

README

telegram

  • Telegram Bot API

  • Api Format: https://api.telegram.org/bot<token>/METHOD_NAME

  • Token Format: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11

Feature

  • NewTelegram(token string)
  • NewTelegramChatId(token, chatId string)
  • UseHost(url string)
  • UseToken(token string)
  • SendText(text string)
  • SendMarkdown(body string) -- The supported Markdown syntax is detailed in Telegram Bot API
  • SendHtml(body string)
  • SetDebug(debug bool)
  • SetGet(get bool)
  • SetSilently(silent bool)
  • SetDisableWebPreview(disable bool)
  • SetChatId(chatId string)
  • SetProxy(proxy string) -- http_proxy eg: http://127.0.0.1:7890

How to get chat_id:

https://api.telegram.org/bot<token>/getUpdates

https://api.telegram.org/bot<token>/deleteWebhook?drop_pending_updates=true

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	OK          bool        `json:"ok"`
	ErrorCode   int         `json:"error_code,omitempty"`
	Description string      `json:"description,omitempty"`
	Result      interface{} `json:"result,omitempty"`
}

type Telegram

type Telegram struct {
	// contains filtered or unexported fields
}

func NewTelegram

func NewTelegram(token string) *Telegram

func NewTelegramChatId

func NewTelegramChatId(token, chatId string) *Telegram

func (*Telegram) SendHtml

func (r *Telegram) SendHtml(body string) error

func (*Telegram) SendMarkdown

func (r *Telegram) SendMarkdown(body string) error

SendMarkdown The supported Markdown syntax is detailed in https://core.telegram.org/bots/api#markdownv2-style

func (*Telegram) SendText

func (r *Telegram) SendText(text string) error

func (*Telegram) SetChatId

func (r *Telegram) SetChatId(chatId string) *Telegram

SetChatId Integer or String, Unique identifier for the target chat or username of the target channel (in the format @channelusername)

func (*Telegram) SetDebug

func (r *Telegram) SetDebug(debug bool) *Telegram

func (*Telegram) SetDisableWebPreview

func (r *Telegram) SetDisableWebPreview(disable bool) *Telegram

SetDisableWebPreview Disables link previews for links in this message

func (*Telegram) SetGet

func (r *Telegram) SetGet(get bool) *Telegram

func (*Telegram) SetProxy added in v0.3.1

func (r *Telegram) SetProxy(proxy string) *Telegram

func (*Telegram) SetSilently

func (r *Telegram) SetSilently(silent bool) *Telegram

SetSilently Sends the message silently. Users will receive a notification with no sound.

func (*Telegram) UseHost

func (r *Telegram) UseHost(url string) notice.Noticer

func (*Telegram) UseSecret

func (r *Telegram) UseSecret(secret string) notice.Noticer

Deprecated

func (*Telegram) UseToken

func (r *Telegram) UseToken(token string) notice.Noticer

Jump to

Keyboard shortcuts

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