|
| 1 | +# @eliza/plugin-dao-forum |
| 2 | + |
| 3 | +A plugin for Eliza that enables automated scraping and analysis of DAO governance discussions from multiple platforms including Discourse forums, Discord channels, and Commonwealth. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Multi-platform support for major DAO communication channels |
| 8 | + - Discourse forums (with API or public access) |
| 9 | + - Discord channels |
| 10 | + - Commonwealth discussions |
| 11 | +- Automatic message aggregation and chronological sorting |
| 12 | +- Metadata preservation (timestamps, authors, sources) |
| 13 | +- Configurable endpoints and credentials |
| 14 | +- Rate-limiting and pagination support |
| 15 | +- Error handling and retry mechanisms |
| 16 | + |
| 17 | +## Installation |
| 18 | + |
| 19 | +```bash |
| 20 | +# Using pnpm (recommended) |
| 21 | +pnpm add @eliza/plugin-dao-forum |
| 22 | + |
| 23 | +# Using npm |
| 24 | +npm install @eliza/plugin-dao-forum |
| 25 | + |
| 26 | +# Using yarn |
| 27 | +yarn add @eliza/plugin-dao-forum |
| 28 | +``` |
| 29 | + |
| 30 | +## Configuration |
| 31 | + |
| 32 | +The plugin accepts the following configuration options: |
| 33 | + |
| 34 | +```typescript |
| 35 | +interface DAOForumConfig { |
| 36 | + // Discourse forum configuration |
| 37 | + discourseUrl?: string; // URL of your Discourse forum |
| 38 | + discourseApiKey?: string; // API key for Discourse (optional) |
| 39 | + usePublicDiscourse?: boolean; // Use public scraping instead of API |
| 40 | + |
| 41 | + // Discord configuration |
| 42 | + discordToken?: string; // Discord bot token |
| 43 | + discordChannelIds?: string[]; // Array of channel IDs to monitor |
| 44 | + |
| 45 | + // Commonwealth configuration |
| 46 | + commonwealthUrl?: string; // URL of your Commonwealth space |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +## Usage |
| 51 | + |
| 52 | +### Basic Setup |
| 53 | + |
| 54 | +```typescript |
| 55 | +// Using public Discourse access (no API key needed) |
| 56 | +const daoForumPlugin = new DAOForumPlugin({ |
| 57 | + discourseUrl: 'https://forum.yourdao.org', |
| 58 | + usePublicDiscourse: true, |
| 59 | + discordToken: process.env.DISCORD_BOT_TOKEN, |
| 60 | + discordChannelIds: ['channel-id-1', 'channel-id-2'], |
| 61 | + commonwealthUrl: 'https://commonwealth.im/your-dao' |
| 62 | +}); |
| 63 | + |
| 64 | +// Using Discourse API (requires admin access) |
| 65 | +const daoForumPlugin = new DAOForumPlugin({ |
| 66 | + discourseUrl: 'https://forum.yourdao.org', |
| 67 | + discourseApiKey: process.env.DISCOURSE_API_KEY, |
| 68 | + discordToken: process.env.DISCORD_BOT_TOKEN, |
| 69 | + discordChannelIds: ['channel-id-1', 'channel-id-2'], |
| 70 | + commonwealthUrl: 'https://commonwealth.im/your-dao' |
| 71 | +}); |
| 72 | +``` |
| 73 | + |
| 74 | +### Integration with Eliza |
| 75 | + |
| 76 | +```typescript |
| 77 | +import { Eliza } from '@eliza/core'; |
| 78 | + |
| 79 | +const eliza = new Eliza({ |
| 80 | + // ... other configuration options |
| 81 | + plugins: [daoForumPlugin] |
| 82 | +}); |
| 83 | +``` |
| 84 | + |
| 85 | +## Platform-Specific Setup |
| 86 | + |
| 87 | +### Discourse Setup |
| 88 | + |
| 89 | +#### Option 1: Public Access (Recommended for non-admins) |
| 90 | +1. Set `usePublicDiscourse: true` in your configuration |
| 91 | +2. Provide the forum URL |
| 92 | +3. No API key needed |
| 93 | +4. Works with any Discourse forum you can access publicly |
| 94 | + |
| 95 | +Limitations of public access: |
| 96 | +- Respects rate limiting automatically (1 second delay between requests) |
| 97 | +- Only fetches publicly available posts |
| 98 | +- May be slightly slower than API access |
| 99 | + |
| 100 | +#### Option 2: API Access (Requires admin privileges) |
| 101 | +1. Go to your Discourse admin panel |
| 102 | +2. Navigate to API settings |
| 103 | +3. Generate a new API key with appropriate permissions |
| 104 | +4. Set the API key in your configuration |
| 105 | + |
| 106 | +Required permissions: |
| 107 | +- Read topics |
| 108 | +- List categories |
| 109 | +- Read users |
| 110 | + |
| 111 | +### Discord Setup |
| 112 | + |
| 113 | +1. Create a new Discord application at https://discord.com/developers/applications |
| 114 | +2. Create a bot for your application |
| 115 | +3. Enable necessary intents (MESSAGE CONTENT, GUILD MESSAGES) |
| 116 | +4. Add the bot to your server with required permissions |
| 117 | +5. Get the channel IDs you want to monitor (Developer Mode must be enabled) |
| 118 | + |
| 119 | +Required permissions: |
| 120 | +- Read Messages/View Channels |
| 121 | +- Read Message History |
| 122 | + |
| 123 | +### Commonwealth Setup |
| 124 | + |
| 125 | +1. No API key required |
| 126 | +2. Provide the URL of your DAO's Commonwealth space |
| 127 | +3. Ensure the discussions are public |
| 128 | + |
| 129 | +## Message Format |
| 130 | + |
| 131 | +The plugin normalizes messages from all sources into a standard format: |
| 132 | + |
| 133 | +```typescript |
| 134 | +interface Message { |
| 135 | + content: { |
| 136 | + text: string; |
| 137 | + metadata: { |
| 138 | + source: 'discourse' | 'discord' | 'commonwealth'; |
| 139 | + url?: string; |
| 140 | + channelId?: string; |
| 141 | + timestamp: Date; |
| 142 | + } |
| 143 | + }; |
| 144 | + user: string; |
| 145 | +} |
| 146 | +``` |
| 147 | + |
| 148 | +## Advanced Usage |
| 149 | + |
| 150 | +### Custom Message Processing |
| 151 | + |
| 152 | +```typescript |
| 153 | +const daoForumPlugin = new DAOForumPlugin({ |
| 154 | + // ... configuration |
| 155 | +}); |
| 156 | + |
| 157 | +// Access raw messages from specific platform |
| 158 | +const discourseMessages = await daoForumPlugin.scrapeDiscourse(); |
| 159 | +const discordMessages = await daoForumPlugin.scrapeDiscord(); |
| 160 | +const commonwealthMessages = await daoForumPlugin.scrapeCommonwealth(); |
| 161 | +``` |
| 162 | + |
| 163 | +### Error Handling |
| 164 | + |
| 165 | +The plugin implements automatic retries for failed requests and graceful degradation when certain platforms are unavailable. Errors are logged but won't crash the application. |
| 166 | + |
| 167 | +## Limitations |
| 168 | + |
| 169 | +- Discord: Limited to 100 messages per channel per request due to API restrictions |
| 170 | +- Commonwealth: HTML scraping may need updates if the site structure changes |
| 171 | +- Rate limits apply to all platforms and should be considered in high-frequency scenarios |
| 172 | + |
| 173 | +## Contributing |
| 174 | + |
| 175 | +Contributions are welcome! Please read our [Contributing Guidelines](../CONTRIBUTING.md) before submitting PRs. |
| 176 | + |
| 177 | +### Development Setup |
| 178 | + |
| 179 | +```bash |
| 180 | +# Clone the repository |
| 181 | +git clone https://github.com/elizaOS/eliza.git |
| 182 | + |
| 183 | +# Install dependencies |
| 184 | +pnpm install |
| 185 | + |
| 186 | +# Build the plugin |
| 187 | +pnpm build |
| 188 | + |
| 189 | +# Run tests |
| 190 | +pnpm test |
| 191 | +``` |
| 192 | + |
| 193 | +## License |
| 194 | + |
| 195 | +MIT - see [LICENSE](../LICENSE) for details |
0 commit comments