karboai 1.2.0 → 1.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/core/karboai.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { KarboConfig } from '../schemas/configs';
|
|
2
|
-
import { MeResponse } from '../schemas/responses';
|
|
2
|
+
import { MembersResponse, MeResponse } from '../schemas/responses';
|
|
3
|
+
import { Message } from '../schemas/karboai/message';
|
|
4
|
+
import { User } from '../schemas/karboai/users';
|
|
3
5
|
export declare class KarboAI {
|
|
4
6
|
private readonly config;
|
|
5
7
|
private readonly httptoolkit;
|
|
@@ -15,5 +17,10 @@ export declare class KarboAI {
|
|
|
15
17
|
createdAt: number;
|
|
16
18
|
}>;
|
|
17
19
|
upload: (path: string) => Promise<string>;
|
|
20
|
+
message: (chatId: string, messageId: string) => Promise<Message>;
|
|
21
|
+
members: (chatId: string, limit?: number, offset?: number) => Promise<MembersResponse>;
|
|
22
|
+
user: (userId: string) => Promise<User>;
|
|
23
|
+
leave: (chatId: string) => Promise<boolean>;
|
|
24
|
+
kick: (chatId: string, userId: string) => Promise<boolean>;
|
|
18
25
|
}
|
|
19
26
|
//# sourceMappingURL=karboai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"karboai.d.ts","sourceRoot":"","sources":["../../src/core/karboai.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AACpE,OAAO,EACL,UAAU,
|
|
1
|
+
{"version":3,"file":"karboai.d.ts","sourceRoot":"","sources":["../../src/core/karboai.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AACpE,OAAO,EACL,eAAe,EAEf,UAAU,EAQX,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,OAAO,EAAiB,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,IAAI,EAAc,MAAM,0BAA0B,CAAC;AAE5D,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;gBAE9B,MAAM,EAAE,WAAW;IAO/B,OAAO,CAAC,WAAW,CAcd;IAEE,EAAE,QAAa,OAAO,CAAC,UAAU,CAAC,CAIpC;IAEE,IAAI,GACT,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,iBAAiB,MAAM;;;OAMpB;IAEE,KAAK,GACV,QAAQ,MAAM,EACd,QAAQ,MAAM,EAAE,EAChB,iBAAiB,MAAM;;;OAMpB;IAEE,MAAM,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,CAWnD;IAEK,OAAO,GACZ,QAAQ,MAAM,EACd,WAAW,MAAM,KAChB,OAAO,CAAC,OAAO,CAAC,CAId;IAEE,OAAO,GACZ,QAAQ,MAAM,EACd,QAAO,MAAY,EACnB,SAAQ,MAAU,KACjB,OAAO,CAAC,eAAe,CAAC,CAItB;IAEE,IAAI,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAI9C;IAEE,KAAK,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC,CAOhD;IAEA,IAAI,GAAU,QAAQ,MAAM,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC,CAO/D;CACR"}
|
package/dist/core/karboai.js
CHANGED
|
@@ -9,6 +9,8 @@ const responses_1 = require("../schemas/responses");
|
|
|
9
9
|
const logger_1 = __importDefault(require("../utils/logger"));
|
|
10
10
|
const utils_1 = require("../utils/utils");
|
|
11
11
|
const httptoolkit_1 = require("./httptoolkit");
|
|
12
|
+
const message_1 = require("../schemas/karboai/message");
|
|
13
|
+
const users_1 = require("../schemas/karboai/users");
|
|
12
14
|
class KarboAI {
|
|
13
15
|
config;
|
|
14
16
|
httptoolkit;
|
|
@@ -50,5 +52,27 @@ class KarboAI {
|
|
|
50
52
|
schema: responses_1.UploadResponseSchema,
|
|
51
53
|
})).url;
|
|
52
54
|
};
|
|
55
|
+
message = async (chatId, messageId) => await this.httptoolkit.get({
|
|
56
|
+
path: `/bot/chat/${chatId}/message/${messageId}`,
|
|
57
|
+
schema: message_1.MessageSchema,
|
|
58
|
+
});
|
|
59
|
+
members = async (chatId, limit = 100, offset = 0) => await this.httptoolkit.get({
|
|
60
|
+
path: `/bot/chat/${chatId}/members?limit=${limit}&offset=${offset}`,
|
|
61
|
+
schema: responses_1.MembersResponseSchema,
|
|
62
|
+
});
|
|
63
|
+
user = async (userId) => await this.httptoolkit.get({
|
|
64
|
+
path: `/bot/user/${userId}`,
|
|
65
|
+
schema: users_1.UserSchema,
|
|
66
|
+
});
|
|
67
|
+
leave = async (chatId) => (await this.httptoolkit.post({
|
|
68
|
+
path: `/bot/leave-chat/${chatId}`,
|
|
69
|
+
body: JSON.stringify({}),
|
|
70
|
+
schema: responses_1.OkResponseSchema,
|
|
71
|
+
})).ok;
|
|
72
|
+
kick = async (chatId, userId) => (await this.httptoolkit.post({
|
|
73
|
+
path: `/bot/chat/${chatId}/kick`,
|
|
74
|
+
body: JSON.stringify({ user_id: userId }),
|
|
75
|
+
schema: responses_1.OkResponseSchema,
|
|
76
|
+
})).ok;
|
|
53
77
|
}
|
|
54
78
|
exports.KarboAI = KarboAI;
|
|
@@ -29,7 +29,33 @@ export declare const MessageResponseSchema: z.ZodPipe<z.ZodObject<{
|
|
|
29
29
|
export declare const UploadResponseSchema: z.ZodObject<{
|
|
30
30
|
url: z.ZodString;
|
|
31
31
|
}, z.core.$strip>;
|
|
32
|
+
export declare const MembersResponseSchema: z.ZodObject<{
|
|
33
|
+
items: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
34
|
+
user_id: z.ZodString;
|
|
35
|
+
nickname: z.ZodString;
|
|
36
|
+
avatar: z.ZodString;
|
|
37
|
+
role: z.ZodNumber;
|
|
38
|
+
short_info: z.ZodString;
|
|
39
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
40
|
+
userId: string;
|
|
41
|
+
nickname: string;
|
|
42
|
+
avatar: string;
|
|
43
|
+
role: number;
|
|
44
|
+
shortInfo: string;
|
|
45
|
+
}, {
|
|
46
|
+
user_id: string;
|
|
47
|
+
nickname: string;
|
|
48
|
+
avatar: string;
|
|
49
|
+
role: number;
|
|
50
|
+
short_info: string;
|
|
51
|
+
}>>>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
export declare const OkResponseSchema: z.ZodObject<{
|
|
54
|
+
ok: z.ZodBoolean;
|
|
55
|
+
}, z.core.$strip>;
|
|
32
56
|
export type MeResponse = z.Infer<typeof MeResponseSchema>;
|
|
33
57
|
export type MessageResponse = z.Infer<typeof MessageResponseSchema>;
|
|
34
58
|
export type UploadResponse = z.Infer<typeof UploadResponseSchema>;
|
|
59
|
+
export type MembersResponse = z.Infer<typeof MembersResponseSchema>;
|
|
60
|
+
export type OkResponse = z.Infer<typeof OkResponseSchema>;
|
|
35
61
|
//# sourceMappingURL=responses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/schemas/responses.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/schemas/responses.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAKpB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;GAYzB,CAAC;AAEL,eAAO,MAAM,qBAAqB;;;;;;;;;GAU9B,CAAC;AAEL,eAAO,MAAM,oBAAoB;;iBAE/B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;iBAEhC,CAAC;AAEH,eAAO,MAAM,gBAAgB;;iBAE3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.UploadResponseSchema = exports.MessageResponseSchema = exports.MeResponseSchema = void 0;
|
|
6
|
+
exports.OkResponseSchema = exports.MembersResponseSchema = exports.UploadResponseSchema = exports.MessageResponseSchema = exports.MeResponseSchema = void 0;
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
8
|
const enums_1 = require("./enums");
|
|
9
|
+
const users_1 = require("./karboai/users");
|
|
9
10
|
exports.MeResponseSchema = zod_1.default
|
|
10
11
|
.object({
|
|
11
12
|
bot_id: zod_1.default.string(),
|
|
@@ -33,3 +34,9 @@ exports.MessageResponseSchema = zod_1.default
|
|
|
33
34
|
exports.UploadResponseSchema = zod_1.default.object({
|
|
34
35
|
url: zod_1.default.string(),
|
|
35
36
|
});
|
|
37
|
+
exports.MembersResponseSchema = zod_1.default.object({
|
|
38
|
+
items: zod_1.default.array(users_1.UserSchema),
|
|
39
|
+
});
|
|
40
|
+
exports.OkResponseSchema = zod_1.default.object({
|
|
41
|
+
ok: zod_1.default.boolean(),
|
|
42
|
+
});
|