-
-
Save so-asano/882c990e67ac630a167cd45872b0af26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const agent = new BskyAgent({ service: 'https://bsky.social' }) | |
await agent.login({ 'identifier': IDENTIFIER, 'password': PASSWORD }) | |
const mentionLikeText = '@mention' | |
const text = `${mentionLikeText} This mention is URL link. I think this is really bad...` | |
const byteStart = 0 | |
const byteEnd = (new TextEncoder().encode(mentionLikeText)).length | |
const richText = new RichText({ text }) | |
if (!richText.facets) { | |
richText.facets = [] | |
} | |
richText.facets?.push({ | |
index: { byteStart: byteStart, byteEnd: byteEnd }, | |
features: [ | |
{ $type: "app.bsky.richtext.facet#link", uri: 'https://example.com/some-bad-url' } | |
], | |
}) | |
const facets = richText.facets | |
const postObj = { | |
$type: 'app.bsky.feed.post', | |
text, | |
facets, | |
langs: ['ja', 'en'], | |
} | |
await agent.post(postObj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment