54 | 55 | {author.name} 56 | 57 |
{" "} 58 |59 | {authorHandle} 60 |
61 | 62 | ) 63 | : (Deleted account)} 64 |59 | {authorHandle} 60 |
61 | 62 | ) 63 | : (Deleted account)} 64 |
85 |
86 | [FediChatBot] is an LLM-powered chatbot for fediverse, of course, built on top
87 | of BotKit. It consists of about 350 lines of code, and it's a good example of
88 | how to build a chatbot with BotKit. You can find the source code at:
89 |
world!',
32 | );
33 |
34 | // Test multiple emojis
35 | assert.equal(
36 | renderCustomEmojis("Good morning :smile: :laughing:", emojis),
37 | 'Good morning
',
38 | );
39 |
40 | // Test emojis adjacent to text
41 | assert.equal(
42 | renderCustomEmojis("Hi:smile:! How are you:laughing:?", emojis),
43 | 'Hi
! How are you
?',
44 | );
45 |
46 | // Test unknown emojis (should not be replaced)
47 | assert.equal(
48 | renderCustomEmojis("This is an :unknown: emoji.", emojis),
49 | "This is an :unknown: emoji.",
50 | );
51 |
52 | // Test emojis mixed with HTML tags
53 | assert.equal(
54 | renderCustomEmojis("Hello :smile: world!
", emojis), 55 | 'Hello
world!
', emojis),
68 | '
',
69 | );
70 |
71 | // Test case sensitivity
72 | assert.equal(
73 | renderCustomEmojis("Case :SmIlE: test", emojis),
74 | 'Case
test',
75 | );
76 |
77 | // Test emojis with underscores
78 | assert.equal(
79 | renderCustomEmojis("Great job :thumbs_up:", emojis),
80 | 'Great job Hi
", emojis), 89 | "Hi
", 90 | ); 91 | 92 | // Test input with only emojis 93 | assert.equal( 94 | renderCustomEmojis(":smile::laughing:", emojis), 95 | '
',
96 | );
97 | });
98 |
--------------------------------------------------------------------------------
/AGENTS.md:
--------------------------------------------------------------------------------
1 | # Guidelines for LLM-Powered Code Assistants
2 |
3 | This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4 |
5 | ## Project Overview
6 |
7 | BotKit is a TypeScript framework for creating ActivityPub bots, built on top of Fedify. It supports both Deno and Node.js environments and provides a simple API for creating standalone ActivityPub servers that function as bots.
8 |
9 | ## Development Commands
10 |
11 | ### Primary Commands (Deno-based)
12 | - `deno task check` - Full codebase validation (type check, lint, format check, publish dry-run, version check)
13 | - `deno task test` - Run Deno tests with network access to hollo.social
14 | - `deno task test:node` - Run Node.js tests via pnpm
15 | - `deno task test-all` - Run all checks and tests (check + test + test:node)
16 | - `deno task coverage` - Generate test coverage report in HTML format
17 |
18 | ### Build Commands
19 | - `pnpm build` - Build via npm script (runs tsdown)
20 | - `pnpm test` - Run Node.js tests after installing dependencies
21 |
22 | ### Code Quality
23 | - `deno lint` - Lint TypeScript code
24 | - `deno fmt` - Format code (excludes .md, .yaml, .yml files)
25 | - `deno fmt --check` - Check code formatting without modifying files
26 | - `deno check src/` - Type check source files
27 |
28 | ## Architecture
29 |
30 | ### Core Module Structure
31 | - **`src/mod.ts`** - Main entry point, re-exports all public APIs
32 | - **`src/bot.ts`** - Core Bot interface and createBot function
33 | - **`src/bot-impl.ts`** - Internal Bot implementation
34 | - **`src/session.ts`** - Session management for bot operations
35 | - **`src/message.ts`** - Message types and ActivityPub objects (Note, Article, etc.)
36 | - **`src/events.ts`** - Event handler type definitions
37 | - **`src/text.ts`** - Text formatting utilities (mention, hashtag, link, etc.)
38 | - **`src/emoji.ts`** - Custom emoji handling
39 | - **`src/reaction.ts`** - Like and reaction implementations
40 | - **`src/repository.ts`** - Data storage abstractions
41 | - **`src/follow.ts`** - Follow request handling
42 |
43 | ### Key Concepts
44 | - **Bot**: The main bot instance created with `createBot()`, handles events and provides session access
45 | - **Session**: Scoped bot operations for publishing content and managing state
46 | - **Message**: ActivityPub objects like Note, Article, Question with rich text support
47 | - **Repository**: Storage backend abstraction (Memory, KV-based, cached variants)
48 | - **Event Handlers**: Functions for responding to ActivityPub activities (mentions, follows, likes, etc.)
49 |
50 | ### Build System
51 | - Uses `tsdown` for cross-platform builds (Deno → Node.js/npm)
52 | - Generates ESM (`dist/*.js`) and CommonJS (`dist/*.cjs`) outputs
53 | - Creates TypeScript definitions for both (`dist/*.d.ts`, `dist/*.d.cts`)
54 | - Includes Temporal polyfill injection for Node.js compatibility
55 |
56 | ### Testing
57 | - Deno tests: `*.test.ts` files, run with `deno task test`
58 | - Node.js tests: Built output tested in `dist/` directory with Node's built-in test runner
59 | - Coverage reports available via `deno task coverage`
60 |
61 | ### Dual Runtime Support
62 | - Primary development in Deno with `deno.json` configuration
63 | - Node.js support via `package.json` and tsdown transpilation
64 | - Separate import maps for each runtime (JSR for Deno, npm for Node.js)
65 |
66 | ## Development Notes
67 |
68 | ### When Running Tests
69 | Always run the full test suite with `deno task test-all` to ensure both Deno and Node.js compatibility.
70 |
71 | ### When Making Changes
72 | 1. Run `deno task check` before committing to validate all aspects
73 | 2. The build process (`tsdown`) generates dual outputs for both runtimes
74 | 3. Tests should work in both Deno and Node.js environments
75 | 4. **Update documentation**: New features must be documented in the `docs/` directory
76 | 5. **Update changelog**: Any user-facing changes must be recorded in `CHANGES.md`
77 |
78 | ### File Organization
79 | - Implementation files: `*-impl.ts` (internal implementations)
80 | - Test files: `*.test.ts` (both unit and integration tests)
81 | - Type definitions: Primarily in `events.ts` and exported through `mod.ts`
82 | - UI components: `src/components/` for JSX/TSX files
83 | - Documentation: `docs/` directory contains user-facing documentation
84 | - Changelog: `CHANGES.md` records all user-facing changes
85 |
--------------------------------------------------------------------------------
/packages/botkit/src/emoji.ts:
--------------------------------------------------------------------------------
1 | // BotKit by Fedify: A framework for creating ActivityPub bots
2 | // Copyright (C) 2025 Hong Minhee 83 | {authorHandle} 84 |
85 | 86 | ) 87 | : (Deleted account)} 88 |94 | This demo shows how to create a simple emoji-based one-time passcode 95 | authentication using BotKit. 96 |
97 | 98 | 114 |128 | A direct message has been sent to{" "} 129 | {props.handle}. Please choose the emojis below to 130 | authenticate: 131 |
132 | 133 |You have successfully authenticated!
159 | :Authentication failed. Please try again.
} 160 | 161 |