fix: issues

This commit is contained in:
Rogee
2024-09-02 16:20:28 +08:00
parent 73ce8585bb
commit 772421c40d
4 changed files with 12 additions and 4 deletions

View File

@@ -17,6 +17,9 @@ type ChannelConfig struct {
}
func NewChannelConfig(channelID int64) *ChannelConfig {
if channelID == 0 {
panic("channel id is required")
}
return &ChannelConfig{ID: channelID}
}
@@ -53,7 +56,7 @@ func (c *ChannelConfig) file(_ context.Context) (string, error) {
// if file not exists then create it
if _, err := os.Stat(channelConfigFile); os.IsNotExist(err) {
// create config file
data, _ := json.Marshal(&ChannelConfig{ID: channelID})
data, _ := json.Marshal(c)
if err := os.WriteFile(channelConfigFile, data, 0o644); err != nil {
return "", errors.Wrap(err, "write channel config")
}