mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
27 lines
657 B
Go
27 lines
657 B
Go
|
package handler
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"m1k1o/neko/internal/types"
|
||
|
"m1k1o/neko/internal/types/event"
|
||
|
"m1k1o/neko/internal/types/message"
|
||
|
"m1k1o/neko/internal/utils"
|
||
|
)
|
||
|
|
||
|
func (h *MessageHandler) refresh(session types.Session) error {
|
||
|
if !(h.state.FileTransferEnabled() && session.Admin() || h.state.UnprivFileTransferEnabled()) {
|
||
|
return errors.New(session.Member().Name + " tried to refresh file list when they can't")
|
||
|
}
|
||
|
|
||
|
files, err := utils.ListFiles(h.state.FileTransferPath())
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return session.Send(
|
||
|
message.FileList{
|
||
|
Event: event.FILETRANSFER_LIST,
|
||
|
Cwd: h.state.FileTransferPath(),
|
||
|
Files: *files,
|
||
|
})
|
||
|
}
|