kbchat

package
v0.0.0-...-1bdf50c Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: BSD-3-Clause Imports: 22 Imported by: 59

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomTimeout

func CustomTimeout(timeout time.Duration) func(*API)

func ErrToOK

func ErrToOK(err *error) string

Types

type API

type API struct {
	sync.Mutex
	*DebugOutput

	Timeout      time.Duration
	LogSendBytes int
	// contains filtered or unexported fields
}

API is the main object used for communicating with the Keybase JSON API

func NewAPI

func NewAPI(runOpts RunOptions, opts ...func(*API)) *API

func Start

func Start(runOpts RunOptions, opts ...func(*API)) (*API, error)

Start fires up the Keybase JSON API in stdin/stdout mode

func (*API) AdvertiseCommands

func (a *API) AdvertiseCommands(ad Advertisement) (SendResponse, error)

func (*API) Broadcast

func (a *API) Broadcast(body string, args ...interface{}) (SendResponse, error)

func (*API) ClearCommands

func (a *API) ClearCommands(filter *chat1.ClearCommandAPIParam) error

func (*API) Command

func (a *API) Command(args ...string) *exec.Cmd

func (*API) DeleteEntry

func (a *API) DeleteEntry(teamName *string, namespace string, entryKey string) (result keybase1.KVDeleteEntryResult, err error)

func (*API) DeleteEntryWithRevision

func (a *API) DeleteEntryWithRevision(teamName *string, namespace string, entryKey string, revision int) (result keybase1.KVDeleteEntryResult, err error)

func (*API) EditByConvID

func (a *API) EditByConvID(convID chat1.ConvIDStr, msgID chat1.MessageID, text string) (SendResponse, error)

func (*API) GetConversation

func (a *API) GetConversation(convID chat1.ConvIDStr) (res chat1.ConvSummary, err error)

func (*API) GetConversations

func (a *API) GetConversations(unreadOnly bool) ([]chat1.ConvSummary, error)

GetConversations reads all conversations from the current user's inbox.

func (*API) GetEntry

func (a *API) GetEntry(teamName *string, namespace string, entryKey string) (result keybase1.KVGetResult, err error)

func (*API) GetMessages

func (a *API) GetMessages(channel chat1.ChatChannel, msgIDs []chat1.MessageID) ([]chat1.Message, error)

func (*API) GetMessagesByConvID

func (a *API) GetMessagesByConvID(conversationID chat1.ConvIDStr, msgIDs []chat1.MessageID) ([]chat1.Message, error)

func (*API) GetTextMessages

func (a *API) GetTextMessages(channel chat1.ChatChannel, unreadOnly bool) ([]chat1.MsgSummary, error)

GetTextMessages fetches all text messages from a given channel. Optionally can filter ont unread status.

func (*API) GetUsername

func (a *API) GetUsername() string

func (*API) GetWalletTxDetails

func (a *API) GetWalletTxDetails(txID string) (wOut WalletOutput, err error)

func (*API) InChatSend

func (a *API) InChatSend(channel chat1.ChatChannel, body string, args ...interface{}) (SendResponse, error)

func (*API) InChatSendByConvID

func (a *API) InChatSendByConvID(convID chat1.ConvIDStr, body string, args ...interface{}) (SendResponse, error)

func (*API) InChatSendByTlfName

func (a *API) InChatSendByTlfName(tlfName string, body string, args ...interface{}) (SendResponse, error)

func (*API) JoinChannel

func (a *API) JoinChannel(teamName string, channelName string) (chat1.EmptyRes, error)

func (*API) LeaveChannel

func (a *API) LeaveChannel(teamName string, channelName string) (chat1.EmptyRes, error)

func (*API) ListChannels

func (a *API) ListChannels(teamName string) ([]string, error)

func (*API) ListCommands

func (a *API) ListCommands(channel chat1.ChatChannel) ([]chat1.UserBotCommandOutput, error)

func (*API) ListCommandsByConvID

func (a *API) ListCommandsByConvID(convID chat1.ConvIDStr) ([]chat1.UserBotCommandOutput, error)

func (*API) ListEntryKeys

func (a *API) ListEntryKeys(teamName *string, namespace string) (result keybase1.KVListEntryResult, err error)

func (*API) ListMembers

func (a *API) ListMembers(channel chat1.ChatChannel) (keybase1.TeamMembersDetails, error)

func (*API) ListMembersByConvID

func (a *API) ListMembersByConvID(conversationID chat1.ConvIDStr) (keybase1.TeamMembersDetails, error)

func (*API) ListMembersOfTeam

func (a *API) ListMembersOfTeam(teamName string) (res keybase1.TeamMembersDetails, err error)

func (*API) ListNamespaces

func (a *API) ListNamespaces(teamName *string) (result keybase1.KVListNamespaceResult, err error)

func (*API) ListUserMemberships

func (a *API) ListUserMemberships(username string) ([]keybase1.AnnotatedMemberInfo, error)

func (*API) Listen

func (a *API) Listen(opts ListenOptions) (*Subscription, error)

Listen fires of a background loop and puts chat messages and wallet events into channels

func (*API) ListenForNewTextMessages

func (a *API) ListenForNewTextMessages() (*Subscription, error)

ListenForNewTextMessages proxies to Listen without wallet events

func (*API) LogSend

func (a *API) LogSend(feedback string) error

func (*API) PutEntry

func (a *API) PutEntry(teamName *string, namespace string, entryKey string, entryValue string) (result keybase1.KVPutResult, err error)

func (*API) PutEntryWithRevision

func (a *API) PutEntryWithRevision(teamName *string, namespace string, entryKey string, entryValue string, revision int) (result keybase1.KVPutResult, err error)

func (*API) ReactByChannel

func (a *API) ReactByChannel(channel chat1.ChatChannel, msgID chat1.MessageID, reaction string) (SendResponse, error)

func (*API) ReactByConvID

func (a *API) ReactByConvID(convID chat1.ConvIDStr, msgID chat1.MessageID, reaction string) (SendResponse, error)

func (*API) SendAttachmentByConvID

func (a *API) SendAttachmentByConvID(convID chat1.ConvIDStr, filename string, title string) (SendResponse, error)

func (*API) SendAttachmentByTeam

func (a *API) SendAttachmentByTeam(teamName string, inChannel *string, filename string, title string) (SendResponse, error)

func (*API) SendMessage

func (a *API) SendMessage(channel chat1.ChatChannel, body string, args ...interface{}) (resp SendResponse, err error)

func (*API) SendMessageByConvID

func (a *API) SendMessageByConvID(convID chat1.ConvIDStr, body string, args ...interface{}) (resp SendResponse, err error)

func (*API) SendMessageByTeamName

func (a *API) SendMessageByTeamName(teamName string, inChannel *string, body string, args ...interface{}) (resp SendResponse, err error)

func (*API) SendMessageByTlfName

func (a *API) SendMessageByTlfName(tlfName string, body string, args ...interface{}) (resp SendResponse, err error)

SendMessageByTlfName sends a message on the given TLF name

func (*API) SendReply

func (a *API) SendReply(channel chat1.ChatChannel, replyTo *chat1.MessageID, body string, args ...interface{}) (SendResponse, error)

func (*API) SendReplyByConvID

func (a *API) SendReplyByConvID(convID chat1.ConvIDStr, replyTo *chat1.MessageID, body string, args ...interface{}) (SendResponse, error)

func (*API) SendReplyByTlfName

func (a *API) SendReplyByTlfName(tlfName string, replyTo *chat1.MessageID, body string, args ...interface{}) (SendResponse, error)

func (*API) Shutdown

func (a *API) Shutdown() (err error)

type APIError

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

func (APIError) Error

func (e APIError) Error() string
type Advertisement struct {
	Alias          string `json:"alias,omitempty"`
	Advertisements []chat1.AdvertiseCommandAPIParam
}

type ChannelsList

type ChannelsList struct {
	Result Result `json:"result"`
	Error  *Error `json:"error,omitempty"`
}

type DebugOutput

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

func NewDebugOutput

func NewDebugOutput(name string) *DebugOutput

func (*DebugOutput) Debug

func (d *DebugOutput) Debug(format string, args ...interface{})

func (*DebugOutput) Trace

func (d *DebugOutput) Trace(err *error, format string, args ...interface{}) func()

type DeleteEntryRes

type DeleteEntryRes struct {
	Result keybase1.KVDeleteEntryResult `json:"result"`
	Error  Error                        `json:"error,omitempty"`
}

type Error

type Error struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
}

Error is for unmarshaling CLI json responses

func (Error) Error

func (e Error) Error() string

type ErrorCode

type ErrorCode int
const (
	RevisionErrorCode          ErrorCode = 2760
	DeleteNonExistentErrorCode ErrorCode = 2762
)

type GetEntryRes

type GetEntryRes struct {
	Result keybase1.KVGetResult `json:"result"`
	Error  Error                `json:"error,omitempty"`
}

type GetMessagesResult

type GetMessagesResult struct {
	Result struct {
		Messages []chat1.Message `json:"messages"`
	} `json:"result"`
	Error *Error `json:"error,omitempty"`
}

type Inbox

type Inbox struct {
	Result Result `json:"result"`
	Error  *Error `json:"error,omitempty"`
}

type JoinChannel

type JoinChannel struct {
	Error  *Error         `json:"error,omitempty"`
	Result chat1.EmptyRes `json:"result"`
}

type KVStoreAPI

type KVStoreAPI interface {
	PutEntry(teamName *string, namespace string, entryKey string, entryValue string) (keybase1.KVPutResult, error)
	PutEntryWithRevision(teamName *string, namespace string, entryKey string, entryValue string, revision int) (keybase1.KVPutResult, error)
	DeleteEntry(teamName *string, namespace string, entryKey string) (keybase1.KVDeleteEntryResult, error)
	DeleteEntryWithRevision(teamName *string, namespace string, entryKey string, revision int) (keybase1.KVDeleteEntryResult, error)
	GetEntry(teamName *string, namespace string, entryKey string) (keybase1.KVGetResult, error)
	ListNamespaces(teamName *string) (keybase1.KVListNamespaceResult, error)
	ListEntryKeys(teamName *string, namespace string) (keybase1.KVListEntryResult, error)
}

type LeaveChannel

type LeaveChannel struct {
	Error  *Error         `json:"error,omitempty"`
	Result chat1.EmptyRes `json:"result"`
}

type ListCommandsResponse

type ListCommandsResponse struct {
	Result struct {
		Commands []chat1.UserBotCommandOutput `json:"commands"`
	} `json:"result"`
	Error *Error `json:"error,omitempty"`
}

type ListEntryKeysRes

type ListEntryKeysRes struct {
	Result keybase1.KVListEntryResult `json:"result"`
	Error  Error                      `json:"error,omitempty"`
}

type ListMembersOutputMembersCategory

type ListMembersOutputMembersCategory struct {
	Username string `json:"username"`
	FullName string `json:"fullName"`
}

type ListNamespacesRes

type ListNamespacesRes struct {
	Result keybase1.KVListNamespaceResult `json:"result"`
	Error  Error                          `json:"error,omitempty"`
}

type ListTeamMembers

type ListTeamMembers struct {
	Result keybase1.TeamDetails `json:"result"`
	Error  Error                `json:"error"`
}

type ListUserMemberships

type ListUserMemberships struct {
	Result keybase1.AnnotatedTeamList `json:"result"`
	Error  Error                      `json:"error"`
}

type ListenOptions

type ListenOptions struct {
	Wallet bool
	Convs  bool
}

type OneshotOptions

type OneshotOptions struct {
	Username string
	PaperKey string
}

type PaymentHolder

type PaymentHolder struct {
	Payment stellar1.PaymentDetailsLocal `json:"notification"`
}

type PutEntryRes

type PutEntryRes struct {
	Result keybase1.KVPutResult `json:"result"`
	Error  Error                `json:"error,omitempty"`
}

type Result

type Result struct {
	Convs []chat1.ConvSummary `json:"conversations"`
}

type RunOptions

type RunOptions struct {
	KeybaseLocation string
	HomeDir         string
	Oneshot         *OneshotOptions
	StartService    bool
	// Have the bot send/receive typing notifications
	EnableTyping bool
	// Disable bot lite mode
	DisableBotLiteMode bool
	// Number of processes to spin up to connect to the keybase service
	NumPipes int
}

func (RunOptions) Command

func (r RunOptions) Command(args ...string) *exec.Cmd

func (RunOptions) Location

func (r RunOptions) Location() string

type SendResponse

type SendResponse struct {
	Result chat1.SendRes `json:"result"`
	Error  *Error        `json:"error,omitempty"`
}

type Subscription

type Subscription struct {
	*DebugOutput
	sync.Mutex
	// contains filtered or unexported fields
}

Subscription has methods to control the background message fetcher loop

func NewSubscription

func NewSubscription() *Subscription

func (*Subscription) Read

func (m *Subscription) Read() (msg SubscriptionMessage, err error)

Read blocks until a new message arrives

func (*Subscription) ReadNewConvs

func (m *Subscription) ReadNewConvs() (conv SubscriptionConversation, err error)

func (*Subscription) ReadWallet

func (m *Subscription) ReadWallet() (msg SubscriptionWalletEvent, err error)

Read blocks until a new message arrives

func (*Subscription) Shutdown

func (m *Subscription) Shutdown()

Shutdown terminates the background process

type SubscriptionConversation

type SubscriptionConversation struct {
	Conversation chat1.ConvSummary
}

type SubscriptionMessage

type SubscriptionMessage struct {
	Message      chat1.MsgSummary
	Conversation chat1.ConvSummary
}

SubscriptionMessage contains a message and conversation object

type SubscriptionWalletEvent

type SubscriptionWalletEvent struct {
	Payment stellar1.PaymentDetailsLocal
}

type Thread

type Thread struct {
	Result chat1.Thread `json:"result"`
	Error  *Error       `json:"error,omitempty"`
}

type TypeHolder

type TypeHolder struct {
	Type string `json:"type"`
}

type UnmarshalError

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

func (UnmarshalError) Error

func (e UnmarshalError) Error() string

type WalletOutput

type WalletOutput struct {
	Result stellar1.PaymentCLILocal `json:"result"`
}

Directories

Path Synopsis
types

Jump to

Keyboard shortcuts

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