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