@satorijs/adapter-dingtalk 1.0.0 → 1.0.1
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/lib/bot.d.ts +1 -1
- package/lib/index.js +19 -12
- package/lib/index.js.map +2 -2
- package/package.json +2 -2
package/lib/bot.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export declare class DingtalkBot extends Bot<DingtalkBot.Config> {
|
|
|
7
7
|
static MessageEncoder: typeof DingtalkMessageEncoder;
|
|
8
8
|
oldHttp: Quester;
|
|
9
9
|
http: Quester;
|
|
10
|
-
refreshTokenTimer: NodeJS.Timeout;
|
|
11
10
|
internal: Internal;
|
|
11
|
+
refreshTokenTimer: NodeJS.Timeout;
|
|
12
12
|
constructor(ctx: Context, config: DingtalkBot.Config);
|
|
13
13
|
initialize(): Promise<void>;
|
|
14
14
|
stop(): Promise<void>;
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
@@ -26,6 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
27
|
mod
|
|
27
28
|
));
|
|
28
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __publicField = (obj, key, value) => {
|
|
31
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
32
|
+
return value;
|
|
33
|
+
};
|
|
29
34
|
|
|
30
35
|
// satori/adapters/dingtalk/src/index.ts
|
|
31
36
|
var src_exports = {};
|
|
@@ -98,9 +103,9 @@ __name(decodeMessage, "decodeMessage");
|
|
|
98
103
|
|
|
99
104
|
// satori/adapters/dingtalk/src/http.ts
|
|
100
105
|
var _HttpServer = class _HttpServer extends import_satori2.Adapter.Server {
|
|
106
|
+
logger = new import_satori2.Logger("dingtalk");
|
|
101
107
|
constructor(ctx, bot) {
|
|
102
108
|
super();
|
|
103
|
-
this.logger = new import_satori2.Logger("dingtalk");
|
|
104
109
|
}
|
|
105
110
|
async start(bot) {
|
|
106
111
|
await bot.refreshToken();
|
|
@@ -136,15 +141,11 @@ var import_form_data = __toESM(require("form-data"));
|
|
|
136
141
|
var escape = /* @__PURE__ */ __name((val) => val.replace(/(?<!\u200b)[\*_~`]/g, "$&").replace(/([\\`*_{}[\]\-(#!>])/g, "\\$&").replace(/([\-\*]|\d\.) /g, "$&").replace(/^(\s{4})/gm, " "), "escape");
|
|
137
142
|
var unescape = /* @__PURE__ */ __name((val) => val.replace(/\u200b([\*_~`])/g, "$1"), "unescape");
|
|
138
143
|
var _DingtalkMessageEncoder = class _DingtalkMessageEncoder extends import_satori3.MessageEncoder {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*/
|
|
145
|
-
this.hasRichContent = true;
|
|
146
|
-
this.listType = null;
|
|
147
|
-
}
|
|
144
|
+
buffer = "";
|
|
145
|
+
/**
|
|
146
|
+
* Markdown: https://open.dingtalk.com/document/isvapp/robot-message-types-and-data-format
|
|
147
|
+
*/
|
|
148
|
+
hasRichContent = true;
|
|
148
149
|
async flush() {
|
|
149
150
|
if (this.buffer.length && !this.hasRichContent) {
|
|
150
151
|
await this.sendMessage("sampleText", {
|
|
@@ -198,6 +199,7 @@ var _DingtalkMessageEncoder = class _DingtalkMessageEncoder extends import_sator
|
|
|
198
199
|
});
|
|
199
200
|
return media_id;
|
|
200
201
|
}
|
|
202
|
+
listType = null;
|
|
201
203
|
async visit(element) {
|
|
202
204
|
const { type, attrs, children } = element;
|
|
203
205
|
if (type === "text") {
|
|
@@ -357,8 +359,13 @@ var Internal = _Internal;
|
|
|
357
359
|
// satori/adapters/dingtalk/src/bot.ts
|
|
358
360
|
var logger = new import_satori6.Logger("dingtalk");
|
|
359
361
|
var _DingtalkBot = class _DingtalkBot extends import_satori6.Bot {
|
|
362
|
+
oldHttp;
|
|
363
|
+
http;
|
|
364
|
+
internal;
|
|
365
|
+
refreshTokenTimer;
|
|
360
366
|
constructor(ctx, config) {
|
|
361
367
|
super(ctx, config);
|
|
368
|
+
this.platform = "dingtalk";
|
|
362
369
|
this.http = ctx.http.extend(config.api);
|
|
363
370
|
this.oldHttp = ctx.http.extend(config.oldApi);
|
|
364
371
|
this.internal = new Internal(this);
|
|
@@ -378,6 +385,7 @@ var _DingtalkBot = class _DingtalkBot extends import_satori6.Bot {
|
|
|
378
385
|
stop() {
|
|
379
386
|
clearTimeout(this.refreshTokenTimer);
|
|
380
387
|
}
|
|
388
|
+
token;
|
|
381
389
|
async refreshToken() {
|
|
382
390
|
const data = await this.internal.getAccessToken({
|
|
383
391
|
appKey: this.config.appkey,
|
|
@@ -416,7 +424,7 @@ var _DingtalkBot = class _DingtalkBot extends import_satori6.Bot {
|
|
|
416
424
|
}
|
|
417
425
|
};
|
|
418
426
|
__name(_DingtalkBot, "DingtalkBot");
|
|
419
|
-
_DingtalkBot
|
|
427
|
+
__publicField(_DingtalkBot, "MessageEncoder", DingtalkMessageEncoder);
|
|
420
428
|
var DingtalkBot = _DingtalkBot;
|
|
421
429
|
((DingtalkBot2) => {
|
|
422
430
|
DingtalkBot2.Config = import_satori6.Schema.intersect([
|
|
@@ -433,7 +441,6 @@ var DingtalkBot = _DingtalkBot;
|
|
|
433
441
|
WsClient.Config
|
|
434
442
|
]);
|
|
435
443
|
})(DingtalkBot || (DingtalkBot = {}));
|
|
436
|
-
DingtalkBot.prototype.platform = "dingtalk";
|
|
437
444
|
|
|
438
445
|
// satori/adapters/dingtalk/src/api/oauth2.ts
|
|
439
446
|
Internal.define({
|