group_helper/models/group.go

43 lines
1.5 KiB
Go
Raw Normal View History

package models
type Group struct {
ID uint `gorm:"primary_key"`
GroupID int64
Size int
UserJoinMessage string `gorm:"column:msg_user_join;type:text"`
UserVerifiedMessage string `gorm:"column:msg_user_verified;type:text"`
UserLeaveMessage string `gorm:"column:msg_user_leave;type:text"`
UserKickMessage string `gorm:"column:msg_user_kick;type:text"`
ForbidWriting bool `gorm:"column:forbid_writing"`
OnlineCheck bool `gorm:"column:online_check"`
KickCooldown int `gorm:"column:kick_cooldown"`
Users []*User `gorm:"many2many:GroupUser;"`
}
func (Group) TableName() string {
return "Groups"
}
func (group *Group) FillDefaultValues() {
if len(group.UserKickMessage) == 0 {
group.UserKickMessage = "[{{user.firstname}} {{user.lastname}}](tg://user?id={{user.id}}) did not verify!\n They are going to leave us."
}
if len(group.UserJoinMessage) == 0 {
group.UserJoinMessage = "[{{user.firstname}} {{user.lastname}}](tg://user?id={{user.id}}) joined us. Hello and Welcome! Please verify that you are not a bot."
}
if len(group.UserLeaveMessage) == 0 {
group.UserLeaveMessage = "[{{user.firstname}} {{user.lastname}}](tg://user?id={{user.id}}) left us."
}
if len(group.UserVerifiedMessage) == 0 {
group.UserVerifiedMessage = "[{{user.firstname}} {{user.lastname}}](tg://user?id={{user.id}}) is now permitted to stay in the chat!"
}
if group.KickCooldown == 0 {
group.KickCooldown = 5
}
}