1
0
mirror of https://github.com/taigrr/wtf synced 2026-03-30 09:25:17 -07:00

WTF-400 GCal extracted to new config format

This commit is contained in:
Chris Cummer
2019-04-14 12:36:38 -07:00
parent 5e1fdef5d4
commit 12a895b9df
5 changed files with 94 additions and 35 deletions

57
modules/gcal/settings.go Normal file
View File

@@ -0,0 +1,57 @@
package gcal
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
type colors struct {
day string
description string
past string
title string
highlights []interface{}
}
type Settings struct {
colors
common *cfg.Common
conflictIcon string
currentIcon string
displayResponseStatus bool
email string
eventCount int
multiCalendar bool
secretFile string
showDeclined bool
textInterval int
withLocation bool
}
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
localConfig, _ := ymlConfig.Get("wtf.mods.gcal")
settings := Settings{
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
conflictIcon: localConfig.UString("conflictIcon", "🚨"),
currentIcon: localConfig.UString("currentIcon", "🔸"),
displayResponseStatus: localConfig.UBool("displayResponseStatus", true),
email: localConfig.UString("email", ""),
eventCount: localConfig.UInt("eventCount", 10),
multiCalendar: localConfig.UBool("multiCalendar", false),
secretFile: localConfig.UString("secretFile", ""),
showDeclined: localConfig.UBool("showDeclined", false),
textInterval: localConfig.UInt("textInterval", 30),
withLocation: localConfig.UBool("withLocation", true),
}
settings.colors.day = localConfig.UString("colors.day", "forestgreen")
settings.colors.description = localConfig.UString("colors.description", "white")
settings.colors.past = localConfig.UString("colors.past", "gray")
settings.colors.title = localConfig.UString("colors.title", "white")
return &settings
}