get ready for more implementation work
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQT/foVVmI9pK13hPWFohAcXSWbK8wUCZv3rNgAKCRBohAcXSWbK 8xjeAP47EcdzJ775/Vgk1ywb2V/oypk7RC7q9LACHeSjOfs1BwD/WmBIrytN9sFo MutxYgzm/yTvIAlzbsQQ9hqJqqKnRAE= =qgBd -----END PGP SIGNATURE-----
5 files changed,
24 insertions(+),
8 deletions(-)
M
adapter/adapter.go
→
adapter/adapter.go
@@ -9,6 +9,6 @@ Init(Settings, *chan SocketData) error
Name() string Subscribe(string) []error Fetch(string, []string) error - Do(string) error + Do(string, []string) error DefaultSubscriptionFilter() string }
M
adapter/mastodon.go
→
adapter/mastodon.go
@@ -104,7 +104,7 @@ func (self *MastoAdapter) Fetch(etype string, ids []string) error {
return nil } -func (self *MastoAdapter) Do(action string) error { +func (self *MastoAdapter) Do(action string, data []string) error { return nil }
M
adapter/misskey.go
→
adapter/misskey.go
@@ -294,6 +294,8 @@
func (self *MisskeyAdapter) Fetch(etype string, ids []string) error { for _, id := range ids { switch etype { + case "byAuthor": + // fetch notes by this author case "message": data, err := self.mk.Notes().Show(id) if err != nil {@@ -360,13 +362,13 @@ if a != nil {
self.send(a) } } - } } return nil } -func (self *MisskeyAdapter) Do(action string) error { +func (self *MisskeyAdapter) Do(action string, data []string) error { + return nil }
M
adapter/nostr.go
→
adapter/nostr.go
@@ -90,7 +90,7 @@ func (self *NostrAdapter) Fetch(etype string, ids []string) error {
return nil } -func (self *NostrAdapter) Do(action string) error { +func (self *NostrAdapter) Do(action string, data []string) error { return nil }
M
cli/cli.go
→
cli/cli.go
@@ -2,6 +2,7 @@ package cli
import ( "encoding/json" + "errors" "io/ioutil" "log"@@ -12,7 +13,11 @@
func Process(args ...string) error { // allocate storage for the settings array var settings []models.Settings - var s models.Settings + var s *models.Settings + + if len(args) < 3 { + return errors.New("CLI requires at least 3 args: ADAPTER ACTION DATA...") + } // get adapter from first arg adapterName := args[0]@@ -30,10 +35,15 @@ return err
} for _, x := range settings { if x.Nickname == adapterName { - s = x + s = &x break } } + + if s == nil { + return errors.New("given adapter " + adapterName + " is not in the config file") + } + // instantiate adapter with config var a adapter.Adapter switch s.Protocol {@@ -46,10 +56,14 @@ a = &adapter.MisskeyAdapter{}
default: break } - a.Init(s, nil) + a.Init(*s, nil) // process remaining args and execute switch args[0] { + case "fetch": + a.Fetch(args[1], args[2:]) + case "do": + a.Do(args[1], args[2:]) default: log.Print(args) }