Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DaemonCmd = &cli.Command{ Name: "daemon", Usage: "daemon", Flags: []cli.Flag{ &cli.StringFlag{ Name: "files", Usage: "传入要导入的Library目录下的单词文件。例如你可以导入一个文件 damon --files=CET4.txt" + "或者多个文件用逗号隔开,damon --files=CET4.txt,CET6.txt", }, &cli.StringFlag{ Name: "spec", Usage: "推送时间频率控制,默认1小时推送一次短语。自定义比如每5分钟推送一次: @every 5m。" + "其他规则参考库github.com/robfig/cron", }, &cli.IntFlag{ Name: "word-number", Usage: "多少个单词组成一个短语", Value: 5, }, &cli.StringFlag{ Name: "strategy", Usage: "单词选择策略,默认随机random,还可选择 leastRecentlyUsed,最近最少被使用的单词", Value: "random", }, &cli.StringFlag{ Name: "conf", Aliases: []string{"c"}, }, &cli.StringFlag{ Name: "bbdc-cookie", EnvVars: []string{"BBDC_COOKIE"}, }, &cli.StringFlag{ Name: "proxy-url", EnvVars: []string{"PROXY_URI"}, }, }, Action: func(cctx *cli.Context) error { settings, err := conf.GetConf(cctx.String("conf")) if err != nil { return err } generator, err := gpt3.NewClient(settings.GptToken, cctx.String("proxy-url")) if err != nil { return err } var collectors []collector.Collector bbcdCookie := cctx.String("bbdc-cookie") if bbcdCookie != "" { collectors = append(collectors, bbdc.New(bbcdCookie)) } files := "CET4.txt" if cctx.String("files") != "" { files = cctx.String("files") } collectors = append(collectors, file.New(files)) importer := collector.NewImporter(collectors...) strategy := selector.Random if cctx.String("strategy") == string(selector.LeastRecentlyUsed) { strategy = selector.LeastRecentlyUsed } s := selector.New(strategy, selector.WithWordNumber(cctx.Int("word-number"))) n := notify.New(settings.Senders()) core := core.New(generator, importer, s, n, core.WithSpec(cctx.String("spec"))) return core.Run() }, }
View Source
var GamesCmd = &cli.Command{
Name: "games",
Usage: "import your own words",
Subcommands: []*cli.Command{
wordChainCmd,
},
}
View Source
var GenCmd = &cli.Command{ Name: "gen", Usage: "offline deals", Action: func(context *cli.Context) error { outPath := "dao/query" g := gen.NewGenerator(gen.Config{ OutPath: outPath, OutFile: outPath + "/query.go", }) g.UseDB(db.Get()) g.GenerateAllTable() g.ApplyBasic(model.Word{}, model.WordPhrase{}, model.Phrase{}) g.Execute() return nil }, }
View Source
var ImportCmd = &cli.Command{ Name: "import", Usage: "import your own words", Action: func(context *cli.Context) error { return nil }, }
ImportCmd todo import your own words
View Source
var PhraseCmd = &cli.Command{ Name: "phrase", Usage: "Generate phrases directly", Flags: []cli.Flag{ &cli.StringFlag{ Name: "conf", Aliases: []string{"c"}, }, &cli.StringFlag{ Name: "proxy-url", EnvVars: []string{"PROXY_URL"}, }, }, Action: func(cctx *cli.Context) error { req := cctx.Args().Get(0) if req == "" { return errors.New("please input your words") } conf, err := conf.GetConf(cctx.String("c")) if err != nil { return err } client, err := gpt3.NewClient(conf.GptToken, cctx.String("proxy-url")) if err != nil { return err } phrase, err := client.Generate(cctx.Context, strings.Split(req, ",")) if err != nil { return err } n := notify.New(conf.Senders()) n.Notify(base.New("", phrase)) n.Wait() logging.Infof("Successfully generated a short phrase") return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.