COde updates
This commit is contained in:
parent
432ee62807
commit
03c5ec07c1
4 changed files with 125 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ type Config struct {
|
|||
TargetChatId *int64 `yaml:"target_chat_id"`
|
||||
EntryMessage string `yaml:"entry_message"`
|
||||
ApprovalMessage string `yaml:"approval_message"`
|
||||
SendApprovalMessage bool `yaml:"send_approval_message"`
|
||||
DeleteRequestAfterDecision bool `yaml:"delete_request_after_decision"`
|
||||
}
|
||||
|
||||
|
|
@ -44,6 +45,7 @@ func (c *Config) CreateConfig() error {
|
|||
TargetChatId: Int64Ptr(0),
|
||||
EntryMessage: "You have requested to join the group, please write a brief message explaining why you want to join.",
|
||||
ApprovalMessage: "",
|
||||
SendApprovalMessage: false,
|
||||
DeleteRequestAfterDecision: false,
|
||||
}
|
||||
|
||||
|
|
@ -52,6 +54,19 @@ func (c *Config) CreateConfig() error {
|
|||
return err
|
||||
}
|
||||
|
||||
// SaveConfig writes the current Config back to config.yaml, overwriting the file.
|
||||
func (c *Config) SaveConfig() error {
|
||||
f, err := os.OpenFile("config.yaml", os.O_WRONLY|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
encoder := yaml.NewEncoder(f)
|
||||
err = encoder.Encode(c)
|
||||
return err
|
||||
}
|
||||
|
||||
// StringPtr returns a pointer to the given string.
|
||||
func StringPtr(s string) *string { return &s }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue