|
1 | 1 | import { getTwitchAPI, logger } from '@dotabod/shared-utils' |
2 | 2 | import { DBSettings, getValueOrDefault } from '../../../settings.js' |
3 | 3 | import { is8500Plus } from '../../../utils/index.js' |
| 4 | +import { getStreamDelay } from '../../getStreamDelay.js' |
4 | 5 | import { type allStates, draftStartByMatchId } from '../../lib/consts.js' |
5 | 6 | import { delayedQueue } from '../../lib/DelayedQueue.js' |
6 | 7 | import { isPlayingMatch } from '../../lib/isPlayingMatch.js' |
@@ -54,10 +55,12 @@ eventHandler.registerEvent('map:game_state', { |
54 | 55 | // Create a clip when the draft starts to get a list of players |
55 | 56 | if ('DOTA_GAMERULES_STATE_PLAYER_DRAFT' === gameState) { |
56 | 57 | draftStartByMatchId.set(dotaClient.client.gsi?.map?.matchid || '', true) |
57 | | - logger.info('[Draft Clip] Draft started, creating clip in 46 seconds', logContext) |
| 58 | + const DRAFT_CLIP_DELAY_MS = 46000 // 46 seconds |
| 59 | + const streamDelay = getStreamDelay(dotaClient.client.settings, dotaClient.client.subscription) |
| 60 | + logger.info('[Draft Clip] Draft started, creating clip in 46 seconds + stream delay', logContext) |
58 | 61 |
|
59 | 62 | // Delay to ensure the draft has started |
60 | | - delayedQueue.addTask(46000, async () => { |
| 63 | + delayedQueue.addTask(DRAFT_CLIP_DELAY_MS + streamDelay, async () => { |
61 | 64 | try { |
62 | 65 | const api = await getTwitchAPI(accountId) |
63 | 66 | const clipId = await api.clips.createClip({ |
@@ -113,8 +116,9 @@ eventHandler.registerEvent('map:game_state', { |
113 | 116 |
|
114 | 117 | if ('DOTA_GAMERULES_STATE_STRATEGY_TIME' === gameState) { |
115 | 118 | const CLIP_DELAY_MS = 50000 // 50 seconds |
| 119 | + const streamDelay = getStreamDelay(dotaClient.client.settings, dotaClient.client.subscription) |
116 | 120 |
|
117 | | - delayedQueue.addTask(CLIP_DELAY_MS, async () => { |
| 121 | + delayedQueue.addTask(CLIP_DELAY_MS + streamDelay, async () => { |
118 | 122 | try { |
119 | 123 | const api = await getTwitchAPI(accountId) |
120 | 124 | const clipId = await api.clips.createClip({ |
|
0 commit comments