Compare commits

...
Sign in to create a new pull request.
Author SHA1 Message Date
2f1a9c9207
Updated scripture. 2026-10-19 23:59:10 -06:00
dcf7728485
Reset scripture.json. 2026-10-17 22:06:01 -06:00
999eea1919
Reset offset to 0. 2026-10-17 22:00:50 -06:00
22e562d5be
Added verses. 2026-10-11 15:06:59 -06:00
34eaa9c298
Bump offset. 2026-10-11 15:00:04 -06:00
4dce56b104
Bump offset and add scripture. 2026-10-05 14:33:49 -06:00
60dfec9b65
Fixed using port from config. 2026-10-02 15:46:04 -06:00
a9c58cba45
Updated to webhooks. 2026-10-02 15:31:53 -06:00
295ac3169d
Fix cron. 2026-10-01 20:36:59 -06:00
f05cba0728
Added verses and bumped offset. 2026-09-29 23:37:18 -06:00
4638688b6b
Bump offset and remove borderline exortation.
It's important, but I want the scripture to be mostly uplifting rather
than not.
2026-09-26 11:16:43 -06:00
7af0d5ce1d
Added passages. 2026-09-23 22:07:20 -06:00
7afe1f94b0
Added missing struct tag. 2026-09-23 21:39:07 -06:00
cb155c0334
Bump offset. 2026-09-23 21:38:53 -06:00
7604da1700
Current bot offset. 2026-09-18 19:36:30 -06:00
a9cec81ee3
Added more scriptures to prototype data source. 2026-09-15 22:22:12 -06:00
7b6ab7444d
Merge remote-tracking branch 'refs/remotes/origin/prototype' into prototype 2026-09-15 16:31:31 -06:00
8d3ffc791b
Current offset. 2026-09-15 16:30:57 -06:00
5 changed files with 59 additions and 44 deletions

View file

@ -2,6 +2,9 @@ package main
import (
"context"
"net"
"net/http"
"net/url"
"os"
"os/signal"
"slices"
@ -55,6 +58,14 @@ type Bot struct {
cancel context.CancelFunc
}
type interceptor struct {
mux *http.ServeMux
}
func (i *interceptor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL)
}
func NewBot() (bot *Bot, errch chan error, err error) {
bot = &Bot{}
@ -74,6 +85,21 @@ func NewBot() (bot *Bot, errch chan error, err error) {
}
bot.Bot = b
u, err := url.Parse(conf.Service.Webhook.URI)
if err != nil {
panic(fmt.Sprintf("malformed URI: %s", conf.Service.Webhook.URI))
}
err = b.SetWebhook(ctx, &telego.SetWebhookParams{
URL: conf.Service.Webhook.URI,
SecretToken: b.SecretToken(),
})
if err != nil {
panic(fmt.Sprintf("failed setting up webhook: %w", err))
}
info, err := b.GetWebhookInfo(ctx)
fmt.Println(info, err)
c := cron.New()
c.AddFunc(fmt.Sprintf("TZ=%s %s",
conf.System.TimeZone,
@ -81,10 +107,23 @@ func NewBot() (bot *Bot, errch chan error, err error) {
c.Start()
bot.Cron = c
updates, err := b.UpdatesViaLongPolling(ctx, nil)
/*updates, err := b.UpdatesViaLongPolling(ctx, nil)
if err != nil {
fmt.Errorf("failed receiving updates: %s", err)
}*/
mux := http.NewServeMux()
updates, err := b.UpdatesViaWebhook(ctx,
telego.WebhookHTTPServeMux(mux, u.Path, b.SecretToken()))
/*bot.Handler, err = th.NewBotHandler(b, updates)
if err != nil {
fmt.Errorf("failed configuring handlers: %s", err)
}
bot.AttachHandlers()*/
go func() {
_ = http.ListenAndServe(net.JoinHostPort(conf.Service.Webhook.Host, conf.Service.Webhook.Port), &interceptor{mux})
}()
bot.Handler, err = th.NewBotHandler(b, updates)
if err != nil {
fmt.Errorf("failed configuring handlers: %s", err)
@ -97,6 +136,7 @@ func NewBot() (bot *Bot, errch chan error, err error) {
func (b *Bot) AttachHandlers() {
fmt.Println("add handlers")
b.Handler.HandleMessage(func(ctx *th.Context, message telego.Message) error {
fmt.Println("handling message")
if !slices.Contains(b.Settings.Chat.Channels, message.Chat.ID) {
fmt.Println("adding chat:", message.Chat.ID)
b.Settings.Chat.Channels = append(b.Settings.Chat.Channels, message.Chat.ID)

View file

@ -27,8 +27,8 @@ type Scripture struct {
}
type ScriptureStore struct {
Verses []*Scripture
Offset int `json:"offset"`
Verses []*Scripture `json:"verses"`
Offset int `json:"offset"`
}
func (s *ScriptureStore) GetVerse() *Scripture {

View file

@ -43,7 +43,7 @@ type Service struct {
type Webhook struct {
URI string `toml:"uri"`
Port int `toml:"port"`
Port string `toml:"port"`
Host string `toml:"host"`
}

View file

@ -1,60 +1,35 @@
{
"verses": [
{
"verse": "Genesis 1:1",
"verse": "Psalm 46:10",
"translation": "BSB",
"content": "In the beginning, God created the heavens and the earth."
"content": "Be still and know that I am God; I will be exalted among the nations, I will be exalted over the earth."
},
{
"verse": "John 6:36",
"verse": "Romans 13:8",
"translation": "BSB",
"content": "Jesus answered, \"I am the bread of life. Whoever comes to Me will never hunger, and whoever believes in Me will never thirst.\""
"content": "Be indebted to no one, except to one another in love. For he who loves his neighbor has fulfilled the law."
},
{
"verse": "Psalm 62:1",
"verse": "Philippians 4:4-5",
"translation": "BSB",
"content": "In God alone my soul finds rest; my salvation comes from Him."
"content": "4Rejoice in the Lord always. I will say it again: Rejoice! 5Let your gentleness be apparent to all. The Lord is near."
},
{
"verse": "Romans 12:12",
"verse": "Micah 7:7",
"translation": "BSB",
"content": "Be joyful in hope, patient in affliction, persistent in prayer."
"content": "But as for me, I will look to the LORD; I will wait for the God of my salvation. My God will hear me."
},
{
"verse": "Psalm 45:6",
"verse": "2 Corinthians 7:10",
"translation": "BSB",
"content": "Your throne, O God, endures forever and ever, and justice is the scepter of Your kingdom."
"content": "Godly sorrow brings repentance that leads to salvation without regret, but worldly sorrow brings death."
},
{
"verse": "Revelation 21:4",
"verse": "Psalm 59:16",
"translation": "BSB",
"content": "'He will wipe away every tear from their eyes,' and there will be no more death or mourning or crying or pain, for the former things have passed away."
},
{
"verse": "James 1:17",
"translation": "BSB",
"content": "Every good and perfect gift is from above, coming down from the Father of the heavenly lights, with whom there is no change or shifting shadow."
},
{
"verse": "Job 42:2",
"translation": "BSB",
"content": "I know that You can do all things and that no plan of Yours can be thwarted."
},
{
"verse": "Psalm 33:6",
"translation": "BSB",
"content": "By the word of the LORD the heavens were made, and all the stars by the breath of His mouth."
},
{
"verse": "1 Corinthians 15:54",
"translation": "BSB",
"content": "When the perishable has been clothed with the imperishable and the mortal with immortality, then the saying that is written will come to pass: \"Death has been swallowed up in victory.\""
},
{
"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."
"content": "But I will sing of Your strength and proclaim Your loving devotion in the morning. For You are my fortress, my refuge in times of trouble."
}
],
"offset": 2
}
"offset": 1
}

View file

@ -3,7 +3,7 @@ base_url = "https://bible.helloao.org/api/"
[daily_scripture]
user_submitted = true
schedule = "* 8 * * *"
schedule = "0 8 * * *"
rotation = "data/daily/rotation"
user = "data/daily/user"