1
0
mirror of https://github.com/Rudi9719/kbtui.git synced 2026-03-31 02:53:32 +00:00
Files
kbtui/cmdUploadFile.go
Gregory Rudolph dfe0f0b27a Le-what?
2019-10-03 12:10:14 -04:00

36 lines
741 B
Go

// +build !rm_basic_commands allcommands uploadcmd
package main
import (
"fmt"
)
func init() {
command := Command{
Cmd: []string{"upload", "u"},
Description: "$filePath $fileName - Upload file with optional name",
Help: "",
Exec: cmdUploadFile,
}
RegisterCommand(command)
}
func cmdUploadFile(cmd []string) {
filePath := cmd[1]
var fileName string
if len(cmd) == 3 {
fileName = cmd[2]
} else {
fileName = ""
}
chat := k.NewChat(channel)
_, err := chat.Upload(fileName, filePath)
if err != nil {
printToView("Feed", fmt.Sprintf("There was an error uploading %s to %s", filePath, channel.Name))
} else {
printToView("Feed", fmt.Sprintf("Uploaded %s to %s", filePath, channel.Name))
}
}