Skip to content

Commit 578ae8b

Browse files
authored
Merge pull request #43 from actionbrk/29-support-threads
enh: Enhance message saving functionality and /channels command
2 parents dc561da + 0e8d348 commit 578ae8b

23 files changed

+915
-259
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ README.md
2424
**/.github
2525
docs
2626
eslint.config.js
27-
.editorconfig
27+
.editorconfig
28+
db

.env.template

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
# Discord Bot Token (Required)
2+
# Get this from the Discord Developer Portal
13
DISCORD_TOKEN=
4+
5+
# Guild ID (Optional, but recommended for development)
6+
# This restricts the bot to a specific server during development
27
GUILD_ID=
3-
HASHNAME=
4-
ITER=
5-
SALT=
8+
9+
# Bot Owner ID (Required)
10+
# Your Discord user ID for admin commands
11+
OWNER_ID=
12+
13+
# Pseudonymization Settings
14+
# Used to protect user privacy
15+
HASHNAME=sha256
16+
ITER=100000
17+
SALT=change-this-to-secure-random-string

CONTRIBUTING.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Contributing to Abeille
2+
3+
Thank you for your interest in contributing to Abeille! This document provides guidelines and instructions for contributing.
4+
5+
## Code of Conduct
6+
7+
By participating in this project, you agree to maintain a respectful and inclusive environment for everyone.
8+
9+
## How Can I Contribute?
10+
11+
### Reporting Bugs
12+
13+
Bugs are tracked as GitHub issues. Create an issue on the repository and provide the following information:
14+
15+
- Use a clear and descriptive title
16+
- Describe the exact steps to reproduce the problem
17+
- Provide specific examples (including configuration files or commands used)
18+
- Describe the behavior you observed and why it is a problem
19+
- Include screenshots and animated GIFs if possible
20+
- Include details about your environment
21+
22+
### Suggesting Enhancements
23+
24+
Enhancement suggestions are also tracked as GitHub issues. When creating an enhancement suggestion:
25+
26+
- Use a clear and descriptive title.
27+
- Provide a detailed description of the suggested enhancement.
28+
- Explain why this enhancement would be useful to most users.
29+
- List some other applications where this enhancement exists, if applicable.
30+
31+
### Your First Code Contribution
32+
33+
Unsure where to begin? Feel free to ask!
34+
35+
### Pull Requests
36+
37+
- Do not include issue numbers in the PR title
38+
- Follow the coding style and use linter
39+
- Document new code based on the project's documentation style
40+
- End all files with a newline
41+
42+
## Styleguides
43+
44+
### Git Commit Messages
45+
46+
- Use the present tense ("Add feature" not "Added feature")
47+
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
48+
- Limit the first line to 72 characters or less
49+
- Reference issues and pull requests after the first line
50+
51+
### TypeScript Styleguide
52+
53+
- Use 2 spaces for indentation
54+
- Prefer `const` over `let`
55+
- Use PascalCase for interfaces, types, and classes
56+
- Use camelCase for functions and variables
57+
- Add appropriate JSDoc comments for public APIs
58+
- Follow eslint configuration rules
59+
60+
## Development Process
61+
62+
1. Fork the repo and create your branch from `master`
63+
2. Install dependencies with `bun install`
64+
3. Make your changes
65+
4. Ensure your code lints with `bun lint`
66+
5. Submit your pull request
67+
68+
## License
69+
70+
By contributing to Abeille, you agree that your contributions will be licensed under the project's license.

README.md

Lines changed: 124 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,86 @@
1-
# abeille
1+
# Abeille 🐝
22

33
![Docker build](https://github.com/actionbrk/abeille/actions/workflows/docker-image.yml/badge.svg) ![Code QL Advanced](https://github.com/actionbrk/abeille/actions/workflows/codeql.yml/badge.svg)
44

5-
Abeille is a Discord bot providing statistics and insights for guilds. It maintains a database with the messages from each connected guild, in order to perform efficient and various search operations (since Discord does not provide any API to perform search operations).
5+
> A powerful Discord bot for collecting and analyzing message statistics and insights for your guilds.
66
7-
There is no public Abeille bot. You should run your own Abeille bot instance by following the steps below.
7+
## Data Flow
88

9-
It depends on :
9+
```mermaid
10+
graph LR
11+
A[Discord Messages] -->|Collected| B[Abeille Bot]
12+
B -->|Pseudonymized| C[SQLite Database]
13+
C -->|Analyzed| D[Statistics & Insights]
14+
D -->|Presented| E[Discord Commands]
15+
B -->|Handles| E
16+
```
17+
18+
## 📋 Table of Contents
19+
20+
- [Overview](#overview)
21+
- [Features](#features)
22+
- [Dependencies](#dependencies)
23+
- [Run Your Own Abeille](#run-your-own-abeille)
24+
- [Setting Up](#setting-up)
25+
- [Environment Variables](#environment-variables)
26+
- [Run](#run)
27+
- [Development](#development)
28+
- [Commands](#commands)
29+
- [Contributing](#contributing)
30+
- [Documentation](#documentation)
31+
32+
## Overview
1033

11-
- [discord.js](https://github.com/discordjs/discord.js)
12-
- [Chart.js](https://github.com/chartjs/Chart.js)
13-
- [ChartjsNodeCanvas](https://github.com/SeanSobey/ChartjsNodeCanvas)
14-
- [winston](https://github.com/winstonjs/winston)
15-
- [date-fns](https://github.com/date-fns/date-fns)
16-
- [chartjs-adapter-date-fns](https://github.com/chartjs/chartjs-adapter-date-fns)
17-
- [nodejs-polars](https://github.com/pola-rs/nodejs-polars)
18-
- [sharp](https://github.com/lovell/sharp)
34+
Abeille is a Discord bot providing statistics and insights for guilds. It maintains a database (one for each guild) with the messages from each connected guild, in order to perform efficient and various search operations (since Discord does not provide any API to perform search operations).
35+
36+
> **Note**: For now, there is no public Abeille bot. You should run your own Abeille bot instance by following the steps below.
1937
2038
## Features
2139

22-
- Saves messages from tracked guilds while using pseudonymization
23-
- Provides slash commands to graph trending expressions, show random messages...
40+
- Saves messages from tracked guilds while using pseudonymization.
41+
- Provides slash commands to graph trending expressions, show random messages.
42+
- Activity analysis including user rankings and comparison.
43+
- Message trend visualization and statistical analysis.
44+
- Admin commands for channel management and data handling.
45+
- Strong privacy controls with data export and deletion options.
46+
- Full localization support (currently English and French).
47+
- Database operations optimized with SQLite FTS5 for efficient text search.
48+
- User data pseudonymization for privacy protection.
49+
50+
## Dependencies
51+
52+
Abeille is built using the following open source libraries:
53+
54+
- [discord.js](https://github.com/discordjs/discord.js) - Discord API client
55+
- [Chart.js](https://github.com/chartjs/Chart.js) - JavaScript charting library
56+
- [ChartjsNodeCanvas](https://github.com/SeanSobey/ChartjsNodeCanvas) - Node.js canvas rendering for Chart.js
57+
- [winston](https://github.com/winstonjs/winston) - Logging library
58+
- [date-fns](https://github.com/date-fns/date-fns) - Date manipulation library
59+
- [chartjs-adapter-date-fns](https://github.com/chartjs/chartjs-adapter-date-fns) - Date adapter for Chart.js
60+
- [nodejs-polars](https://github.com/pola-rs/nodejs-polars) - Data manipulation library
61+
- [sharp](https://github.com/lovell/sharp) - Image processing library
2462

25-
## Run your own Abeille
63+
## Run Your Own Abeille
2664

2765
Abeille is not (yet) a public Discord bot. You can run your own instance of Abeille by following these steps:
2866

29-
### Setting up
67+
### Setting Up
3068

31-
1. Create a folder.
32-
2. Copy [compose.yaml.template](compose.yaml.template) into the folder.
33-
3. Rename it to `compose.yaml`.
34-
4. Configure `.compose.yaml` file.
69+
1. Create a folder
70+
2. Copy [compose.yaml.template](compose.yaml.template) into the folder
71+
3. Rename it to `compose.yaml`
72+
4. Configure `compose.yaml` file
3573

36-
### Environment variables
74+
### Environment Variables
3775

3876
| Variable | Description | Example Value | Default Value |
3977
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ------------------ |
4078
| `DISCORD_TOKEN` | The token for your Discord bot. You can obtain this from the Discord Developer Portal after creating a bot application. | `your-bot-token` | _None_ |
4179
| `GUILD_ID` | _(Optional, recommended for development)_ The ID of the Discord guild (server) you want the bot to operate in. You can find this by enabling Developer Mode in Discord and right-clicking on the server name. | `123456789012345678` | _None_ |
42-
| `OWNER_ID` | Your Discord ID. Used for specials commands. | `123456789012345678` | _None_ |
43-
| `HASHNAME` | A unique identifier used for pseudonymizing user data. Choose a random string. | `sha256` | `sha512` |
80+
| `OWNER_ID` | Your Discord ID. Used for special commands. | `123456789012345678` | _None_ |
81+
| `HASHNAME` | The hash algorithm used for hmac pseudonymization (if you don't know what to choose, leave the default value). | `sha256` | `sha512` |
4482
| `ITER` | The number of iterations for hashing operations. A higher value increases security but may impact performance. | `10000` | `100000` |
45-
| `SALT` | A random string used to add additional security to the hashing process. Generate a secure random string. Recommended length is 16 (cf. [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) ) | `random-salt-string` | `bee-default-salt` |
83+
| `SALT` | A random string used to add additional security to the hashing process. Generate a secure random string. Recommended length is 16 (cf. [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf)). | `random-salt-string` | `bee-default-salt` |
4684

4785
### Run
4886

@@ -52,19 +90,77 @@ You can now start Abeille by running the following command:
5290
docker compose up -d --pull always
5391
```
5492

55-
> By default, the `compose.yaml` file will pull the `latest` tag, which is pushed to Docker Hub whenever the `master` branch is updated.
56-
> So you may have to run `docker compose down/up` from time to time in order to get the latest features (and run `docker image prune -a` to make some space).
93+
> **Note**: By default, the `compose.yaml` file will pull the `latest` tag, which is pushed to Docker Hub whenever the `master` branch is updated.
94+
> You may have to run `docker compose down && docker compose up -d` from time to time in order to get the latest features (and run `docker image prune -a` to make some space).
5795
5896
Check logs by running:
5997

6098
```bash
6199
docker logs abeille
62100
```
63101

64-
## Develop
102+
## Development
65103

66104
1. Clone project
67105
2. Install bun from [Bun website](https://bun.sh/)
68-
3. Copy and rename `.env.template` to `.env.local` and complete variables (cf. Environnement variables configuration)
106+
3. Copy and rename `.env.template` to `.env.local` and complete variables (see [Environment Variables](#environment-variables) configuration)
69107
4. Run `bun install` to install dependencies
70108
5. Run `bun dev` to start your bot
109+
110+
## Commands
111+
112+
Abeille offers various slash commands grouped by category:
113+
114+
### Activity Commands
115+
116+
- `/trend` - Visualize trends of specific words or phrases over time.
117+
- `/rank` - Show user activity rankings for specific expressions.
118+
- `/compare` - Compare activity between different expressions.
119+
120+
### Message Commands
121+
122+
- `/random` - Display a random message from the guild.
123+
124+
### Admin Commands
125+
126+
- `/channels` - List all tracked channels and their message counts.
127+
- `/purge` - Clean deleted messages from the database. (_may be removed in the future_)
128+
- `/save` - Force a complete save of all messages. (_may be removed in the future_)
129+
- `/savechannel` - Force save messages from a specific channel. (_may be removed in the future_)
130+
131+
### Privacy Commands
132+
133+
- `/delete` - Delete a specific message from Abeille's database (if you want to be sure that Abeille has taken into account the Discord deletion).
134+
- `/export` - Download your personal data collected by Abeille (in CSV).
135+
- `/register` - Opt-in to allow Abeille to store and display your username in rankings.
136+
- `/unregister` - Opt-out and remove your username from Abeille's storage (and future rankings).
137+
138+
### Developer Commands (_may be removed in the future_)
139+
140+
- `/db` - Database management operations.
141+
- `/logging` - Configure logging level.
142+
143+
### Utility Commands
144+
145+
- `/ping` - Check if the bot is responsive.
146+
147+
## Contributing
148+
149+
Contributions to Abeille are welcome! Here's how you can contribute:
150+
151+
1. Fork the repository
152+
2. Create a feature branch: `git checkout -b my-new-feature`
153+
3. Commit your changes: `git commit -am 'Add some feature'`
154+
4. Push to the branch: `git push origin my-new-feature`
155+
5. Submit a pull request
156+
157+
Please make sure your code follows the existing code style.
158+
159+
## Documentation
160+
161+
For more detailed information about Abeille, please see the following documentation:
162+
163+
- [Architecture Overview](docs/ARCHITECTURE.md) - Learn about Abeille's internal structure
164+
- [Security Best Practices](docs/SECURITY.md) - Important security recommendations
165+
166+
For developers interested in the database structure, see the [SaveScenarios.drawio](docs/SaveScenarios.drawio) diagram.

0 commit comments

Comments
 (0)