slack-term 1.32.0 → 1.32.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/dist/cli.js +65 -65
- package/package.json +1 -1
- package/ts/cli.ts +21 -3
package/package.json
CHANGED
package/ts/cli.ts
CHANGED
|
@@ -929,14 +929,27 @@ async function recipientTzFor(token: string, channelId: string, cookie?: string)
|
|
|
929
929
|
}
|
|
930
930
|
}
|
|
931
931
|
|
|
932
|
-
|
|
932
|
+
/** `when` is the moment the message will ACTUALLY reach the person — which is
|
|
933
|
+
* now for a send, and `post_at` for a schedule. Judging a scheduled message by
|
|
934
|
+
* the clock at schedule time answers a question nobody asked: `schedule send`
|
|
935
|
+
* is the one command where the delivery time is stated outright, and reading
|
|
936
|
+
* it off `Date.now()` warned about a message set for December because it was
|
|
937
|
+
* scheduled after 23:00. A warning that is false on the command where the
|
|
938
|
+
* answer is written in the arguments teaches people to ignore the warning. */
|
|
939
|
+
function requireCode(
|
|
940
|
+
provided: string | undefined,
|
|
941
|
+
expected: string,
|
|
942
|
+
contextLines: string[],
|
|
943
|
+
recipientTz?: string | null,
|
|
944
|
+
when: Date = new Date(),
|
|
945
|
+
): void {
|
|
933
946
|
// The clock goes to stdout with the rest of the preview, not to stderr with
|
|
934
947
|
// the code. The preview is what you are asked to LOOK at before committing,
|
|
935
948
|
// and "what time is it where they are" is part of that picture — a caller
|
|
936
949
|
// doing `send ... 2>/dev/null` to read the preview would otherwise drop the
|
|
937
950
|
// one line added to stop a 01:00 send.
|
|
938
951
|
for (const line of contextLines) console.log(line);
|
|
939
|
-
const clock = quietHoursNotice(
|
|
952
|
+
const clock = quietHoursNotice(when, recipientTz);
|
|
940
953
|
if (clock) console.log(clock);
|
|
941
954
|
if (provided !== undefined) {
|
|
942
955
|
console.error(`Code mismatch (got ${provided}, expected ${expected})`);
|
|
@@ -2725,6 +2738,11 @@ async function cmdScheduleSend(token: string, args: ScheduleSendArgs): Promise<v
|
|
|
2725
2738
|
const destOverride = args.targetOverride ? ` [${args.targetOverride} → ${channelId}]` : "";
|
|
2726
2739
|
|
|
2727
2740
|
if (args.code !== code) {
|
|
2741
|
+
// Quiet hours are judged on post_at, in the recipient's zone — the two facts
|
|
2742
|
+
// that decide whether a phone buzzes at 3am, and the two this gate was
|
|
2743
|
+
// guessing at. `send` already resolves the zone; here the time is known
|
|
2744
|
+
// exactly, which is the one command where it is.
|
|
2745
|
+
const recipientTz = await recipientTzFor(token, channelId, args.cookie);
|
|
2728
2746
|
requireCode(args.code, code, [
|
|
2729
2747
|
`--- Scheduling message -----------------------`,
|
|
2730
2748
|
fromLine(self, { asBot: args.asBot, pad: 9 }),
|
|
@@ -2732,7 +2750,7 @@ async function cmdScheduleSend(token: string, args: ScheduleSendArgs): Promise<v
|
|
|
2732
2750
|
` At: ${fmtPostAt(postAt)}`,
|
|
2733
2751
|
` Message: ${args.message}`,
|
|
2734
2752
|
`---------------------------------------------`,
|
|
2735
|
-
]);
|
|
2753
|
+
], recipientTz, new Date(postAt * 1000));
|
|
2736
2754
|
}
|
|
2737
2755
|
const id = await scheduleMessage(token, channelId, args.message, postAt, threadTs, args.cookie);
|
|
2738
2756
|
console.log(`✓ Scheduled (id: ${id}, at: ${postAtDate})`);
|