This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.go
66 lines (54 loc) · 1.74 KB
/
app.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"context"
"github.com/fatih/color"
config "github.com/asunlabs/owlly/config"
core "owlly/v2/core"
// account "github.com/asunlabs/owlly/core/account"
bot "owlly/v2/core/bot"
)
// ==================================================================== //
// ========================== Init Wails app ========================== //
// ==================================================================== //
type App struct {
ctx context.Context
}
func NewApp() *App {
return &App{}
}
// @dev startup is called when the app starts. The context is saved so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
// connect DB
if ok, _ := config.ConnectDB(); ok {
color.Green("Setup.go: DB connected")
} else {
color.Red("Setup.go: DB connection failed")
}
// init listener for Go <=> JS
EventListener(ctx)
}
// ==================================================================== //
// ========================== Init Owlly app ========================== //
// ==================================================================== //
type Owlly struct{}
func NewOwlly() *Owlly {
return &Owlly{}
}
// @dev Go/Js binding
func (o *Owlly) InitEnvBot() bool {
if ok := core.InitEnvBot_(); ok {
return true
}
return false
}
func (o *Owlly) CreateEnvBotConfig(botConfig config.ModelEnvBot) {
bot.CreateEnvBotConfig(botConfig)
}
// ==================================================================== //
// ======================= Wails event listener ======================= //
// ==================================================================== //
// @dev runtime context should be obtained from the OnStartup or OnDomReady hooks.
func EventListener(ctx context.Context) {
bot.HandleSlackUpdate(ctx)
}