mirror of
https://onedev.fprog.nl/goscreenshot
synced 2026-02-15 20:43:42 +01:00
Added interval to json config.
This commit is contained in:
parent
2c4cd0c705
commit
855d7bfdb2
9
main.go
9
main.go
|
|
@ -13,7 +13,7 @@ import (
|
|||
const screenshot_path = "screenshot.png"
|
||||
const config_path = "config.json"
|
||||
|
||||
func GetConfig() (string, string, error) {
|
||||
func GetConfig() (string, string, string, error) {
|
||||
configFile, err := os.ReadFile(config_path)
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -33,8 +33,9 @@ func GetConfig() (string, string, error) {
|
|||
|
||||
token := config["token"].(string)
|
||||
channelId := config["channelId"].(string)
|
||||
interval := config["interval"].(string)
|
||||
|
||||
return token, channelId, nil
|
||||
return token, channelId, interval, nil
|
||||
}
|
||||
|
||||
func SendScreenshots(discord *discordgo.Session, channelId string, sleepDuration time.Duration) {
|
||||
|
|
@ -86,7 +87,7 @@ func SendScreenshots(discord *discordgo.Session, channelId string, sleepDuration
|
|||
}
|
||||
|
||||
func main() {
|
||||
token, channelId, err := GetConfig()
|
||||
token, channelId, interval, err := GetConfig()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -98,7 +99,7 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
sleepDuration, err := time.ParseDuration("3s")
|
||||
sleepDuration, err := time.ParseDuration(interval)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue