tdclient

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: MIT Imports: 13 Imported by: 1

README

tdclient

Simple client library.

import "github.com/tada-team/tdclient"

func main() {
    verbose := true
    token := "secret"
    team := "uid"
    chat := "chat jid"
    
    client, err := tdclient.NewSession("https://web.tada.team", verbose)
    if err != nil {
        panic(err)
    }
    
    client.SetToken("secret")
   
    ws, err := client.Ws(team, nil)
    if err != nil {
        panic(err)
    }
    
    ws.SendPlainMessage(chat, "hello, world") 
}

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, verbose bool) (Session, error)

func (Session) Me

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

func (Session) Ping

func (s Session) Ping() error

func (*Session) SetToken

func (s *Session) SetToken(token string)

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) 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(e 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)

Jump to

Keyboard shortcuts

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