@effect/chat-telegram 0.0.0-stage → 4.1.5
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/AGENTS.md +434 -0
- package/CLAUDE.md +434 -0
- package/LICENSE +21 -0
- package/README.md +121 -2
- package/ai-docs/README.md +44 -0
- package/ai-docs/package.json +36 -0
- package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +52 -0
- package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
- package/ai-docs/src/01_effect/01_basics/index.md +7 -0
- package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
- package/ai-docs/src/01_effect/02_schema/index.md +7 -0
- package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
- package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
- package/ai-docs/src/01_effect/03_services/index.md +5 -0
- package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
- package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
- package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
- package/ai-docs/src/01_effect/04_errors/index.md +1 -0
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
- package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
- package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
- package/ai-docs/src/01_effect/05_resources/index.md +3 -0
- package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
- package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
- package/ai-docs/src/01_effect/06_running/index.md +1 -0
- package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
- package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
- package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
- package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
- package/ai-docs/src/03_stream/30_encoding.ts +163 -0
- package/ai-docs/src/03_stream/index.md +4 -0
- package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
- package/ai-docs/src/04_integration/index.md +5 -0
- package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
- package/ai-docs/src/05_batching/index.md +3 -0
- package/ai-docs/src/06_schedule/10_schedules.ts +111 -0
- package/ai-docs/src/06_schedule/index.md +3 -0
- package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
- package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
- package/ai-docs/src/07_datetime/index.md +5 -0
- package/ai-docs/src/08_observability/10_logging.ts +66 -0
- package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
- package/ai-docs/src/08_observability/index.md +7 -0
- package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
- package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
- package/ai-docs/src/09_testing/index.md +1 -0
- package/ai-docs/src/10_predicate/01_basics.ts +14 -0
- package/ai-docs/src/10_predicate/index.md +9 -0
- package/ai-docs/src/40_sql/10_basics.ts +175 -0
- package/ai-docs/src/40_sql/index.md +6 -0
- package/ai-docs/src/50_http-client/10_basics.ts +102 -0
- package/ai-docs/src/50_http-client/index.md +3 -0
- package/ai-docs/src/51_http-server/10_basics.ts +118 -0
- package/ai-docs/src/51_http-server/20_testing.ts +100 -0
- package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
- package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
- package/ai-docs/src/51_http-server/fixtures/api/Users.ts +107 -0
- package/ai-docs/src/51_http-server/fixtures/domain/User.ts +21 -0
- package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
- package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +37 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +80 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users.ts +183 -0
- package/ai-docs/src/51_http-server/index.md +3 -0
- package/ai-docs/src/52_graphql/10_basics.ts +117 -0
- package/ai-docs/src/52_graphql/20_testing.ts +45 -0
- package/ai-docs/src/52_graphql/30_batching.ts +118 -0
- package/ai-docs/src/52_graphql/40_aliased-batching.ts +124 -0
- package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
- package/ai-docs/src/52_graphql/index.md +6 -0
- package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
- package/ai-docs/src/60_child-process/index.md +3 -0
- package/ai-docs/src/70_cli/10_basics.ts +162 -0
- package/ai-docs/src/70_cli/index.md +5 -0
- package/ai-docs/src/71_ai/10_language-model.ts +156 -0
- package/ai-docs/src/71_ai/20_tools.ts +226 -0
- package/ai-docs/src/71_ai/30_chat.ts +158 -0
- package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
- package/ai-docs/src/71_ai/index.md +5 -0
- package/ai-docs/src/80_cluster/10_entities.ts +97 -0
- package/ai-docs/src/80_cluster/index.md +4 -0
- package/ai-docs/src/index.md +10 -0
- package/ai-docs/tsconfig.json +28 -0
- package/dist/TelegramBotApi.d.ts +153 -0
- package/dist/TelegramBotApi.d.ts.map +1 -0
- package/dist/TelegramBotApi.js +219 -0
- package/dist/TelegramBotApi.js.map +1 -0
- package/dist/TelegramChat.d.ts +390 -0
- package/dist/TelegramChat.d.ts.map +1 -0
- package/dist/TelegramChat.js +359 -0
- package/dist/TelegramChat.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/actions.d.ts +2 -0
- package/dist/internal/actions.d.ts.map +1 -0
- package/dist/internal/actions.js +88 -0
- package/dist/internal/actions.js.map +1 -0
- package/dist/internal/adapter.d.ts +2 -0
- package/dist/internal/adapter.d.ts.map +1 -0
- package/dist/internal/adapter.js +309 -0
- package/dist/internal/adapter.js.map +1 -0
- package/dist/internal/address.d.ts +2 -0
- package/dist/internal/address.d.ts.map +1 -0
- package/dist/internal/address.js +26 -0
- package/dist/internal/address.js.map +1 -0
- package/dist/internal/commands.d.ts +2 -0
- package/dist/internal/commands.d.ts.map +1 -0
- package/dist/internal/commands.js +30 -0
- package/dist/internal/commands.js.map +1 -0
- package/dist/internal/errors.d.ts +2 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +136 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/markdown.d.ts +9 -0
- package/dist/internal/markdown.d.ts.map +1 -0
- package/dist/internal/markdown.js +708 -0
- package/dist/internal/markdown.js.map +1 -0
- package/dist/internal/normalize.d.ts +2 -0
- package/dist/internal/normalize.d.ts.map +1 -0
- package/dist/internal/normalize.js +276 -0
- package/dist/internal/normalize.js.map +1 -0
- package/dist/internal/options.d.ts +2 -0
- package/dist/internal/options.d.ts.map +1 -0
- package/dist/internal/options.js +6 -0
- package/dist/internal/options.js.map +1 -0
- package/dist/internal/polling.d.ts +2 -0
- package/dist/internal/polling.d.ts.map +1 -0
- package/dist/internal/polling.js +68 -0
- package/dist/internal/polling.js.map +1 -0
- package/dist/internal/receive.d.ts +2 -0
- package/dist/internal/receive.d.ts.map +1 -0
- package/dist/internal/receive.js +183 -0
- package/dist/internal/receive.js.map +1 -0
- package/dist/internal/webhook.d.ts +2 -0
- package/dist/internal/webhook.d.ts.map +1 -0
- package/dist/internal/webhook.js +61 -0
- package/dist/internal/webhook.js.map +1 -0
- package/package.json +62 -3
- package/src/TelegramBotApi.ts +282 -0
- package/src/TelegramChat.ts +542 -0
- package/src/index.ts +18 -0
- package/src/internal/actions.ts +95 -0
- package/src/internal/adapter.ts +319 -0
- package/src/internal/address.ts +33 -0
- package/src/internal/commands.ts +37 -0
- package/src/internal/errors.ts +148 -0
- package/src/internal/markdown.ts +805 -0
- package/src/internal/normalize.ts +283 -0
- package/src/internal/options.ts +12 -0
- package/src/internal/polling.ts +86 -0
- package/src/internal/receive.ts +268 -0
- package/src/internal/webhook.ts +85 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { Registry } from "effect/chat/ChatAdapter";
|
|
2
|
+
import type { ChatError } from "effect/chat/ChatError";
|
|
3
|
+
import type { ChatEvent } from "effect/chat/ChatEvent";
|
|
4
|
+
import { ChatHandler } from "effect/chat/ChatHandler";
|
|
5
|
+
import type * as ChatInteraction from "effect/chat/ChatInteraction";
|
|
6
|
+
import type { ParseMention } from "effect/chat/ChatTest";
|
|
7
|
+
import type { ChatThread } from "effect/chat/ChatThread";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
9
|
+
import * as Duration from "effect/Duration";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
12
|
+
import * as HttpRouter from "effect/http/HttpRouter";
|
|
13
|
+
import * as Layer from "effect/Layer";
|
|
14
|
+
import * as Option from "effect/Option";
|
|
15
|
+
import type * as Redacted from "effect/Redacted";
|
|
16
|
+
import type * as Schema from "effect/Schema";
|
|
17
|
+
import * as TelegramBotApi from "./TelegramBotApi.ts";
|
|
18
|
+
/**
|
|
19
|
+
* Capabilities that are built but stay off until their live checks pass.
|
|
20
|
+
*
|
|
21
|
+
* **Details**
|
|
22
|
+
*
|
|
23
|
+
* - `files`: rich-message media sent as multipart `attach://` parts,
|
|
24
|
+
* up to 10 per post and 50 MB each.
|
|
25
|
+
* - `buttons`: inline keyboards. A click is dispatched only when its
|
|
26
|
+
* `data` matches a button in Telegram's copy of the message.
|
|
27
|
+
* - `commands`: messages that start with a `bot_command` for this bot.
|
|
28
|
+
*
|
|
29
|
+
* @stability unstable
|
|
30
|
+
* @category models
|
|
31
|
+
* @since 4.1.5
|
|
32
|
+
*/
|
|
33
|
+
export interface Unverified {
|
|
34
|
+
readonly files?: boolean | undefined;
|
|
35
|
+
readonly buttons?: boolean | undefined;
|
|
36
|
+
readonly commands?: boolean | undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* What became of one update given to `receive`.
|
|
40
|
+
*
|
|
41
|
+
* **Details**
|
|
42
|
+
*
|
|
43
|
+
* - `accepted`: its event was accepted, or its click or command was
|
|
44
|
+
* answered, refused or not.
|
|
45
|
+
* - `unhandled`: it gave nothing and went to `onUnhandled`.
|
|
46
|
+
* - `notAccepted`: the `ChatHandler` failed `NotAccepted` or passed
|
|
47
|
+
* `deadline`.
|
|
48
|
+
* - `invalid`: it is not an update, or it should give an event and could
|
|
49
|
+
* not be read.
|
|
50
|
+
*
|
|
51
|
+
* @stability unstable
|
|
52
|
+
* @category models
|
|
53
|
+
* @since 4.1.5
|
|
54
|
+
*/
|
|
55
|
+
export type Outcome = "accepted" | "unhandled" | "notAccepted" | "invalid";
|
|
56
|
+
/**
|
|
57
|
+
* Options for running updates.
|
|
58
|
+
*
|
|
59
|
+
* @stability unstable
|
|
60
|
+
* @category models
|
|
61
|
+
* @since 4.1.5
|
|
62
|
+
*/
|
|
63
|
+
export interface ReceiveOptions {
|
|
64
|
+
/** Updates that give no event, the excluded contexts among them. */
|
|
65
|
+
readonly onUnhandled?: ((update: Schema.Json) => Effect.Effect<void>) | undefined;
|
|
66
|
+
/** How long `ChatHandler.handle` has before the update is `notAccepted`. Default 10 seconds. */
|
|
67
|
+
readonly deadline?: Duration.Input | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* How long a click handler has before the click is answered. Default 2.5
|
|
70
|
+
* seconds. The handler then keeps running, detached, and the update is
|
|
71
|
+
* `accepted`: Telegram does not send it again.
|
|
72
|
+
*/
|
|
73
|
+
readonly clickDeadline?: Duration.Input | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* How long a command handler has. Default 10 seconds. The handler is then
|
|
76
|
+
* interrupted, and the update is `accepted`: Telegram does not send it
|
|
77
|
+
* again.
|
|
78
|
+
*/
|
|
79
|
+
readonly commandDeadline?: Duration.Input | undefined;
|
|
80
|
+
}
|
|
81
|
+
declare const TelegramChat_base: Context.ServiceClass<TelegramChat, "@effect/chat-telegram/TelegramChat", {
|
|
82
|
+
readonly botId: string;
|
|
83
|
+
readonly environment: TelegramBotApi.Environment;
|
|
84
|
+
readonly receive: (update: unknown, options?: ReceiveOptions | undefined) => Effect.Effect<Outcome, never, ChatHandler>;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* The Telegram adapter's own service.
|
|
88
|
+
*
|
|
89
|
+
* **Details**
|
|
90
|
+
*
|
|
91
|
+
* - `botId` is the numeric id in front of the token's colon.
|
|
92
|
+
* - `receive` runs one update, already authenticated and parsed, as both
|
|
93
|
+
* transports do, for a consumer's own transport. It needs a
|
|
94
|
+
* `ChatHandler`. Clicks and commands go to `ChatInteraction.Handler`
|
|
95
|
+
* when there is one in context: without it a click is answered and
|
|
96
|
+
* dropped, and a command is an ordinary message.
|
|
97
|
+
*
|
|
98
|
+
* @stability unstable
|
|
99
|
+
* @category services
|
|
100
|
+
* @since 4.1.5
|
|
101
|
+
*/
|
|
102
|
+
export declare class TelegramChat extends TelegramChat_base {
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Registers the Telegram adapter in the `Registry` and provides the
|
|
106
|
+
* `TelegramChat` and `TelegramBotApi` services.
|
|
107
|
+
*
|
|
108
|
+
* **Details**
|
|
109
|
+
*
|
|
110
|
+
* - The descriptor has `edit`, `delete`, `replyTo`, `download`,
|
|
111
|
+
* `getThread` and `getUser`, beside `post`, and whatever `unverified`
|
|
112
|
+
* turns on.
|
|
113
|
+
* - `environment: "test"` uses Telegram's test environment.
|
|
114
|
+
* - `apiUrl` is for a local Bot API server and is privileged configuration.
|
|
115
|
+
* - Fails `Unauthenticated` when the token has no bot id. The token is not
|
|
116
|
+
* checked against Telegram here; the first call does that.
|
|
117
|
+
* - The bot's username, which commands and `@` mentions need, is read with
|
|
118
|
+
* `getMe` on the first message and kept. While it can't be read, a
|
|
119
|
+
* message update is `invalid`, and Telegram sends it again.
|
|
120
|
+
*
|
|
121
|
+
* @stability unstable
|
|
122
|
+
* @category layers
|
|
123
|
+
* @since 4.1.5
|
|
124
|
+
*/
|
|
125
|
+
export declare const layer: (options: {
|
|
126
|
+
readonly token: Redacted.Redacted<string>;
|
|
127
|
+
readonly environment?: TelegramBotApi.Environment | undefined;
|
|
128
|
+
readonly apiUrl?: string | undefined;
|
|
129
|
+
readonly unverified?: Unverified | undefined;
|
|
130
|
+
}) => Layer.Layer<TelegramChat | TelegramBotApi.TelegramBotApi, ChatError, HttpClient.HttpClient | Registry>;
|
|
131
|
+
/**
|
|
132
|
+
* The header Telegram sends the webhook secret in. An app that records
|
|
133
|
+
* server request headers must add it to `Headers.CurrentRedactedNames`,
|
|
134
|
+
* keeping the names already there, in the layer it serves:
|
|
135
|
+
* `Layer.provideMerge` reaches the server span, `Layer.provide` on the
|
|
136
|
+
* webhook alone does not. The README has the setup.
|
|
137
|
+
*
|
|
138
|
+
* @stability unstable
|
|
139
|
+
* @category constants
|
|
140
|
+
* @since 4.1.5
|
|
141
|
+
*/
|
|
142
|
+
export declare const secretHeader: string;
|
|
143
|
+
/**
|
|
144
|
+
* `POST {path}`: the bot's webhook.
|
|
145
|
+
*
|
|
146
|
+
* **Details**
|
|
147
|
+
*
|
|
148
|
+
* - The `X-Telegram-Bot-Api-Secret-Token` header must equal
|
|
149
|
+
* `secretToken`, compared in constant time. Otherwise the answer is 401
|
|
150
|
+
* and the body is not read. The layer fails unless `secretToken` is 32 to
|
|
151
|
+
* 256 characters of `A-Za-z0-9_-`.
|
|
152
|
+
* - 413 past `maxBodyBytes` (1 MiB by default), 400 for a body that can't
|
|
153
|
+
* be read or is not an update. `maxBodyBytes` must be a non-negative safe
|
|
154
|
+
* integer; another value is a defect when the layer is built.
|
|
155
|
+
* - The update goes through `receive`: 200 for `accepted` and
|
|
156
|
+
* `unhandled`, 503 for `notAccepted` and `invalid`, which Telegram
|
|
157
|
+
* sends again. A click or command is answered 200 after its reply
|
|
158
|
+
* attempt.
|
|
159
|
+
*
|
|
160
|
+
* @stability unstable
|
|
161
|
+
* @category layers
|
|
162
|
+
* @since 4.1.5
|
|
163
|
+
*/
|
|
164
|
+
export declare const layerWebhook: (options: ReceiveOptions & {
|
|
165
|
+
readonly path: `/${string}`;
|
|
166
|
+
readonly secretToken: Redacted.Redacted<string>;
|
|
167
|
+
readonly maxBodyBytes?: number | undefined;
|
|
168
|
+
}) => Layer.Layer<never, ChatError, HttpRouter.HttpRouter | TelegramChat | ChatHandler>;
|
|
169
|
+
/**
|
|
170
|
+
* Long polling with `getUpdates`, for a long-running process.
|
|
171
|
+
*
|
|
172
|
+
* **Details**
|
|
173
|
+
*
|
|
174
|
+
* - Updates run one at a time, in order, through `receive`. An update is
|
|
175
|
+
* confirmed only after it ran, so a process that dies part way sees it
|
|
176
|
+
* again.
|
|
177
|
+
* - `notAccepted` and `invalid` are retried up to `maxAttempts` times (3
|
|
178
|
+
* by default) with a backoff, then logged as an error and skipped:
|
|
179
|
+
* `getUpdates` is one queue, and retrying forever would stall the bot.
|
|
180
|
+
* - The layer fails with `InvalidRequest` and detail `conflict` when
|
|
181
|
+
* Telegram answers 409 at start: a webhook is set, or another process
|
|
182
|
+
* polls. It never deletes a webhook itself. A later 409 stops polling
|
|
183
|
+
* with an error log.
|
|
184
|
+
*
|
|
185
|
+
* @stability unstable
|
|
186
|
+
* @category layers
|
|
187
|
+
* @since 4.1.5
|
|
188
|
+
*/
|
|
189
|
+
export declare const layerPolling: (options?: ReceiveOptions & {
|
|
190
|
+
/** The long-poll timeout. Default 30 seconds. */
|
|
191
|
+
readonly timeout?: Duration.Input | undefined;
|
|
192
|
+
readonly maxAttempts?: number | undefined;
|
|
193
|
+
}) => Layer.Layer<never, ChatError, TelegramChat | TelegramBotApi.TelegramBotApi | ChatHandler>;
|
|
194
|
+
/**
|
|
195
|
+
* Registers the webhook with exactly the `allowed_updates` the adapter
|
|
196
|
+
* reads. It is never called by the adapter itself.
|
|
197
|
+
*
|
|
198
|
+
* @stability unstable
|
|
199
|
+
* @category webhooks
|
|
200
|
+
* @since 4.1.5
|
|
201
|
+
*/
|
|
202
|
+
export declare const setWebhook: (options: {
|
|
203
|
+
readonly url: string;
|
|
204
|
+
readonly secretToken: Redacted.Redacted<string>;
|
|
205
|
+
readonly maxConnections?: number | undefined;
|
|
206
|
+
readonly dropPendingUpdates?: boolean | undefined;
|
|
207
|
+
}) => Effect.Effect<void, ChatError, TelegramBotApi.TelegramBotApi>;
|
|
208
|
+
/**
|
|
209
|
+
* The `setMyCommands` payload for a group's commands.
|
|
210
|
+
*
|
|
211
|
+
* **Details**
|
|
212
|
+
*
|
|
213
|
+
* - Fails `InvalidRequest` with detail `invalid_command_names` when a
|
|
214
|
+
* command id is not `[a-z0-9_]{1,32}`. The portable rule allows `-`;
|
|
215
|
+
* Telegram does not.
|
|
216
|
+
* - An `argument` has no Telegram counterpart and is appended to the
|
|
217
|
+
* description.
|
|
218
|
+
* - Commands are registered as ordinary, not ephemeral: this version has
|
|
219
|
+
* no `ephemeral`.
|
|
220
|
+
*
|
|
221
|
+
* @stability unstable
|
|
222
|
+
* @category commands
|
|
223
|
+
* @since 4.1.5
|
|
224
|
+
*/
|
|
225
|
+
export declare const commandRequests: (group: ChatInteraction.Group<any>) => Effect.Effect<{
|
|
226
|
+
readonly commands: ReadonlyArray<{
|
|
227
|
+
readonly command: string;
|
|
228
|
+
readonly description: string;
|
|
229
|
+
}>;
|
|
230
|
+
}, ChatError>;
|
|
231
|
+
/**
|
|
232
|
+
* Sends a group's commands with `setMyCommands`.
|
|
233
|
+
*
|
|
234
|
+
* @stability unstable
|
|
235
|
+
* @category commands
|
|
236
|
+
* @since 4.1.5
|
|
237
|
+
*/
|
|
238
|
+
export declare const setCommands: (group: ChatInteraction.Group<any>, options?: {
|
|
239
|
+
readonly scope?: Schema.Json | undefined;
|
|
240
|
+
readonly languageCode?: string | undefined;
|
|
241
|
+
}) => Effect.Effect<void, ChatError, TelegramBotApi.TelegramBotApi>;
|
|
242
|
+
/**
|
|
243
|
+
* The address of a chat, or of a forum topic in it.
|
|
244
|
+
*
|
|
245
|
+
* @stability unstable
|
|
246
|
+
* @category constructors
|
|
247
|
+
* @since 4.1.5
|
|
248
|
+
*/
|
|
249
|
+
export declare const thread: (chatId: string | number, messageThreadId?: string | number | undefined) => ChatThread;
|
|
250
|
+
/**
|
|
251
|
+
* The parts of a Telegram address, or `None` for another platform's or a
|
|
252
|
+
* malformed one.
|
|
253
|
+
*
|
|
254
|
+
* @stability unstable
|
|
255
|
+
* @category destructors
|
|
256
|
+
* @since 4.1.5
|
|
257
|
+
*/
|
|
258
|
+
export declare const parts: (thread: ChatThread) => Option.Option<{
|
|
259
|
+
readonly chatId: string;
|
|
260
|
+
readonly messageThreadId?: string | undefined;
|
|
261
|
+
}>;
|
|
262
|
+
/**
|
|
263
|
+
* What the normalisers need to know about the bot.
|
|
264
|
+
*
|
|
265
|
+
* @stability unstable
|
|
266
|
+
* @category models
|
|
267
|
+
* @since 4.1.5
|
|
268
|
+
*/
|
|
269
|
+
export interface NormalizeContext {
|
|
270
|
+
readonly botId: string;
|
|
271
|
+
/** The bot's username without `@`, from `getMe`. */
|
|
272
|
+
readonly botUsername: string;
|
|
273
|
+
readonly environment?: TelegramBotApi.Environment | undefined;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The normaliser, for a consumer's own transport. It checks no secret:
|
|
277
|
+
* that is the transport's job.
|
|
278
|
+
*
|
|
279
|
+
* **Details**
|
|
280
|
+
*
|
|
281
|
+
* - A `message` or `channel_post` with text, a caption, a file or rich
|
|
282
|
+
* content gives a `MessageCreated`. `text` is verbatim, and empty for
|
|
283
|
+
* an inbound rich message, whose content is only in `raw`.
|
|
284
|
+
* - `text_mention` entities are mentions by id. An `@username` is a
|
|
285
|
+
* mention only when it names the bot.
|
|
286
|
+
* - The author is `sender_chat` when there is one, else `from`.
|
|
287
|
+
* - A private (ephemeral) message, a service message, and anything from a
|
|
288
|
+
* business connection, a channel's direct messages or guest mode give
|
|
289
|
+
* none, as does every other update. Commands are messages here too:
|
|
290
|
+
* `receive` is what routes them.
|
|
291
|
+
* - `raw` is the update.
|
|
292
|
+
*
|
|
293
|
+
* @stability unstable
|
|
294
|
+
* @category normalization
|
|
295
|
+
* @since 4.1.5
|
|
296
|
+
*/
|
|
297
|
+
export declare const normalize: (update: unknown, context: NormalizeContext) => ReadonlyArray<ChatEvent>;
|
|
298
|
+
/**
|
|
299
|
+
* The click or command of an update, as `receive` would dispatch it.
|
|
300
|
+
*
|
|
301
|
+
* **Details**
|
|
302
|
+
*
|
|
303
|
+
* A click is given only when its `data` is the `callback_data` of a button
|
|
304
|
+
* in Telegram's own copy of the message. That proves the bot put the button
|
|
305
|
+
* there, not that it is still current or that this user may press it.
|
|
306
|
+
*
|
|
307
|
+
* @stability unstable
|
|
308
|
+
* @category normalization
|
|
309
|
+
* @since 4.1.5
|
|
310
|
+
*/
|
|
311
|
+
export declare const normalizeInteraction: (update: unknown, context: NormalizeContext) => Option.Option<ChatInteraction.ButtonClicked | ChatInteraction.CommandInvoked>;
|
|
312
|
+
/**
|
|
313
|
+
* The delivery key of an update, or of an event or interaction whose `raw`
|
|
314
|
+
* is one: `{botId}.{update_id}.{date}`, with `test.` in front in the test
|
|
315
|
+
* environment. Telegram sends an update again until it gets a 200 (or an
|
|
316
|
+
* offset moves past it), clicks and commands included, so a handler whose
|
|
317
|
+
* work must not be lost or run twice commits this key and a recoverable
|
|
318
|
+
* work item in one transaction before it returns. A click or command
|
|
319
|
+
* past its deadline counts as answered and is not sent again, so that
|
|
320
|
+
* holds only for a commit within the deadline. The README has the recipe.
|
|
321
|
+
*
|
|
322
|
+
* @stability unstable
|
|
323
|
+
* @category normalization
|
|
324
|
+
* @since 4.1.5
|
|
325
|
+
*/
|
|
326
|
+
export declare const deliveryKey: (raw: unknown, context: {
|
|
327
|
+
readonly botId: string;
|
|
328
|
+
readonly environment?: TelegramBotApi.Environment | undefined;
|
|
329
|
+
}) => Option.Option<string>;
|
|
330
|
+
/**
|
|
331
|
+
* Reads a mention for `ChatTest`. A mention's text is a display name or an
|
|
332
|
+
* `@username`, neither of which holds the id, so this is always `None`;
|
|
333
|
+
* a message's `mentions` come from its entities.
|
|
334
|
+
*
|
|
335
|
+
* @stability unstable
|
|
336
|
+
* @category testing
|
|
337
|
+
* @since 4.1.5
|
|
338
|
+
*/
|
|
339
|
+
export declare const parseMention: ParseMention;
|
|
340
|
+
/**
|
|
341
|
+
* Telegram options for every write inside an effect.
|
|
342
|
+
*
|
|
343
|
+
* @stability unstable
|
|
344
|
+
* @category models
|
|
345
|
+
* @since 4.1.5
|
|
346
|
+
*/
|
|
347
|
+
export interface TelegramPostOptions {
|
|
348
|
+
/**
|
|
349
|
+
* Users whose `[name](tg://user?id=…)` links in the Markdown stay links.
|
|
350
|
+
* Any other `tg://` link becomes text. Default: none.
|
|
351
|
+
*/
|
|
352
|
+
readonly notify?: {
|
|
353
|
+
readonly users?: ReadonlyArray<string> | undefined;
|
|
354
|
+
} | undefined;
|
|
355
|
+
/** Sends posts with `disable_notification`. */
|
|
356
|
+
readonly silent?: boolean | undefined;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Scoped Telegram options for every write inside `effect`. Nested calls
|
|
360
|
+
* merge, the inner one winning field by field. Answers to commands and
|
|
361
|
+
* follow-ups ignore them.
|
|
362
|
+
*
|
|
363
|
+
* @stability unstable
|
|
364
|
+
* @category combinators
|
|
365
|
+
* @since 4.1.5
|
|
366
|
+
*/
|
|
367
|
+
export declare const withPostOptions: {
|
|
368
|
+
/**
|
|
369
|
+
* Scoped Telegram options for every write inside `effect`. Nested calls
|
|
370
|
+
* merge, the inner one winning field by field. Answers to commands and
|
|
371
|
+
* follow-ups ignore them.
|
|
372
|
+
*
|
|
373
|
+
* @stability unstable
|
|
374
|
+
* @category combinators
|
|
375
|
+
* @since 4.1.5
|
|
376
|
+
*/
|
|
377
|
+
(options: TelegramPostOptions): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
378
|
+
/**
|
|
379
|
+
* Scoped Telegram options for every write inside `effect`. Nested calls
|
|
380
|
+
* merge, the inner one winning field by field. Answers to commands and
|
|
381
|
+
* follow-ups ignore them.
|
|
382
|
+
*
|
|
383
|
+
* @stability unstable
|
|
384
|
+
* @category combinators
|
|
385
|
+
* @since 4.1.5
|
|
386
|
+
*/
|
|
387
|
+
<A, E, R>(effect: Effect.Effect<A, E, R>, options: TelegramPostOptions): Effect.Effect<A, E, R>;
|
|
388
|
+
};
|
|
389
|
+
export {};
|
|
390
|
+
//# sourceMappingURL=TelegramChat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TelegramChat.d.ts","sourceRoot":"","sources":["../src/TelegramChat.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK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