mirror of
https://github.com/Rudi9719/kbtui.git
synced 2026-03-22 08:47:24 +00:00
Yeet haw, downloads are working and some edits were made to reactions
This commit is contained in:
32
cmdDownload.go
Normal file
32
cmdDownload.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// +build !rm_basic_commands allcommands downloadcmd
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
command := Command{
|
||||||
|
Cmd: []string{"download", "d"},
|
||||||
|
Description: "Download a file",
|
||||||
|
Help: "",
|
||||||
|
Exec: cmdDownloadFile,
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterCommand(command)
|
||||||
|
}
|
||||||
|
|
||||||
|
func cmdDownloadFile(cmd []string) {
|
||||||
|
messageID, _ := strconv.Atoi(cmd[1])
|
||||||
|
fileName := cmd[2]
|
||||||
|
|
||||||
|
chat := k.NewChat(channel)
|
||||||
|
_, err := chat.Download(messageID, fmt.Sprintf("%s/%s", downloadPath, fileName))
|
||||||
|
if err != nil {
|
||||||
|
printToView("Feed", fmt.Sprintf("There was an error downloading %s from %s", fileName, channel.Name))
|
||||||
|
} else {
|
||||||
|
printToView("Feed", fmt.Sprintf("Downloaded %s from %s", fileName, channel.Name))
|
||||||
|
}
|
||||||
|
}
|
||||||
17
main.go
17
main.go
@ -124,15 +124,7 @@ func formatOutput(api keybase.ChatAPI) string {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func downloadFile(messageID int, fileName string) {
|
|
||||||
chat := k.NewChat(channel)
|
|
||||||
_, err := chat.Download(messageID, fmt.Sprintf("%s/%s", downloadPath, fileName))
|
|
||||||
if err != nil {
|
|
||||||
printToView("Feed", fmt.Sprintf("There was an error downloading %s from %s", fileName, channel.Name))
|
|
||||||
} else {
|
|
||||||
printToView("Feed", fmt.Sprintf("Downloaded %s from %s", fileName, channel.Name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func populateList() {
|
func populateList() {
|
||||||
_, maxY := g.Size()
|
_, maxY := g.Size()
|
||||||
@ -353,12 +345,7 @@ func handleInput() error {
|
|||||||
}
|
}
|
||||||
if inputString[:1] == "+" {
|
if inputString[:1] == "+" {
|
||||||
cmd := strings.Split(inputString, " ")
|
cmd := strings.Split(inputString, " ")
|
||||||
if len(cmd) == 3 {
|
RunCommand(cmd...)
|
||||||
RunCommand("react", cmd[1], cmd[2])
|
|
||||||
}
|
|
||||||
if len(cmd) == 2 {
|
|
||||||
RunCommand("react", cmd[1])
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
go sendChat(inputString)
|
go sendChat(inputString)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user