justusbot/internal/bible/types.go

66 lines
1.1 KiB
Go
Raw Normal View History

package bible
2026-09-10 22:31:23 -06:00
import (
"encoding/json"
"os"
)
2026-09-10 22:31:23 -06:00
type Bible struct {
}
type Metadata struct {
}
type Book struct {
}
type Chapter struct {
}
type VerseSpec struct {
2026-09-10 22:31:23 -06:00
}
2026-09-10 22:31:23 -06:00
type Scripture struct {
Verse string
Translation string
Content string
}
type ScriptureStore struct {
Verses []*Scripture
Offset int
}
func (s *ScriptureStore) GetVerse() *Scripture {
if s.Offset < len(s.Verses) {
s.Offset++
return s.Verses[s.Offset]
}
if len(s.Verses) == 1 {
2026-09-10 22:31:23 -06:00
s.Offset = 1
return s.Verses[0]
}
return &Scripture{
Verse: "3 John 11",
Translation: "BSB",
Content: "Beloved, do not imitate what is evil, but what is good. The one who does good is of God; the one who does evil has not seen God.",
}
}
func OpenStore(name string) (*ScriptureStore, error) {
s := &ScriptureStore{}
buf, err := os.ReadFile(name)
if err != nil {
return nil, err
}
err = json.Unmarshal(buf, s)
2026-09-10 22:31:23 -06:00
return s, err
}
func SaveStore(name string, s *ScriptureStore) error {
buf, err := json.Marshal(s)
if err != nil {
return err
}
return os.WriteFile(name, buf, 0o644)
}