@goodandready/dsh-messenger-gateway 0.3.21 → 0.3.22
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/adapters/discord.js +8 -0
- package/lib/adapters/slack.js +6 -0
- package/lib/adapters/telegram.js +712 -708
- package/lib/client.js +320 -1
- package/lib/commands.js +74 -73
- package/lib/config.js +104 -104
- package/lib/content-guard.js +14 -14
- package/lib/gateway.js +1772 -1737
- package/lib/index.js +532 -500
- package/lib/locales/en.js +123 -114
- package/lib/locales/index.js +21 -21
- package/lib/locales/zh.js +123 -114
- package/lib/scheduler.js +159 -159
- package/lib/telegram-errors.js +0 -0
- package/lib/text.js +39 -39
- package/lib/updater.js +304 -0
- package/package.json +1 -1
package/lib/adapters/discord.js
CHANGED
|
@@ -84,6 +84,8 @@ export class DiscordAdapter {
|
|
|
84
84
|
method: 'POST',
|
|
85
85
|
headers: { 'Content-Type': 'application/json' },
|
|
86
86
|
body: JSON.stringify(payloadJson),
|
|
87
|
+
keepalive: true,
|
|
88
|
+
signal: AbortSignal.timeout(15000),
|
|
87
89
|
})
|
|
88
90
|
if (!res.ok) {
|
|
89
91
|
const errText = await res.text().catch(() => '')
|
|
@@ -122,6 +124,8 @@ export class DiscordAdapter {
|
|
|
122
124
|
Authorization: `Bot ${this.botToken}`,
|
|
123
125
|
},
|
|
124
126
|
body: form,
|
|
127
|
+
keepalive: true,
|
|
128
|
+
signal: AbortSignal.timeout(30000),
|
|
125
129
|
})
|
|
126
130
|
if (!res.ok) {
|
|
127
131
|
const errText = await res.text().catch(() => '')
|
|
@@ -156,6 +160,8 @@ export class DiscordAdapter {
|
|
|
156
160
|
'Content-Type': 'application/json',
|
|
157
161
|
},
|
|
158
162
|
body: JSON.stringify(body),
|
|
163
|
+
keepalive: true,
|
|
164
|
+
signal: AbortSignal.timeout(15000),
|
|
159
165
|
})
|
|
160
166
|
if (!res.ok) {
|
|
161
167
|
const errText = await res.text().catch(() => '')
|
|
@@ -174,6 +180,8 @@ export class DiscordAdapter {
|
|
|
174
180
|
'Content-Type': 'application/json',
|
|
175
181
|
},
|
|
176
182
|
body: JSON.stringify(body),
|
|
183
|
+
keepalive: true,
|
|
184
|
+
signal: AbortSignal.timeout(15000),
|
|
177
185
|
})
|
|
178
186
|
if (!res.ok) {
|
|
179
187
|
const errText = await res.text().catch(() => '')
|
package/lib/adapters/slack.js
CHANGED
|
@@ -83,6 +83,8 @@ export class SlackAdapter {
|
|
|
83
83
|
method: 'POST',
|
|
84
84
|
headers: { 'Content-Type': 'application/json' },
|
|
85
85
|
body: JSON.stringify(payloadJson),
|
|
86
|
+
keepalive: true,
|
|
87
|
+
signal: AbortSignal.timeout(15000),
|
|
86
88
|
})
|
|
87
89
|
if (!res.ok) {
|
|
88
90
|
const errText = await res.text().catch(() => '')
|
|
@@ -116,6 +118,8 @@ export class SlackAdapter {
|
|
|
116
118
|
'Content-Type': 'application/json; charset=utf-8',
|
|
117
119
|
},
|
|
118
120
|
body: JSON.stringify(reqBody),
|
|
121
|
+
keepalive: true,
|
|
122
|
+
signal: AbortSignal.timeout(15000),
|
|
119
123
|
})
|
|
120
124
|
const json = typeof res.json === 'function' ? await res.json().catch(() => ({})) : {}
|
|
121
125
|
if (!res.ok || json?.ok === false) {
|
|
@@ -141,6 +145,8 @@ export class SlackAdapter {
|
|
|
141
145
|
'Content-Type': 'application/json; charset=utf-8',
|
|
142
146
|
},
|
|
143
147
|
body: JSON.stringify(body),
|
|
148
|
+
keepalive: true,
|
|
149
|
+
signal: AbortSignal.timeout(15000),
|
|
144
150
|
})
|
|
145
151
|
const json = typeof res.json === 'function' ? await res.json().catch(() => ({})) : {}
|
|
146
152
|
if (!res.ok || json?.ok === false) {
|