@grom.js/effect-tg 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -5
- package/dist/BotApi.d.ts +10 -12
- package/dist/BotApi.d.ts.map +1 -1
- package/dist/BotApi.js +2 -2
- package/dist/BotApi.js.map +1 -1
- package/dist/BotApiError.d.ts +46 -71
- package/dist/BotApiError.d.ts.map +1 -1
- package/dist/BotApiError.js +59 -41
- package/dist/BotApiError.js.map +1 -1
- package/dist/BotApiTransport.d.ts +10 -17
- package/dist/BotApiTransport.d.ts.map +1 -1
- package/dist/BotApiTransport.js +2 -7
- package/dist/BotApiTransport.js.map +1 -1
- package/dist/BotApiUrl.d.ts +6 -8
- package/dist/BotApiUrl.d.ts.map +1 -1
- package/dist/BotApiUrl.js.map +1 -1
- package/dist/Content.d.ts.map +1 -1
- package/dist/Dialog.d.ts +96 -41
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +60 -25
- package/dist/Dialog.js.map +1 -1
- package/dist/File.d.ts +1 -2
- package/dist/File.d.ts.map +1 -1
- package/dist/File.js +1 -1
- package/dist/File.js.map +1 -1
- package/dist/Markup.d.ts.map +1 -1
- package/dist/Runner.d.ts +1 -1
- package/dist/Runner.d.ts.map +1 -1
- package/dist/Send.d.ts +57 -130
- package/dist/Send.d.ts.map +1 -1
- package/dist/Send.js +65 -128
- package/dist/Send.js.map +1 -1
- package/dist/Text.d.ts.map +1 -1
- package/dist/internal/botApi.d.ts +3 -1
- package/dist/internal/botApi.d.ts.map +1 -1
- package/dist/internal/botApi.gen.d.ts +6501 -0
- package/dist/internal/botApi.gen.d.ts.map +1 -0
- package/dist/internal/botApi.gen.js +2 -0
- package/dist/internal/botApi.gen.js.map +1 -0
- package/dist/internal/botApi.js +2 -6
- package/dist/internal/botApi.js.map +1 -1
- package/dist/internal/botApiError.d.ts +5 -2
- package/dist/internal/botApiError.d.ts.map +1 -1
- package/dist/internal/botApiError.js +8 -18
- package/dist/internal/botApiError.js.map +1 -1
- package/dist/internal/botApiTransport.d.ts +5 -2
- package/dist/internal/botApiTransport.d.ts.map +1 -1
- package/dist/internal/botApiTransport.js +14 -10
- package/dist/internal/botApiTransport.js.map +1 -1
- package/dist/internal/dialog.d.ts +27 -10
- package/dist/internal/dialog.d.ts.map +1 -1
- package/dist/internal/dialog.js +88 -14
- package/dist/internal/dialog.js.map +1 -1
- package/dist/internal/file.d.ts +1 -1
- package/dist/internal/file.d.ts.map +1 -1
- package/dist/internal/file.js +1 -1
- package/dist/internal/file.js.map +1 -1
- package/dist/internal/runner.d.ts +4 -5
- package/dist/internal/runner.d.ts.map +1 -1
- package/dist/internal/runner.js +14 -19
- package/dist/internal/runner.js.map +1 -1
- package/dist/internal/send.d.ts +4 -4
- package/dist/internal/send.d.ts.map +1 -1
- package/dist/internal/send.js +62 -51
- package/dist/internal/send.js.map +1 -1
- package/package.json +12 -10
- package/src/BotApi.ts +38 -31
- package/src/BotApiError.ts +109 -63
- package/src/BotApiTransport.ts +18 -20
- package/src/BotApiUrl.ts +6 -8
- package/src/Content.ts +14 -14
- package/src/Dialog.ts +164 -42
- package/src/File.ts +3 -4
- package/src/Markup.ts +5 -5
- package/src/Send.ts +114 -202
- package/src/Text.ts +5 -5
- package/src/internal/botApi.gen.ts +6783 -0
- package/src/internal/botApi.ts +7 -11
- package/src/internal/botApiError.ts +15 -20
- package/src/internal/botApiTransport.ts +25 -17
- package/src/internal/dialog.ts +109 -26
- package/src/internal/file.ts +1 -1
- package/src/internal/runner.ts +34 -38
- package/src/internal/send.ts +161 -132
- package/dist/internal/botApiMethods.gen.d.ts +0 -2026
- package/dist/internal/botApiMethods.gen.d.ts.map +0 -1
- package/dist/internal/botApiMethods.gen.js +0 -2
- package/dist/internal/botApiMethods.gen.js.map +0 -1
- package/dist/internal/botApiShape.gen.d.ts +0 -398
- package/dist/internal/botApiShape.gen.d.ts.map +0 -1
- package/dist/internal/botApiShape.gen.js +0 -2
- package/dist/internal/botApiShape.gen.js.map +0 -1
- package/dist/internal/botApiTypes.gen.d.ts +0 -3903
- package/dist/internal/botApiTypes.gen.d.ts.map +0 -1
- package/dist/internal/botApiTypes.gen.js +0 -2
- package/dist/internal/botApiTypes.gen.js.map +0 -1
- package/src/internal/botApiMethods.gen.ts +0 -2027
- package/src/internal/botApiShape.gen.ts +0 -398
- package/src/internal/botApiTypes.gen.ts +0 -4178
package/src/Send.ts
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import type * as BotApi from './BotApi.ts'
|
|
6
6
|
import type * as BotApiError from './BotApiError.ts'
|
|
7
|
-
import type * as BotApiTransport from './BotApiTransport.ts'
|
|
8
7
|
import type * as Content from './Content.ts'
|
|
9
|
-
import type * as
|
|
8
|
+
import type * as Dialog from './Dialog.ts'
|
|
10
9
|
import type * as Markup from './Markup.ts'
|
|
11
10
|
import * as Context from 'effect/Context'
|
|
12
11
|
import * as Data from 'effect/Data'
|
|
@@ -14,104 +13,66 @@ import * as Effect from 'effect/Effect'
|
|
|
14
13
|
import * as Effectable from 'effect/Effectable'
|
|
15
14
|
import * as Function from 'effect/Function'
|
|
16
15
|
import * as Inspectable from 'effect/Inspectable'
|
|
17
|
-
import * as Pipeable from 'effect/Pipeable'
|
|
18
16
|
import * as internal from './internal/send.ts'
|
|
19
17
|
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// ─── Services ─────────────────────────────────────────────────────
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Service providing the target dialog for sending messages.
|
|
28
|
-
*/
|
|
29
|
-
export class Dialog extends Context.Tag('@grom.js/effect-tg/Send/Dialog')<
|
|
30
|
-
Dialog,
|
|
31
|
-
Dialog_.Dialog
|
|
32
|
-
>() {}
|
|
33
|
-
|
|
34
|
-
// ─── Options ──────────────────────────────────────────────────────
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Options for sending a message.
|
|
38
|
-
*
|
|
39
|
-
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1message_send_options.html td.td_api.messageSendOptions}
|
|
40
|
-
*/
|
|
41
|
-
export class Options extends Data.Class<{
|
|
42
|
-
disableNotification?: boolean
|
|
43
|
-
protectContent?: boolean
|
|
44
|
-
allowPaidBroadcast?: boolean
|
|
45
|
-
}> {}
|
|
46
|
-
|
|
47
|
-
// ─── Direct Send ──────────────────────────────────────────────────
|
|
18
|
+
// =============================================================================
|
|
19
|
+
// Send Methods
|
|
20
|
+
// =============================================================================
|
|
48
21
|
|
|
49
22
|
/**
|
|
50
|
-
* Sends a message
|
|
51
|
-
*
|
|
52
|
-
* Prefer {@linkcode message} for more composability.
|
|
53
|
-
*
|
|
54
|
-
* Example:
|
|
55
|
-
* ```ts
|
|
56
|
-
* yield* Send.sendMessage({
|
|
57
|
-
* content: new Content.Text({
|
|
58
|
-
* text,
|
|
59
|
-
* linkPreview: Option.none(),
|
|
60
|
-
* }),
|
|
61
|
-
* dialog: new Dialog.UserId(userId),
|
|
62
|
-
* options: new Send.Options({
|
|
63
|
-
* protectContent: true,
|
|
64
|
-
* }),
|
|
65
|
-
* })
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1send_message.html td.td_api.sendMessage}
|
|
23
|
+
* Sends a message by calling the appropriate `send*` Bot API method
|
|
24
|
+
* and passing the required parameters.
|
|
69
25
|
*/
|
|
70
26
|
export const sendMessage: (params: {
|
|
71
27
|
content: Content.Content
|
|
72
|
-
dialog:
|
|
28
|
+
dialog: Dialog.Dialog | Dialog.DialogId
|
|
73
29
|
options?: Options
|
|
74
30
|
markup?: Markup.Markup
|
|
75
31
|
}) => Effect.Effect<
|
|
76
32
|
BotApi.Types.Message,
|
|
77
|
-
BotApiError.BotApiError
|
|
33
|
+
BotApiError.BotApiError,
|
|
78
34
|
BotApi.BotApi
|
|
79
35
|
> = internal.sendMessage
|
|
80
36
|
|
|
81
|
-
//
|
|
37
|
+
// =============================================================================
|
|
38
|
+
// MessageToSend
|
|
39
|
+
// =============================================================================
|
|
82
40
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
BotApi.BotApi | Dialog
|
|
87
|
-
>
|
|
41
|
+
export const MessageToSendTypeId: unique symbol = Symbol.for('@grom.js/effect-tg/Send/MessageToSend')
|
|
42
|
+
|
|
43
|
+
export type MessageToSendTypeId = typeof MessageToSendTypeId
|
|
88
44
|
|
|
89
45
|
/**
|
|
90
|
-
*
|
|
46
|
+
* Message prepared to be sent.
|
|
91
47
|
*/
|
|
92
48
|
export interface MessageToSend extends
|
|
93
49
|
Inspectable.Inspectable,
|
|
94
|
-
|
|
50
|
+
Effect.Effect<
|
|
51
|
+
BotApi.Types.Message,
|
|
52
|
+
BotApiError.BotApiError,
|
|
53
|
+
BotApi.BotApi | TargetDialog
|
|
54
|
+
>
|
|
95
55
|
{
|
|
96
56
|
readonly [MessageToSendTypeId]: typeof MessageToSendTypeId
|
|
97
57
|
readonly content: Content.Content
|
|
98
|
-
readonly
|
|
99
|
-
readonly
|
|
58
|
+
readonly markup?: Markup.Markup
|
|
59
|
+
readonly options?: Options
|
|
100
60
|
}
|
|
101
61
|
|
|
102
|
-
const
|
|
103
|
-
[MessageToSendTypeId]: MessageToSendTypeId,
|
|
104
|
-
...Effectable.CommitPrototype,
|
|
62
|
+
const MessageToSendProto = {
|
|
105
63
|
...Inspectable.BaseProto,
|
|
64
|
+
...Effectable.CommitPrototype,
|
|
106
65
|
|
|
107
|
-
|
|
66
|
+
[MessageToSendTypeId]: MessageToSendTypeId,
|
|
67
|
+
|
|
68
|
+
commit(this: MessageToSend) {
|
|
108
69
|
return Effect.flatMap(
|
|
109
|
-
|
|
70
|
+
TargetDialog,
|
|
110
71
|
dialog => sendMessage({
|
|
111
72
|
dialog,
|
|
112
73
|
content: this.content,
|
|
113
|
-
options: this.options,
|
|
114
74
|
markup: this.markup,
|
|
75
|
+
options: this.options,
|
|
115
76
|
}),
|
|
116
77
|
)
|
|
117
78
|
},
|
|
@@ -120,99 +81,108 @@ const Proto = {
|
|
|
120
81
|
return {
|
|
121
82
|
_id: this[MessageToSendTypeId].description,
|
|
122
83
|
content: this.content,
|
|
123
|
-
options: this.options,
|
|
124
84
|
markup: this.markup,
|
|
85
|
+
options: this.options,
|
|
125
86
|
}
|
|
126
87
|
},
|
|
127
|
-
|
|
128
|
-
pipe() {
|
|
129
|
-
// eslint-disable-next-line prefer-rest-params
|
|
130
|
-
return Pipeable.pipeArguments(this, arguments)
|
|
131
|
-
},
|
|
132
88
|
}
|
|
133
89
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Creates a message prepared to be sent with the specified content
|
|
92
|
+
* and optional parameters.
|
|
93
|
+
*/
|
|
94
|
+
export const message = (content: Content.Content, params?: {
|
|
137
95
|
markup?: Markup.Markup
|
|
96
|
+
options?: Options
|
|
138
97
|
}): MessageToSend => {
|
|
139
|
-
const self = Object.create(
|
|
140
|
-
self.content =
|
|
141
|
-
self.
|
|
142
|
-
self.
|
|
98
|
+
const self = Object.create(MessageToSendProto)
|
|
99
|
+
self.content = content
|
|
100
|
+
self.markup = params?.markup
|
|
101
|
+
self.options = params?.options
|
|
143
102
|
return self
|
|
144
103
|
}
|
|
145
104
|
|
|
146
|
-
//
|
|
105
|
+
// =============================================================================
|
|
106
|
+
// TargetDialog
|
|
107
|
+
// =============================================================================
|
|
147
108
|
|
|
148
109
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* Example:
|
|
152
|
-
* ```ts
|
|
153
|
-
* yield* Send.message(content).pipe(
|
|
154
|
-
* Send.withProtection,
|
|
155
|
-
* Send.to(dialog),
|
|
156
|
-
* )
|
|
157
|
-
* ```
|
|
110
|
+
* Target dialog for sending messages.
|
|
158
111
|
*/
|
|
159
|
-
export
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// ─── Dialog Provider ──────────────────────────────────────────────
|
|
112
|
+
export class TargetDialog extends Context.Tag('@grom.js/effect-tg/Send/TargetDialog')<
|
|
113
|
+
TargetDialog,
|
|
114
|
+
Dialog.Dialog | Dialog.DialogId
|
|
115
|
+
>() {}
|
|
164
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Provides the target dialog for sending messages.
|
|
119
|
+
*/
|
|
165
120
|
export const to: {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
*
|
|
169
|
-
* Example:
|
|
170
|
-
* ```ts
|
|
171
|
-
* // Per-message
|
|
172
|
-
* yield* Send.message(content).pipe(
|
|
173
|
-
* Send.withProtection,
|
|
174
|
-
* Send.to(dialog),
|
|
175
|
-
* )
|
|
176
|
-
*
|
|
177
|
-
* // For entire handler (multiple sends)
|
|
178
|
-
* const handler = Effect.gen(function* () {
|
|
179
|
-
* yield* Send.message(content1)
|
|
180
|
-
* yield* Send.message(content2)
|
|
181
|
-
* }).pipe(Send.to(dialog))
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
(dialog: Dialog_.Dialog): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Dialog>>
|
|
185
|
-
<A, E, R>(effect: Effect.Effect<A, E, R>, dialog: Dialog_.Dialog): Effect.Effect<A, E, Exclude<R, Dialog>>
|
|
121
|
+
(dialog: Dialog.Dialog): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, TargetDialog>>
|
|
122
|
+
<A, E, R>(effect: Effect.Effect<A, E, R>, dialog: Dialog.Dialog): Effect.Effect<A, E, Exclude<R, TargetDialog>>
|
|
186
123
|
} = Function.dual(2, <A, E, R>(
|
|
187
124
|
effect: Effect.Effect<A, E, R>,
|
|
188
|
-
dialog:
|
|
189
|
-
): Effect.Effect<A, E, Exclude<R,
|
|
190
|
-
Effect.provideService(effect,
|
|
125
|
+
dialog: Dialog.Dialog,
|
|
126
|
+
): Effect.Effect<A, E, Exclude<R, TargetDialog>> => (
|
|
127
|
+
Effect.provideService(effect, TargetDialog, dialog)
|
|
191
128
|
))
|
|
192
129
|
|
|
193
|
-
//
|
|
130
|
+
// =============================================================================
|
|
131
|
+
// Reply Markup
|
|
132
|
+
// =============================================================================
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Sets the reply markup for the message.
|
|
136
|
+
*/
|
|
137
|
+
export const withMarkup: {
|
|
138
|
+
(markup: Markup.Markup): (self: MessageToSend) => MessageToSend
|
|
139
|
+
(self: MessageToSend, markup: Markup.Markup): MessageToSend
|
|
140
|
+
} = Function.dual(2, (
|
|
141
|
+
self: MessageToSend,
|
|
142
|
+
markup: Markup.Markup,
|
|
143
|
+
): MessageToSend => (
|
|
144
|
+
message(self.content, {
|
|
145
|
+
markup,
|
|
146
|
+
options: self.options,
|
|
147
|
+
})
|
|
148
|
+
))
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Removes the reply markup from the message.
|
|
152
|
+
*/
|
|
153
|
+
export const withoutMarkup: (
|
|
154
|
+
self: MessageToSend,
|
|
155
|
+
) => MessageToSend = self => message(self.content, {
|
|
156
|
+
markup: undefined,
|
|
157
|
+
options: self.options,
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
// =============================================================================
|
|
161
|
+
// Send Options
|
|
162
|
+
// =============================================================================
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Options for sending a message.
|
|
166
|
+
*/
|
|
167
|
+
export class Options extends Data.Class<{
|
|
168
|
+
disableNotification?: boolean
|
|
169
|
+
protectContent?: boolean
|
|
170
|
+
allowPaidBroadcast?: boolean
|
|
171
|
+
}> {}
|
|
172
|
+
|
|
173
|
+
export const options = (args: {
|
|
174
|
+
disableNotification?: boolean
|
|
175
|
+
protectContent?: boolean
|
|
176
|
+
allowPaidBroadcast?: boolean
|
|
177
|
+
}): Options => new Options(args)
|
|
194
178
|
|
|
195
179
|
/**
|
|
196
180
|
* Modifies the options for sending a message by merging with existing options.
|
|
197
181
|
*
|
|
198
|
-
* Example:
|
|
199
|
-
* ```ts
|
|
200
|
-
* yield* Send.message(content).pipe(
|
|
201
|
-
* Send.withOptions({
|
|
202
|
-
* disableNotification: true,
|
|
203
|
-
* protectContent: true,
|
|
204
|
-
* }),
|
|
205
|
-
* Send.to(dialog),
|
|
206
|
-
* )
|
|
207
|
-
* ```
|
|
208
|
-
*
|
|
209
182
|
* Available shortcuts:
|
|
210
|
-
* - {@linkcode withoutNotification}
|
|
211
|
-
* - {@linkcode
|
|
212
|
-
* - {@linkcode
|
|
213
|
-
* - {@linkcode withContentProtection}
|
|
214
|
-
* - {@linkcode withoutPaidBroadcast}
|
|
215
|
-
* - {@linkcode withPaidBroadcast}
|
|
183
|
+
* - {@linkcode withNotification} / {@linkcode withoutNotification}
|
|
184
|
+
* - {@linkcode withContentProtection} / {@linkcode withoutContentProtection}
|
|
185
|
+
* - {@linkcode withPaidBroadcast} / {@linkcode withoutPaidBroadcast}
|
|
216
186
|
*/
|
|
217
187
|
export const withOptions: {
|
|
218
188
|
(options: Options): (self: MessageToSend) => MessageToSend
|
|
@@ -221,22 +191,17 @@ export const withOptions: {
|
|
|
221
191
|
self: MessageToSend,
|
|
222
192
|
options: Options,
|
|
223
193
|
): MessageToSend => (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
options
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
markup: self.markup,
|
|
232
|
-
},
|
|
233
|
-
)
|
|
194
|
+
message(self.content, {
|
|
195
|
+
markup: self.markup,
|
|
196
|
+
options: new Options({
|
|
197
|
+
...self.options,
|
|
198
|
+
...options,
|
|
199
|
+
}),
|
|
200
|
+
})
|
|
234
201
|
))
|
|
235
202
|
|
|
236
203
|
/**
|
|
237
204
|
* Disables notification for the message.
|
|
238
|
-
*
|
|
239
|
-
* Shortcut for `withOptions({ disableNotification: true })`.
|
|
240
205
|
*/
|
|
241
206
|
export const withoutNotification: (
|
|
242
207
|
self: MessageToSend,
|
|
@@ -244,8 +209,6 @@ export const withoutNotification: (
|
|
|
244
209
|
|
|
245
210
|
/**
|
|
246
211
|
* Enables notification for the message.
|
|
247
|
-
*
|
|
248
|
-
* Shortcut for `withOptions({ disableNotification: false })`.
|
|
249
212
|
*/
|
|
250
213
|
export const withNotification: (
|
|
251
214
|
self: MessageToSend,
|
|
@@ -253,8 +216,6 @@ export const withNotification: (
|
|
|
253
216
|
|
|
254
217
|
/**
|
|
255
218
|
* Allows message content to be saved and forwarded.
|
|
256
|
-
*
|
|
257
|
-
* Shortcut for `withOptions({ protectContent: false })`.
|
|
258
219
|
*/
|
|
259
220
|
export const withoutContentProtection: (
|
|
260
221
|
self: MessageToSend,
|
|
@@ -262,8 +223,6 @@ export const withoutContentProtection: (
|
|
|
262
223
|
|
|
263
224
|
/**
|
|
264
225
|
* Protects message content from saving and forwarding.
|
|
265
|
-
*
|
|
266
|
-
* Shortcut for `withOptions({ protectContent: true })`.
|
|
267
226
|
*/
|
|
268
227
|
export const withContentProtection: (
|
|
269
228
|
self: MessageToSend,
|
|
@@ -271,8 +230,6 @@ export const withContentProtection: (
|
|
|
271
230
|
|
|
272
231
|
/**
|
|
273
232
|
* Disallows paid broadcast for the message.
|
|
274
|
-
*
|
|
275
|
-
* Shortcut for `withOptions({ allowPaidBroadcast: false })`.
|
|
276
233
|
*/
|
|
277
234
|
export const withoutPaidBroadcast: (
|
|
278
235
|
self: MessageToSend,
|
|
@@ -280,52 +237,7 @@ export const withoutPaidBroadcast: (
|
|
|
280
237
|
|
|
281
238
|
/**
|
|
282
239
|
* Allows paid broadcast for the message.
|
|
283
|
-
*
|
|
284
|
-
* Shortcut for `withOptions({ allowPaidBroadcast: true })`.
|
|
285
240
|
*/
|
|
286
241
|
export const withPaidBroadcast: (
|
|
287
242
|
self: MessageToSend,
|
|
288
243
|
) => MessageToSend = withOptions({ allowPaidBroadcast: true })
|
|
289
|
-
|
|
290
|
-
// ─── Markup Combinators ──────────────────────────────────────────
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Sets the reply markup for the message.
|
|
294
|
-
*
|
|
295
|
-
* Example:
|
|
296
|
-
* ```ts
|
|
297
|
-
* yield* Send.message(content).pipe(
|
|
298
|
-
* Send.withMarkup(
|
|
299
|
-
* new Markup.ForceReply({
|
|
300
|
-
* selective: false,
|
|
301
|
-
* inputPlaceholder: Option.some("effect-tg or grammY?"),
|
|
302
|
-
* }),
|
|
303
|
-
* ),
|
|
304
|
-
* Send.to(dialog),
|
|
305
|
-
* )
|
|
306
|
-
* ```
|
|
307
|
-
*/
|
|
308
|
-
export const withMarkup: {
|
|
309
|
-
(markup: Markup.Markup): (self: MessageToSend) => MessageToSend
|
|
310
|
-
(self: MessageToSend, markup: Markup.Markup): MessageToSend
|
|
311
|
-
} = Function.dual(2, (
|
|
312
|
-
self: MessageToSend,
|
|
313
|
-
markup: Markup.Markup,
|
|
314
|
-
): MessageToSend => (
|
|
315
|
-
make({
|
|
316
|
-
content: self.content,
|
|
317
|
-
options: self.options,
|
|
318
|
-
markup,
|
|
319
|
-
})
|
|
320
|
-
))
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Removes the reply markup from the message.
|
|
324
|
-
*/
|
|
325
|
-
export const withoutMarkup: (
|
|
326
|
-
self: MessageToSend,
|
|
327
|
-
) => MessageToSend = self => make({
|
|
328
|
-
content: self.content,
|
|
329
|
-
options: self.options,
|
|
330
|
-
markup: undefined,
|
|
331
|
-
})
|
package/src/Text.ts
CHANGED
|
@@ -5,11 +5,11 @@ import * as Data from 'effect/Data'
|
|
|
5
5
|
/**
|
|
6
6
|
* Formatted text.
|
|
7
7
|
*/
|
|
8
|
-
export type Text
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export type Text =
|
|
9
|
+
| Plain
|
|
10
|
+
| Html
|
|
11
|
+
| Markdown
|
|
12
|
+
| Tgx
|
|
13
13
|
|
|
14
14
|
export class Plain extends Data.TaggedClass('Plain')<{
|
|
15
15
|
text: string
|