mirror of
https://github.com/HugeFrog24/go-telegram-bot.git
synced 2026-03-02 00:14:34 +00:00
MVP
md formatting doesnt work yet Started implementing owner feature Add .gitattributes to enforce LF line endings Temporary commit before merge Updated owner management Updated json and gitignore Proceed with role management Again, CI Fix some lint errors Implemented screening Per-bot API keys implemented Use getRoleByName func Fix unused imports Upgrade actions rm unused function Upgrade action Fix unaddressed errors
This commit is contained in:
13
models.go
Executable file → Normal file
13
models.go
Executable file → Normal file
@@ -11,7 +11,7 @@ type BotModel struct {
|
||||
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
|
||||
Users []User `gorm:"foreignKey:BotID;constraint:OnDelete:CASCADE"` // Associated users
|
||||
Messages []Message `gorm:"foreignKey:BotID;constraint:OnDelete:CASCADE"`
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ type ConfigModel struct {
|
||||
TempBanDuration string `json:"temp_ban_duration"`
|
||||
SystemPrompts string `json:"system_prompts"` // Consider JSON string or separate table
|
||||
TelegramToken string `json:"telegram_token"`
|
||||
Active bool `json:"active"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
@@ -53,9 +54,15 @@ type Role struct {
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
BotID uint `gorm:"index"` // Added foreign key to BotModel
|
||||
TelegramID int64 `gorm:"uniqueIndex"` // Consider composite unique index if TelegramID is unique per Bot
|
||||
BotID uint `gorm:"index"` // Foreign key to BotModel
|
||||
TelegramID int64 `gorm:"uniqueIndex;not null"` // Unique per user
|
||||
Username string
|
||||
RoleID uint
|
||||
Role Role `gorm:"foreignKey:RoleID"`
|
||||
IsOwner bool `gorm:"default:false"` // Indicates if the user is the owner
|
||||
}
|
||||
|
||||
// Compound unique index to ensure only one owner per bot
|
||||
func (User) TableName() string {
|
||||
return "users"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user