[core] Add delete event for deleted chat messages

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-02-11 20:10:19 +01:00
parent 4da9f592e5
commit 08185ced3e
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
3 changed files with 32 additions and 0 deletions

View file

@ -20,6 +20,7 @@ var (
eventTypeBits = ptrStr("bits") eventTypeBits = ptrStr("bits")
eventTypeChannelPointRedeem = ptrStr("channelpoint_redeem") eventTypeChannelPointRedeem = ptrStr("channelpoint_redeem")
eventTypeClearChat = ptrStr("clearchat") eventTypeClearChat = ptrStr("clearchat")
eventTypeDelete = ptrStr("delete")
eventTypeFollow = ptrStr("follow") eventTypeFollow = ptrStr("follow")
eventTypeGiftPaidUpgrade = ptrStr("giftpaidupgrade") eventTypeGiftPaidUpgrade = ptrStr("giftpaidupgrade")
eventTypeHost = ptrStr("host") eventTypeHost = ptrStr("host")
@ -44,6 +45,7 @@ var (
eventTypeBits, eventTypeBits,
eventTypeChannelPointRedeem, eventTypeChannelPointRedeem,
eventTypeClearChat, eventTypeClearChat,
eventTypeDelete,
eventTypeFollow, eventTypeFollow,
eventTypeGiftPaidUpgrade, eventTypeGiftPaidUpgrade,
eventTypeHost, eventTypeHost,

18
irc.go
View file

@ -135,6 +135,12 @@ func (i ircHandler) Handle(c *irc.Client, m *irc.Message) {
// chat or timed out. // chat or timed out.
i.handleClearChat(m) i.handleClearChat(m)
case "CLEARMSG":
// CLEARMSG (Twitch Commands)
// Removes a single message from a channel. This is triggered by
// the/delete <target-msg-id> command on IRC.
i.handleClearMessage(m)
case "JOIN": case "JOIN":
// JOIN (Default IRC Command) // JOIN (Default IRC Command)
// User enters the channel, might be triggered multiple times // User enters the channel, might be triggered multiple times
@ -241,6 +247,18 @@ func (i ircHandler) handleClearChat(m *irc.Message) {
go handleMessage(i.c, m, evt, fields) go handleMessage(i.c, m, evt, fields)
} }
func (i ircHandler) handleClearMessage(m *irc.Message) {
fields := plugins.FieldCollectionFromData(map[string]interface{}{
"channel": i.getChannel(m), // Compatibility to plugins.DeriveChannel
"message_id": m.Tags["target-msg-id"],
"target_name": m.Tags["login"],
})
log.WithFields(log.Fields(fields.Data())).
WithField("message", m.Trailing()).
Info("Message was deleted")
go handleMessage(i.c, m, eventTypeDelete, fields)
}
func (i ircHandler) handleJoin(m *irc.Message) { func (i ircHandler) handleJoin(m *irc.Message) {
fields := plugins.FieldCollectionFromData(map[string]interface{}{ fields := plugins.FieldCollectionFromData(map[string]interface{}{
"channel": i.getChannel(m), // Compatibility to plugins.DeriveChannel "channel": i.getChannel(m), // Compatibility to plugins.DeriveChannel

View file

@ -56,6 +56,18 @@ Fields:
- `channel` - The channel the event occurred in - `channel` - The channel the event occurred in
## `delete`
Moderator action caused a chat message to be deleted.
Note: This event does **not** contain the acting user! You cannot use the `{{.user}}` variable.
Fields:
- `channel` - The channel the event occurred in
- `message_id` - The UUID of the message being deleted
- `target_name` - Login name of the author of the deleted message
## `follow` ## `follow`
User followed the channel. This event is not de-duplicated and therefore might be used to spam! (Only available when EventSub support is available!) User followed the channel. This event is not de-duplicated and therefore might be used to spam! (Only available when EventSub support is available!)