@@ -123,9 +123,27 @@ class SatoriAdapter extends Service {
123123 }
124124
125125 start ( ) {
126+ this . ctx . on ( 'llob/config-updated' , async input => {
127+ const old = omit ( this . config , [ 'ffmpeg' ] )
128+ const inputSatoriConfig = {
129+ ...input . satori ,
130+ onlyLocalhost : input . onlyLocalhost
131+ }
132+ if ( ! isDeepStrictEqual ( old , inputSatoriConfig ) ) {
133+ await this . server . stop ( )
134+ this . server . updateConfig ( inputSatoriConfig )
135+ if ( inputSatoriConfig . enable ) {
136+ this . server . start ( )
137+ }
138+ }
139+ Object . assign ( this . config , { ...inputSatoriConfig , ffmpeg : input . ffmpeg } )
140+ } )
126141 if ( this . config . enable ) {
127142 this . server . start ( )
128143 }
144+ else {
145+ return
146+ }
129147 this . ctx . on ( 'nt/message-created' , async input => {
130148 const event = await this . handleMessage ( input )
131149 . catch ( e => this . ctx . logger . error ( e ) )
@@ -158,22 +176,6 @@ class SatoriAdapter extends Service {
158176 this . server . dispatch ( event )
159177 }
160178 } )
161-
162- this . ctx . on ( 'llob/config-updated' , async input => {
163- const old = omit ( this . config , [ 'ffmpeg' ] )
164- const inputSatoriConfig = {
165- ...input . satori ,
166- onlyLocalhost : input . onlyLocalhost
167- }
168- if ( ! isDeepStrictEqual ( old , inputSatoriConfig ) ) {
169- await this . server . stop ( )
170- this . server . updateConfig ( inputSatoriConfig )
171- if ( inputSatoriConfig . enable ) {
172- this . server . start ( )
173- }
174- }
175- Object . assign ( this . config , { ...inputSatoriConfig , ffmpeg : input . ffmpeg } )
176- } )
177179 }
178180
179181 event ( type : string , data : Partial < ObjectToSnake < Event > > ) : ObjectToSnake < Event > {
0 commit comments