mirror of
https://github.com/HugeFrog24/go-telegram-bot.git
synced 2026-03-02 00:14:34 +00:00
27 lines
521 B
Go
27 lines
521 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
MemorySize int `json:"memory_size"`
|
|
MessagePerHour int `json:"messages_per_hour"`
|
|
MessagePerDay int `json:"messages_per_day"`
|
|
TempBanDuration string `json:"temp_ban_duration"`
|
|
}
|
|
|
|
func loadConfig(filename string) (Config, error) {
|
|
var config Config
|
|
file, err := os.Open(filename)
|
|
if err != nil {
|
|
return config, err
|
|
}
|
|
defer file.Close()
|
|
|
|
decoder := json.NewDecoder(file)
|
|
err = decoder.Decode(&config)
|
|
return config, err
|
|
}
|