feat: add rate limiting and improve event handling

- Introduced rate limiting configuration in config.toml with options for enabling, requests per second (RPS), and burst capacity.
- Enhanced event handling in the OneBot11 adapter to ignore messages sent by the bot itself.
- Updated the dispatcher to register rate limit middleware based on configuration settings.
- Refactored WebSocket message handling to support flexible JSON parsing and improved event type detection.
- Removed deprecated echo plugin and associated tests to streamline the codebase.
This commit is contained in:
lafay
2026-01-05 01:00:38 +08:00
parent 44fe05ff62
commit d16261e6bd
11 changed files with 1001 additions and 427 deletions

View File

@@ -15,6 +15,7 @@ type Config struct {
Log LogConfig `toml:"log"`
Protocol ProtocolConfig `toml:"protocol"`
Bots []BotConfig `toml:"bots"`
Engine EngineConfig `toml:"engine"`
}
// ServerConfig 服务器配置
@@ -39,6 +40,18 @@ type ProtocolConfig struct {
Options map[string]string `toml:"options"`
}
// EngineConfig 引擎配置
type EngineConfig struct {
RateLimit RateLimitConfig `toml:"rate_limit"`
}
// RateLimitConfig 限流配置
type RateLimitConfig struct {
Enabled bool `toml:"enabled"` // 是否启用限流
RPS int `toml:"rps"` // 每秒请求数
Burst int `toml:"burst"` // 突发容量
}
// BotConfig Bot 配置
type BotConfig struct {
ID string `toml:"id"`