|
|
@ -21,9 +21,21 @@ func init() { |
|
|
|
|
|
|
|
|
|
|
|
func cmdEdit(cmd []string) { |
|
|
|
func cmdEdit(cmd []string) { |
|
|
|
var messageId int |
|
|
|
var messageId int |
|
|
|
|
|
|
|
chat := k.NewChat(channel) |
|
|
|
|
|
|
|
if len(cmd) == 2 || len(cmd) == 1 { |
|
|
|
if len(cmd) == 2 { |
|
|
|
if len(cmd) == 2 { |
|
|
|
messageId, _ = strconv.Atoi(cmd[1]) |
|
|
|
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 |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if len(cmd) < 3 { |
|
|
|
if len(cmd) < 3 { |
|
|
@ -31,7 +43,6 @@ func cmdEdit(cmd []string) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
messageId, _ = strconv.Atoi(cmd[1]) |
|
|
|
messageId, _ = strconv.Atoi(cmd[1]) |
|
|
|
chat := k.NewChat(channel) |
|
|
|
|
|
|
|
newMessage := strings.Join(cmd[2:], " ") |
|
|
|
newMessage := strings.Join(cmd[2:], " ") |
|
|
|
_, err := chat.Edit(messageId, newMessage) |
|
|
|
_, err := chat.Edit(messageId, newMessage) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|