crowbartools / Firebot

A powerful all-in-one bot for Twitch streamers
https://firebot.app
GNU General Public License v3.0
348 stars 97 forks source link

[Feature Request] Raid Start and Raid Sendoff event triggers #2175

Open TheGinGear opened 1 year ago

TheGinGear commented 1 year ago

Adding two new Event Triggers: The start of raiding someone else, and the send off of a raid to another channel.

Additional context The ability to have events happen when you start a raid and when the raid actually sends off would be nice. For example, OBS ending the stream 5 seconds after the raid is sent off so you don't have to manually, and worry about forgetting. Pop ups and alerts of the raid-ee on screen, when you first start the raid countdown; like swapping scenes and showing clips of the person you're going to raid, or just credits when you start raiding off.

JoeruCodes commented 8 months ago

I would like to work on the following:

I'll break it down for simplicity:

  1. We need a raid start event using EventSub.
  2. Additionally, we might need a raid completion event. However, there is an issue since there is currently no documentation available in the Twitch API which explicitly mentions a sent off raid event in the EventSub, as far as my knowledge extends...

One potential approach is to implement a start raid event using EventSub. Then, upon receiving a completion notification, we can proceed to trigger the raid completion event...

Basically, we can define the completion notification as follows: an event which is first made live on a raid started event and then its triggered during a sudden efflux of users...

zunderscore commented 8 months ago

There are currently no pending outgoing raid events on EventSub, so marking this as blocked.

Wissididom commented 8 months ago

But I'm already doing that in my Custom Script:

let apiClient = runRequest.modules.twitchApi.getClient();
await apiClient.eventSub.createSubscription(
  "channel.raid",
  "1",
  {
    from_broadcaster_user_id: runRequest.firebot.accounts.streamer.userId,
  },
  {
    method: "websocket",
    session_id: websocket_session_id_from_welcome_payload
  },
  runRequest.firebot.accounts.streamer.userId,
);

I just don't know how to differentiate between Start and Sendoff with that subscription type. Not sure, but I think this is just the Sendoff. So I think that it would just need a second EventSub subscription on channel.raid with from_broadcaster_user_id instead of to_broadcaster_user_id. Documentation: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelraid

zunderscore commented 8 months ago

That tells us that the raid has occurred, so we might be able to setup a sendoff event from it, but there is still no event that tells us a raid is starting.

zunderscore commented 8 months ago

I've updated my comment above to be more precise.

karrbs commented 2 weeks ago

I am confused as to why this blocked.

For the start event could you not just subscribe to the channel.raid and then listen for an event like below?

twitchApi.eventSub.on('channel.raid', (event) => {
  if (event.from_broadcaster_id === myChannelId && event.to_broadcaster_id !== myChannelId) {
    console.log(`Raid initiated by ${myChannelId} to ${event.to_broadcaster_id}`);
  }
});
Wissididom commented 2 weeks ago

I am confused as to why this blocked.

For the start event could you not just subscribe to the channel.raid and then listen for an event like below?

twitchApi.eventSub.on('channel.raid', (event) => {
  if (event.from_broadcaster_id === myChannelId && event.to_broadcaster_id !== myChannelId) {
    console.log(`Raid initiated by ${myChannelId} to ${event.to_broadcaster_id}`);
  }
});

From what I've understood because that event is the raid send-off and not starting the event, meaning when the viewers actually get sent over. There is no event, that gets triggered when you start the raid (meaning the countdown).

karrbs commented 2 weeks ago

I am confused as to why this blocked. For the start event could you not just subscribe to the channel.raid and then listen for an event like below?

twitchApi.eventSub.on('channel.raid', (event) => {
  if (event.from_broadcaster_id === myChannelId && event.to_broadcaster_id !== myChannelId) {
    console.log(`Raid initiated by ${myChannelId} to ${event.to_broadcaster_id}`);
  }
});

From what I've understood because that event is the raid send-off and not starting the event, meaning when the viewers actually get sent over. There is no event, that gets triggered when you start the raid (meaning the countdown).

I don't think you are wrong on that this would detect that as well but it is more of a inference that has to be made in the code. This is what I believe based on what the doc says here https://dev.twitch.tv/docs/api/raids/#get-notified-when-a-raid-begins

dennisrijsdijk commented 2 weeks ago

Raid start would only be possible when Firebot is the app that starts the raid through Twitch REST API. When streamers start the raid through Twitch Chat or another app, we are not notified.

The EventSub Event only sends out a message when the sendoff happens. We should be able to add an event for this, as there's no conditions as to when we do or don't have the information from Twitch.

TheGinGear commented 2 weeks ago

I mean, in this case, how does streamer.bot do it? They have triggers for raid start, send, and cancelled.

phroggster commented 2 weeks ago

Does the raid start event trigger fire in streamer[dot]bot when the raid is initiated from a different interface, such as from your own chat panel on twitch.tv from /raid in a web browser? Because I doubt it does, unless it's using undocumented APIs that are subject to change/removal/restriction at any time.

TheGinGear commented 2 weeks ago

It has done that for a year now I think, yes. I believe it being able to do that is why I put in the initial request. You can view the documentation yourself; it is explicitly stated as such.

Raid Cancelled Raid Start Raid Send

phroggster commented 2 weeks ago

The three links provided all rely on undocumented PubSub APIs, which is not something that Firebot can support. I also don't see anywhere in those pages where it states that raiding from another client or browser will still fire off their Raid Start event.

Besides, PubSub is being permanently retired on April 14, 2025, and I can guarantee you that every bot that relies upon it will be unable to use it after that date. Of course, you can vote to make it an accessible API.