55import { login } from './mi/account' ;
66import { getDeviceList , findDeviceByName } from './mi/mina' ;
77import { MessagePoller , type PollingMessage } from './polling' ;
8+ import { speak } from './speaker' ;
89import type { AuthedAccount } from './mi/types' ;
910import { XiaoaiSessionHandler } from './XiaoaiSessionHandler' ;
1011
@@ -29,6 +30,7 @@ export interface XiaoaiServiceOptions {
2930export class XiaoaiService implements IChannelService {
3031 private authed : AuthedAccount | undefined ;
3132 private poller : MessagePoller | undefined ;
33+ private deviceId : string = '' ;
3234 private logger ?: ILogger ;
3335 private options : XiaoaiServiceOptions ;
3436
@@ -41,6 +43,16 @@ export class XiaoaiService implements IChannelService {
4143 return new XiaoaiSessionHandler ( session , this ) ;
4244 }
4345
46+ async sendText ( _sessionId : string , text : string ) : Promise < void > {
47+ if ( ! this . authed || ! this . deviceId ) return ;
48+ await speak ( this . authed , this . deviceId , text , {
49+ chunkLimit : this . options . textChunkLimit ,
50+ volume : this . options . volume ,
51+ } ) ;
52+ }
53+ async sendFile ( _sessionId : string , _file : string | Buffer , _fileName ?: string ) : Promise < void > { }
54+ async sendNative ( _sessionId : string , _payload : any ) : Promise < void > { }
55+
4456 getAuthedAccount ( ) : AuthedAccount | undefined {
4557 return this . authed ;
4658 }
@@ -75,6 +87,7 @@ export class XiaoaiService implements IChannelService {
7587 ( msg ) => this . handleMessage ( msg ) ,
7688 this . logger ,
7789 ) ;
90+ this . deviceId = matched . deviceID ;
7891 this . poller . startDevice ( matched . deviceID , device ) ;
7992 }
8093
0 commit comments