File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 let toastIndex = 0 ;
1313 eventManager . on ( 'preChat:getMessageAuto' , function drawAnnouncement ( data ) {
1414 const setting = settings . value ( 'underscript.announcement.draws' ) ;
15- if ( this . canceled || setting === 'chat' || ! data . message . includes ( 'has just obtained' ) ) return ;
15+ const index = data . message . indexOf ( ' has just obtained ' ) ;
16+ if ( this . canceled || setting === 'chat' || ! ~ index ) return ;
1617 const both = setting === 'both' ;
1718 this . canceled = ! both ;
1819 if ( both || setting === 'toast' ) {
20+ const owner = data . message . substring ( 0 , index ) ;
21+ const card = data . message . substring ( index + 19 , data . message . length - 2 ) ;
22+
23+ const last = toastIndex > 0 && toasts [ ( toastIndex - 1 ) % 3 ] ;
24+ if ( last && last . exists ( ) && ( true || last . time + 1000 > Date . now ( ) ) ) {
25+ if ( owner === last . owner ) {
26+ const text = `${ owner } has just obtained ${ last . cards . join ( ', ' ) } and ${ card } !` ;
27+ last . setText ( text ) ;
28+ last . cards . push ( card ) ;
29+ return ;
30+ }
31+ }
1932 if ( toasts [ toastIndex % 3 ] ) { // Close any old toast
2033 toasts [ toastIndex % 3 ] . close ( ) ;
2134 }
22- toasts [ toastIndex % 3 ] = fn . toast ( {
35+
36+ const toast = fn . toast ( {
2337 text : data . message ,
2438 css : {
2539 color : 'yellow' ,
2640 footer : { color : 'white' } ,
2741 }
2842 } ) ;
43+ toast . cards = [ card ] ;
44+ toast . owner = owner ;
45+ toast . time = Date . now ( ) ;
46+ toasts [ toastIndex % 3 ] = toast ;
2947 toastIndex += 1 ;
3048 }
3149 } ) ;
You can’t perform that action at this time.
0 commit comments