Browse Source

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

pull/1/head
Gregory Rudolph 5 years ago
parent
commit
a459f62cdf
  1. 32
      cmdDownload.go
  2. 17
      main.go

32
cmdDownload.go

@ -0,0 +1,32 @@ @@ -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

@ -124,15 +124,7 @@ func formatOutput(api keybase.ChatAPI) string { @@ -124,15 +124,7 @@ func formatOutput(api keybase.ChatAPI) string {
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() {
_, maxY := g.Size()
@ -353,12 +345,7 @@ func handleInput() error { @@ -353,12 +345,7 @@ func handleInput() error {
}
if inputString[:1] == "+" {
cmd := strings.Split(inputString, " ")
if len(cmd) == 3 {
RunCommand("react", cmd[1], cmd[2])
}
if len(cmd) == 2 {
RunCommand("react", cmd[1])
}
RunCommand(cmd...)
} else {
go sendChat(inputString)
}

Loading…
Cancel
Save