justusbot/internal/app/app.go

61 lines
966 B
Go

package app
import (
"context"
"os"
"github.com/mymmrac/telego"
th "github.com/mymmrac/telego/telegohandler"
"github.com/robfig/cron/v3"
"code.destrealm.net/zancarius/justusbot/internal/settings"
"go.destrealm.net/vfs"
)
type app struct {
ds *datastore
settings *settings.Settings
cron *cron.Cron
}
func NewApp(conf string) (*app, error) {
a := &app{}
cwd, err := os.Getwd()
if err != nil {
return nil, err
}
if root, err := vfs.NewVFS(cwd); err == nil {
a.ds, err = newDataStore(root)
if s, err := settings.LoadSettings(conf, root); err != nil {
return nil, err
} else {
a.settings = s
}
} else {
return nil, err
}
return a, nil
}
func (a *app) Start() error {
return nil
}
type chats struct {
}
type bot struct {
settings *settings.Settings
tgbot *telego.Bot
handler *th.BotHandler
ctx context.Context
cancel context.CancelFunc
chats *chats
}
func newBot() (*bot, error) {
return nil, nil
}