refactor: complete core features

This commit is contained in:
krau
2024-11-09 09:07:00 +08:00
parent fbdfc04ad8
commit 20e06fbf46
14 changed files with 380 additions and 106 deletions

21
types/model.go Normal file
View File

@@ -0,0 +1,21 @@
package types
import (
"gorm.io/gorm"
)
type ReceivedFile struct {
gorm.Model
Processing bool
ChatID int64
MessageID int
ReplyMessageID int
FileName string
}
type User struct {
gorm.Model
UserID int64 `gorm:"uniqueIndex"`
Silent bool
DefaultStorage string
}

View File

@@ -2,6 +2,7 @@ package types
import (
"context"
"fmt"
"github.com/gotd/td/tg"
)
@@ -30,7 +31,7 @@ type Task struct {
Ctx context.Context
Error error
Status TaskStatus
FileName string
File *File
Storage StorageType
StoragePath string
@@ -40,7 +41,11 @@ type Task struct {
}
func (t Task) String() string {
return t.FileName
return fmt.Sprintf("[%d:%d]:%s", t.ChatID, t.MessageID, t.File.FileName)
}
func (t Task) FileName() string {
return t.File.FileName
}
type File struct {