mirror of
https://github.com/Rudi9719/kbtui.git
synced 2026-03-22 11:07:22 +00:00
Add edit
This commit is contained in:
40
cmdEdit.go
Normal file
40
cmdEdit.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// +build !rm_basic_commands allcommands editcmd
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
command := Command{
|
||||||
|
Cmd: []string{"edit", "e"},
|
||||||
|
Description: "$messageId - Edit a message (messageID is optional)",
|
||||||
|
Help: "",
|
||||||
|
Exec: cmdEdit,
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterCommand(command)
|
||||||
|
}
|
||||||
|
|
||||||
|
func cmdEdit(cmd []string) {
|
||||||
|
var messageId int
|
||||||
|
if len(cmd) == 2 {
|
||||||
|
messageId, _ = strconv.Atoi(cmd[1])
|
||||||
|
printToView("Input", fmt.Sprintf("/edit %d Type edit here",messageId))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(cmd) < 3 {
|
||||||
|
printToView("Feed", "Not enough options for Edit")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
messageId, _ = strconv.Atoi(cmd[1])
|
||||||
|
chat := k.NewChat(channel)
|
||||||
|
newMessage := strings.Join(cmd[2:], " ")
|
||||||
|
chat.Edit(messageId,newMessage)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user