-
Notifications
You must be signed in to change notification settings - Fork 1
/
transport.go
41 lines (37 loc) · 1.53 KB
/
transport.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package transport // package github.com/justanotherorganization/justanotherbotkit/transport
import (
"context"
"errors"
)
type (
// Transport provides standard io access to a network transport layer.
Transport interface {
// TunnelEvents translates a specified network's events to Events tunneling them into evCh.
// The session is terminated when ctx.Done returns.
TunnelEvents(ctx context.Context, evCh chan *Event, errCh chan error)
// SendMessage sends a message using the default format specified in the given transport.
SendMessage(dest, msg string) error
// SendEvent sends a new event over the given transport.
SendEvent(ev *Event) error
// Channels lists all the channels we have access to via this transport.
Channels() ([]*Channel, error)
// GetUser returns the full user data for the provided name or ID.
GetUser(user string) (*User, error)
// GetUsers returns a list of all known users.
GetUsers() ([]*User, error)
// GetConversation gets a private conversation for the given user ID.
// This varies depending on network (may just be the user ID) but is required for Slack.
GetConversation(userID string) (string, error)
}
// Config is a transport configuration.
Config struct {
Token string
IgnoreUsers []string
}
)
var (
// ErrNilTransport should be returned in places where a transport is required but is not set.
ErrNilTransport = errors.New("transport cannot be nil")
// ErrUserNotFound is returned if teh transport cannot locate a given user.
ErrUserNotFound = errors.New("user not found")
)