Support message placeholders and configuration of message
This commit is contained in:
parent
00377f7670
commit
05e12f4436
10
main.go
10
main.go
|
@ -21,10 +21,14 @@ var (
|
||||||
func setupConfiguration() {
|
func setupConfiguration() {
|
||||||
viper.SetDefault("prohibitedPhrases", "")
|
viper.SetDefault("prohibitedPhrases", "")
|
||||||
viper.SetDefault("channels", "")
|
viper.SetDefault("channels", "")
|
||||||
|
viper.SetDefault("message", "Hi {username}, you've posted a message that was automatically removed for matching a filter. If you need help, please use the correct channel.")
|
||||||
|
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
viper.SetConfigName("ottomate")
|
viper.SetConfigName("ottomate")
|
||||||
|
viper.AddConfigPath("/etc/ottomate/")
|
||||||
|
viper.AddConfigPath("$HOME/.ottomate")
|
||||||
|
viper.AddConfigPath(".")
|
||||||
|
|
||||||
viper.ReadInConfig()
|
viper.ReadInConfig()
|
||||||
}
|
}
|
||||||
|
@ -154,7 +158,11 @@ func messageCreate(e *gateway.MessageCreateEvent) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = s.SendText(ch.ID, "")
|
message := viper.GetString("message")
|
||||||
|
|
||||||
|
replacer := strings.NewReplacer("{username}", e.Author.Username, "{message}", e.Content)
|
||||||
|
|
||||||
|
_, err = s.SendText(ch.ID, replacer.Replace(message))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Unable to send message
|
// Unable to send message
|
||||||
|
|
Loading…
Reference in New Issue