towns-bot 0.0.334 → 0.0.336
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.js +1341 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1375 -35
- package/dist/index.mjs.map +1 -1
- package/index.js +1 -1
- package/package.json +10 -4
package/dist/index.js
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
8
11
|
var __copyProps = (to, from, except, desc) => {
|
|
9
12
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
13
|
for (let key of __getOwnPropNames(from))
|
|
@@ -21,13 +24,774 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
25
|
mod
|
|
23
26
|
));
|
|
24
|
-
|
|
27
|
+
|
|
28
|
+
// ../../node_modules/debug/node_modules/ms/index.js
|
|
29
|
+
var require_ms = __commonJS({
|
|
30
|
+
"../../node_modules/debug/node_modules/ms/index.js"(exports2, module2) {
|
|
31
|
+
"use strict";
|
|
32
|
+
var s = 1e3;
|
|
33
|
+
var m = s * 60;
|
|
34
|
+
var h = m * 60;
|
|
35
|
+
var d = h * 24;
|
|
36
|
+
var w = d * 7;
|
|
37
|
+
var y = d * 365.25;
|
|
38
|
+
module2.exports = function(val, options) {
|
|
39
|
+
options = options || {};
|
|
40
|
+
var type = typeof val;
|
|
41
|
+
if (type === "string" && val.length > 0) {
|
|
42
|
+
return parse3(val);
|
|
43
|
+
} else if (type === "number" && isFinite(val)) {
|
|
44
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
45
|
+
}
|
|
46
|
+
throw new Error(
|
|
47
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
function parse3(str) {
|
|
51
|
+
str = String(str);
|
|
52
|
+
if (str.length > 100) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
56
|
+
str
|
|
57
|
+
);
|
|
58
|
+
if (!match) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var n = parseFloat(match[1]);
|
|
62
|
+
var type = (match[2] || "ms").toLowerCase();
|
|
63
|
+
switch (type) {
|
|
64
|
+
case "years":
|
|
65
|
+
case "year":
|
|
66
|
+
case "yrs":
|
|
67
|
+
case "yr":
|
|
68
|
+
case "y":
|
|
69
|
+
return n * y;
|
|
70
|
+
case "weeks":
|
|
71
|
+
case "week":
|
|
72
|
+
case "w":
|
|
73
|
+
return n * w;
|
|
74
|
+
case "days":
|
|
75
|
+
case "day":
|
|
76
|
+
case "d":
|
|
77
|
+
return n * d;
|
|
78
|
+
case "hours":
|
|
79
|
+
case "hour":
|
|
80
|
+
case "hrs":
|
|
81
|
+
case "hr":
|
|
82
|
+
case "h":
|
|
83
|
+
return n * h;
|
|
84
|
+
case "minutes":
|
|
85
|
+
case "minute":
|
|
86
|
+
case "mins":
|
|
87
|
+
case "min":
|
|
88
|
+
case "m":
|
|
89
|
+
return n * m;
|
|
90
|
+
case "seconds":
|
|
91
|
+
case "second":
|
|
92
|
+
case "secs":
|
|
93
|
+
case "sec":
|
|
94
|
+
case "s":
|
|
95
|
+
return n * s;
|
|
96
|
+
case "milliseconds":
|
|
97
|
+
case "millisecond":
|
|
98
|
+
case "msecs":
|
|
99
|
+
case "msec":
|
|
100
|
+
case "ms":
|
|
101
|
+
return n;
|
|
102
|
+
default:
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function fmtShort(ms) {
|
|
107
|
+
var msAbs = Math.abs(ms);
|
|
108
|
+
if (msAbs >= d) {
|
|
109
|
+
return Math.round(ms / d) + "d";
|
|
110
|
+
}
|
|
111
|
+
if (msAbs >= h) {
|
|
112
|
+
return Math.round(ms / h) + "h";
|
|
113
|
+
}
|
|
114
|
+
if (msAbs >= m) {
|
|
115
|
+
return Math.round(ms / m) + "m";
|
|
116
|
+
}
|
|
117
|
+
if (msAbs >= s) {
|
|
118
|
+
return Math.round(ms / s) + "s";
|
|
119
|
+
}
|
|
120
|
+
return ms + "ms";
|
|
121
|
+
}
|
|
122
|
+
function fmtLong(ms) {
|
|
123
|
+
var msAbs = Math.abs(ms);
|
|
124
|
+
if (msAbs >= d) {
|
|
125
|
+
return plural(ms, msAbs, d, "day");
|
|
126
|
+
}
|
|
127
|
+
if (msAbs >= h) {
|
|
128
|
+
return plural(ms, msAbs, h, "hour");
|
|
129
|
+
}
|
|
130
|
+
if (msAbs >= m) {
|
|
131
|
+
return plural(ms, msAbs, m, "minute");
|
|
132
|
+
}
|
|
133
|
+
if (msAbs >= s) {
|
|
134
|
+
return plural(ms, msAbs, s, "second");
|
|
135
|
+
}
|
|
136
|
+
return ms + " ms";
|
|
137
|
+
}
|
|
138
|
+
function plural(ms, msAbs, n, name) {
|
|
139
|
+
var isPlural = msAbs >= n * 1.5;
|
|
140
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// ../../node_modules/debug/src/common.js
|
|
146
|
+
var require_common = __commonJS({
|
|
147
|
+
"../../node_modules/debug/src/common.js"(exports2, module2) {
|
|
148
|
+
"use strict";
|
|
149
|
+
function setup(env) {
|
|
150
|
+
createDebug.debug = createDebug;
|
|
151
|
+
createDebug.default = createDebug;
|
|
152
|
+
createDebug.coerce = coerce;
|
|
153
|
+
createDebug.disable = disable;
|
|
154
|
+
createDebug.enable = enable;
|
|
155
|
+
createDebug.enabled = enabled;
|
|
156
|
+
createDebug.humanize = require_ms();
|
|
157
|
+
createDebug.destroy = destroy;
|
|
158
|
+
Object.keys(env).forEach((key) => {
|
|
159
|
+
createDebug[key] = env[key];
|
|
160
|
+
});
|
|
161
|
+
createDebug.names = [];
|
|
162
|
+
createDebug.skips = [];
|
|
163
|
+
createDebug.formatters = {};
|
|
164
|
+
function selectColor(namespace) {
|
|
165
|
+
let hash = 0;
|
|
166
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
167
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
168
|
+
hash |= 0;
|
|
169
|
+
}
|
|
170
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
171
|
+
}
|
|
172
|
+
createDebug.selectColor = selectColor;
|
|
173
|
+
function createDebug(namespace) {
|
|
174
|
+
let prevTime;
|
|
175
|
+
let enableOverride = null;
|
|
176
|
+
let namespacesCache;
|
|
177
|
+
let enabledCache;
|
|
178
|
+
function debug2(...args) {
|
|
179
|
+
if (!debug2.enabled) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const self = debug2;
|
|
183
|
+
const curr = Number(/* @__PURE__ */ new Date());
|
|
184
|
+
const ms = curr - (prevTime || curr);
|
|
185
|
+
self.diff = ms;
|
|
186
|
+
self.prev = prevTime;
|
|
187
|
+
self.curr = curr;
|
|
188
|
+
prevTime = curr;
|
|
189
|
+
args[0] = createDebug.coerce(args[0]);
|
|
190
|
+
if (typeof args[0] !== "string") {
|
|
191
|
+
args.unshift("%O");
|
|
192
|
+
}
|
|
193
|
+
let index = 0;
|
|
194
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
195
|
+
if (match === "%%") {
|
|
196
|
+
return "%";
|
|
197
|
+
}
|
|
198
|
+
index++;
|
|
199
|
+
const formatter = createDebug.formatters[format];
|
|
200
|
+
if (typeof formatter === "function") {
|
|
201
|
+
const val = args[index];
|
|
202
|
+
match = formatter.call(self, val);
|
|
203
|
+
args.splice(index, 1);
|
|
204
|
+
index--;
|
|
205
|
+
}
|
|
206
|
+
return match;
|
|
207
|
+
});
|
|
208
|
+
createDebug.formatArgs.call(self, args);
|
|
209
|
+
const logFn = self.log || createDebug.log;
|
|
210
|
+
logFn.apply(self, args);
|
|
211
|
+
}
|
|
212
|
+
debug2.namespace = namespace;
|
|
213
|
+
debug2.useColors = createDebug.useColors();
|
|
214
|
+
debug2.color = createDebug.selectColor(namespace);
|
|
215
|
+
debug2.extend = extend;
|
|
216
|
+
debug2.destroy = createDebug.destroy;
|
|
217
|
+
Object.defineProperty(debug2, "enabled", {
|
|
218
|
+
enumerable: true,
|
|
219
|
+
configurable: false,
|
|
220
|
+
get: () => {
|
|
221
|
+
if (enableOverride !== null) {
|
|
222
|
+
return enableOverride;
|
|
223
|
+
}
|
|
224
|
+
if (namespacesCache !== createDebug.namespaces) {
|
|
225
|
+
namespacesCache = createDebug.namespaces;
|
|
226
|
+
enabledCache = createDebug.enabled(namespace);
|
|
227
|
+
}
|
|
228
|
+
return enabledCache;
|
|
229
|
+
},
|
|
230
|
+
set: (v) => {
|
|
231
|
+
enableOverride = v;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
if (typeof createDebug.init === "function") {
|
|
235
|
+
createDebug.init(debug2);
|
|
236
|
+
}
|
|
237
|
+
return debug2;
|
|
238
|
+
}
|
|
239
|
+
function extend(namespace, delimiter) {
|
|
240
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
241
|
+
newDebug.log = this.log;
|
|
242
|
+
return newDebug;
|
|
243
|
+
}
|
|
244
|
+
function enable(namespaces) {
|
|
245
|
+
createDebug.save(namespaces);
|
|
246
|
+
createDebug.namespaces = namespaces;
|
|
247
|
+
createDebug.names = [];
|
|
248
|
+
createDebug.skips = [];
|
|
249
|
+
let i;
|
|
250
|
+
const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
|
|
251
|
+
const len = split.length;
|
|
252
|
+
for (i = 0; i < len; i++) {
|
|
253
|
+
if (!split[i]) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
namespaces = split[i].replace(/\*/g, ".*?");
|
|
257
|
+
if (namespaces[0] === "-") {
|
|
258
|
+
createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
|
|
259
|
+
} else {
|
|
260
|
+
createDebug.names.push(new RegExp("^" + namespaces + "$"));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function disable() {
|
|
265
|
+
const namespaces = [
|
|
266
|
+
...createDebug.names.map(toNamespace),
|
|
267
|
+
...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
|
|
268
|
+
].join(",");
|
|
269
|
+
createDebug.enable("");
|
|
270
|
+
return namespaces;
|
|
271
|
+
}
|
|
272
|
+
function enabled(name) {
|
|
273
|
+
if (name[name.length - 1] === "*") {
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
let i;
|
|
277
|
+
let len;
|
|
278
|
+
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
279
|
+
if (createDebug.skips[i].test(name)) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
|
284
|
+
if (createDebug.names[i].test(name)) {
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
function toNamespace(regexp) {
|
|
291
|
+
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
292
|
+
}
|
|
293
|
+
function coerce(val) {
|
|
294
|
+
if (val instanceof Error) {
|
|
295
|
+
return val.stack || val.message;
|
|
296
|
+
}
|
|
297
|
+
return val;
|
|
298
|
+
}
|
|
299
|
+
function destroy() {
|
|
300
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
301
|
+
}
|
|
302
|
+
createDebug.enable(createDebug.load());
|
|
303
|
+
return createDebug;
|
|
304
|
+
}
|
|
305
|
+
module2.exports = setup;
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// ../../node_modules/debug/src/browser.js
|
|
310
|
+
var require_browser = __commonJS({
|
|
311
|
+
"../../node_modules/debug/src/browser.js"(exports2, module2) {
|
|
312
|
+
"use strict";
|
|
313
|
+
exports2.formatArgs = formatArgs;
|
|
314
|
+
exports2.save = save;
|
|
315
|
+
exports2.load = load;
|
|
316
|
+
exports2.useColors = useColors;
|
|
317
|
+
exports2.storage = localstorage();
|
|
318
|
+
exports2.destroy = /* @__PURE__ */ (() => {
|
|
319
|
+
let warned = false;
|
|
320
|
+
return () => {
|
|
321
|
+
if (!warned) {
|
|
322
|
+
warned = true;
|
|
323
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
})();
|
|
327
|
+
exports2.colors = [
|
|
328
|
+
"#0000CC",
|
|
329
|
+
"#0000FF",
|
|
330
|
+
"#0033CC",
|
|
331
|
+
"#0033FF",
|
|
332
|
+
"#0066CC",
|
|
333
|
+
"#0066FF",
|
|
334
|
+
"#0099CC",
|
|
335
|
+
"#0099FF",
|
|
336
|
+
"#00CC00",
|
|
337
|
+
"#00CC33",
|
|
338
|
+
"#00CC66",
|
|
339
|
+
"#00CC99",
|
|
340
|
+
"#00CCCC",
|
|
341
|
+
"#00CCFF",
|
|
342
|
+
"#3300CC",
|
|
343
|
+
"#3300FF",
|
|
344
|
+
"#3333CC",
|
|
345
|
+
"#3333FF",
|
|
346
|
+
"#3366CC",
|
|
347
|
+
"#3366FF",
|
|
348
|
+
"#3399CC",
|
|
349
|
+
"#3399FF",
|
|
350
|
+
"#33CC00",
|
|
351
|
+
"#33CC33",
|
|
352
|
+
"#33CC66",
|
|
353
|
+
"#33CC99",
|
|
354
|
+
"#33CCCC",
|
|
355
|
+
"#33CCFF",
|
|
356
|
+
"#6600CC",
|
|
357
|
+
"#6600FF",
|
|
358
|
+
"#6633CC",
|
|
359
|
+
"#6633FF",
|
|
360
|
+
"#66CC00",
|
|
361
|
+
"#66CC33",
|
|
362
|
+
"#9900CC",
|
|
363
|
+
"#9900FF",
|
|
364
|
+
"#9933CC",
|
|
365
|
+
"#9933FF",
|
|
366
|
+
"#99CC00",
|
|
367
|
+
"#99CC33",
|
|
368
|
+
"#CC0000",
|
|
369
|
+
"#CC0033",
|
|
370
|
+
"#CC0066",
|
|
371
|
+
"#CC0099",
|
|
372
|
+
"#CC00CC",
|
|
373
|
+
"#CC00FF",
|
|
374
|
+
"#CC3300",
|
|
375
|
+
"#CC3333",
|
|
376
|
+
"#CC3366",
|
|
377
|
+
"#CC3399",
|
|
378
|
+
"#CC33CC",
|
|
379
|
+
"#CC33FF",
|
|
380
|
+
"#CC6600",
|
|
381
|
+
"#CC6633",
|
|
382
|
+
"#CC9900",
|
|
383
|
+
"#CC9933",
|
|
384
|
+
"#CCCC00",
|
|
385
|
+
"#CCCC33",
|
|
386
|
+
"#FF0000",
|
|
387
|
+
"#FF0033",
|
|
388
|
+
"#FF0066",
|
|
389
|
+
"#FF0099",
|
|
390
|
+
"#FF00CC",
|
|
391
|
+
"#FF00FF",
|
|
392
|
+
"#FF3300",
|
|
393
|
+
"#FF3333",
|
|
394
|
+
"#FF3366",
|
|
395
|
+
"#FF3399",
|
|
396
|
+
"#FF33CC",
|
|
397
|
+
"#FF33FF",
|
|
398
|
+
"#FF6600",
|
|
399
|
+
"#FF6633",
|
|
400
|
+
"#FF9900",
|
|
401
|
+
"#FF9933",
|
|
402
|
+
"#FFCC00",
|
|
403
|
+
"#FFCC33"
|
|
404
|
+
];
|
|
405
|
+
function useColors() {
|
|
406
|
+
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
413
|
+
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
414
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
415
|
+
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
416
|
+
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
417
|
+
}
|
|
418
|
+
function formatArgs(args) {
|
|
419
|
+
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
|
|
420
|
+
if (!this.useColors) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const c = "color: " + this.color;
|
|
424
|
+
args.splice(1, 0, c, "color: inherit");
|
|
425
|
+
let index = 0;
|
|
426
|
+
let lastC = 0;
|
|
427
|
+
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
428
|
+
if (match === "%%") {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
index++;
|
|
432
|
+
if (match === "%c") {
|
|
433
|
+
lastC = index;
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
args.splice(lastC, 0, c);
|
|
437
|
+
}
|
|
438
|
+
exports2.log = console.debug || console.log || (() => {
|
|
439
|
+
});
|
|
440
|
+
function save(namespaces) {
|
|
441
|
+
try {
|
|
442
|
+
if (namespaces) {
|
|
443
|
+
exports2.storage.setItem("debug", namespaces);
|
|
444
|
+
} else {
|
|
445
|
+
exports2.storage.removeItem("debug");
|
|
446
|
+
}
|
|
447
|
+
} catch (error) {
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
function load() {
|
|
451
|
+
let r;
|
|
452
|
+
try {
|
|
453
|
+
r = exports2.storage.getItem("debug");
|
|
454
|
+
} catch (error) {
|
|
455
|
+
}
|
|
456
|
+
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
457
|
+
r = process.env.DEBUG;
|
|
458
|
+
}
|
|
459
|
+
return r;
|
|
460
|
+
}
|
|
461
|
+
function localstorage() {
|
|
462
|
+
try {
|
|
463
|
+
return localStorage;
|
|
464
|
+
} catch (error) {
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
module2.exports = require_common()(exports2);
|
|
468
|
+
var { formatters } = module2.exports;
|
|
469
|
+
formatters.j = function(v) {
|
|
470
|
+
try {
|
|
471
|
+
return JSON.stringify(v);
|
|
472
|
+
} catch (error) {
|
|
473
|
+
return "[UnexpectedJSONParseError]: " + error.message;
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
// ../../node_modules/has-flag/index.js
|
|
480
|
+
var require_has_flag = __commonJS({
|
|
481
|
+
"../../node_modules/has-flag/index.js"(exports2, module2) {
|
|
482
|
+
"use strict";
|
|
483
|
+
module2.exports = (flag, argv = process.argv) => {
|
|
484
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
485
|
+
const position = argv.indexOf(prefix + flag);
|
|
486
|
+
const terminatorPosition = argv.indexOf("--");
|
|
487
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
// ../../node_modules/supports-color/index.js
|
|
493
|
+
var require_supports_color = __commonJS({
|
|
494
|
+
"../../node_modules/supports-color/index.js"(exports2, module2) {
|
|
495
|
+
"use strict";
|
|
496
|
+
var os = require("os");
|
|
497
|
+
var tty = require("tty");
|
|
498
|
+
var hasFlag = require_has_flag();
|
|
499
|
+
var { env } = process;
|
|
500
|
+
var flagForceColor;
|
|
501
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
502
|
+
flagForceColor = 0;
|
|
503
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
504
|
+
flagForceColor = 1;
|
|
505
|
+
}
|
|
506
|
+
function envForceColor() {
|
|
507
|
+
if ("FORCE_COLOR" in env) {
|
|
508
|
+
if (env.FORCE_COLOR === "true") {
|
|
509
|
+
return 1;
|
|
510
|
+
}
|
|
511
|
+
if (env.FORCE_COLOR === "false") {
|
|
512
|
+
return 0;
|
|
513
|
+
}
|
|
514
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function translateLevel(level) {
|
|
518
|
+
if (level === 0) {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
return {
|
|
522
|
+
level,
|
|
523
|
+
hasBasic: true,
|
|
524
|
+
has256: level >= 2,
|
|
525
|
+
has16m: level >= 3
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
529
|
+
const noFlagForceColor = envForceColor();
|
|
530
|
+
if (noFlagForceColor !== void 0) {
|
|
531
|
+
flagForceColor = noFlagForceColor;
|
|
532
|
+
}
|
|
533
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
534
|
+
if (forceColor === 0) {
|
|
535
|
+
return 0;
|
|
536
|
+
}
|
|
537
|
+
if (sniffFlags) {
|
|
538
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
539
|
+
return 3;
|
|
540
|
+
}
|
|
541
|
+
if (hasFlag("color=256")) {
|
|
542
|
+
return 2;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
546
|
+
return 0;
|
|
547
|
+
}
|
|
548
|
+
const min = forceColor || 0;
|
|
549
|
+
if (env.TERM === "dumb") {
|
|
550
|
+
return min;
|
|
551
|
+
}
|
|
552
|
+
if (process.platform === "win32") {
|
|
553
|
+
const osRelease = os.release().split(".");
|
|
554
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
555
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
556
|
+
}
|
|
557
|
+
return 1;
|
|
558
|
+
}
|
|
559
|
+
if ("CI" in env) {
|
|
560
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
561
|
+
return 1;
|
|
562
|
+
}
|
|
563
|
+
return min;
|
|
564
|
+
}
|
|
565
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
566
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
567
|
+
}
|
|
568
|
+
if (env.COLORTERM === "truecolor") {
|
|
569
|
+
return 3;
|
|
570
|
+
}
|
|
571
|
+
if ("TERM_PROGRAM" in env) {
|
|
572
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
573
|
+
switch (env.TERM_PROGRAM) {
|
|
574
|
+
case "iTerm.app":
|
|
575
|
+
return version >= 3 ? 3 : 2;
|
|
576
|
+
case "Apple_Terminal":
|
|
577
|
+
return 2;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
581
|
+
return 2;
|
|
582
|
+
}
|
|
583
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
584
|
+
return 1;
|
|
585
|
+
}
|
|
586
|
+
if ("COLORTERM" in env) {
|
|
587
|
+
return 1;
|
|
588
|
+
}
|
|
589
|
+
return min;
|
|
590
|
+
}
|
|
591
|
+
function getSupportLevel(stream, options = {}) {
|
|
592
|
+
const level = supportsColor(stream, {
|
|
593
|
+
streamIsTTY: stream && stream.isTTY,
|
|
594
|
+
...options
|
|
595
|
+
});
|
|
596
|
+
return translateLevel(level);
|
|
597
|
+
}
|
|
598
|
+
module2.exports = {
|
|
599
|
+
supportsColor: getSupportLevel,
|
|
600
|
+
stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
|
|
601
|
+
stderr: getSupportLevel({ isTTY: tty.isatty(2) })
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
// ../../node_modules/debug/src/node.js
|
|
607
|
+
var require_node = __commonJS({
|
|
608
|
+
"../../node_modules/debug/src/node.js"(exports2, module2) {
|
|
609
|
+
"use strict";
|
|
610
|
+
var tty = require("tty");
|
|
611
|
+
var util = require("util");
|
|
612
|
+
exports2.init = init2;
|
|
613
|
+
exports2.log = log2;
|
|
614
|
+
exports2.formatArgs = formatArgs;
|
|
615
|
+
exports2.save = save;
|
|
616
|
+
exports2.load = load;
|
|
617
|
+
exports2.useColors = useColors;
|
|
618
|
+
exports2.destroy = util.deprecate(
|
|
619
|
+
() => {
|
|
620
|
+
},
|
|
621
|
+
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
|
622
|
+
);
|
|
623
|
+
exports2.colors = [6, 2, 3, 4, 5, 1];
|
|
624
|
+
try {
|
|
625
|
+
const supportsColor = require_supports_color();
|
|
626
|
+
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
627
|
+
exports2.colors = [
|
|
628
|
+
20,
|
|
629
|
+
21,
|
|
630
|
+
26,
|
|
631
|
+
27,
|
|
632
|
+
32,
|
|
633
|
+
33,
|
|
634
|
+
38,
|
|
635
|
+
39,
|
|
636
|
+
40,
|
|
637
|
+
41,
|
|
638
|
+
42,
|
|
639
|
+
43,
|
|
640
|
+
44,
|
|
641
|
+
45,
|
|
642
|
+
56,
|
|
643
|
+
57,
|
|
644
|
+
62,
|
|
645
|
+
63,
|
|
646
|
+
68,
|
|
647
|
+
69,
|
|
648
|
+
74,
|
|
649
|
+
75,
|
|
650
|
+
76,
|
|
651
|
+
77,
|
|
652
|
+
78,
|
|
653
|
+
79,
|
|
654
|
+
80,
|
|
655
|
+
81,
|
|
656
|
+
92,
|
|
657
|
+
93,
|
|
658
|
+
98,
|
|
659
|
+
99,
|
|
660
|
+
112,
|
|
661
|
+
113,
|
|
662
|
+
128,
|
|
663
|
+
129,
|
|
664
|
+
134,
|
|
665
|
+
135,
|
|
666
|
+
148,
|
|
667
|
+
149,
|
|
668
|
+
160,
|
|
669
|
+
161,
|
|
670
|
+
162,
|
|
671
|
+
163,
|
|
672
|
+
164,
|
|
673
|
+
165,
|
|
674
|
+
166,
|
|
675
|
+
167,
|
|
676
|
+
168,
|
|
677
|
+
169,
|
|
678
|
+
170,
|
|
679
|
+
171,
|
|
680
|
+
172,
|
|
681
|
+
173,
|
|
682
|
+
178,
|
|
683
|
+
179,
|
|
684
|
+
184,
|
|
685
|
+
185,
|
|
686
|
+
196,
|
|
687
|
+
197,
|
|
688
|
+
198,
|
|
689
|
+
199,
|
|
690
|
+
200,
|
|
691
|
+
201,
|
|
692
|
+
202,
|
|
693
|
+
203,
|
|
694
|
+
204,
|
|
695
|
+
205,
|
|
696
|
+
206,
|
|
697
|
+
207,
|
|
698
|
+
208,
|
|
699
|
+
209,
|
|
700
|
+
214,
|
|
701
|
+
215,
|
|
702
|
+
220,
|
|
703
|
+
221
|
|
704
|
+
];
|
|
705
|
+
}
|
|
706
|
+
} catch (error) {
|
|
707
|
+
}
|
|
708
|
+
exports2.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
709
|
+
return /^debug_/i.test(key);
|
|
710
|
+
}).reduce((obj, key) => {
|
|
711
|
+
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
712
|
+
return k.toUpperCase();
|
|
713
|
+
});
|
|
714
|
+
let val = process.env[key];
|
|
715
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
716
|
+
val = true;
|
|
717
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
718
|
+
val = false;
|
|
719
|
+
} else if (val === "null") {
|
|
720
|
+
val = null;
|
|
721
|
+
} else {
|
|
722
|
+
val = Number(val);
|
|
723
|
+
}
|
|
724
|
+
obj[prop] = val;
|
|
725
|
+
return obj;
|
|
726
|
+
}, {});
|
|
727
|
+
function useColors() {
|
|
728
|
+
return "colors" in exports2.inspectOpts ? Boolean(exports2.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
729
|
+
}
|
|
730
|
+
function formatArgs(args) {
|
|
731
|
+
const { namespace: name, useColors: useColors2 } = this;
|
|
732
|
+
if (useColors2) {
|
|
733
|
+
const c = this.color;
|
|
734
|
+
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
735
|
+
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
736
|
+
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
737
|
+
args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m");
|
|
738
|
+
} else {
|
|
739
|
+
args[0] = getDate() + name + " " + args[0];
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
function getDate() {
|
|
743
|
+
if (exports2.inspectOpts.hideDate) {
|
|
744
|
+
return "";
|
|
745
|
+
}
|
|
746
|
+
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
747
|
+
}
|
|
748
|
+
function log2(...args) {
|
|
749
|
+
return process.stderr.write(util.format(...args) + "\n");
|
|
750
|
+
}
|
|
751
|
+
function save(namespaces) {
|
|
752
|
+
if (namespaces) {
|
|
753
|
+
process.env.DEBUG = namespaces;
|
|
754
|
+
} else {
|
|
755
|
+
delete process.env.DEBUG;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
function load() {
|
|
759
|
+
return process.env.DEBUG;
|
|
760
|
+
}
|
|
761
|
+
function init2(debug2) {
|
|
762
|
+
debug2.inspectOpts = {};
|
|
763
|
+
const keys = Object.keys(exports2.inspectOpts);
|
|
764
|
+
for (let i = 0; i < keys.length; i++) {
|
|
765
|
+
debug2.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
module2.exports = require_common()(exports2);
|
|
769
|
+
var { formatters } = module2.exports;
|
|
770
|
+
formatters.o = function(v) {
|
|
771
|
+
this.inspectOpts.colors = this.useColors;
|
|
772
|
+
return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
773
|
+
};
|
|
774
|
+
formatters.O = function(v) {
|
|
775
|
+
this.inspectOpts.colors = this.useColors;
|
|
776
|
+
return util.inspect(v, this.inspectOpts);
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
// ../../node_modules/debug/src/index.js
|
|
782
|
+
var require_src = __commonJS({
|
|
783
|
+
"../../node_modules/debug/src/index.js"(exports2, module2) {
|
|
784
|
+
"use strict";
|
|
785
|
+
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
786
|
+
module2.exports = require_browser();
|
|
787
|
+
} else {
|
|
788
|
+
module2.exports = require_node();
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
});
|
|
25
792
|
|
|
26
793
|
// src/index.ts
|
|
27
|
-
var
|
|
28
|
-
module.exports = __toCommonJS(src_exports);
|
|
29
|
-
var import_minimist = __toESM(require("minimist"));
|
|
30
|
-
var import_picocolors4 = require("picocolors");
|
|
794
|
+
var import_picocolors5 = require("picocolors");
|
|
31
795
|
|
|
32
796
|
// src/modules/init.ts
|
|
33
797
|
var fs2 = __toESM(require("fs"));
|
|
@@ -259,9 +1023,9 @@ var TEMPLATES = {
|
|
|
259
1023
|
packagePath: "bot-ask-poll"
|
|
260
1024
|
}
|
|
261
1025
|
};
|
|
262
|
-
async function init(
|
|
263
|
-
const projectName =
|
|
264
|
-
const template =
|
|
1026
|
+
async function init(argv) {
|
|
1027
|
+
const projectName = argv._[1];
|
|
1028
|
+
const template = argv.template || "quickstart";
|
|
265
1029
|
if (!projectName) {
|
|
266
1030
|
console.error((0, import_picocolors2.red)("Error: Please provide a project name"));
|
|
267
1031
|
console.log((0, import_picocolors2.yellow)("Usage: towns-bot init <project-name>"));
|
|
@@ -423,71 +1187,610 @@ async function getLatestVersion(packageName) {
|
|
|
423
1187
|
});
|
|
424
1188
|
}
|
|
425
1189
|
|
|
426
|
-
// src/
|
|
427
|
-
var
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
1190
|
+
// src/modules/update-commands.ts
|
|
1191
|
+
var import_fs2 = __toESM(require("fs"));
|
|
1192
|
+
var import_path2 = __toESM(require("path"));
|
|
1193
|
+
var import_url = require("url");
|
|
1194
|
+
var dotenv = __toESM(require("dotenv"));
|
|
1195
|
+
var import_ethers = require("ethers");
|
|
1196
|
+
var import_zod = require("zod");
|
|
1197
|
+
var import_picocolors4 = require("picocolors");
|
|
1198
|
+
var import_sdk = require("@towns-protocol/sdk");
|
|
1199
|
+
|
|
1200
|
+
// ../dlog/dist/binary.js
|
|
1201
|
+
var import_wire = require("@bufbuild/protobuf/wire");
|
|
1202
|
+
|
|
1203
|
+
// ../../node_modules/@noble/hashes/esm/utils.js
|
|
1204
|
+
function isBytes(a) {
|
|
1205
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
1206
|
+
}
|
|
1207
|
+
function abytes(b, ...lengths) {
|
|
1208
|
+
if (!isBytes(b))
|
|
1209
|
+
throw new Error("Uint8Array expected");
|
|
1210
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
1211
|
+
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
|
1212
|
+
}
|
|
1213
|
+
var hasHexBuiltin = /* @__PURE__ */ (() => (
|
|
1214
|
+
// @ts-ignore
|
|
1215
|
+
typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
|
|
1216
|
+
))();
|
|
1217
|
+
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
1218
|
+
function bytesToHex(bytes) {
|
|
1219
|
+
abytes(bytes);
|
|
1220
|
+
if (hasHexBuiltin)
|
|
1221
|
+
return bytes.toHex();
|
|
1222
|
+
let hex = "";
|
|
1223
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1224
|
+
hex += hexes[bytes[i]];
|
|
433
1225
|
}
|
|
434
|
-
|
|
1226
|
+
return hex;
|
|
1227
|
+
}
|
|
1228
|
+
var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
1229
|
+
function asciiToBase16(ch) {
|
|
1230
|
+
if (ch >= asciis._0 && ch <= asciis._9)
|
|
1231
|
+
return ch - asciis._0;
|
|
1232
|
+
if (ch >= asciis.A && ch <= asciis.F)
|
|
1233
|
+
return ch - (asciis.A - 10);
|
|
1234
|
+
if (ch >= asciis.a && ch <= asciis.f)
|
|
1235
|
+
return ch - (asciis.a - 10);
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
function hexToBytes(hex) {
|
|
1239
|
+
if (typeof hex !== "string")
|
|
1240
|
+
throw new Error("hex string expected, got " + typeof hex);
|
|
1241
|
+
if (hasHexBuiltin)
|
|
1242
|
+
return Uint8Array.fromHex(hex);
|
|
1243
|
+
const hl = hex.length;
|
|
1244
|
+
const al = hl / 2;
|
|
1245
|
+
if (hl % 2)
|
|
1246
|
+
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
1247
|
+
const array = new Uint8Array(al);
|
|
1248
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
1249
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
1250
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
1251
|
+
if (n1 === void 0 || n2 === void 0) {
|
|
1252
|
+
const char = hex[hi] + hex[hi + 1];
|
|
1253
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
1254
|
+
}
|
|
1255
|
+
array[ai] = n1 * 16 + n2;
|
|
1256
|
+
}
|
|
1257
|
+
return array;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
// ../../node_modules/ethereum-cryptography/esm/utils.js
|
|
1261
|
+
function hexToBytes2(data) {
|
|
1262
|
+
const sliced = data.startsWith("0x") ? data.substring(2) : data;
|
|
1263
|
+
return hexToBytes(sliced);
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
// ../dlog/dist/binary.js
|
|
1267
|
+
function bin_fromHexString(hexString) {
|
|
1268
|
+
return hexToBytes2(hexString);
|
|
1269
|
+
}
|
|
1270
|
+
function bin_toHexString(uint8Array) {
|
|
1271
|
+
return bytesToHex(uint8Array);
|
|
1272
|
+
}
|
|
1273
|
+
function shortenHexString(s) {
|
|
1274
|
+
if (s.startsWith("0x")) {
|
|
1275
|
+
return s.length > 12 ? s.slice(0, 6) + ".." + s.slice(-4) : s;
|
|
1276
|
+
} else {
|
|
1277
|
+
return s.length > 10 ? s.slice(0, 4) + ".." + s.slice(-4) : s;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
function isHexString(value) {
|
|
1281
|
+
if (value.length === 0 || (value.length & 1) !== 0) {
|
|
1282
|
+
return false;
|
|
1283
|
+
}
|
|
1284
|
+
return /^(0x)?[0-9a-fA-F]+$/.test(value);
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// ../dlog/dist/check.js
|
|
1288
|
+
var import_proto = require("@towns-protocol/proto");
|
|
1289
|
+
|
|
1290
|
+
// ../dlog/dist/dlog.js
|
|
1291
|
+
var import_debug = __toESM(require_src(), 1);
|
|
1292
|
+
|
|
1293
|
+
// ../dlog/dist/utils.js
|
|
1294
|
+
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
1295
|
+
var isNodeEnv = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
1296
|
+
function isTestEnv() {
|
|
1297
|
+
return isNodeEnv && (process.env.NODE_ENV === "test" || process.env.VITEST === "true" || process.env.JEST_WORKER_ID !== void 0 || process.env.TS_JEST === "1");
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
// ../dlog/dist/dlog.js
|
|
1301
|
+
import_debug.default.enabled = (ns) => {
|
|
1302
|
+
if (ns.length > 0 && ns[ns.length - 1] === "*") {
|
|
1303
|
+
return true;
|
|
1304
|
+
}
|
|
1305
|
+
for (const s of import_debug.default.skips) {
|
|
1306
|
+
if (s instanceof RegExp) {
|
|
1307
|
+
if (s.test(ns)) {
|
|
1308
|
+
return false;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
for (const s of import_debug.default.names) {
|
|
1313
|
+
if (s instanceof RegExp) {
|
|
1314
|
+
if (s.test(ns)) {
|
|
1315
|
+
return true;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
const opts = allDlogs.get(ns)?.opts;
|
|
1320
|
+
if (opts !== void 0) {
|
|
1321
|
+
if (!opts.allowJest && isTestEnv()) {
|
|
1322
|
+
return false;
|
|
1323
|
+
} else {
|
|
1324
|
+
return opts.defaultEnabled ?? false;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
return false;
|
|
1328
|
+
};
|
|
1329
|
+
if (import_debug.default.namespaces === void 0) {
|
|
1330
|
+
;
|
|
1331
|
+
import_debug.default.namespaces = "";
|
|
1332
|
+
}
|
|
1333
|
+
var MAX_CALL_STACK_SZ = 18;
|
|
1334
|
+
var hasOwnProperty = (obj, prop) => {
|
|
1335
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1336
|
+
};
|
|
1337
|
+
var cloneAndFormat = (obj, opts) => {
|
|
1338
|
+
return _cloneAndFormat(obj, 0, /* @__PURE__ */ new WeakSet(), opts?.shortenHex === true);
|
|
1339
|
+
};
|
|
1340
|
+
var _cloneAndFormat = (obj, depth, seen, shorten) => {
|
|
1341
|
+
if (depth > MAX_CALL_STACK_SZ) {
|
|
1342
|
+
return "MAX_CALL_STACK_SZ exceeded";
|
|
1343
|
+
}
|
|
1344
|
+
if (typeof obj === "object" && obj !== null) {
|
|
1345
|
+
if (seen.has(obj)) {
|
|
1346
|
+
return "[circular reference]";
|
|
1347
|
+
}
|
|
1348
|
+
seen.add(obj);
|
|
1349
|
+
}
|
|
1350
|
+
if (typeof obj === "string") {
|
|
1351
|
+
return isHexString(obj) && shorten ? shortenHexString(obj) : obj;
|
|
1352
|
+
}
|
|
1353
|
+
if (obj instanceof Uint8Array) {
|
|
1354
|
+
return shorten ? shortenHexString(bin_toHexString(obj)) : bin_toHexString(obj);
|
|
1355
|
+
}
|
|
1356
|
+
if (obj instanceof BigInt || typeof obj === "bigint") {
|
|
1357
|
+
return obj.toString();
|
|
1358
|
+
}
|
|
1359
|
+
if (Array.isArray(obj)) {
|
|
1360
|
+
return obj.map((e) => _cloneAndFormat(e, depth + 1, seen, shorten));
|
|
1361
|
+
}
|
|
1362
|
+
if (typeof obj === "object" && obj !== null) {
|
|
1363
|
+
if (obj instanceof Error) {
|
|
1364
|
+
return obj.stack || obj.message;
|
|
1365
|
+
}
|
|
1366
|
+
if (typeof obj[Symbol.iterator] === "function") {
|
|
1367
|
+
const newObj2 = [];
|
|
1368
|
+
for (const e of obj) {
|
|
1369
|
+
newObj2.push(_cloneAndFormat(e, depth + 1, seen, shorten));
|
|
1370
|
+
}
|
|
1371
|
+
return newObj2;
|
|
1372
|
+
}
|
|
1373
|
+
const newObj = {};
|
|
1374
|
+
for (const key in obj) {
|
|
1375
|
+
if (hasOwnProperty(obj, key)) {
|
|
1376
|
+
let newKey = key;
|
|
1377
|
+
if (typeof key === "string" && isHexString(key) && shorten) {
|
|
1378
|
+
newKey = shortenHexString(key);
|
|
1379
|
+
}
|
|
1380
|
+
if (key == "emitter") {
|
|
1381
|
+
newObj[newKey] = "[emitter]";
|
|
1382
|
+
} else {
|
|
1383
|
+
newObj[newKey] = _cloneAndFormat(obj[key], depth + 1, seen, shorten);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
return newObj;
|
|
1388
|
+
}
|
|
1389
|
+
return obj;
|
|
1390
|
+
};
|
|
1391
|
+
var allDlogs = /* @__PURE__ */ new Map();
|
|
1392
|
+
var customErrorLogger = void 0;
|
|
1393
|
+
var customWarnLogger = void 0;
|
|
1394
|
+
var isSingleLineLogsMode = typeof process !== "undefined" && process.env.SINGLE_LINE_LOGS === "true";
|
|
1395
|
+
var makeDlog = (d, opts) => {
|
|
1396
|
+
if (opts?.warn) {
|
|
1397
|
+
d.log = (...args) => {
|
|
1398
|
+
const warnLogger = customWarnLogger || console.warn;
|
|
1399
|
+
warnLogger(...args);
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
if (opts?.printStack) {
|
|
1403
|
+
d.log = (...args) => {
|
|
1404
|
+
const errorLogger = customErrorLogger || console.error;
|
|
1405
|
+
errorLogger(...args);
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
const dlog = (...args) => {
|
|
1409
|
+
if (!d.enabled || args.length === 0) {
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
const fmt = [];
|
|
1413
|
+
const newArgs = [];
|
|
1414
|
+
const tailArgs = [];
|
|
1415
|
+
for (let i = 0; i < args.length; i++) {
|
|
1416
|
+
let c = args[i];
|
|
1417
|
+
if (typeof c === "string") {
|
|
1418
|
+
fmt.push("%s ");
|
|
1419
|
+
if (isHexString(c)) {
|
|
1420
|
+
c = shortenHexString(c);
|
|
1421
|
+
}
|
|
1422
|
+
newArgs.push(c);
|
|
1423
|
+
} else if (typeof c === "object" && c !== null) {
|
|
1424
|
+
if (c instanceof Error) {
|
|
1425
|
+
if (isSingleLineLogsMode) {
|
|
1426
|
+
fmt.push("%o\n");
|
|
1427
|
+
} else {
|
|
1428
|
+
fmt.push("%O\n");
|
|
1429
|
+
}
|
|
1430
|
+
tailArgs.push(c);
|
|
1431
|
+
} else {
|
|
1432
|
+
if (isSingleLineLogsMode) {
|
|
1433
|
+
fmt.push("%o\n");
|
|
1434
|
+
} else {
|
|
1435
|
+
fmt.push("%O\n");
|
|
1436
|
+
}
|
|
1437
|
+
newArgs.push(cloneAndFormat(c, { shortenHex: true }));
|
|
1438
|
+
}
|
|
1439
|
+
} else {
|
|
1440
|
+
if (isSingleLineLogsMode) {
|
|
1441
|
+
fmt.push("%o ");
|
|
1442
|
+
} else {
|
|
1443
|
+
fmt.push("%O ");
|
|
1444
|
+
}
|
|
1445
|
+
newArgs.push(c);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
d(fmt.join(""), ...newArgs, ...tailArgs);
|
|
1449
|
+
};
|
|
1450
|
+
dlog.baseDebug = d;
|
|
1451
|
+
dlog.namespace = d.namespace;
|
|
1452
|
+
dlog.opts = opts;
|
|
1453
|
+
dlog.extend = (sub, delimiter) => {
|
|
1454
|
+
return makeDlog(d.extend(sub, delimiter), opts);
|
|
1455
|
+
};
|
|
1456
|
+
Object.defineProperty(dlog, "enabled", {
|
|
1457
|
+
enumerable: true,
|
|
1458
|
+
configurable: false,
|
|
1459
|
+
get: () => d.enabled,
|
|
1460
|
+
set: (v) => d.enabled = v
|
|
1461
|
+
});
|
|
1462
|
+
allDlogs.set(d.namespace, dlog);
|
|
1463
|
+
return dlog;
|
|
1464
|
+
};
|
|
1465
|
+
var dlogError = (ns) => {
|
|
1466
|
+
const l = makeDlog((0, import_debug.default)(ns), { defaultEnabled: true, printStack: true, allowJest: true });
|
|
1467
|
+
return l;
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1470
|
+
// ../dlog/dist/check.js
|
|
1471
|
+
var log = dlogError("csb:error");
|
|
1472
|
+
|
|
1473
|
+
// src/modules/update-commands.ts
|
|
1474
|
+
var import_proto2 = require("@towns-protocol/proto");
|
|
1475
|
+
var import_protobuf = require("@bufbuild/protobuf");
|
|
1476
|
+
var slashCommandSchema = import_zod.z.object({
|
|
1477
|
+
name: import_zod.z.string().min(1, "Command name is required").max(32, "Command name must be 32 characters or less").regex(
|
|
1478
|
+
/^[a-zA-Z][a-zA-Z0-9_]*$/,
|
|
1479
|
+
"Command name must start with a letter and contain only letters, numbers, and underscores"
|
|
1480
|
+
),
|
|
1481
|
+
description: import_zod.z.string().min(1, "Command description is required").max(256, "Command description must be 256 characters or less")
|
|
1482
|
+
}).transform((data) => (0, import_protobuf.create)(import_proto2.SlashCommandSchema, data));
|
|
1483
|
+
async function updateCommands(argv) {
|
|
1484
|
+
const filePath = argv.file || argv._[1];
|
|
1485
|
+
const bearerToken = argv.bearerToken || argv._[2];
|
|
1486
|
+
const envFile = argv.envFile || ".env";
|
|
1487
|
+
if (!filePath || !bearerToken) {
|
|
1488
|
+
console.error((0, import_picocolors4.red)("Error: Missing required arguments"));
|
|
1489
|
+
console.log();
|
|
1490
|
+
console.log((0, import_picocolors4.yellow)("Usage:"));
|
|
1491
|
+
console.log(" towns-bot update-commands <file-path> <bearer-token>");
|
|
1492
|
+
console.log((0, import_picocolors4.cyan)(" OR"));
|
|
1493
|
+
console.log(
|
|
1494
|
+
" towns-bot update-commands --file <path> --bearerToken <token> [--envFile <path>]"
|
|
1495
|
+
);
|
|
1496
|
+
console.log();
|
|
1497
|
+
console.log((0, import_picocolors4.yellow)("Arguments:"));
|
|
1498
|
+
console.log(" file-path Path to file exporting slash commands");
|
|
1499
|
+
console.log(" bearer-token Owner's bearer token for authentication");
|
|
1500
|
+
console.log();
|
|
1501
|
+
console.log((0, import_picocolors4.yellow)("Options:"));
|
|
1502
|
+
console.log(" -f, --file <path> Path to commands file");
|
|
1503
|
+
console.log(" -t, --bearerToken <token> Bearer token");
|
|
1504
|
+
console.log(" -e, --envFile <path> Path to .env file (default: .env)");
|
|
1505
|
+
console.log();
|
|
1506
|
+
console.log((0, import_picocolors4.yellow)("Note:"));
|
|
1507
|
+
console.log(
|
|
1508
|
+
" The bot address and environment are read from APP_PRIVATE_DATA in your .env file"
|
|
1509
|
+
);
|
|
1510
|
+
process.exit(1);
|
|
1511
|
+
}
|
|
1512
|
+
const envPath = import_path2.default.resolve(envFile);
|
|
1513
|
+
if (!import_fs2.default.existsSync(envPath)) {
|
|
1514
|
+
console.error((0, import_picocolors4.red)(`Error: Environment file not found: ${envPath}`));
|
|
1515
|
+
console.log((0, import_picocolors4.yellow)("Please ensure your .env file exists and contains APP_PRIVATE_DATA"));
|
|
1516
|
+
process.exit(1);
|
|
1517
|
+
}
|
|
1518
|
+
dotenv.config({ path: envPath });
|
|
1519
|
+
const appPrivateDataStr = process.env.APP_PRIVATE_DATA;
|
|
1520
|
+
if (!appPrivateDataStr) {
|
|
1521
|
+
console.error((0, import_picocolors4.red)("Error: APP_PRIVATE_DATA not found in environment variables"));
|
|
1522
|
+
console.log((0, import_picocolors4.yellow)("Please ensure your .env file contains APP_PRIVATE_DATA"));
|
|
1523
|
+
process.exit(1);
|
|
1524
|
+
}
|
|
1525
|
+
let privateKey;
|
|
1526
|
+
let env;
|
|
1527
|
+
try {
|
|
1528
|
+
const appPrivateData = (0, import_sdk.parseAppPrivateData)(appPrivateDataStr);
|
|
1529
|
+
privateKey = appPrivateData.privateKey;
|
|
1530
|
+
env = appPrivateData.env;
|
|
1531
|
+
} catch {
|
|
1532
|
+
console.error((0, import_picocolors4.red)("Error: Failed to parse APP_PRIVATE_DATA"));
|
|
1533
|
+
console.log((0, import_picocolors4.yellow)("Please ensure APP_PRIVATE_DATA is in the correct format"));
|
|
1534
|
+
process.exit(1);
|
|
1535
|
+
}
|
|
1536
|
+
if (!env) {
|
|
1537
|
+
console.error((0, import_picocolors4.red)("Error: Environment not found in APP_PRIVATE_DATA"));
|
|
1538
|
+
process.exit(1);
|
|
1539
|
+
}
|
|
1540
|
+
let appClientAddress;
|
|
1541
|
+
try {
|
|
1542
|
+
const wallet = new import_ethers.ethers.Wallet(privateKey);
|
|
1543
|
+
appClientAddress = wallet.address.toLowerCase();
|
|
1544
|
+
} catch {
|
|
1545
|
+
console.error((0, import_picocolors4.red)("Error: Failed to derive address from private key"));
|
|
1546
|
+
process.exit(1);
|
|
1547
|
+
}
|
|
1548
|
+
try {
|
|
1549
|
+
const resolvedPath = import_path2.default.resolve(filePath);
|
|
1550
|
+
if (!import_fs2.default.existsSync(resolvedPath)) {
|
|
1551
|
+
throw new Error(`File not found: ${resolvedPath}`);
|
|
1552
|
+
}
|
|
1553
|
+
let commands = [];
|
|
1554
|
+
const fileUrl = (0, import_url.pathToFileURL)(resolvedPath).href;
|
|
1555
|
+
try {
|
|
1556
|
+
const module2 = await import(fileUrl);
|
|
1557
|
+
commands = module2.default || module2.commands;
|
|
1558
|
+
if (!commands) {
|
|
1559
|
+
throw new Error('No default export or "commands" export found in file');
|
|
1560
|
+
}
|
|
1561
|
+
} catch (error) {
|
|
1562
|
+
throw new Error(
|
|
1563
|
+
`Failed to import commands file: ${error instanceof Error ? error.message : String(error)}`
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1566
|
+
try {
|
|
1567
|
+
const validatedCommands = import_zod.z.array(slashCommandSchema).parse(commands);
|
|
1568
|
+
commands = validatedCommands;
|
|
1569
|
+
} catch (zodError) {
|
|
1570
|
+
if (zodError instanceof import_zod.z.ZodError) {
|
|
1571
|
+
const errors = zodError.errors.map((err) => {
|
|
1572
|
+
const path5 = err.path.length > 0 ? `[${err.path.join(".")}]` : "";
|
|
1573
|
+
return ` ${path5} ${err.message}`;
|
|
1574
|
+
}).join("\n");
|
|
1575
|
+
throw new Error(`Invalid slash commands:
|
|
1576
|
+
${errors}`);
|
|
1577
|
+
}
|
|
1578
|
+
throw zodError;
|
|
1579
|
+
}
|
|
1580
|
+
console.log((0, import_picocolors4.cyan)("Found"), (0, import_picocolors4.green)(commands.length.toString()), (0, import_picocolors4.cyan)("commands:"));
|
|
1581
|
+
for (const cmd of commands) {
|
|
1582
|
+
console.log(` /${(0, import_picocolors4.green)(cmd.name)} - ${cmd.description}`);
|
|
1583
|
+
}
|
|
1584
|
+
try {
|
|
1585
|
+
const signerContext = await (0, import_sdk.makeSignerContextFromBearerToken)(bearerToken);
|
|
1586
|
+
const appRegistryUrl = (0, import_sdk.getAppRegistryUrl)(env);
|
|
1587
|
+
const { appRegistryRpcClient } = await import_sdk.AppRegistryService.authenticate(
|
|
1588
|
+
signerContext,
|
|
1589
|
+
appRegistryUrl
|
|
1590
|
+
);
|
|
1591
|
+
const appId = bin_fromHexString(appClientAddress);
|
|
1592
|
+
const { metadata } = await appRegistryRpcClient.getAppMetadata({ appId });
|
|
1593
|
+
if (!metadata) {
|
|
1594
|
+
throw new Error("App not found or you do not have permission to modify it");
|
|
1595
|
+
}
|
|
1596
|
+
console.log();
|
|
1597
|
+
await appRegistryRpcClient.setAppMetadata({
|
|
1598
|
+
appId,
|
|
1599
|
+
metadata: {
|
|
1600
|
+
...metadata,
|
|
1601
|
+
slashCommands: commands
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
console.log((0, import_picocolors4.cyan)("Bot:"), metadata.displayName);
|
|
1605
|
+
console.log((0, import_picocolors4.green)("\u2713"), "Slash commands updated successfully!");
|
|
1606
|
+
process.exit(0);
|
|
1607
|
+
} catch (authError) {
|
|
1608
|
+
const errorMessage = authError instanceof Error ? authError.message : String(authError);
|
|
1609
|
+
if (errorMessage.includes("app was not found in registry")) {
|
|
1610
|
+
throw new Error(
|
|
1611
|
+
`Bot not found: ${appClientAddress}
|
|
1612
|
+
|
|
1613
|
+
Make sure the bot address is correct and the bot exists on the ${env} network.`
|
|
1614
|
+
);
|
|
1615
|
+
} else if (errorMessage.includes("permission") || errorMessage.includes("unauthorized")) {
|
|
1616
|
+
throw new Error(
|
|
1617
|
+
`Permission denied: You don't have permission to modify this bot.
|
|
1618
|
+
|
|
1619
|
+
Make sure the bearer token belongs to the bot owner.`
|
|
1620
|
+
);
|
|
1621
|
+
} else if (errorMessage.includes("invalid") || errorMessage.includes("malformed")) {
|
|
1622
|
+
throw new Error(
|
|
1623
|
+
`Invalid bearer token format.
|
|
1624
|
+
|
|
1625
|
+
Please check that the bearer token is correctly formatted.`
|
|
1626
|
+
);
|
|
1627
|
+
} else {
|
|
1628
|
+
throw new Error(
|
|
1629
|
+
`Failed to update commands: ${errorMessage}
|
|
1630
|
+
|
|
1631
|
+
Please check your bearer token and bot address.`
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
} catch (error) {
|
|
1636
|
+
console.error((0, import_picocolors4.red)("Error:"), error instanceof Error ? error.message : error);
|
|
1637
|
+
process.exit(1);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
// src/parser.ts
|
|
1642
|
+
var import_minimist = __toESM(require("minimist"));
|
|
1643
|
+
var COMMAND_CONFIGS = {
|
|
1644
|
+
init: {
|
|
1645
|
+
string: ["template"],
|
|
1646
|
+
alias: { t: "template" },
|
|
1647
|
+
default: { template: "quickstart" }
|
|
1648
|
+
},
|
|
1649
|
+
update: {
|
|
1650
|
+
// No special config needed
|
|
1651
|
+
},
|
|
1652
|
+
"list-commands": {
|
|
1653
|
+
string: ["file"],
|
|
1654
|
+
alias: { f: "file" }
|
|
1655
|
+
},
|
|
1656
|
+
"update-commands": {
|
|
1657
|
+
// Force all positional args after command to be strings (prevents hex->number conversion)
|
|
1658
|
+
string: ["file", "bearerToken", "envFile", "_"],
|
|
1659
|
+
alias: {
|
|
1660
|
+
f: "file",
|
|
1661
|
+
t: "bearerToken",
|
|
1662
|
+
e: "envFile"
|
|
1663
|
+
},
|
|
1664
|
+
default: { envFile: ".env" }
|
|
1665
|
+
}
|
|
1666
|
+
};
|
|
1667
|
+
function parseArgs(args) {
|
|
1668
|
+
const initial = (0, import_minimist.default)(args, {
|
|
1669
|
+
stopEarly: true,
|
|
1670
|
+
boolean: ["help"],
|
|
1671
|
+
alias: { h: "help" }
|
|
1672
|
+
});
|
|
1673
|
+
const command = initial._[0];
|
|
1674
|
+
if (!command || initial.help) {
|
|
1675
|
+
return initial;
|
|
1676
|
+
}
|
|
1677
|
+
const commandConfig = COMMAND_CONFIGS[command] || {};
|
|
1678
|
+
const booleanOptions = Array.isArray(commandConfig.boolean) ? ["help", ...commandConfig.boolean] : ["help"];
|
|
1679
|
+
const parsed = (0, import_minimist.default)(args, {
|
|
1680
|
+
...commandConfig,
|
|
1681
|
+
boolean: booleanOptions,
|
|
1682
|
+
alias: {
|
|
1683
|
+
...commandConfig.alias,
|
|
1684
|
+
h: "help"
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1687
|
+
return parsed;
|
|
1688
|
+
}
|
|
1689
|
+
function isInitArgs(args) {
|
|
1690
|
+
return args._[0] === "init";
|
|
1691
|
+
}
|
|
1692
|
+
function isUpdateArgs(args) {
|
|
1693
|
+
return args._[0] === "update";
|
|
1694
|
+
}
|
|
1695
|
+
function isUpdateCommandsArgs(args) {
|
|
1696
|
+
return args._[0] === "update-commands";
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
// src/index.ts
|
|
435
1700
|
async function main() {
|
|
436
|
-
const
|
|
437
|
-
|
|
1701
|
+
const args = parseArgs(process.argv.slice(2));
|
|
1702
|
+
const command = args._[0];
|
|
1703
|
+
if (args.help || !command) {
|
|
438
1704
|
showHelp();
|
|
439
1705
|
return;
|
|
440
1706
|
}
|
|
441
1707
|
try {
|
|
442
1708
|
switch (command) {
|
|
443
1709
|
case "init":
|
|
444
|
-
|
|
1710
|
+
if (isInitArgs(args)) {
|
|
1711
|
+
await init(args);
|
|
1712
|
+
}
|
|
445
1713
|
break;
|
|
446
1714
|
case "update":
|
|
447
|
-
|
|
1715
|
+
if (isUpdateArgs(args)) {
|
|
1716
|
+
await update(args);
|
|
1717
|
+
}
|
|
1718
|
+
break;
|
|
1719
|
+
case "update-commands":
|
|
1720
|
+
if (isUpdateCommandsArgs(args)) {
|
|
1721
|
+
await updateCommands(args);
|
|
1722
|
+
}
|
|
448
1723
|
break;
|
|
449
1724
|
default:
|
|
450
|
-
console.error((0,
|
|
1725
|
+
console.error((0, import_picocolors5.red)(`Unknown command: ${command}`));
|
|
451
1726
|
showHelp();
|
|
452
1727
|
process.exit(1);
|
|
453
1728
|
}
|
|
454
1729
|
} catch (error) {
|
|
455
|
-
console.error((0,
|
|
1730
|
+
console.error((0, import_picocolors5.red)("Error:"), error instanceof Error ? error.message : error);
|
|
456
1731
|
process.exit(1);
|
|
457
1732
|
}
|
|
458
1733
|
}
|
|
459
1734
|
function showHelp() {
|
|
460
1735
|
console.log(`
|
|
461
|
-
${(0,
|
|
1736
|
+
${(0, import_picocolors5.cyan)("towns-bot")} - CLI for creating and managing Towns Protocol bot projects
|
|
462
1737
|
|
|
463
|
-
${(0,
|
|
1738
|
+
${(0, import_picocolors5.yellow)("Usage:")}
|
|
464
1739
|
towns-bot <command> [options]
|
|
465
1740
|
|
|
466
|
-
${(0,
|
|
467
|
-
${(0,
|
|
468
|
-
${(0,
|
|
1741
|
+
${(0, import_picocolors5.yellow)("Commands:")}
|
|
1742
|
+
${(0, import_picocolors5.green)("init")} [project-name] Create a new bot project
|
|
1743
|
+
${(0, import_picocolors5.green)("update")} Update @towns-protocol dependencies to latest versions
|
|
1744
|
+
${(0, import_picocolors5.green)("list-commands")} List slash commands from a file
|
|
1745
|
+
${(0, import_picocolors5.green)("update-commands")} Update slash commands for a bot
|
|
469
1746
|
|
|
470
|
-
${(0,
|
|
471
|
-
-t, --template <name>
|
|
1747
|
+
${(0, import_picocolors5.yellow)("Init Options:")}
|
|
1748
|
+
-t, --template <name> Template to use:
|
|
472
1749
|
${Object.entries(TEMPLATES).map(
|
|
473
|
-
([key, template]) => `
|
|
1750
|
+
([key, template]) => ` ${key} - ${template.description}`
|
|
474
1751
|
).join("\n")}
|
|
475
|
-
|
|
476
|
-
-h, --help Show this help message
|
|
1752
|
+
Default: quickstart
|
|
477
1753
|
|
|
478
|
-
${(0,
|
|
479
|
-
|
|
480
|
-
|
|
1754
|
+
${(0, import_picocolors5.yellow)("List Commands Options:")}
|
|
1755
|
+
-f, --file <path> Path to commands file
|
|
1756
|
+
|
|
1757
|
+
${(0, import_picocolors5.yellow)("Update Commands Options:")}
|
|
1758
|
+
-f, --file <path> Path to commands file
|
|
1759
|
+
-t, --bearerToken <token> Bearer token for authentication
|
|
1760
|
+
-e, --envFile <path> Path to .env file (default: .env)
|
|
1761
|
+
|
|
1762
|
+
${(0, import_picocolors5.yellow)("Global Options:")}
|
|
1763
|
+
-h, --help Show this help message
|
|
481
1764
|
|
|
482
|
-
|
|
1765
|
+
${(0, import_picocolors5.yellow)("Examples:")}
|
|
1766
|
+
${(0, import_picocolors5.cyan)("# Create a new bot project")}
|
|
1767
|
+
towns-bot init my-bot
|
|
483
1768
|
towns-bot init my-ai-bot --template thread-ai
|
|
484
1769
|
|
|
485
|
-
${(0,
|
|
1770
|
+
${(0, import_picocolors5.cyan)("# Update dependencies")}
|
|
486
1771
|
towns-bot update
|
|
1772
|
+
|
|
1773
|
+
${(0, import_picocolors5.cyan)("# List slash commands")}
|
|
1774
|
+
towns-bot list-commands src/commands.ts
|
|
1775
|
+
towns-bot list-commands --file src/commands.ts
|
|
1776
|
+
|
|
1777
|
+
${(0, import_picocolors5.cyan)("# Update slash commands (positional arguments)")}
|
|
1778
|
+
towns-bot update-commands commands.ts token123
|
|
1779
|
+
|
|
1780
|
+
${(0, import_picocolors5.cyan)("# Update slash commands (named arguments)")}
|
|
1781
|
+
towns-bot update-commands --file commands.ts --bearerToken token123
|
|
1782
|
+
towns-bot update-commands -f commands.ts -t token123 -e custom.env
|
|
1783
|
+
|
|
1784
|
+
${(0, import_picocolors5.cyan)("Note: Bot address and environment are read from APP_PRIVATE_DATA in .env")}
|
|
487
1785
|
`);
|
|
488
1786
|
}
|
|
489
1787
|
main().catch((error) => {
|
|
490
|
-
console.error((0,
|
|
1788
|
+
console.error((0, import_picocolors5.red)("Unexpected error:"), error);
|
|
491
1789
|
process.exit(1);
|
|
492
1790
|
});
|
|
1791
|
+
/*! Bundled license information:
|
|
1792
|
+
|
|
1793
|
+
@noble/hashes/esm/utils.js:
|
|
1794
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
1795
|
+
*/
|
|
493
1796
|
//# sourceMappingURL=index.js.map
|