mirror of
https://github.com/HugeFrog24/go-telegram-bot.git
synced 2026-03-02 00:14:34 +00:00
Multibot finished
This commit is contained in:
24
models.go
24
models.go
@@ -6,8 +6,29 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type BotModel struct {
|
||||
gorm.Model
|
||||
Identifier string `gorm:"uniqueIndex"` // Renamed from ID to Identifier
|
||||
Name string
|
||||
Configs []ConfigModel `gorm:"foreignKey:BotID;constraint:OnDelete:CASCADE"`
|
||||
Users []User `gorm:"foreignKey:BotID;constraint:OnDelete:CASCADE"` // Added foreign key
|
||||
Messages []Message `gorm:"foreignKey:BotID;constraint:OnDelete:CASCADE"`
|
||||
}
|
||||
|
||||
type ConfigModel struct {
|
||||
gorm.Model
|
||||
BotID uint `gorm:"index"`
|
||||
MemorySize int `json:"memory_size"`
|
||||
MessagePerHour int `json:"messages_per_hour"`
|
||||
MessagePerDay int `json:"messages_per_day"`
|
||||
TempBanDuration string `json:"temp_ban_duration"`
|
||||
SystemPrompts string `json:"system_prompts"` // Consider JSON string or separate table
|
||||
TelegramToken string `json:"telegram_token"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
gorm.Model
|
||||
BotID uint
|
||||
ChatID int64
|
||||
UserID int64
|
||||
Username string
|
||||
@@ -29,7 +50,8 @@ type Role struct {
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
TelegramID int64 `gorm:"uniqueIndex"`
|
||||
BotID uint `gorm:"index"` // Added foreign key to BotModel
|
||||
TelegramID int64 `gorm:"uniqueIndex"` // Consider composite unique index if TelegramID is unique per Bot
|
||||
Username string
|
||||
RoleID uint
|
||||
Role Role `gorm:"foreignKey:RoleID"`
|
||||
|
||||
Reference in New Issue
Block a user