diff --git a/client/rivescript_macros.go b/client/rivescript_macros.go index 3dbeb36..ddfe94f 100644 --- a/client/rivescript_macros.go +++ b/client/rivescript_macros.go @@ -54,6 +54,19 @@ func (h *BotHandlers) setObjectMacros() { return "[react: invalid number of parameters]" }) + // Mark a camera NSFW for a username. + h.rs.SetSubroutine("nsfw", func(rs *rivescript.RiveScript, args []string) string { + if len(args) >= 1 { + var username = strings.TrimPrefix(args[0], "@") + h.client.Send(messages.Message{ + Action: messages.ActionMessage, + Message: fmt.Sprintf("/nsfw %s", username), + }) + return "" + } + return "[nsfw: invalid number of parameters]" + }) + // Takeback a message (admin action especially) h.rs.SetSubroutine("takeback", func(rs *rivescript.RiveScript, args []string) string { if len(args) >= 1 { @@ -120,4 +133,25 @@ func (h *BotHandlers) setObjectMacros() { } return "" }) + + // Send a public chat message to a channel name. + h.rs.SetSubroutine("send-message", func(rs *rivescript.RiveScript, args []string) string { + if len(args) >= 2 { + var ( + channel = args[0] + message = strings.Join(args[1:], " ") + ) + + // Slide into their DMs. + log.Error("Send chat to [%s]: %s", channel, message) + h.client.Send(messages.Message{ + Action: messages.ActionMessage, + Channel: channel, + Message: message, + }) + } else { + return "[send-message: invalid number of parameters]" + } + return "" + }) } diff --git a/docs/Chatbot.md b/docs/Chatbot.md index 43a83c2..477e831 100644 --- a/docs/Chatbot.md +++ b/docs/Chatbot.md @@ -171,6 +171,25 @@ Example: say you have a global keyword trigger on public rooms and want to DM a < topic ``` +**Note:** the `dm` command will auto insert the @ prefix for the channel name, so it can only send to DM threads. Use `send-message` for the ability to send a message to a public channel (or DM thread) by having more control over the exact spelling of the channel name. + +## Send Message + +Send a chat message to a public channel. Like the `dm` macro but doesn't assume it to be a DM thread. + +Usage: `send-message ` + +Example: + +```rivescript ++ to * send the message * +* <> true => This command is only available to operators. +- I will send that to the channel. +^ send-message "{sentence}{/sentence}" +``` + +Then you could say: "to lobby send the message hey everyone" to send to a public channel (by its internal ID), or "to @soandso send the message hey there" to send it to a DM thread. + ## Takeback Take back a message by its ID. This may be useful if you have a global moderator trigger set up so you can remove a user's message. @@ -211,3 +230,17 @@ Example: ``` Note: the `report` command returns no text (except on error). + +## NSFW + +Send a BareRTC `/nsfw` operator command to mark a user's camera as Explicit. + +Usage: `nsfw ` + +Example: + +```rivescript ++ please mark the camera red for * +- I will issue the NSFW camera command for: +^ nsfw +```