Add chat events for webhooks and scripts #1376
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey there, apologies for the unsolicited PR—feel free to completely reject this if it's out of scope!
This PR adds three new events for webhooks and scripts:
PrivateMessageReceived,PublicChatMessageReceived, andRoomMessageReceived. The format for these looks like this:{ "type": "PrivateMessageReceived", "version": 0, "username": "User", "message": "Example message", "blacklisted": false, "id": "ba0392f7-154a-40d2-bf3e-463fcb3cefaf", "timestamp": "2025-06-25T21:50:05.3390708Z" } { "type": "RoomMessageReceived", "version": 0, "roomName": "ExampleRoom", "username": "User", "message": "Example message", "blacklisted": false, "id": "6e105322-e16d-4626-ac71-434f0da6b679", "timestamp": "2025-06-25T22:23:57.5679935Z" }I made the decision to send chat events before the blacklist check, and include
blacklistedin the data, under the assumption that consumers will perform their own filtering. However, if you'd rather the blacklist always be respected, or an option be added for this, I'm happy to change it.On the other hand, I chose to filter out replayed messages entirely. Again, happy to change this and add a field to the data if you prefer.
I also haven't been able to test
PublicChatMessageReceived—does slskd actually have public chat capability? If not, I can remove this event if it would just be bloat.Finally, with regards to the code: I currently raise the events directly in
Application.cs, as that's where Pushbullet notifications are also pushed. This required addingEventBustoApplication. I noticed the existing events mostly exist in their appropriateServiceclasses, so I could move these if you like (e.g. toConversationServiceperhaps?).My personal stake in this PR is only the private chat feature, but if you're interested in more coverage in the event bus for future PRs, I'd be willing to take a look!