-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
50 lines (37 loc) · 926 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//go:build embedconfig
package main
import (
"fmt"
"log"
_ "embed"
"github.com/kotet/akizuki-bot/pkg/akizuki"
"gopkg.in/yaml.v2"
)
//go:embed config.yaml
var configYAML []byte
type Config struct {
Mastodon akizuki.DefaultTootConfig `yaml:"mastodon"`
ScreenshotOne akizuki.ScreenShotOneConfig `yaml:"screenshotone"`
}
func main() {
var config Config
err := yaml.Unmarshal(configYAML, &config)
if err != nil {
log.Fatalln(err.Error())
}
bot, err := akizuki.NewBot()
if err != nil {
log.Fatalln(err.Error())
}
toot, err := akizuki.DefaultToot(config.Mastodon)
if err != nil {
log.Fatalln(err.Error())
}
shot := akizuki.ScreenShotOneTakeScreenShot(config.ScreenshotOne)
bot.SetFormat(
func(item *akizuki.Item) string {
return fmt.Sprintf("[%v] %v %v\n%v", item.ItemCode, item.Name, item.Price, item.Url)
},
).SetToot(toot).SetTakeScreenshot(shot)
fmt.Println(bot.RunOnce())
}