@@ -60,6 +60,7 @@ const localConfig =
6060 twitchCategoryErrorsText : "" ,
6161 twitchCategoryErrorsShowCounter : 0 ,
6262 currentTwitchGameCategoryId : - 1 , // as reported by twitch
63+ currentTwitchStreamTitle : "" , // as reported by twitch
6364
6465 sendUserTwitchChatCredentialsTimeout : 5000 ,
6566 sendUserTwitchChatCredentialsHandle : null ,
@@ -2196,7 +2197,7 @@ function onDataCenterMessage (server_packet)
21962197 // -----------------------------------------------------------------------------------
21972198 else if ( extension_packet . type === "action_GetTwitchStats" )
21982199 {
2199- sendCurrentGameData ( extension_packet . data . actionID )
2200+ sendTwitchStats ( extension_packet . data . actionID )
22002201 }
22012202 // -----------------------------------------------------------------------------------
22022203 // action_GetTwitchStats
@@ -2629,6 +2630,7 @@ async function connectTwitch ()
26292630
26302631 // set our current game id and add it to the history
26312632 localConfig . currentTwitchGameCategoryId = channelData . gameId ;
2633+ localConfig . currentTwitchStreamTitle = channelData . title ;
26322634 // need to do this here as we don't have the game image in the current data.
26332635 addGameToHistoryFromGameName ( channelData . gameName )
26342636 // Connect to the pub sub event listener
@@ -2645,7 +2647,7 @@ async function connectTwitch ()
26452647 //to start up (if we have just started the server)
26462648 setTimeout ( ( ) =>
26472649 {
2648- sendCurrentGameData ( "twitch" )
2650+ sendTwitchStats ( "twitch" )
26492651 } , 5000 ) ;
26502652
26512653 } )
@@ -4021,13 +4023,13 @@ function sendGameCategoriesTrigger (id = "twitch")
40214023 sendTrigger ( trigger )
40224024}
40234025// ===========================================================================
4024- // FUNCTION: sendCurrentGameData
4026+ // FUNCTION: sendTwitchStats
40254027// ===========================================================================
40264028/**
40274029 * sends trigger_TwitchGamedChanged
40284030 * @param {number } [triggerId="twitch"] ref id from action
40294031 */
4030- function sendCurrentGameData ( triggerId = "twitch" )
4032+ function sendTwitchStats ( triggerId = "twitch" )
40314033{
40324034 let trigger = findTriggerByMessageType ( "trigger_TwitchGamedChanged" ) ;
40334035 const game = serverConfig . twitchCategoriesHistory . find ( e => e . id === localConfig . currentTwitchGameCategoryId ) ;
@@ -4036,6 +4038,14 @@ function sendCurrentGameData (triggerId = "twitch")
40364038 trigger . parameters = { triggerId : triggerId , id : game . id , name : game . name , imageURL : game . imageURL }
40374039 sendTrigger ( trigger )
40384040 }
4041+
4042+ trigger = findTriggerByMessageType ( "trigger_TwitchTitleChanged" ) ;
4043+ if ( game )
4044+ {
4045+ trigger . parameters = { triggerId : triggerId , title : localConfig . currentTwitchStreamTitle }
4046+ sendTrigger ( trigger )
4047+ }
4048+
40394049}
40404050// ===========================================================================
40414051// FUNCTION: raidChannel
@@ -4083,6 +4093,16 @@ function pubSubTriggerCallback (trigger)
40834093 //save the serverConfig so we remember the changes
40844094 SaveConfigToServer ( )
40854095 }
4096+ else if ( trigger . messagetype == "trigger_TwitchTitleChanged" )
4097+ {
4098+ // change our setup so it matches the data from twitch
4099+ localConfig . currentTwitchStreamTitle = trigger . parameters . title ;
4100+
4101+ //update any of our modals
4102+ SendSettingsWidgetSmall ( )
4103+ //save the serverConfig so we remember the changes
4104+ SaveConfigToServer ( )
4105+ }
40864106 else
40874107 logger . log ( localConfig . SYSTEM_LOGGING_TAG + serverConfig . extensionname + ".getClipById" , "pubSubTriggerCallback() no handler for " , trigger . messagetype , " twitch callback message" ) ;
40884108}
0 commit comments