telegram

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(botToken string, chatId string, text string) error

func SendComplex

func SendComplex(botToken string, chatId int64, text ...any) error

Types

type RobotAdapter

type RobotAdapter struct {
	TeleBot *tgbotapi.BotAPI
}

func NewBot

func NewBot(token string) (RobotAdapter, error)

func (*RobotAdapter) Send

func (r *RobotAdapter) Send(chat_id int64, v ...any)

send telegram

type TelegramMessageReq

type TelegramMessageReq struct {
	Ok     bool             `json:"ok"`
	Result []map[string]any `json:"result"`
}

type TelegramPrivateMessageStruct

type TelegramPrivateMessageStruct struct {
	MessageID int `json:"message_id"`
	From      struct {
		ID           int    `json:"id"`
		IsBot        bool   `json:"is_bot"`
		FirstName    string `json:"first_name"`
		Username     string `json:"username"`
		LanguageCode string `json:"language_code"`
	} `json:"from"`
	Chat struct {
		ID        int    `json:"id"`
		FirstName string `json:"first_name"`
		Username  string `json:"username"`
		Type      string `json:"type"`
	} `json:"chat"`
	Date     int    `json:"date"`
	Text     string `json:"text"`
	Entities []struct {
		Offset int    `json:"offset"`
		Length int    `json:"length"`
		Type   string `json:"type"`
	} `json:"entities"`
}

func ReadTgbotPrivateMsgs

func ReadTgbotPrivateMsgs(botToken string) (msgs []TelegramPrivateMessageStruct, err error)

Read msgs sent to the bot. Msgs sent by the bot and msgs from group will not be included.

Jump to

Keyboard shortcuts

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