tdclient

package module
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 16 Imported by: 1

README

tdclient

Simple client library.

Feedback

Join team: https://web.tada.team/api/v3/join/nWqYT1DgHnsS08pck1l9eq4ELVgVCm7q6xTxtHEVnu

Examples

Get server version
go run examples/serverinfo/main.go
go run examples/serverinfo/main.go -verbose
go run examples/serverinfo/main.go -verbose -server https://demo.tada.team

Any example have -verbose and -server options. Default server value is https://web.tada.team.

Authorization token

Some examples need authorization token. You have two options:

Bot token

Create bot by typing /newbot <BOTNAME> command in @TadaBot direct chat. Allowed for team admin only.

Token from your personal account

For server with sms authorization:

go run examples/smsauth/main.go

For server with Active Directory authorization:

go run examples/passwordauth/main.go
Contacts

go run examples/contacts/main.go -team <team uid> -token <token>

Messaging

Using websockets:

go run examples/send-message/main.go -team <team uid> -token <token> -chat <chat jid> -message <message text>

or

Using http API only:

go run examples/send-message-http/main.go -team <team uid> -token <token> -chat <chat jid> -message <message text>

How to get team uid and chat jid:

https://demo.tada.team/dbd248d7-25c2-4e8f-a23a-99baf63223e9/chats/g-dce6f5fd-b741-40a6-aa9c-c0e928d9dac5

  • dbd248d7-25c2-4e8f-a23a-99baf63223e9 – team uid
  • g-dce6f5fd-b741-40a6-aa9c-c0e928d9dac5 – chat jid
Simple bot

Echobot: make response to every direct message.

go run examples/echobot/main.go -team <team uid> -token <token>

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Timeout = errors.New("Timeout")

Functions

This section is empty.

Types

type Session

type Session struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewSession

func NewSession(server string) (Session, error)

func (Session) AddContact added in v0.2.2

func (s Session) AddContact(teamUid string, phone string) (tdproto.Contact, error)

func (Session) AuthByPasswordGetToken added in v0.2.0

func (s Session) AuthByPasswordGetToken(login, password string) (tdapi.Auth, error)

func (Session) AuthBySmsGetToken added in v0.2.0

func (s Session) AuthBySmsGetToken(phone, code string) (tdapi.Auth, error)

func (Session) AuthBySmsSendCode added in v0.2.0

func (s Session) AuthBySmsSendCode(phone string) (tdapi.SmsCode, error)

func (Session) Contacts added in v0.1.9

func (s Session) Contacts(teamUid string) ([]tdproto.Contact, error)

func (*Session) Features added in v0.1.8

func (s *Session) Features() (*tdproto.Features, error)

func (Session) Me

func (s Session) Me(teamUid string) (tdproto.Contact, error)

func (Session) Ping

func (s Session) Ping() error

func (Session) SendPlaintextMessage added in v0.2.4

func (s Session) SendPlaintextMessage(teamUid string, chat tdproto.JID, text string) (tdproto.Message, error)

func (*Session) SetCookie added in v0.1.8

func (s *Session) SetCookie(v string)

func (*Session) SetToken

func (s *Session) SetToken(v string)

func (*Session) SetVerbose added in v0.1.8

func (s *Session) SetVerbose(v bool)

func (*Session) Ws added in v0.1.4

func (s *Session) Ws(team string, onfail func(error)) (*WsSession, error)

type WsSession added in v0.1.4

type WsSession struct {
	*Session
	// contains filtered or unexported fields
}

func (*WsSession) Close added in v0.2.3

func (w *WsSession) Close() error

func (*WsSession) DeleteMessage added in v0.1.4

func (w *WsSession) DeleteMessage(uid string) string

func (*WsSession) Ping added in v0.1.4

func (w *WsSession) Ping() string

func (*WsSession) Send added in v0.1.4

func (w *WsSession) Send(event tdproto.Event) string

func (*WsSession) SendPlainMessage added in v0.1.4

func (w *WsSession) SendPlainMessage(to tdproto.JID, text string) string

func (*WsSession) WaitFor added in v0.1.6

func (w *WsSession) WaitFor(name string, v interface{}) error

func (*WsSession) WaitForConfirm added in v0.1.4

func (w *WsSession) WaitForConfirm() (string, error)

func (*WsSession) WaitForMessage added in v0.1.4

func (w *WsSession) WaitForMessage() (tdproto.Message, bool, error)

Directories

Path Synopsis
contacts command
echobot command
passwordauth command
send-message command
serverinfo command
smsauth command

Jump to

Keyboard shortcuts

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