mirror of https://github.com/Rudi9719/kbtui.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
896 B
43 lines
896 B
// +build !rm_basic_commands allcommands reactcmd |
|
|
|
package main |
|
|
|
import ( |
|
"strconv" |
|
"strings" |
|
) |
|
|
|
func init() { |
|
command := Command{ |
|
Cmd: []string{"react", "r", "+"}, |
|
Description: "$messageID $reaction - React to a message (messageID is optional)", |
|
Help: "", |
|
Exec: cmdReact, |
|
} |
|
|
|
RegisterCommand(command) |
|
} |
|
|
|
func cmdReact(cmd []string) { |
|
if len(cmd) > 2 { |
|
reactToMessageID(cmd[1], strings.Join(cmd[2:], " ")) |
|
} else if len(cmd) == 2 { |
|
reactToMessage(cmd[1]) |
|
} |
|
|
|
} |
|
|
|
func reactToMessage(reaction string) { |
|
doReact(lastMessage.ID, reaction) |
|
} |
|
func reactToMessageID(messageID string, reaction string) { |
|
ID, _ := strconv.Atoi(messageID) |
|
doReact(ID, reaction) |
|
} |
|
func doReact(messageID int, reaction string) { |
|
chat := k.NewChat(channel) |
|
_, err := chat.React(messageID, reaction) |
|
if err != nil { |
|
printError("There was an error reacting to the message.") |
|
} |
|
}
|
|
|