mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-08 16:20:02 +00:00
[core] Add delete
event for deleted chat messages
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
4da9f592e5
commit
08185ced3e
3 changed files with 32 additions and 0 deletions
|
@ -20,6 +20,7 @@ var (
|
|||
eventTypeBits = ptrStr("bits")
|
||||
eventTypeChannelPointRedeem = ptrStr("channelpoint_redeem")
|
||||
eventTypeClearChat = ptrStr("clearchat")
|
||||
eventTypeDelete = ptrStr("delete")
|
||||
eventTypeFollow = ptrStr("follow")
|
||||
eventTypeGiftPaidUpgrade = ptrStr("giftpaidupgrade")
|
||||
eventTypeHost = ptrStr("host")
|
||||
|
@ -44,6 +45,7 @@ var (
|
|||
eventTypeBits,
|
||||
eventTypeChannelPointRedeem,
|
||||
eventTypeClearChat,
|
||||
eventTypeDelete,
|
||||
eventTypeFollow,
|
||||
eventTypeGiftPaidUpgrade,
|
||||
eventTypeHost,
|
||||
|
|
18
irc.go
18
irc.go
|
@ -135,6 +135,12 @@ func (i ircHandler) Handle(c *irc.Client, m *irc.Message) {
|
|||
// chat or timed out.
|
||||
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":
|
||||
// JOIN (Default IRC Command)
|
||||
// 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)
|
||||
}
|
||||
|
||||
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) {
|
||||
fields := plugins.FieldCollectionFromData(map[string]interface{}{
|
||||
"channel": i.getChannel(m), // Compatibility to plugins.DeriveChannel
|
||||
|
|
|
@ -56,6 +56,18 @@ Fields:
|
|||
|
||||
- `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`
|
||||
|
||||
User followed the channel. This event is not de-duplicated and therefore might be used to spam! (Only available when EventSub support is available!)
|
||||
|
|
Loading…
Reference in a new issue