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:
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user