@effect-ak/tg-bot-client 0.2.3 → 0.3.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/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
- package/readme.md +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ declare class TgBotClientError extends TgBotClientError_base<{
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
type TgBotClientSettingsInput = {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
bot_token: string;
|
|
31
|
+
base_url?: string;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
type TgBotClientConfigObject = Required<TgBotClientSettingsInput>;
|
package/dist/index.js
CHANGED
|
@@ -65,7 +65,7 @@ var isMessageEffect = (input) => {
|
|
|
65
65
|
// src/client/config.ts
|
|
66
66
|
var makeTgBotClientConfig = (input) => TgBotClientConfig.of({
|
|
67
67
|
...input,
|
|
68
|
-
|
|
68
|
+
base_url: input.base_url ?? defaultBaseUrl
|
|
69
69
|
});
|
|
70
70
|
var TgBotClientConfig = class extends Context.Tag("TgBotClientConfig")() {
|
|
71
71
|
};
|
|
@@ -92,7 +92,7 @@ var TgBotClientError = class _TgBotClientError extends Data.TaggedError("TgBotCl
|
|
|
92
92
|
// src/client/guards.ts
|
|
93
93
|
var isFileContent = (input) => typeof input == "object" && input != null && ("file_content" in input && input.file_content instanceof Uint8Array) && ("file_name" in input && typeof input.file_name == "string");
|
|
94
94
|
var isTgBotApiResponse = (input) => typeof input == "object" && input != null && ("ok" in input && typeof input.ok == "boolean");
|
|
95
|
-
var isTgBotClientSettingsInput = (input) => typeof input == "object" && input != null && ("
|
|
95
|
+
var isTgBotClientSettingsInput = (input) => typeof input == "object" && input != null && ("bot_token" in input && typeof input.bot_token == "string");
|
|
96
96
|
|
|
97
97
|
// src/client/execute-request/payload.ts
|
|
98
98
|
var makePayload = (body) => {
|
|
@@ -116,7 +116,7 @@ var makePayload = (body) => {
|
|
|
116
116
|
var execute = (config, method, input) => Micro.gen(function* () {
|
|
117
117
|
const httpResponse = yield* Micro.tryPromise({
|
|
118
118
|
try: () => fetch(
|
|
119
|
-
`${config
|
|
119
|
+
`${config.base_url}/bot${config.bot_token}/${String.snakeToCamel(method)}`,
|
|
120
120
|
{
|
|
121
121
|
body: makePayload(input) ?? null,
|
|
122
122
|
method: "POST"
|
|
@@ -179,7 +179,7 @@ var getFile = (fileId, config, execute2) => Micro3.gen(function* () {
|
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
181
|
const file_name = file_path.replaceAll("/", "-");
|
|
182
|
-
const url = `${config
|
|
182
|
+
const url = `${config.base_url}/file/bot${config.bot_token}/${file_path}`;
|
|
183
183
|
const fileContent = yield* Micro3.tryPromise({
|
|
184
184
|
try: () => fetch(url).then((_) => _.arrayBuffer()),
|
|
185
185
|
catch: (cause) => new TgBotClientError({
|
package/dist/index.mjs
CHANGED
|
@@ -22,7 +22,7 @@ var isMessageEffect = (input) => {
|
|
|
22
22
|
// src/client/config.ts
|
|
23
23
|
var makeTgBotClientConfig = (input) => TgBotClientConfig.of({
|
|
24
24
|
...input,
|
|
25
|
-
|
|
25
|
+
base_url: input.base_url ?? defaultBaseUrl
|
|
26
26
|
});
|
|
27
27
|
var TgBotClientConfig = class extends Context.Tag("TgBotClientConfig")() {
|
|
28
28
|
};
|
|
@@ -49,7 +49,7 @@ var TgBotClientError = class _TgBotClientError extends Data.TaggedError("TgBotCl
|
|
|
49
49
|
// src/client/guards.ts
|
|
50
50
|
var isFileContent = (input) => typeof input == "object" && input != null && ("file_content" in input && input.file_content instanceof Uint8Array) && ("file_name" in input && typeof input.file_name == "string");
|
|
51
51
|
var isTgBotApiResponse = (input) => typeof input == "object" && input != null && ("ok" in input && typeof input.ok == "boolean");
|
|
52
|
-
var isTgBotClientSettingsInput = (input) => typeof input == "object" && input != null && ("
|
|
52
|
+
var isTgBotClientSettingsInput = (input) => typeof input == "object" && input != null && ("bot_token" in input && typeof input.bot_token == "string");
|
|
53
53
|
|
|
54
54
|
// src/client/execute-request/payload.ts
|
|
55
55
|
var makePayload = (body) => {
|
|
@@ -73,7 +73,7 @@ var makePayload = (body) => {
|
|
|
73
73
|
var execute = (config, method, input) => Micro.gen(function* () {
|
|
74
74
|
const httpResponse = yield* Micro.tryPromise({
|
|
75
75
|
try: () => fetch(
|
|
76
|
-
`${config
|
|
76
|
+
`${config.base_url}/bot${config.bot_token}/${String.snakeToCamel(method)}`,
|
|
77
77
|
{
|
|
78
78
|
body: makePayload(input) ?? null,
|
|
79
79
|
method: "POST"
|
|
@@ -136,7 +136,7 @@ var getFile = (fileId, config, execute2) => Micro3.gen(function* () {
|
|
|
136
136
|
);
|
|
137
137
|
}
|
|
138
138
|
const file_name = file_path.replaceAll("/", "-");
|
|
139
|
-
const url = `${config
|
|
139
|
+
const url = `${config.base_url}/file/bot${config.bot_token}/${file_path}`;
|
|
140
140
|
const fileContent = yield* Micro3.tryPromise({
|
|
141
141
|
try: () => fetch(url).then((_) => _.arrayBuffer()),
|
|
142
142
|
catch: (cause) => new TgBotClientError({
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -31,7 +31,7 @@ This client facilitates interaction with the Telegram Bot API. It was created pr
|
|
|
31
31
|
import { makeTgBotClient } from "@effect-ak/tg-bot-client"
|
|
32
32
|
|
|
33
33
|
const client = makeTgBotClient({
|
|
34
|
-
|
|
34
|
+
bot_token: "" //your token taken from bot father
|
|
35
35
|
});
|
|
36
36
|
```
|
|
37
37
|
|