@grom.js/effect-tg 0.13.0 → 0.14.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 +11 -12
- package/dist/Bot.d.ts +2 -3
- package/dist/Bot.d.ts.map +1 -1
- package/dist/Bot.js +1 -2
- package/dist/Bot.js.map +1 -1
- package/dist/BotApi.d.ts +6 -6
- package/dist/BotApi.d.ts.map +1 -1
- package/dist/BotApi.js +1 -2
- package/dist/BotApi.js.map +1 -1
- package/dist/BotApiError.d.ts +15 -19
- package/dist/BotApiError.d.ts.map +1 -1
- package/dist/BotApiError.js +10 -12
- package/dist/BotApiError.js.map +1 -1
- package/dist/BotApiTransport.d.ts +5 -8
- package/dist/BotApiTransport.d.ts.map +1 -1
- package/dist/BotApiTransport.js +1 -2
- package/dist/BotApiTransport.js.map +1 -1
- package/dist/BotApiUrl.d.ts +6 -9
- package/dist/BotApiUrl.d.ts.map +1 -1
- package/dist/BotApiUrl.js +1 -2
- package/dist/BotApiUrl.js.map +1 -1
- package/dist/Content.d.ts +89 -155
- package/dist/Content.d.ts.map +1 -1
- package/dist/Content.js +26 -119
- package/dist/Content.js.map +1 -1
- package/dist/Dialog.d.ts +28 -58
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +29 -48
- package/dist/Dialog.js.map +1 -1
- package/dist/File.d.ts +11 -6
- package/dist/File.d.ts.map +1 -1
- package/dist/File.js +19 -3
- package/dist/File.js.map +1 -1
- package/dist/Markup.d.ts +8 -21
- package/dist/Markup.d.ts.map +1 -1
- package/dist/Markup.js +12 -13
- package/dist/Markup.js.map +1 -1
- package/dist/Runner.d.ts +3 -1
- package/dist/Runner.d.ts.map +1 -1
- package/dist/Runner.js.map +1 -1
- package/dist/Send.d.ts +14 -14
- package/dist/Send.d.ts.map +1 -1
- package/dist/Send.js +6 -13
- package/dist/Send.js.map +1 -1
- package/dist/Text.d.ts +13 -26
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +4 -13
- package/dist/Text.js.map +1 -1
- package/dist/internal/botApi.d.ts +3 -3
- package/dist/internal/botApi.d.ts.map +1 -1
- package/dist/internal/botApi.js +2 -1
- package/dist/internal/botApi.js.map +1 -1
- package/dist/internal/botApiTransport.d.ts +2 -2
- package/dist/internal/botApiTransport.d.ts.map +1 -1
- package/dist/internal/botApiTransport.js +3 -4
- package/dist/internal/botApiTransport.js.map +1 -1
- package/dist/internal/dialog.d.ts.map +1 -1
- package/dist/internal/dialog.js +8 -16
- package/dist/internal/dialog.js.map +1 -1
- package/dist/internal/file.d.ts +5 -2
- package/dist/internal/file.d.ts.map +1 -1
- package/dist/internal/file.js +3 -0
- package/dist/internal/file.js.map +1 -1
- package/dist/internal/send.d.ts +6 -4
- package/dist/internal/send.d.ts.map +1 -1
- package/dist/internal/send.js +18 -17
- package/dist/internal/send.js.map +1 -1
- package/package.json +1 -1
- package/src/Bot.ts +3 -4
- package/src/BotApi.ts +7 -8
- package/src/BotApiError.ts +19 -25
- package/src/BotApiTransport.ts +6 -9
- package/src/BotApiUrl.ts +7 -10
- package/src/Content.ts +128 -130
- package/src/Dialog.ts +79 -73
- package/src/File.ts +36 -5
- package/src/Markup.ts +37 -27
- package/src/Runner.ts +5 -1
- package/src/Send.ts +27 -26
- package/src/Text.ts +21 -18
- package/src/internal/botApi.ts +5 -6
- package/src/internal/botApiTransport.ts +5 -6
- package/src/internal/dialog.ts +8 -16
- package/src/internal/file.ts +5 -2
- package/src/internal/send.ts +23 -23
package/src/BotApiError.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as HttpBody from '@effect/platform/HttpBody'
|
|
2
2
|
import type * as HttpClientError from '@effect/platform/HttpClientError'
|
|
3
3
|
import type * as BotApiTransport from './BotApiTransport.ts'
|
|
4
|
-
import
|
|
4
|
+
import { TypeIdError } from '@effect/platform/Error'
|
|
5
5
|
import * as Duration from 'effect/Duration'
|
|
6
6
|
import * as Match from 'effect/Match'
|
|
7
7
|
import * as Option from 'effect/Option'
|
|
@@ -9,7 +9,7 @@ import * as Predicate from 'effect/Predicate'
|
|
|
9
9
|
import * as Dialog from './Dialog.ts'
|
|
10
10
|
import * as internal from './internal/botApiError.ts'
|
|
11
11
|
|
|
12
|
-
export const TypeId = '@grom.js/effect-tg/BotApiError'
|
|
12
|
+
export const TypeId: unique symbol = Symbol.for('@grom.js/effect-tg/BotApiError')
|
|
13
13
|
|
|
14
14
|
export type TypeId = typeof TypeId
|
|
15
15
|
|
|
@@ -25,14 +25,12 @@ export type BotApiError =
|
|
|
25
25
|
/**
|
|
26
26
|
* Error caused by the transport when accessing Bot API.
|
|
27
27
|
*/
|
|
28
|
-
export class TransportError extends
|
|
29
|
-
cause:
|
|
28
|
+
export class TransportError extends TypeIdError(TypeId, 'TransportError')<{
|
|
29
|
+
readonly cause:
|
|
30
30
|
| HttpClientError.HttpClientError
|
|
31
31
|
| HttpBody.HttpBodyError
|
|
32
32
|
}> {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
override get message() {
|
|
33
|
+
override get message(): string {
|
|
36
34
|
return Match.value(this.cause).pipe(
|
|
37
35
|
Match.tagsExhaustive({
|
|
38
36
|
RequestError: e => e.message,
|
|
@@ -48,43 +46,39 @@ export class TransportError extends Data.TaggedError('TransportError')<{
|
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
export class MethodFailed extends
|
|
52
|
-
response: FailureResponse
|
|
53
|
-
possibleReason: MethodFailureReason
|
|
49
|
+
export class MethodFailed extends TypeIdError(TypeId, 'MethodFailed')<{
|
|
50
|
+
readonly response: FailureResponse
|
|
51
|
+
readonly possibleReason: MethodFailureReason
|
|
54
52
|
}> {
|
|
55
|
-
readonly [TypeId]: TypeId = TypeId
|
|
56
|
-
|
|
57
53
|
override get message() {
|
|
58
54
|
return `(${this.response.error_code}) ${this.response.description}`
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
export class GroupUpgraded extends
|
|
63
|
-
response: FailureResponse
|
|
64
|
-
supergroup: Dialog.Supergroup
|
|
58
|
+
export class GroupUpgraded extends TypeIdError(TypeId, 'GroupUpgraded')<{
|
|
59
|
+
readonly response: FailureResponse
|
|
60
|
+
readonly supergroup: Dialog.Supergroup
|
|
65
61
|
}> {
|
|
66
|
-
readonly [TypeId]: TypeId = TypeId
|
|
67
|
-
|
|
68
62
|
override get message() {
|
|
69
63
|
return `Group has been upgraded to a supergroup with ID ${this.supergroup.id}.`
|
|
70
64
|
}
|
|
71
65
|
}
|
|
72
66
|
|
|
73
|
-
export class RateLimited extends
|
|
74
|
-
response: FailureResponse
|
|
75
|
-
retryAfter: Duration.Duration
|
|
67
|
+
export class RateLimited extends TypeIdError(TypeId, 'RateLimited')<{
|
|
68
|
+
readonly response: FailureResponse
|
|
69
|
+
readonly retryAfter: Duration.Duration
|
|
76
70
|
}> {
|
|
77
|
-
readonly [TypeId]: TypeId = TypeId
|
|
78
|
-
|
|
79
71
|
override get message() {
|
|
80
72
|
return `Flood limit exceeded. Should wait for ${Duration.format(this.retryAfter)} before retrying.`
|
|
81
73
|
}
|
|
82
74
|
}
|
|
83
75
|
|
|
84
|
-
export class InternalServerError extends
|
|
85
|
-
response: FailureResponse
|
|
76
|
+
export class InternalServerError extends TypeIdError(TypeId, 'InternalServerError')<{
|
|
77
|
+
readonly response: FailureResponse
|
|
86
78
|
}> {
|
|
87
|
-
|
|
79
|
+
override get message() {
|
|
80
|
+
return `Internal error (${this.response.error_code}): ${this.response.description}`
|
|
81
|
+
}
|
|
88
82
|
}
|
|
89
83
|
|
|
90
84
|
export const fromResponse = (response: FailureResponse): BotApiError => {
|
package/src/BotApiTransport.ts
CHANGED
|
@@ -7,18 +7,15 @@ import * as Layer from 'effect/Layer'
|
|
|
7
7
|
import * as BotApiUrl from './BotApiUrl.ts'
|
|
8
8
|
import * as internal from './internal/botApiTransport.ts'
|
|
9
9
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
Service
|
|
13
|
-
>() {}
|
|
14
|
-
|
|
15
|
-
export interface Service {
|
|
16
|
-
sendRequest: (
|
|
10
|
+
export interface BotApiTransport {
|
|
11
|
+
readonly sendRequest: (
|
|
17
12
|
method: string,
|
|
18
13
|
params: unknown,
|
|
19
14
|
) => Effect.Effect<BotApiResponse, BotApiError.TransportError>
|
|
20
15
|
}
|
|
21
16
|
|
|
17
|
+
export const BotApiTransport: Context.Tag<BotApiTransport, BotApiTransport> = Context.GenericTag<BotApiTransport>('@grom.js/effect-tg/BotApiTransport')
|
|
18
|
+
|
|
22
19
|
/**
|
|
23
20
|
* @see https://core.telegram.org/bots/api#making-requests
|
|
24
21
|
*/
|
|
@@ -36,8 +33,8 @@ export type BotApiResponse =
|
|
|
36
33
|
|
|
37
34
|
export const make: (options: {
|
|
38
35
|
httpClient: HttpClient.HttpClient
|
|
39
|
-
botApiUrl: BotApiUrl.
|
|
40
|
-
}) =>
|
|
36
|
+
botApiUrl: BotApiUrl.BotApiUrl
|
|
37
|
+
}) => BotApiTransport = internal.make
|
|
41
38
|
|
|
42
39
|
export const layer: Layer.Layer<
|
|
43
40
|
BotApiTransport,
|
package/src/BotApiUrl.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import * as Context from 'effect/Context'
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
>() {}
|
|
7
|
-
|
|
8
|
-
export interface Service {
|
|
9
|
-
toMethod: (method: string) => URL
|
|
10
|
-
toFile: (filePath: string) => URL
|
|
3
|
+
export interface BotApiUrl {
|
|
4
|
+
readonly toMethod: (method: string) => URL
|
|
5
|
+
readonly toFile: (filePath: string) => URL
|
|
11
6
|
}
|
|
12
7
|
|
|
13
|
-
export const
|
|
8
|
+
export const BotApiUrl: Context.Tag<BotApiUrl, BotApiUrl> = Context.GenericTag<BotApiUrl>('@grom.js/effect-tg/BotApiUrl')
|
|
9
|
+
|
|
10
|
+
export const makeProd = (token: string): BotApiUrl => (
|
|
14
11
|
{
|
|
15
12
|
toMethod: (method: string) => new URL(`https://api.telegram.org/bot${token}/${method}`),
|
|
16
13
|
toFile: (filePath: string) => new URL(`https://api.telegram.org/file/bot${token}/${filePath}`),
|
|
17
14
|
}
|
|
18
15
|
)
|
|
19
16
|
|
|
20
|
-
export const makeTest = (token: string):
|
|
17
|
+
export const makeTest = (token: string): BotApiUrl => (
|
|
21
18
|
{
|
|
22
19
|
toMethod: (method: string) => new URL(`https://api.telegram.org/bot${token}/test/${method}`),
|
|
23
20
|
// TODO: make sure this works in test environment
|
package/src/Content.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type * as Duration from 'effect/Duration'
|
|
|
2
2
|
import type * as File from './File.ts'
|
|
3
3
|
import type * as LinkPreview from './LinkPreview.ts'
|
|
4
4
|
import type * as Text_ from './Text.ts'
|
|
5
|
-
import * as Data from 'effect/Data'
|
|
6
5
|
import * as Option from 'effect/Option'
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -28,184 +27,171 @@ export type Content =
|
|
|
28
27
|
| Sticker
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
|
-
* Content of a text message.
|
|
32
|
-
*
|
|
33
30
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_text.html TDLib • td_api.inputMessageText}
|
|
34
31
|
* @see {@link https://core.telegram.org/bots/api#sendmessage Bot API • sendMessage}
|
|
35
32
|
*/
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
export interface Text {
|
|
34
|
+
readonly _tag: 'Text'
|
|
35
|
+
readonly text: Text_.Text
|
|
36
|
+
readonly linkPreview: Option.Option<LinkPreview.LinkPreview>
|
|
37
|
+
}
|
|
40
38
|
|
|
41
39
|
/**
|
|
42
|
-
* Content of a photo message.
|
|
43
|
-
*
|
|
44
40
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_photo.html TDLib • td_api.inputMessagePhoto}
|
|
45
41
|
* @see {@link https://core.telegram.org/bots/api#sendphoto Bot API • sendPhoto}
|
|
46
42
|
*/
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
export interface Photo {
|
|
44
|
+
readonly _tag: 'Photo'
|
|
45
|
+
readonly file: File.FileId | File.External | File.InputFile
|
|
46
|
+
readonly caption: Option.Option<Text_.Text>
|
|
47
|
+
readonly layout: 'caption-above' | 'caption-below'
|
|
48
|
+
readonly spoiler: boolean
|
|
49
|
+
}
|
|
53
50
|
|
|
54
51
|
/**
|
|
55
|
-
* Content of an audio message.
|
|
56
|
-
*
|
|
57
52
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_audio.html TDLib • td_api.inputMessageAudio}
|
|
58
53
|
* @see {@link https://core.telegram.org/bots/api#sendaudio Bot API • sendAudio}
|
|
59
54
|
*/
|
|
60
|
-
export
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
export interface Audio {
|
|
56
|
+
readonly _tag: 'Audio'
|
|
57
|
+
readonly file: File.FileId | File.External | File.InputFile
|
|
58
|
+
readonly caption: Option.Option<Text_.Text>
|
|
59
|
+
readonly duration: Option.Option<Duration.Duration>
|
|
60
|
+
readonly performer: Option.Option<string>
|
|
61
|
+
readonly title: Option.Option<string>
|
|
62
|
+
readonly thumbnail: Option.Option<File.InputFile>
|
|
63
|
+
}
|
|
68
64
|
|
|
69
65
|
/**
|
|
70
|
-
* Content of a document message.
|
|
71
|
-
*
|
|
72
66
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_document.html TDLib • td_api.inputMessageDocument}
|
|
73
67
|
* @see {@link https://core.telegram.org/bots/api#senddocument Bot API • sendDocument}
|
|
74
68
|
*/
|
|
75
|
-
export
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
export interface Document {
|
|
70
|
+
readonly _tag: 'Document'
|
|
71
|
+
readonly file: File.FileId | File.External | File.InputFile
|
|
72
|
+
readonly caption: Option.Option<Text_.Text>
|
|
73
|
+
readonly thumbnail: Option.Option<File.InputFile>
|
|
74
|
+
readonly contentTypeDetection: boolean
|
|
75
|
+
}
|
|
81
76
|
|
|
82
77
|
/**
|
|
83
|
-
* Content of a video message.
|
|
84
|
-
*
|
|
85
78
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_video.html TDLib • td_api.inputMessageVideo}
|
|
86
79
|
* @see {@link https://core.telegram.org/bots/api#sendvideo Bot API • sendVideo}
|
|
87
80
|
*/
|
|
88
|
-
export
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
81
|
+
export interface Video {
|
|
82
|
+
readonly _tag: 'Video'
|
|
83
|
+
readonly file: File.FileId | File.External | File.InputFile
|
|
84
|
+
readonly caption: Option.Option<Text_.Text>
|
|
85
|
+
readonly layout: 'caption-above' | 'caption-below'
|
|
86
|
+
readonly spoiler: boolean
|
|
87
|
+
readonly duration: Option.Option<Duration.Duration>
|
|
88
|
+
readonly width: Option.Option<number>
|
|
89
|
+
readonly height: Option.Option<number>
|
|
90
|
+
readonly thumbnail: Option.Option<File.InputFile>
|
|
91
|
+
readonly cover: Option.Option<File.FileId | File.External | File.InputFile>
|
|
92
|
+
readonly startAt: Option.Option<Duration.Duration>
|
|
93
|
+
readonly supportsStreaming: boolean
|
|
94
|
+
}
|
|
101
95
|
|
|
102
96
|
/**
|
|
103
|
-
* Content of an animation message (GIF or video without sound).
|
|
104
|
-
*
|
|
105
97
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_animation.html TDLib • td_api.inputMessageAnimation}
|
|
106
98
|
* @see {@link https://core.telegram.org/bots/api#sendanimation Bot API • sendAnimation}
|
|
107
99
|
*/
|
|
108
|
-
export
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
100
|
+
export interface Animation {
|
|
101
|
+
readonly _tag: 'Animation'
|
|
102
|
+
readonly file: File.FileId | File.External | File.InputFile
|
|
103
|
+
readonly caption: Option.Option<Text_.Text>
|
|
104
|
+
readonly layout: 'caption-above' | 'caption-below'
|
|
105
|
+
readonly spoiler: boolean
|
|
106
|
+
readonly duration: Option.Option<Duration.Duration>
|
|
107
|
+
readonly width: Option.Option<number>
|
|
108
|
+
readonly height: Option.Option<number>
|
|
109
|
+
readonly thumbnail: Option.Option<File.InputFile>
|
|
110
|
+
}
|
|
118
111
|
|
|
119
112
|
/**
|
|
120
|
-
* Content of a voice note message.
|
|
121
|
-
*
|
|
122
113
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_voice_note.html TDLib • td_api.inputMessageVoiceNote}
|
|
123
114
|
* @see {@link https://core.telegram.org/bots/api#sendvoice Bot API • sendVoice}
|
|
124
115
|
*/
|
|
125
|
-
export
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
116
|
+
export interface Voice {
|
|
117
|
+
readonly _tag: 'Voice'
|
|
118
|
+
readonly file: File.FileId | File.External | File.InputFile
|
|
119
|
+
readonly caption: Option.Option<Text_.Text>
|
|
120
|
+
readonly duration: Option.Option<Duration.Duration>
|
|
121
|
+
}
|
|
130
122
|
|
|
131
123
|
/**
|
|
132
|
-
* Content of a video note message (round video).
|
|
133
|
-
*
|
|
134
124
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_video_note.html TDLib • td_api.inputMessageVideoNote}
|
|
135
125
|
* @see {@link https://core.telegram.org/bots/api#sendvideonote Bot API • sendVideoNote}
|
|
136
126
|
*/
|
|
137
|
-
export
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
127
|
+
export interface VideoNote {
|
|
128
|
+
readonly _tag: 'VideoNote'
|
|
129
|
+
readonly file: File.FileId | File.InputFile
|
|
130
|
+
readonly duration: Option.Option<Duration.Duration>
|
|
131
|
+
readonly diameter: Option.Option<number>
|
|
132
|
+
readonly thumbnail: Option.Option<File.InputFile>
|
|
133
|
+
}
|
|
143
134
|
|
|
144
135
|
/**
|
|
145
|
-
* Content of a location message.
|
|
146
|
-
*
|
|
147
136
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_location.html TDLib • td_api.inputMessageLocation}
|
|
148
137
|
* @see {@link https://core.telegram.org/bots/api#sendlocation Bot API • sendLocation}
|
|
149
138
|
*/
|
|
150
|
-
export
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
139
|
+
export interface Location {
|
|
140
|
+
readonly _tag: 'Location'
|
|
141
|
+
readonly latitude: number
|
|
142
|
+
readonly longitude: number
|
|
143
|
+
readonly uncertaintyRadius: Option.Option<number>
|
|
144
|
+
readonly livePeriod: Option.Option<Duration.Duration>
|
|
145
|
+
readonly heading: Option.Option<number>
|
|
146
|
+
readonly proximityAlertRadius: Option.Option<number>
|
|
147
|
+
}
|
|
158
148
|
|
|
159
149
|
/**
|
|
160
|
-
* Content of a venue message.
|
|
161
|
-
*
|
|
162
150
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_venue.html TDLib • td_api.inputMessageVenue}
|
|
163
151
|
* @see {@link https://core.telegram.org/bots/api#sendvenue Bot API • sendVenue}
|
|
164
152
|
*/
|
|
165
|
-
export
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
153
|
+
export interface Venue {
|
|
154
|
+
readonly _tag: 'Venue'
|
|
155
|
+
readonly latitude: number
|
|
156
|
+
readonly longitude: number
|
|
157
|
+
readonly title: string
|
|
158
|
+
readonly address: string
|
|
159
|
+
readonly foursquareId: Option.Option<string>
|
|
160
|
+
readonly foursquareType: Option.Option<string>
|
|
161
|
+
readonly googlePlaceId: Option.Option<string>
|
|
162
|
+
readonly googlePlaceType: Option.Option<string>
|
|
163
|
+
}
|
|
175
164
|
|
|
176
165
|
/**
|
|
177
|
-
* Content of a contact message.
|
|
178
|
-
*
|
|
179
166
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_contact.html TDLib • td_api.inputMessageContact}
|
|
180
167
|
* @see {@link https://core.telegram.org/bots/api#sendcontact Bot API • sendContact}
|
|
181
168
|
*/
|
|
182
|
-
export
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
169
|
+
export interface Contact {
|
|
170
|
+
readonly _tag: 'Contact'
|
|
171
|
+
readonly phoneNumber: string
|
|
172
|
+
readonly firstName: string
|
|
173
|
+
readonly lastName: Option.Option<string>
|
|
174
|
+
readonly vcard: Option.Option<string>
|
|
175
|
+
}
|
|
188
176
|
|
|
189
177
|
/**
|
|
190
|
-
* Content of a dice message.
|
|
191
|
-
*
|
|
192
178
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_dice.html TDLib • td_api.inputMessageDice}
|
|
193
179
|
* @see {@link https://core.telegram.org/bots/api#senddice Bot API • sendDice}
|
|
194
180
|
*/
|
|
195
|
-
export
|
|
196
|
-
|
|
197
|
-
|
|
181
|
+
export interface Dice {
|
|
182
|
+
readonly _tag: 'Dice'
|
|
183
|
+
readonly emoji: '🎲' | '🎯' | '🏀' | '⚽' | '🎳' | '🎰'
|
|
184
|
+
}
|
|
198
185
|
|
|
199
186
|
/**
|
|
200
|
-
* Content of a sticker message.
|
|
201
|
-
*
|
|
202
187
|
* @see {@link https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1input_message_sticker.html TDLib • td_api.inputMessageSticker}
|
|
203
188
|
* @see {@link https://core.telegram.org/bots/api#sendsticker Bot API • sendSticker}
|
|
204
189
|
*/
|
|
205
|
-
export
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
190
|
+
export interface Sticker {
|
|
191
|
+
readonly _tag: 'Sticker'
|
|
192
|
+
readonly file: File.FileId | File.External | File.InputFile
|
|
193
|
+
readonly emoji: Option.Option<string>
|
|
194
|
+
}
|
|
209
195
|
|
|
210
196
|
// ——— Constructors ——————————————————————————————————————————————————————————
|
|
211
197
|
|
|
@@ -214,7 +200,8 @@ export const text = (
|
|
|
214
200
|
options?: {
|
|
215
201
|
linkPreview?: LinkPreview.LinkPreview
|
|
216
202
|
},
|
|
217
|
-
) =>
|
|
203
|
+
): Text => ({
|
|
204
|
+
_tag: 'Text',
|
|
218
205
|
text,
|
|
219
206
|
linkPreview: Option.fromNullable(options?.linkPreview),
|
|
220
207
|
})
|
|
@@ -226,7 +213,8 @@ export const photo = (
|
|
|
226
213
|
layout?: 'caption-above' | 'caption-below'
|
|
227
214
|
spoiler?: boolean
|
|
228
215
|
},
|
|
229
|
-
): Photo =>
|
|
216
|
+
): Photo => ({
|
|
217
|
+
_tag: 'Photo',
|
|
230
218
|
file,
|
|
231
219
|
caption: Option.fromNullable(options.caption),
|
|
232
220
|
layout: options.layout ?? 'caption-below',
|
|
@@ -242,7 +230,8 @@ export const audio = (
|
|
|
242
230
|
title?: string
|
|
243
231
|
thumbnail?: File.InputFile
|
|
244
232
|
},
|
|
245
|
-
): Audio =>
|
|
233
|
+
): Audio => ({
|
|
234
|
+
_tag: 'Audio',
|
|
246
235
|
file,
|
|
247
236
|
caption: Option.fromNullable(options.caption),
|
|
248
237
|
duration: Option.fromNullable(options.duration),
|
|
@@ -258,7 +247,8 @@ export const document = (
|
|
|
258
247
|
thumbnail?: File.InputFile
|
|
259
248
|
contentTypeDetection?: boolean
|
|
260
249
|
},
|
|
261
|
-
): Document =>
|
|
250
|
+
): Document => ({
|
|
251
|
+
_tag: 'Document',
|
|
262
252
|
file,
|
|
263
253
|
caption: Option.fromNullable(options.caption),
|
|
264
254
|
thumbnail: Option.fromNullable(options.thumbnail),
|
|
@@ -279,7 +269,8 @@ export const video = (
|
|
|
279
269
|
startAt?: Duration.Duration
|
|
280
270
|
supportsStreaming?: boolean
|
|
281
271
|
},
|
|
282
|
-
): Video =>
|
|
272
|
+
): Video => ({
|
|
273
|
+
_tag: 'Video',
|
|
283
274
|
file,
|
|
284
275
|
caption: Option.fromNullable(options.caption),
|
|
285
276
|
layout: options.layout ?? 'caption-below',
|
|
@@ -304,7 +295,8 @@ export const animation = (
|
|
|
304
295
|
height?: number
|
|
305
296
|
thumbnail?: File.InputFile
|
|
306
297
|
},
|
|
307
|
-
): Animation =>
|
|
298
|
+
): Animation => ({
|
|
299
|
+
_tag: 'Animation',
|
|
308
300
|
file,
|
|
309
301
|
caption: Option.fromNullable(options.caption),
|
|
310
302
|
layout: options.layout ?? 'caption-below',
|
|
@@ -321,7 +313,8 @@ export const voice = (
|
|
|
321
313
|
caption?: Text_.Text
|
|
322
314
|
duration?: Duration.Duration
|
|
323
315
|
},
|
|
324
|
-
): Voice =>
|
|
316
|
+
): Voice => ({
|
|
317
|
+
_tag: 'Voice',
|
|
325
318
|
file,
|
|
326
319
|
caption: Option.fromNullable(options.caption),
|
|
327
320
|
duration: Option.fromNullable(options.duration),
|
|
@@ -334,7 +327,8 @@ export const videoNote = (
|
|
|
334
327
|
diameter?: number
|
|
335
328
|
thumbnail?: File.InputFile
|
|
336
329
|
},
|
|
337
|
-
): VideoNote =>
|
|
330
|
+
): VideoNote => ({
|
|
331
|
+
_tag: 'VideoNote',
|
|
338
332
|
file,
|
|
339
333
|
duration: Option.fromNullable(options.duration),
|
|
340
334
|
diameter: Option.fromNullable(options.diameter),
|
|
@@ -345,7 +339,8 @@ export const location = (options: {
|
|
|
345
339
|
latitude: number
|
|
346
340
|
longitude: number
|
|
347
341
|
uncertaintyRadius?: number
|
|
348
|
-
}): Location =>
|
|
342
|
+
}): Location => ({
|
|
343
|
+
_tag: 'Location',
|
|
349
344
|
latitude: options.latitude,
|
|
350
345
|
longitude: options.longitude,
|
|
351
346
|
uncertaintyRadius: Option.fromNullable(options.uncertaintyRadius),
|
|
@@ -361,7 +356,8 @@ export const liveLocation = (options: {
|
|
|
361
356
|
livePeriod: Duration.Duration
|
|
362
357
|
heading?: number
|
|
363
358
|
proximityAlertRadius?: number
|
|
364
|
-
}): Location =>
|
|
359
|
+
}): Location => ({
|
|
360
|
+
_tag: 'Location',
|
|
365
361
|
latitude: options.latitude,
|
|
366
362
|
longitude: options.longitude,
|
|
367
363
|
uncertaintyRadius: Option.fromNullable(options.uncertaintyRadius),
|
|
@@ -379,7 +375,8 @@ export const venue = (options: {
|
|
|
379
375
|
foursquareType?: string
|
|
380
376
|
googlePlaceId?: string
|
|
381
377
|
googlePlaceType?: string
|
|
382
|
-
}): Venue =>
|
|
378
|
+
}): Venue => ({
|
|
379
|
+
_tag: 'Venue',
|
|
383
380
|
latitude: options.latitude,
|
|
384
381
|
longitude: options.longitude,
|
|
385
382
|
title: options.title,
|
|
@@ -395,16 +392,17 @@ export const contact = (options: {
|
|
|
395
392
|
firstName: string
|
|
396
393
|
lastName?: string
|
|
397
394
|
vcard?: string
|
|
398
|
-
}): Contact =>
|
|
395
|
+
}): Contact => ({
|
|
396
|
+
_tag: 'Contact',
|
|
399
397
|
phoneNumber: options.phoneNumber,
|
|
400
398
|
firstName: options.firstName,
|
|
401
399
|
lastName: Option.fromNullable(options.lastName),
|
|
402
400
|
vcard: Option.fromNullable(options.vcard),
|
|
403
401
|
})
|
|
404
402
|
|
|
405
|
-
export const dice = (emoji: Dice['emoji']): Dice =>
|
|
403
|
+
export const dice = (emoji: Dice['emoji']): Dice => ({ _tag: 'Dice', emoji })
|
|
406
404
|
|
|
407
405
|
export const sticker = (
|
|
408
406
|
file: File.FileId | File.External | File.InputFile,
|
|
409
407
|
emoji?: string,
|
|
410
|
-
): Sticker =>
|
|
408
|
+
): Sticker => ({ _tag: 'Sticker', file, emoji: Option.fromNullable(emoji) })
|