diff --git a/discordfs.go b/discordfs.go index 6d93f74..cef4ef1 100644 --- a/discordfs.go +++ b/discordfs.go @@ -1,7 +1,6 @@ package main import ( - "context" "flag" "log" "os" @@ -27,12 +26,12 @@ func main() { } conf := &struct { - Address string - Auth types.Auth - User string `Discord login (email address)` - Logdir types.Logdir - Listen types.ListenAddress - }{"discordapp.com", "password", "", "none", "none"} + Address string `altid:"address,no_prompt"` + Auth types.Auth `altid:"auth,Authentication method to use"` + User string `altid:"user,prompt:Discord login (email address)"` + Logdir types.Logdir `altid:"logdir,no_prompt"` + Listen types.ListenAddress `altid:"listen_address,no_prompt"` + }{"discordapp.com", "password", "", "", ""} if *setup { if e := config.Create(conf, *srv, "", *debug); e != nil { @@ -51,9 +50,7 @@ func main() { log.Fatalf("Error initiating discord session %v", err) } - ctx, cancel := context.WithCancel(context.Background()) - - s := &server{cancel: cancel} + s := &server{} dg.AddHandler(s.ready) dg.AddHandler(s.msgCreate) dg.AddHandler(s.msgUpdate) @@ -68,7 +65,7 @@ func main() { dg.AddHandler(s.guildMemUpd) dg.AddHandler(s.userUpdate) - ctrl, err := fs.CreateCtlFile(ctx, s, string(conf.Logdir), *mtpt, *srv, "feed", *debug) + ctrl, err := fs.New(s, string(conf.Logdir), *mtpt, *srv, "feed", *debug) if err != nil { log.Fatal(err) } diff --git a/go.mod b/go.mod index c5207e3..23d3ac5 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module github.com/altid/discordfs go 1.14 require ( - github.com/altid/libs v0.0.6 + github.com/altid/libs v0.1.6-final github.com/bwmarrin/discordgo v0.20.2 ) diff --git a/go.sum b/go.sum index 59ef927..2005292 100644 --- a/go.sum +++ b/go.sum @@ -1,46 +1,19 @@ 9fans.net/go v0.0.2 h1:RYM6lWITV8oADrwLfdzxmt8ucfW6UtP9v1jg4qAbqts= 9fans.net/go v0.0.2/go.mod h1:lfPdxjq9v8pVQXUMBCx5EO5oLXWQFlKRQgs1kEkjoIM= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/altid/libs v0.0.5-alpha h1:kvcrk+mN8x4nOQiTXi4q3z9MaITk5DmrRwx28OfGNek= -github.com/altid/libs v0.0.5-alpha/go.mod h1:todXfpc6fK7UL83IaQYYFFmDDN8fRHpq62wmfiUhs70= -github.com/altid/libs v0.0.6 h1:aWhtU5m5RI8Jri/EtUYgrPFJyj8P9g4q/hWj1vi+eyw= -github.com/altid/libs v0.0.6/go.mod h1:XX9tfc6JC3aXrRkDpXxDqfLNHLSo8l5RG8UWMwXjD68= -github.com/altid/server v0.0.0 h1:HrflibdS+1cXPa4CL5nwai6g1vWYXwwM8pMzVGLbVY4= +github.com/altid/libs v0.1.6-final h1:vx13TtsQOuSauY4l5pjosnQgfBUTXk1505Xu11iUwnM= +github.com/altid/libs v0.1.6-final/go.mod h1:XX9tfc6JC3aXrRkDpXxDqfLNHLSo8l5RG8UWMwXjD68= github.com/bwmarrin/discordgo v0.20.2 h1:nA7jiTtqUA9lT93WL2jPjUp8ZTEInRujBdx1C9gkr20= github.com/bwmarrin/discordgo v0.20.2/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q= +github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/knieriem/g v0.1.2/go.mod h1:zYg1CmnYJBZ34OwOIRIqoBsvVxbGRjgE4kLQrHz7DBg= -github.com/lionkov/go9p v0.0.0-20180620135904-0a603dd6808a/go.mod h1:Nbrxd4FljESFB/bUvzT5xm1VNO2VfzMKSIv4L++4J4U= -github.com/lionkov/go9p v0.0.0-20190125202718-b4200817c487/go.mod h1:Nbrxd4FljESFB/bUvzT5xm1VNO2VfzMKSIv4L++4J4U= github.com/mischief/ndb v0.0.0-20131219140803-a27299009a40 h1:ip5r+E7C1yo2glg9M2mzsI498AxAGXgIX9hfBbeVjJQ= github.com/mischief/ndb v0.0.0-20131219140803-a27299009a40/go.mod h1:dumNHRNWG/onXBRnVYKT4aAqdFDvZzOu5hGYBPmOf/A= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20200222142934-3c8601c510d0/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/handlers.go b/handlers.go index 63cda53..610abfa 100644 --- a/handlers.go +++ b/handlers.go @@ -5,7 +5,6 @@ import ( "path" "runtime" - "github.com/altid/libs/fs" "github.com/altid/libs/markup" "github.com/bwmarrin/discordgo" ) @@ -96,14 +95,7 @@ func (s *server) chanCreate(ds *discordgo.Session, event *discordgo.ChannelCreat return } - input, err := fs.NewInput(s, workdir, name, *debug) - if err != nil { - errorWrite(s.c, err) - return - } - - defer s.c.Event(path.Join(workdir, name, "input")) - go input.Start() + s.c.Input(name) } func (s *server) chanUpdate(ds *discordgo.Session, event *discordgo.ChannelUpdate) { diff --git a/server.go b/server.go index 4783d10..a77fb25 100644 --- a/server.go +++ b/server.go @@ -1,7 +1,6 @@ package main import ( - "context" "errors" "path" "strings" @@ -14,7 +13,6 @@ import ( var workdir = path.Join(*mtpt, *srv) type server struct { - cancel context.CancelFunc c *fs.Control dg *discordgo.Session guilds []*discordgo.Guild @@ -61,10 +59,10 @@ func (s *server) Handle(bufname string, l *markup.Lexer) error { // TODO(halfwit) We want to allow markup as well case markup.ErrorText: case markup.URLLink, markup.URLText, markup.ImagePath, markup.ImageLink, markup.ImageText: - case markup.ColorText, markup.ColorTextBold: + case markup.ColorText, markup.ColorTextBold, markup.ColorTextStrong: case markup.BoldText: case markup.EmphasisText: - case markup.UnderlineText: + case markup.StrongText: default: m.Write(i.Data) }