Appearance
Mention users in a story
What it is for. Adding mentions to a story you published.
What you call. MediaAddMentionedUser({ mediaId, userIds, mentionSharingEnabled? }), inside the main of an entry (Effects inside main). mediaId is the story's media id (what shareToYourStory() answered, A story), userIds are the ids of the accounts as strings (the userId of a profile handle, Profiles), and mentionSharingEnabled is on unless you turn it off.
What you get. The mentioned accounts, each with its username, full_name, pk_id and whether it is private or verified.
ts
import { AndroidIgpapi, FeedTimelineScreen, MediaAddMentionedUser } from '@igpapi/android';
import { Effect } from 'effect';
import { readFile } from 'node:fs/promises';
// The checkpoint saved in "Your first program".
const saved = JSON.parse(await readFile('session.json', 'utf8'));
// The story's media id is what `shareToYourStory()` answered when you published it; the accounts' ids are the
// `userId` of their profile handles. Here they come from the command line: `node mention.ts <storyMediaId> <userId>…`.
const [storyMediaId = '', ...userIds] = process.argv.slice(2);
const mentioned = await AndroidIgpapi.launch({
checkpoint: saved,
screen: FeedTimelineScreen,
main: _feed =>
Effect.gen(function* () {
const result = yield* MediaAddMentionedUser({ mediaId: storyMediaId, userIds });
return result.mentioned_users.map(user => user.username);
}),
});
console.log(mentioned);