- Added new entries to .gitignore for database files. - Updated go.mod and go.sum to include new indirect dependencies for database and ORM support. - Refactored event handling to improve message reply functionality in the protocol. - Enhanced the dispatcher to allow for better event processing and logging. - Removed outdated plugin documentation and unnecessary files to streamline the codebase. - Improved welcome message formatting and screenshot options for better user experience.
38 lines
875 B
Go
38 lines
875 B
Go
package echo
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"cellbot/internal/engine"
|
|
"cellbot/internal/protocol"
|
|
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func init() {
|
|
// 注册 /echo 命令
|
|
engine.OnCommand("/echo").
|
|
Handle(func(ctx context.Context, event protocol.Event, botManager *protocol.BotManager, logger *zap.Logger) error {
|
|
// 获取消息内容
|
|
data := event.GetData()
|
|
rawMessage, ok := data["raw_message"].(string)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
// 解析命令参数(/echo 后面的内容)
|
|
parts := strings.Fields(rawMessage)
|
|
if len(parts) < 2 {
|
|
// 如果没有参数,返回提示
|
|
return event.ReplyText(ctx, botManager, logger, "用法: /echo <消息内容>")
|
|
}
|
|
|
|
// 获取要回显的内容
|
|
echoContent := strings.Join(parts[1:], " ")
|
|
|
|
// 使用 ReplyText 发送回复
|
|
return event.ReplyText(ctx, botManager, logger, echoContent)
|
|
})
|
|
}
|