telegramapi

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2017 License: MIT Imports: 11 Imported by: 0

README

telegramapi

Work-in-progress MTProto and full Telegram API implementation in Go

TL compiler

TODOs:

  • handle types with multiple constructors
  • handle types with two constructors, one of which is ‘...Empty’
  • add ReadBoxed methods
  • add String method to generated types

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	IP   string
	Port int
}

func (*Addr) Endpoint

func (o *Addr) Endpoint() string

func (*Addr) Read

func (o *Addr) Read(r *tl.Reader, ver int)

func (*Addr) Write

func (o *Addr) Write(w *tl.Writer)

type Chat

type Chat struct {
	Type ChatType

	// user ID, chat ID or channnel ID
	ID int

	User *User

	// valid for users and channels
	AccessHash uint64

	// valid for chats and channels
	Title string

	Messages *MessageList

	// valid for channels and users
	Username string
}

func (*Chat) TitleOrName

func (chat *Chat) TitleOrName() string

type ChatType

type ChatType int
const (
	UserChat ChatType = iota
	ChatChat
	ChannelChat
)

type Conn

type Conn struct {
	Options
	// contains filtered or unexported fields
}

func New

func New(options Options, state *State, delegate Delegate) *Conn

func (*Conn) CompleteLoginWith2FAPassword

func (c *Conn) CompleteLoginWith2FAPassword(password []byte) error

func (*Conn) CompleteLoginWithCode

func (c *Conn) CompleteLoginWithCode(code string) error

func (*Conn) Fail

func (c *Conn) Fail(err error)

func (*Conn) HandleUnknownReply

func (c *Conn) HandleUnknownReply(r tl.Object) error

func (*Conn) LoadChats

func (c *Conn) LoadChats(contacts *ContactList) error

func (*Conn) LoadHistory

func (c *Conn) LoadHistory(contacts *ContactList, chat *Chat, limit int) error

func (*Conn) LoginState

func (c *Conn) LoginState() LoginState

func (*Conn) Run

func (c *Conn) Run() error

func (*Conn) Send

func (c *Conn) Send(o tl.Object) (tl.Object, error)

func (*Conn) Shutdown

func (c *Conn) Shutdown()

func (*Conn) StartLogin

func (c *Conn) StartLogin(phoneNumber string) error

func (*Conn) SwitchToDC

func (c *Conn) SwitchToDC(dc int)

type ContactList

type ContactList struct {
	Self *User

	Chats    []*Chat
	SelfChat *Chat

	Users        map[int]*User
	UserChats    map[int]*Chat
	ChatChats    map[int]*Chat
	ChannelChats map[int]*Chat
}

func NewContactList

func NewContactList() *ContactList

func (*ContactList) FindChatByPeer

func (contacts *ContactList) FindChatByPeer(peer mtproto.TLPeerType) *Chat

type DCState

type DCState struct {
	ID int

	PrimaryAddr Addr

	Auth        mtproto.AuthResult
	FramerState mtproto.FramerState
}

func (*DCState) Clone

func (o *DCState) Clone() *DCState

func (*DCState) Read

func (o *DCState) Read(r *tl.Reader, ver int)

func (*DCState) Write

func (o *DCState) Write(w *tl.Writer)

type Delegate

type Delegate interface {
	HandleConnectionReady()
	HandleStateChanged(newState *State)
}

type LoginState

type LoginState int
const (
	LoggedOut LoginState = iota
	LoggedIn
	WaitingForCode
	WaitingFor2FA
)

type Message

type Message struct {
	ID   int
	Type MessageType

	Date     time.Time
	EditDate time.Time

	From *User

	FwdFrom    *User
	FwdChannel *Chat
	FwdDate    time.Time

	ReplyToID int
	ReplyTo   *Message

	Text string
}

type MessageList

type MessageList struct {
	TopMessage   *Message
	Messages     []*Message
	MessagesByID map[int]*Message
	MinKnownID   int
}

type MessageType

type MessageType int
const (
	NormalMessage MessageType = iota
)

type Options

type Options struct {
	SeedAddr  Addr
	PublicKey string
	Verbose   int

	APIID   int
	APIHash string
}

type State

type State struct {
	PreferredDC int

	DCs map[int]*DCState

	LoginState    LoginState
	PhoneNumber   string
	PhoneCodeHash string

	UserID    int
	FirstName string
	LastName  string
	Username  string
}

func (*State) Clone

func (o *State) Clone() *State

func (*State) Cmd

func (o *State) Cmd() uint32

func (*State) ReadBareFrom

func (o *State) ReadBareFrom(r *tl.Reader)

func (*State) WriteBareTo

func (o *State) WriteBareTo(w *tl.Writer)

type User

type User struct {
	ID        int
	Username  string
	FirstName string
	LastName  string
}

func (*User) Name

func (user *User) Name() string

Directories

Path Synopsis
cmd
Infinite Garble Extension (IGE) mode.
Infinite Garble Extension (IGE) mode.
PQ factorization derived from org.telegram.mtproto.secure.pq.PQLopatin of github.com/ex3ndr/telegram-mt
PQ factorization derived from org.telegram.mtproto.secure.pq.PQLopatin of github.com/ex3ndr/telegram-mt
Code generated by tlc (github.com/andreyvit/telegramapi/tl/cmd/tlc).
Code generated by tlc (github.com/andreyvit/telegramapi/tl/cmd/tlc).
tl
tlc

Jump to

Keyboard shortcuts

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