Change Channel to use chat1.Channel
This commit is contained in:
8
chat.go
8
chat.go
@ -9,6 +9,8 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"samhofi.us/x/keybase/types/chat1"
|
||||
)
|
||||
|
||||
// Returns a string representation of a message id suitable for use in a
|
||||
@ -42,7 +44,7 @@ func getID(id uint) string {
|
||||
}
|
||||
|
||||
// Creates a string of a json-encoded channel to pass to keybase chat api-listen --filter-channel
|
||||
func createFilterString(channel Channel) string {
|
||||
func createFilterString(channel chat1.ChatChannel) string {
|
||||
if channel.Name == "" {
|
||||
return ""
|
||||
}
|
||||
@ -51,7 +53,7 @@ func createFilterString(channel Channel) string {
|
||||
}
|
||||
|
||||
// Creates a string of json-encoded channels to pass to keybase chat api-listen --filter-channels
|
||||
func createFiltersString(channels []Channel) string {
|
||||
func createFiltersString(channels []chat1.ChatChannel) string {
|
||||
if len(channels) == 0 {
|
||||
return ""
|
||||
}
|
||||
@ -285,7 +287,7 @@ func (c Chat) Delete(messageID int) (ChatAPI, error) {
|
||||
// ChatList returns a list of all conversations.
|
||||
// You can pass a Channel to use as a filter here, but you'll probably want to
|
||||
// leave the TopicName empty.
|
||||
func (k *Keybase) ChatList(opts ...Channel) (ChatAPI, error) {
|
||||
func (k *Keybase) ChatList(opts ...chat1.ChatChannel) (ChatAPI, error) {
|
||||
m := ChatAPI{
|
||||
Params: ¶ms{},
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"samhofi.us/x/keybase/types/chat1"
|
||||
)
|
||||
|
||||
// Possible MemberTypes
|
||||
@ -72,7 +74,7 @@ func (k *Keybase) Exec(command ...string) ([]byte, error) {
|
||||
}
|
||||
|
||||
// NewChat returns a new Chat instance
|
||||
func (k *Keybase) NewChat(channel Channel) Chat {
|
||||
func (k *Keybase) NewChat(channel chat1.ChatChannel) Chat {
|
||||
return Chat{
|
||||
keybase: k,
|
||||
Channel: channel,
|
||||
|
||||
27
types.go
27
types.go
@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"samhofi.us/x/keybase/types/chat1"
|
||||
)
|
||||
|
||||
// RunOptions holds a set of options to be passed to Run
|
||||
@ -15,8 +17,8 @@ type RunOptions struct {
|
||||
HideExploding bool // Ignore exploding messages
|
||||
Dev bool // Subscribe to dev channel messages
|
||||
Wallet bool // Subscribe to wallet events
|
||||
FilterChannel Channel // Only subscribe to messages from specified channel
|
||||
FilterChannels []Channel // Only subscribe to messages from specified channels
|
||||
FilterChannel chat1.ChatChannel // Only subscribe to messages from specified channel
|
||||
FilterChannels []chat1.ChatChannel // Only subscribe to messages from specified channels
|
||||
}
|
||||
|
||||
// ChatAPI holds information about a message received by the `keybase chat api-listen` command
|
||||
@ -231,7 +233,7 @@ type content struct {
|
||||
type msg struct {
|
||||
ID int `json:"id"`
|
||||
ConversationID string `json:"conversation_id"`
|
||||
Channel Channel `json:"channel"`
|
||||
Channel chat1.ChatChannel `json:"channel"`
|
||||
Sender sender `json:"sender"`
|
||||
SentAt int `json:"sent_at"`
|
||||
SentAtMs int64 `json:"sent_at_ms"`
|
||||
@ -296,15 +298,6 @@ type notification struct {
|
||||
Details details `json:"details"`
|
||||
}
|
||||
|
||||
// Channel holds information about a conversation
|
||||
type Channel struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Public bool `json:"public,omitempty"`
|
||||
MembersType string `json:"members_type,omitempty"`
|
||||
TopicType string `json:"topic_type,omitempty"`
|
||||
TopicName string `json:"topic_name,omitempty"`
|
||||
}
|
||||
|
||||
type BotCommand struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
@ -342,7 +335,7 @@ func (d *duration) MarshalJSON() (b []byte, err error) {
|
||||
}
|
||||
|
||||
type options struct {
|
||||
Channel *Channel `json:"channel,omitempty"`
|
||||
Channel *chat1.ChatChannel `json:"channel,omitempty"`
|
||||
MessageID int `json:"message_id,omitempty"`
|
||||
Message *mesg `json:"message,omitempty"`
|
||||
Pagination *pagination `json:"pagination,omitempty"`
|
||||
@ -438,7 +431,7 @@ type rateLimits struct {
|
||||
|
||||
type conversation struct {
|
||||
ID string `json:"id"`
|
||||
Channel Channel `json:"channel"`
|
||||
Channel chat1.ChatChannel `json:"channel"`
|
||||
Unread bool `json:"unread"`
|
||||
ActiveAt int `json:"active_at"`
|
||||
ActiveAtMs int64 `json:"active_at_ms"`
|
||||
@ -831,7 +824,7 @@ type Keybase struct {
|
||||
// Chat holds basic information about a specific conversation
|
||||
type Chat struct {
|
||||
keybase *Keybase
|
||||
Channel Channel
|
||||
Channel chat1.ChatChannel
|
||||
}
|
||||
|
||||
type chat interface {
|
||||
@ -900,10 +893,10 @@ type kvInterface interface {
|
||||
type keybase interface {
|
||||
AdvertiseCommand(advertisement BotAdvertisement) (ChatAPI, error)
|
||||
AdvertiseCommands(advertisements []BotAdvertisement) (ChatAPI, error)
|
||||
ChatList(opts ...Channel) (ChatAPI, error)
|
||||
ChatList(opts ...chat1.ChatChannel) (ChatAPI, error)
|
||||
ClearCommands() (ChatAPI, error)
|
||||
CreateTeam(name string) (TeamAPI, error)
|
||||
NewChat(channel Channel) Chat
|
||||
NewChat(channel chat1.ChatChannel) Chat
|
||||
NewTeam(name string) Team
|
||||
NewKV(team string) KV
|
||||
NewWallet() Wallet
|
||||
|
||||
Reference in New Issue
Block a user