@@ -17,6 +17,35 @@ export interface Stringable {
17
17
toString ( ) : string ;
18
18
}
19
19
20
+ /**
21
+ * Represents caption object with optional formatting entities.
22
+ *
23
+ * This interface is used to store plain caption along with its associated
24
+ * formatting information (such as bold, italic, links, etc.) as message entities.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const formattedCaption: CaptionWithEntities = {
29
+ * caption: "Hello world!",
30
+ * caption_entities: [
31
+ * { type: "bold", offset: 0, length: 5 },
32
+ * { type: "italic", offset: 6, length: 5 }
33
+ * ]
34
+ * };
35
+ * ```
36
+ */
37
+ export interface CaptionWithEntities {
38
+ /**
39
+ * Plain caption value for this `FormattedString`
40
+ */
41
+ caption : string ;
42
+
43
+ /**
44
+ * Format caption_entities for this `FormattedString`
45
+ */
46
+ caption_entities ?: MessageEntity [ ] ;
47
+ }
48
+
20
49
/**
21
50
* Represents text object with optional formatting entities.
22
51
*
@@ -47,32 +76,59 @@ export interface TextWithEntities {
47
76
}
48
77
49
78
/**
50
- * Represents caption object with optional formatting entities.
79
+ * Represents text object with optional formatting entities.
51
80
*
52
- * This interface is used to store plain caption along with its associated
81
+ * This interface is used to store plain text along with its associated
53
82
* formatting information (such as bold, italic, links, etc.) as message entities.
54
83
*
55
84
* @example
56
85
* ```typescript
57
- * const formattedCaption: CaptionWithEntities = {
58
- * caption : "Hello world!",
59
- * caption_entities : [
86
+ * const formattedText: TextWithTextEntities = {
87
+ * text : "Hello world!",
88
+ * text_entities : [
60
89
* { type: "bold", offset: 0, length: 5 },
61
90
* { type: "italic", offset: 6, length: 5 }
62
91
* ]
63
92
* };
64
93
* ```
65
94
*/
66
- export interface CaptionWithEntities {
95
+ export interface TextWithTextEntities {
67
96
/**
68
- * Plain caption value for this `FormattedString`
97
+ * Plain text value for this `FormattedString`
69
98
*/
70
- caption : string ;
99
+ text : string ;
100
+ /**
101
+ * Format entities for this `FormattedString`
102
+ */
103
+ text_entities ?: MessageEntity [ ] ;
104
+ }
71
105
106
+ /**
107
+ * Represents title object with optional formatting entities.
108
+ *
109
+ * This interface is used to store plain title along with its associated
110
+ * formatting information (such as bold, italic, links, etc.) as message entities.
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const formattedTitle: TitleWithTitleEntities = {
115
+ * title: "Hello world!",
116
+ * title_entities: [
117
+ * { type: "bold", offset: 0, length: 5 },
118
+ * { type: "italic", offset: 6, length: 5 }
119
+ * ]
120
+ * };
121
+ * ```
122
+ */
123
+ export interface TitleWithTitleEntities {
72
124
/**
73
- * Format caption_entities for this `FormattedString`
125
+ * Plain text value for this `FormattedString`
74
126
*/
75
- caption_entities ?: MessageEntity [ ] ;
127
+ title : string ;
128
+ /**
129
+ * Format entities for this `FormattedString`
130
+ */
131
+ title_entities ?: MessageEntity [ ] ;
76
132
}
77
133
78
134
/**
@@ -81,7 +137,12 @@ export interface CaptionWithEntities {
81
137
* and caption content in Telegram Bot API calls.
82
138
*/
83
139
export class FormattedString
84
- implements TextWithEntities , CaptionWithEntities , Stringable {
140
+ implements
141
+ CaptionWithEntities ,
142
+ TextWithEntities ,
143
+ TextWithTextEntities ,
144
+ TitleWithTitleEntities ,
145
+ Stringable {
85
146
/**
86
147
* The entities backing this FormattedString.
87
148
*/
@@ -121,6 +182,30 @@ export class FormattedString
121
182
return this . rawText ;
122
183
}
123
184
185
+ /**
186
+ * Gets the title. Alias for rawText.
187
+ * Used when this FormattedString is used as title.
188
+ */
189
+ get title ( ) {
190
+ return this . rawText ;
191
+ }
192
+
193
+ /**
194
+ * Gets the text_entities. Alias for rawEntities.
195
+ * Used when this FormattedString is used as text with text_entities.
196
+ */
197
+ get text_entities ( ) {
198
+ return this . rawEntities ;
199
+ }
200
+
201
+ /**
202
+ * Gets the title_entities. Alias for rawEntities.
203
+ * Used when this FormattedString is used as title_entities.
204
+ */
205
+ get title_entities ( ) {
206
+ return this . rawEntities ;
207
+ }
208
+
124
209
/**
125
210
* Gets the caption entities. This is an alias for the raw entities.
126
211
* Used when this FormattedString is used as caption content.
@@ -1202,7 +1287,7 @@ export function linkMessage(
1202
1287
"linkMessage can only be used for supergroups and channel messages. Refusing to transform into link." ,
1203
1288
) ;
1204
1289
return fmt `${ stringLike } ` ;
1205
- } else if ( chatId < - 1002147483647 || chatId > - 1000000000000 ) {
1290
+ } else if ( chatId < - 1997852516352 || chatId > - 1000000000001 ) {
1206
1291
console . warn (
1207
1292
"linkMessage is not able to link messages whose chatIds are greater than -1000000000000 or less than -1002147483647 at this moment. Refusing to transform into link." ,
1208
1293
) ;
0 commit comments