feat: enhance event handling and add scheduling capabilities

- Introduced a new scheduler to manage timed tasks within the event dispatcher.
- Updated the dispatcher to support the new scheduler, allowing for improved event processing.
- Enhanced action serialization in the OneBot11 adapter to convert message chains to the appropriate format.
- Added new dependencies for cron scheduling and other indirect packages in go.mod and go.sum.
- Improved logging for event publishing and handler matching, providing better insights during execution.
- Refactored plugin loading to include scheduled job management.
This commit is contained in:
lafay
2026-01-05 04:33:30 +08:00
parent d16261e6bd
commit 64cd81b7f1
14 changed files with 2130 additions and 27 deletions

View File

@@ -78,9 +78,10 @@ func (eb *EventBus) Stop() {
// Publish 发布事件
func (eb *EventBus) Publish(event protocol.Event) {
eb.logger.Info("Publishing event to channel",
eb.logger.Debug("Publishing event to channel",
zap.String("event_type", string(event.GetType())),
zap.String("detail_type", event.GetDetailType()),
zap.String("self_id", event.GetSelfID()),
zap.Int("channel_len", len(eb.eventChan)),
zap.Int("channel_cap", cap(eb.eventChan)))
@@ -88,8 +89,10 @@ func (eb *EventBus) Publish(event protocol.Event) {
case eb.eventChan <- event:
atomic.AddInt64(&eb.metrics.PublishedTotal, 1)
atomic.StoreInt64(&eb.metrics.LastEventTime, time.Now().Unix())
eb.logger.Info("Event successfully queued",
zap.String("event_type", string(event.GetType())))
eb.logger.Info("Event published successfully",
zap.String("event_type", string(event.GetType())),
zap.String("detail_type", event.GetDetailType()),
zap.String("self_id", event.GetSelfID()))
case <-eb.ctx.Done():
atomic.AddInt64(&eb.metrics.DroppedTotal, 1)
eb.logger.Warn("Event bus is shutting down, event dropped",