45 Commits

Author SHA1 Message Date
Sam
111d41b901 Update ListMembers to output correct type 2020-04-22 13:30:01 -04:00
Sam
300e330b8d Update AVDL compiled types 2020-04-22 13:29:22 -04:00
Sam
d69b73c5c1 use v2 types 2020-04-09 09:15:14 -04:00
Sam
b51c00a910 Update AVDL compiled types 2020-04-08 22:55:36 -04:00
Sam
0fd676670f Version 2 2020-04-06 12:43:35 -04:00
Sam
74992fe2c3 Remove ReadMessage -- it will eventually be replaced by the API's get method 2020-03-30 14:06:59 -04:00
Sam
74fb4a152b Add ListMembers methods 2020-03-14 21:27:40 -04:00
Sam
07f5168a6a subscriptionChannels should not be exported 2020-03-12 11:35:36 -04:00
0631dc60a7 updated phrasing to match go standards 2020-03-12 15:23:08 +00:00
71d1800637 added comments to exported types 2020-03-12 15:21:46 +00:00
Sam
c852393504 Fix download methods 2020-03-12 09:01:41 -04:00
Sam
ef7a20a94b Add download methods 2020-03-12 00:48:26 -04:00
Sam
21b141b7a1 Add UploadToChannel and UploadToConversation 2020-03-12 00:31:59 -04:00
Sam
8cef252023 Remove chat.Read() chat.Next() and chat.Previous() as they have been replaced 2020-03-12 00:24:48 -04:00
Sam
dd6726911e Remove old advertisement types as they are no longer used 2020-03-12 00:15:07 -04:00
Sam
0316bc6db1 Add AdvertiseCommands and ClearCommands 2020-03-12 00:07:38 -04:00
Sam
a22970a284 Add Next and Previous read methods 2020-03-11 17:16:46 -04:00
Sam
ad3edadc79 Add read methods 2020-03-11 15:21:48 -04:00
Sam
5a7a6d7538 Simplify funcs that wrap SendMessage 2020-03-08 11:47:34 -04:00
Sam
4e55ebaf05 Remove more custom types 2020-03-08 10:33:20 -04:00
Sam
6c11327289 Convert keystore funcs to use avdl compiled types 2020-03-06 14:17:23 -05:00
Sam
f6d26e1905 Add license 2020-03-03 08:15:49 -05:00
Sam
0feb664405 Remove wallet and convs from options, and instead automatically enable them if the correct handlers are present 2020-03-02 22:02:21 -05:00
Sam
ca2a1fdf25 Remove custom types 2020-02-29 10:12:15 -05:00
Sam
c031c36a00 Move types to types.go 2020-02-29 00:49:50 -05:00
Sam
5f211c7a90 Add support for new-conversation events 2020-02-29 00:39:22 -05:00
Sam
3bcca84908 Allow different types of notifications to come through separate channels 2020-02-29 00:24:40 -05:00
Sam
93daa56db1 Add GetConversations() 2020-02-16 23:49:58 -05:00
Sam
c272c05092 Add GetConversations 2020-02-16 23:21:20 -05:00
Sam
67ffd89a00 Add delete message funcs 2020-02-16 22:14:44 -05:00
Sam
97adac7fa4 Remove chat.React() 2020-02-16 22:08:15 -05:00
Sam
e24450a0af Add ReactByChannel and ReactByConvID 2020-02-16 22:00:04 -05:00
Sam
5bcd11703a Change the word To to By since it seems to make more sense 2020-02-16 21:53:59 -05:00
Sam
c4f06fa79b Remove chat.Edit 2020-02-16 16:11:56 -05:00
Sam
b50d3bcfa2 Clean up some of the comments 2020-02-16 16:09:08 -05:00
Sam
b55e4b8315 Add Edit funcs 2020-02-16 15:59:37 -05:00
Sam
450f2c1558 Add method arg to SendMessage 2020-02-16 15:58:44 -05:00
Sam
219ef492f5 Remove chat.Reply 2020-02-16 15:52:30 -05:00
Sam
26e487659c Ephemeral duration should be optional 2020-02-16 15:38:25 -05:00
Sam
3faadfd076 Add ReplyToChannel and ReplyToConvID, and attempt to fix ephemeral sends 2020-02-16 15:22:47 -05:00
Sam
d791203856 Add SendEphemeralToChannel and SendEphemeralToConvID 2020-02-16 14:48:13 -05:00
Sam
285567309a Add SendMessageToConvID 2020-02-16 14:07:26 -05:00
Sam
4e2656445c Add SendMessage and SendMessageToChannel, and the necessary types to go with them 2020-02-16 14:01:39 -05:00
Sam
0cfaa93505 Change Channel to use chat1.Channel 2020-01-29 17:07:42 -05:00
Sam
6d85c97e05 Add avdl compiled types 2020-01-29 16:19:18 -05:00
171 changed files with 7 additions and 2498 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"os/exec"
"time"
"samhofi.us/x/keybase/v2/types/chat1"
@ -36,15 +37,7 @@ func getNewMessages(k *Keybase, subs *subscriptionChannels, execOptions []string
execString = append(execString, execOptions...)
}
for {
cmd := make([]string, 0)
if k.HomePath != "" {
cmd = append(cmd, "--home", k.HomePath)
}
cmd = append(cmd, execString...)
execCmd := execCommand(k.ExePath, cmd...)
execCmd := exec.Command(k.Path, execString...)
stdOut, _ := execCmd.StdoutPipe()
execCmd.Start()
scanner := bufio.NewScanner(stdOut)
@ -751,37 +744,3 @@ func (k *Keybase) ListMembersOfConversation(convID chat1.ConvIDStr) (chat1.ChatM
}
return k.ListMembers(opts)
}
// ListConvsOnName returns a list of all conversations for a chat1.ChatChannel
func (k *Keybase) ListConvsOnName(channel chat1.ChatChannel) (*[]chat1.ConvSummary, error) {
type result struct {
Conversations []chat1.ConvSummary `json:"conversations"`
}
type res struct {
Result result `json:"result"`
Error *Error `json:"error,omitempty"`
}
var r res
arg := newListConvsOnNameArg(channel)
jsonBytes, _ := json.Marshal(arg)
cmdOut, err := k.Exec("chat", "api", "-m", string(jsonBytes))
if err != nil {
return nil, err
}
err = json.Unmarshal(cmdOut, &r)
if err != nil {
return nil, err
}
if r.Error != nil {
return nil, fmt.Errorf("%v", r.Error.Message)
}
return &r.Result.Conversations, nil
}

View File

2
go.mod
View File

@ -1,3 +1,3 @@
module samhofi.us/x/keybase
module samhofi.us/x/keybase/v2
go 1.13

View File

@ -9,9 +9,6 @@ import (
"samhofi.us/x/keybase/v2/types/chat1"
)
// Used for testing
var execCommand = exec.Command
// Possible MemberTypes
const (
TEAM string = "team"
@ -24,33 +21,13 @@ const (
CHAT string = "chat"
)
// New returns a new Keybase
func New(opts ...KeybaseOpt) *Keybase {
k := &Keybase{ExePath: "keybase"}
for _, opt := range opts {
opt.apply(k)
}
s := k.status()
k.Version = k.version()
k.LoggedIn = s.LoggedIn
if k.LoggedIn {
k.Username = s.Username
k.Device = s.Device.Name
}
return k
}
// NewKeybase returns a new Keybase. Optionally, you can pass a string containing the path to the Keybase executable as the first argument.
// This is deprecated and will be removed in a future update. Use New() instead.
func NewKeybase(path ...string) *Keybase {
k := &Keybase{}
if len(path) < 1 {
k.ExePath = "keybase"
k.Path = "keybase"
} else {
k.ExePath = path[0]
k.Path = path[0]
}
s := k.status()
@ -65,15 +42,7 @@ func NewKeybase(path ...string) *Keybase {
// Exec executes the given Keybase command
func (k *Keybase) Exec(command ...string) ([]byte, error) {
cmd := make([]string, 0)
if k.HomePath != "" {
cmd = append(cmd, "--home", k.HomePath)
}
cmd = append(cmd, command...)
out, err := execCommand(k.ExePath, cmd...).Output()
out, err := exec.Command(k.Path, command...).Output()
if err != nil {
return []byte{}, err
}

View File

View File

@ -20,37 +20,6 @@ type RunOptions struct {
FilterChannels []chat1.ChatChannel // Only subscribe to messages from specified channels
}
// KeybaseOpt configures a Keybase
type KeybaseOpt interface {
apply(kb *Keybase)
}
// SetExePath sets the path to the Keybase executable
func SetExePath(path string) KeybaseOpt {
return setExePath{path}
}
type setExePath struct {
path string
}
func (o setExePath) apply(kb *Keybase) {
kb.ExePath = o.path
}
// SetHomePath sets the path to the Keybase home directory
func SetHomePath(path string) KeybaseOpt {
return setHomePath{path}
}
type setHomePath struct {
path string
}
func (o setHomePath) apply(kb *Keybase) {
kb.HomePath = o.path
}
type subscriptionType struct {
Type string `json:"type"`
}
@ -114,7 +83,6 @@ type SendMessageOptions struct {
ReplyTo *chat1.MessageID `json:"reply_to,omitempty"`
ExplodingLifetime *ExplodingLifetime `json:"exploding_lifetime,omitempty"`
UnreadOnly bool `json:"unread_only,omitempty"`
NonBlock bool `json:"nonblock,omitempty"`
}
type sendMessageParams struct {
@ -239,24 +207,6 @@ func newListMembersArg(options ListMembersOptions) listMembersArg {
}
}
type listConvsOnNameParams struct {
Options chat1.ChatChannel
}
type listConvsOnNameArg struct {
Method string
Params listConvsOnNameParams
}
func newListConvsOnNameArg(channel chat1.ChatChannel) listConvsOnNameArg {
return listConvsOnNameArg{
Method: "listconvsonname",
Params: listConvsOnNameParams{
Options: channel,
},
}
}
// KVOptions holds a set of options to be passed to the KV methods
type KVOptions struct {
Team *string `json:"team"`
@ -1004,8 +954,7 @@ type userBlocks struct {
// Keybase holds basic information about the local Keybase executable
type Keybase struct {
HomePath string
ExePath string
Path string
Username string
LoggedIn bool
Version string

Some files were not shown because too many files have changed in this diff Show More