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

Updated command from changes to framework

This commit is contained in:
Gregory Rudolph
2019-10-04 13:13:02 -04:00
parent f9bb61cbc3
commit 71e0596f96

View File

@ -21,9 +21,21 @@ func init() {
func cmdEdit(cmd []string) {
var messageId int
chat := k.NewChat(channel)
if len(cmd) == 2 || len(cmd) == 1 {
if len(cmd) == 2 {
messageId, _ = strconv.Atoi(cmd[1])
printToView("Input", fmt.Sprintf("/edit %d Type edit here", messageId))
} else {
messageId = lastMessage.ID
}
origMessage, _ := chat.ReadMessage(messageId)
if origMessage.Result.Messages[0].Msg.Content.Type != "text" {
printToView("Feed", fmt.Sprintf("%+v", origMessage))
return
}
editString := origMessage.Result.Messages[0].Msg.Content.Text.Body
printToView("Input", fmt.Sprintf("/edit %d %s", messageId, editString))
return
}
if len(cmd) < 3 {
@ -31,7 +43,6 @@ func cmdEdit(cmd []string) {
return
}
messageId, _ = strconv.Atoi(cmd[1])
chat := k.NewChat(channel)
newMessage := strings.Join(cmd[2:], " ")
_, err := chat.Edit(messageId, newMessage)
if err != nil {