-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -452,3 +452,32 @@ The above code will create a text like this: | |
> [!NOTE] | ||
> The `markdown()` function does not support raw HTML syntax. | ||
Determining if the text mentions an account | ||
------------------------------------------- | ||
You can determine if the text mentions an account by using the `mentions()` | ||
function. It returns `true` if the text mentions the account, | ||
otherwise `false`: | ||
~~~~ typescript | ||
import { type Actor, markdown, mention, mentions, text } from "@fedify/botkit"; | ||
const actor: Actor = getActor( // A hypothetical function that returns an Actor object | ||
"@[email protected]" | ||
); | ||
const actor2: Actor = getActor("@[email protected]"); | ||
const md = markdown("Hello, @[email protected]!"); | ||
console.log(await mentions(md, actor)); // true | ||
console.log(await mentions(md, actor2)); // false | ||
const txt = text`Hi, ${actor2}!` | ||
console.log(await mentions(txt, actor)); // false | ||
console.log(await mentions(txt, actor2)); // true | ||
const noMention = text`Hello, world!`; | ||
console.log(await mentions(noMention, actor)); // false | ||
console.log(await mentions(noMention, actor2)); // false | ||
~~~~ |
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
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