group_helper/models/group.go

45 lines
1.6 KiB
Go

package models
type Group struct {
ID uint64 `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;"`
AdminGroupID uint64 `gorm:"column:admin_group_id"`
ControlledGroups []*Group `gorm:"foreignkey:admin_group_id"`
}
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
}
}