1
0
mirror of https://github.com/Rudi9719/kbtui.git synced 2026-03-22 11:07:22 +00:00

Yeet haw, downloads are working and some edits were made to reactions

This commit is contained in:
Gregory Rudolph
2019-10-03 10:13:13 -04:00
parent 8cb0950c25
commit a459f62cdf
2 changed files with 34 additions and 15 deletions

32
cmdDownload.go Normal file
View 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
View File

@ -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)
} }