group_helper/message/replace.go

19 lines
719 B
Go
Raw Permalink Normal View History

package message
import (
"git.dragon-labs.de/alphyron/group_helper/models"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
"strconv"
"strings"
)
func ReplaceMessage(message string, user *tgbotapi.User, group *models.Group) string {
message = strings.Replace(message, "{{user.firstname}}", user.FirstName, -1)
message = strings.Replace(message, "{{user.lastname}}", user.LastName, -1)
message = strings.Replace(message, "{{user.username}}", user.UserName, -1)
message = strings.Replace(message, "{{user.name}}", user.UserName, -1)
message = strings.Replace(message, "{{user.id}}", strconv.Itoa(user.ID), -1)
message = strings.Replace(message, "{{group.rules}}", group.Rules, -1)
return message
}