feat: download telegraph images , close #5

This commit is contained in:
krau
2025-03-22 11:52:43 +08:00
parent 19efab0665
commit 3e3a320672
16 changed files with 333 additions and 40 deletions

View File

@@ -21,10 +21,12 @@ func initCache() {
gob.Register(types.File{})
gob.Register(tg.InputDocumentFileLocation{})
gob.Register(tg.InputPhotoFileLocation{})
gob.Register(tg.Message{})
gob.Register(tg.PeerUser{})
Cache = &CommonCache{cache: freecache.NewCache(10 * 1024 * 1024)}
}
func (c *CommonCache) Get(key string, value *types.File) error {
func (c *CommonCache) Get(key string, value any) error {
c.mu.RLock()
defer c.mu.RUnlock()
data, err := Cache.cache.Get([]byte(key))
@@ -39,7 +41,7 @@ func (c *CommonCache) Get(key string, value *types.File) error {
return nil
}
func (c *CommonCache) Set(key string, value *types.File, expireSeconds int) error {
func (c *CommonCache) Set(key string, value any, expireSeconds int) error {
c.mu.Lock()
defer c.mu.Unlock()
var buf bytes.Buffer