@rcpooley/botyard 0.4.0 → 0.4.2
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/botyard.js +3 -3
- package/dist/watch.js +5 -3
- package/package.json +1 -1
package/dist/botyard.js
CHANGED
|
@@ -187,7 +187,7 @@ const COMMANDS = [
|
|
|
187
187
|
'Names are 1-100 characters; words after <channel> are joined, so quotes are optional. Without --from it is a new public thread with no opening message.',
|
|
188
188
|
'For a new topic: post a short opening message in the channel, then botyard thread <server> <channel> <name> --from <that message id>, and keep the discussion in the thread. The channel then holds one entrance post per topic.',
|
|
189
189
|
'Threads close themselves after a week without messages; sending to one opens it again.',
|
|
190
|
-
"--add <user id> adds that person to the thread (repeat it, up to 10),
|
|
190
|
+
"--add <user id> adds that person to the thread (repeat it, up to 10), without a ping (Discord shows an 'added to the thread' line in it). Discord notifies someone about a thread's messages only once they are a member of it, so add the humans who should hear about it. Someone Discord refuses (not in the server, say) is listed and the thread is still made. For a thread that already exists: botyard thread-add.",
|
|
191
191
|
],
|
|
192
192
|
args: 3,
|
|
193
193
|
rest: true,
|
|
@@ -210,7 +210,7 @@ const COMMANDS = [
|
|
|
210
210
|
name: 'thread-add',
|
|
211
211
|
group: 'Writing',
|
|
212
212
|
usage: 'thread-add <server> <thread> <user id>...',
|
|
213
|
-
summary: 'add people to an existing thread,
|
|
213
|
+
summary: 'add people to an existing thread, without a ping',
|
|
214
214
|
details: [
|
|
215
215
|
'Adds each user id to the thread without pinging them. Discord notifies a person about a thread\'s messages only once they are a member of it, so this is how the humans who own a project get notified of the threads you start.',
|
|
216
216
|
'<thread> is its id or, while it is active, its name. A user id is a number (Discord: Settings > Advanced > Developer Mode, then right-click a person > Copy User ID).',
|
|
@@ -433,7 +433,7 @@ function commandHelp(c) {
|
|
|
433
433
|
}
|
|
434
434
|
/** Who a thread's members call added, and who Discord refused. */
|
|
435
435
|
function memberLines(added, failed) {
|
|
436
|
-
return [...(added.length > 0 ? [`Added (
|
|
436
|
+
return [...(added.length > 0 ? [`Added (no ping): ${added.join(', ')}`] : []), ...failed.map((f) => `Could not add ${f.id}: ${f.error}`)];
|
|
437
437
|
}
|
|
438
438
|
function quote(s) {
|
|
439
439
|
return /^[\w#.-]+$/.test(s) ? s : `"${s.replace(/"/g, '\\"')}"`;
|
package/dist/watch.js
CHANGED
|
@@ -77,7 +77,7 @@ export async function watch(o) {
|
|
|
77
77
|
// catch up on what was posted while it was down; the stream's own copy of
|
|
78
78
|
// any of those is skipped by the id check in print().
|
|
79
79
|
if (last > 0n)
|
|
80
|
-
await catchUp(o, [...asked, ...seen.values()], seen, print);
|
|
80
|
+
await catchUp(o, [...asked, ...seen.values()], seen, print, o.includeOwn ? null : me.bot.userId || me.bot.id);
|
|
81
81
|
else {
|
|
82
82
|
const named = [...o.servers.map((s) => `all of ${s}`), ...o.channels.map((c) => `${c} and its threads`), ...o.threads.map((c) => `thread ${c}`)];
|
|
83
83
|
const scope = named.length ? named.join(', ') : 'every server, channel and thread this key can read';
|
|
@@ -115,13 +115,15 @@ function named(ref, thread) {
|
|
|
115
115
|
return { server: { id: server, name: server }, channel: { id: channel, name: channel, thread, parentId: null, parentName: null } };
|
|
116
116
|
}
|
|
117
117
|
/** Read the channels and threads this run has seen and print what is newer than the last message printed, oldest first. */
|
|
118
|
-
|
|
118
|
+
// `own` is the bot's user id when its own messages are to be left out: the
|
|
119
|
+
// stream drops them server-side, but catch-up reads history, which has them.
|
|
120
|
+
async function catchUp(o, channels, seen, print, own) {
|
|
119
121
|
const missed = [];
|
|
120
122
|
for (const where of channels) {
|
|
121
123
|
try {
|
|
122
124
|
const page = await call(o.url, o.key, 'GET', `/servers/${seg(where.server.id)}/channels/${seg(where.channel.id)}/messages?limit=100`);
|
|
123
125
|
// A channel asked for by name prints under its real name once one of its messages has come through the stream.
|
|
124
|
-
missed.push(...page.messages.map((m) => ({ ...m, ...(seen.get(m.channelId) ?? where) })));
|
|
126
|
+
missed.push(...page.messages.filter((m) => m.author.id !== own).map((m) => ({ ...m, ...(seen.get(m.channelId) ?? where) })));
|
|
125
127
|
}
|
|
126
128
|
catch (e) {
|
|
127
129
|
o.log(`botyard: could not catch up on ${place(where)} (${e instanceof Error ? e.message : e})`);
|