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.

44 lines
905 B

6 years ago
// +build !rm_basic_commands allcommands reactcmd
package main
import (
"strconv"
"strings"
)
6 years ago
func init() {
command := Command{
Cmd: []string{"react", "r", "+"},
6 years ago
Description: "$messageId $reaction - React to a message (messageID is optional)",
6 years ago
Help: "",
6 years ago
Exec: cmdReact,
6 years ago
}
RegisterCommand(command)
}
func cmdReact(cmd []string) {
if len(cmd) > 2 {
reactToMessageId(cmd[1], strings.Join(cmd[2:], " "))
6 years ago
} else if len(cmd) == 2 {
6 years ago
reactToMessage(cmd[1])
}
}
func reactToMessage(reaction string) {
6 years ago
doReact(lastMessage.ID, reaction)
6 years ago
}
func reactToMessageId(messageId string, reaction string) {
ID, _ := strconv.Atoi(messageId)
6 years ago
doReact(ID, reaction)
}
func doReact(messageId int, reaction string) {
chat := k.NewChat(channel)
_, err := chat.React(messageId, reaction)
if err != nil {
printToView("Feed", "There was an error reacting to the message.")
}
6 years ago
}