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
// Action any /me action
Action
// Spoiler is for commented out messages
Spoiler
// Reaction Icon reaction if service supports it
Reaction
// 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) Send(c Connector, kind Kind, args ...any) (string, error) {
switch kind {
case Spoiler:
mb.Messages = append(mb.Messages, "||"+args[1].(string)+"||")
return fmt.Sprintf("m-%d", len(mb.Actions)-1), nil
case Message:
mb.Messages = append(mb.Messages, args[1].(string))
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...)
case bot.Message:
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:
return d.sendMessage(args[0].(string), args[1].(string), true, args...)
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)
output += line + "\n"
}
p.bot.Send(c, bot.Message, channel, output)
p.bot.Send(c, bot.Spoiler, channel, output)
return true
}