refactor to fmt.Sprintf()
This commit is contained in:
@@ -3,7 +3,6 @@ package bot
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (b *Bot) runStop(ctx context.Context) {
|
func (b *Bot) runStop(ctx context.Context) {
|
||||||
@@ -49,15 +48,10 @@ func (b *Bot) getOption(ctx context.Context, name string) {
|
|||||||
|
|
||||||
value := cfg.Get(name)
|
value := cfg.Get(name)
|
||||||
if value == "" {
|
if value == "" {
|
||||||
var msg strings.Builder
|
msg := fmt.Sprintf("`%s` is not set, kupo.\n"+
|
||||||
msg.WriteString(fmt.Sprintf("`%s` is not set, kupo.", name))
|
|
||||||
msg.WriteString("\n")
|
|
||||||
msg.WriteString(fmt.Sprintf(
|
|
||||||
"To set it, send a `%s %s VALUE` command.",
|
"To set it, send a `%s %s VALUE` command.",
|
||||||
b.prefix,
|
name, b.prefix, name)
|
||||||
name,
|
b.SendNotice(ctx, evt.RoomID, msg)
|
||||||
))
|
|
||||||
b.SendNotice(ctx, evt.RoomID, msg.String())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,15 +59,10 @@ func (b *Bot) getOption(ctx context.Context, name string) {
|
|||||||
value = value + "@" + b.domain
|
value = value + "@" + b.domain
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg strings.Builder
|
msg := fmt.Sprintf("`%s` of this room is `%s`\n"+
|
||||||
msg.WriteString(fmt.Sprintf("`%s` of this room is `%s`", name, value))
|
|
||||||
msg.WriteString("\n")
|
|
||||||
msg.WriteString(fmt.Sprintf(
|
|
||||||
"To set it to a new value, send a `%s %s VALUE` command.",
|
"To set it to a new value, send a `%s %s VALUE` command.",
|
||||||
b.prefix,
|
name, value, b.prefix, name)
|
||||||
name,
|
b.SendNotice(ctx, evt.RoomID, msg)
|
||||||
))
|
|
||||||
b.SendNotice(ctx, evt.RoomID, msg.String())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bot) setOption(ctx context.Context, name, value string) {
|
func (b *Bot) setOption(ctx context.Context, name, value string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user