11import { Bot , BotTypes } from './Bot' ;
2+ import { BundledMessageBase , DummyBundledMessage } from './BundledMessage' ;
3+ import { BaseTextMessageAction } from './BaseTextMessageAction' ;
24
35export abstract class SendMessageResult < T extends BotTypes > {
46 protected constructor (
@@ -14,48 +16,6 @@ export abstract class SendMessageResult<T extends BotTypes> {
1416 public abstract fileId ?: T [ 'SendableFile' ] ;
1517}
1618
17- export abstract class BaseTextMessageAction < T extends BotTypes > {
18- protected constructor (
19- protected readonly bot : Bot < T >
20- ) {
21- }
22-
23- protected _text : string ;
24-
25- public setText ( text : string ) {
26- this . _text = text ;
27- return this ;
28- }
29-
30- protected _parseAsHtml = false ;
31-
32- // 如果 html 不支持,会自动清除 html 标签
33- public setHtml ( html : string ) {
34- if ( this . bot . isHtmlMessageSupported ) {
35- this . _text = html ;
36- this . _parseAsHtml = true ;
37- } else {
38- this . _text = html . replace ( / < [ ^ > ] + > / g, '' ) ;
39- }
40- return this ;
41- }
42-
43- protected _buttons : MessageButton [ ] [ ] = [ ] ;
44-
45- public addButtons ( buttons : MessageButton [ ] | MessageButton ) {
46- if ( ! Array . isArray ( buttons ) ) {
47- buttons = [ buttons ] ;
48- }
49- this . _buttons . push ( buttons ) ;
50- return this ;
51- }
52-
53- public setButtons ( buttons : MessageButton [ ] [ ] ) {
54- this . _buttons = buttons ;
55- return this ;
56- }
57- }
58-
5919abstract class DispatchableMessageAction < T extends BotTypes > extends BaseTextMessageAction < T > {
6020 public abstract dispatch ( ) : Promise < SendMessageResult < T > > ;
6121
@@ -94,6 +54,7 @@ export abstract class SendMessageAction<T extends BotTypes> extends Dispatchable
9454 protected _file : T [ 'SendableFile' ] = null ;
9555 protected _fileType : 'audio' | 'document' | 'photo' = null ;
9656 protected _templatedMessage : TemplatedMessage < T > = null ;
57+ protected _bundledMessage : BundledMessageBase < T > = null ;
9758
9859 public addPhoto ( file : T [ 'SendableFile' ] ) {
9960 this . _fileType = 'photo' ;
@@ -113,6 +74,13 @@ export abstract class SendMessageAction<T extends BotTypes> extends Dispatchable
11374 return this ;
11475 }
11576
77+ // 仅在 QQ 中支持
78+ public addBundledMessage ( ) {
79+ this . _bundledMessage = new DummyBundledMessage ( this . bot ) ;
80+ return this . _bundledMessage ;
81+ }
82+
83+ // 仅在 QQ 官 Bot 中支持,弃用
11684 public setTemplatedMessage ( template : T [ 'MessageTemplateID' ] , values : Record < string , string > ) {
11785 this . _templatedMessage = new TemplatedMessage ( template , values ) ;
11886 return this ;
0 commit comments