bot: add spoiler message type

This commit is contained in:
Chris Sexton 2023-08-02 16:52:11 -04:00
parent b63b317dfc
commit c91fdcdf29
4 changed files with 9 additions and 1 deletions

View File

@ -26,6 +26,8 @@ const (
Reply Reply
// Action any /me action // Action any /me action
Action Action
// Spoiler is for commented out messages
Spoiler
// Reaction Icon reaction if service supports it // Reaction Icon reaction if service supports it
Reaction Reaction
// Edit message ref'd new message to replace // Edit message ref'd new message to replace

View File

@ -37,6 +37,9 @@ func (mb *MockBot) GetPassword() string { return "12345" }
func (mb *MockBot) SetQuiet(bool) {} func (mb *MockBot) SetQuiet(bool) {}
func (mb *MockBot) Send(c Connector, kind Kind, args ...any) (string, error) { func (mb *MockBot) Send(c Connector, kind Kind, args ...any) (string, error) {
switch kind { switch kind {
case Spoiler:
mb.Messages = append(mb.Messages, "||"+args[1].(string)+"||")
return fmt.Sprintf("m-%d", len(mb.Actions)-1), nil
case Message: case Message:
mb.Messages = append(mb.Messages, args[1].(string)) mb.Messages = append(mb.Messages, args[1].(string))
return fmt.Sprintf("m-%d", len(mb.Actions)-1), nil return fmt.Sprintf("m-%d", len(mb.Actions)-1), nil

View File

@ -74,6 +74,9 @@ func (d Discord) Send(kind bot.Kind, args ...any) (string, error) {
return d.sendMessage(args[0].(string), args[2].(string), false, args...) return d.sendMessage(args[0].(string), args[2].(string), false, args...)
case bot.Message: case bot.Message:
return d.sendMessage(args[0].(string), args[1].(string), false, args...) return d.sendMessage(args[0].(string), args[1].(string), false, args...)
case bot.Spoiler:
outgoing := "||" + args[1].(string) + "||"
return d.sendMessage(args[0].(string), outgoing, false, args...)
case bot.Action: case bot.Action:
return d.sendMessage(args[0].(string), args[1].(string), true, args...) return d.sendMessage(args[0].(string), args[1].(string), true, args...)
case bot.Edit: case bot.Edit:

View File

@ -104,7 +104,7 @@ func (p *TalkerPlugin) message(c bot.Connector, kind bot.Kind, message msg.Messa
line = strings.Replace(line, "{nick}", nick, 1) line = strings.Replace(line, "{nick}", nick, 1)
output += line + "\n" output += line + "\n"
} }
p.bot.Send(c, bot.Message, channel, output) p.bot.Send(c, bot.Spoiler, channel, output)
return true return true
} }