tg

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Auth

func Auth(phone string, appID int64, appHash string, sessionPath string, password string, newSession bool) error

Types

type Client

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

func New

func New(appID int, appHash, sessionPath string) *Client

func (*Client) GetDialogs

func (c *Client) GetDialogs(args DialogsArguments) (*mcp.ToolResponse, error)

GetDialogs returns a list of dialogs (chats, channels, groups)

func (*Client) GetHistory

func (c *Client) GetHistory(args HistoryArguments) (*mcp.ToolResponse, error)

func (*Client) GetMe

func (c *Client) GetMe(_ EmptyArguments) (*mcp.ToolResponse, error)

func (*Client) ReadHistory added in v0.1.12

func (c *Client) ReadHistory(args ReadArguments) (*mcp.ToolResponse, error)

func (*Client) SendDraft added in v0.1.11

func (c *Client) SendDraft(args DraftArguments) (*mcp.ToolResponse, error)

func (*Client) T

func (c *Client) T() *telegram.Client

type DialogInfo

type DialogInfo struct {
	Name        string       `json:"name,omitempty"`
	Type        string       `json:"type"`
	Title       string       `json:"title"`
	LastMessage *MessageInfo `json:"last_message,omitempty"`
	Empty       bool         `json:"empty,omitempty"`
}

type DialogType

type DialogType string

DialogType represents the type of dialog for filtering

const (
	DialogTypeUnknown DialogType = "unknown"
	DialogTypeAll     DialogType = ""
	DialogTypeUser    DialogType = "user"
	DialogTypeBot     DialogType = "bot"
	DialogTypeChat    DialogType = "chat"
	DialogTypeChannel DialogType = "channel"

	DefaultDialogsLimit = 100
)

type DialogsArguments

type DialogsArguments struct {
	Offset     string `json:"offset,omitempty" jsonschema:"description=Offset for continuation"`
	OnlyUnread bool   `json:"only_unread,omitempty" jsonschema:"description=Include only dialogs with unread mark"`
}

nolint:lll

type DialogsOffset

type DialogsOffset struct {
	MsgID int `json:"msg_id"`
	Date  int `json:"offset_date"`
	Peer  tg.InputPeerClass
}

func (DialogsOffset) MarshalJSON

func (o DialogsOffset) MarshalJSON() ([]byte, error)

func (*DialogsOffset) String

func (o *DialogsOffset) String() string

func (*DialogsOffset) UnmarshalJSON

func (o *DialogsOffset) UnmarshalJSON(data []byte) error

type DialogsResponse

type DialogsResponse struct {
	Dialogs []DialogInfo  `json:"dialogs"`
	Offset  DialogsOffset `json:"offset"`
}

type DraftArguments added in v0.1.11

type DraftArguments struct {
	Name string `json:"name" jsonschema:"required,description=Name of the dialog"`
	Text string `json:"text" jsonschema:"required,description=Plain text of the message"`
}

type DraftResponse added in v0.1.11

type DraftResponse struct {
	Success bool `json:"success"`
}

type EmptyArguments

type EmptyArguments struct{}

type HistoryArguments

type HistoryArguments struct {
	Name   string `json:"name" jsonschema:"required,description=Name of the dialog"`
	Offset int    `json:"offset,omitempty" jsonschema:"description=Offset for continuation"`
}

type HistoryResponse

type HistoryResponse struct {
	Messages []MessageInfo `json:"messages"`
	Offset   int           `json:"offset,omitempty"`
}

type MeResponse

type MeResponse struct {
	ID        int64  `json:"id" jsonschema:"required,description=User ID"`
	FirstName string `json:"first_name" jsonschema:"required,description=User's first name"`
	LastName  string `json:"last_name" jsonschema:"description=User's last name"`
	Username  string `json:"username" jsonschema:"description=User's username"`
}

type MessageInfo

type MessageInfo struct {
	Who      string `json:"who,omitempty"`
	When     string `json:"when"`
	Text     string `json:"text,omitempty"`
	IsUnread bool   `json:"is_unread,omitempty"`
	// contains filtered or unexported fields
}

type ReadArguments added in v0.1.12

type ReadArguments struct {
	Name string `json:"name" jsonschema:"description=Name of the dialog"`
}

type ReadResponse added in v0.1.12

type ReadResponse struct {
	Result string `json:"result"`
}

Jump to

Keyboard shortcuts

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