fix: make bot greeting name configurable via bot_name setting
The /start greeting in Telegram and the DingTalk reply title were
hardcoded as "PicoClaw". Users who customize their bot's identity
via soul.md still see "Hello! I am PicoClaw" on the first message.
Add a bot_name field to agents.defaults config (default: "PicoClaw")
so all channels use the configured name instead of a hardcoded string.
Config example:
{"agents": {"defaults": {"bot_name": "MyBot"}}}
Or via environment variable:
PICOCLAW_AGENTS_DEFAULTS_BOT_NAME=MyBot
Closes #288
This commit is contained in:
parent
e7f15afdd4
commit
e808fb0831
4 changed files with 16 additions and 4 deletions
|
|
@ -23,6 +23,7 @@ type DingTalkChannel struct {
|
||||||
config config.DingTalkConfig
|
config config.DingTalkConfig
|
||||||
clientID string
|
clientID string
|
||||||
clientSecret string
|
clientSecret string
|
||||||
|
botName string
|
||||||
streamClient *client.StreamClient
|
streamClient *client.StreamClient
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
|
|
@ -31,11 +32,15 @@ type DingTalkChannel struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDingTalkChannel creates a new DingTalk channel instance
|
// NewDingTalkChannel creates a new DingTalk channel instance
|
||||||
func NewDingTalkChannel(cfg config.DingTalkConfig, messageBus *bus.MessageBus) (*DingTalkChannel, error) {
|
func NewDingTalkChannel(cfg config.DingTalkConfig, messageBus *bus.MessageBus, botName string) (*DingTalkChannel, error) {
|
||||||
if cfg.ClientID == "" || cfg.ClientSecret == "" {
|
if cfg.ClientID == "" || cfg.ClientSecret == "" {
|
||||||
return nil, fmt.Errorf("dingtalk client_id and client_secret are required")
|
return nil, fmt.Errorf("dingtalk client_id and client_secret are required")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if botName == "" {
|
||||||
|
botName = "PicoClaw"
|
||||||
|
}
|
||||||
|
|
||||||
base := NewBaseChannel("dingtalk", cfg, messageBus, cfg.AllowFrom)
|
base := NewBaseChannel("dingtalk", cfg, messageBus, cfg.AllowFrom)
|
||||||
|
|
||||||
return &DingTalkChannel{
|
return &DingTalkChannel{
|
||||||
|
|
@ -43,6 +48,7 @@ func NewDingTalkChannel(cfg config.DingTalkConfig, messageBus *bus.MessageBus) (
|
||||||
config: cfg,
|
config: cfg,
|
||||||
clientID: cfg.ClientID,
|
clientID: cfg.ClientID,
|
||||||
clientSecret: cfg.ClientSecret,
|
clientSecret: cfg.ClientSecret,
|
||||||
|
botName: botName,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,7 +181,7 @@ func (c *DingTalkChannel) SendDirectReply(ctx context.Context, sessionWebhook, c
|
||||||
|
|
||||||
// Convert string content to []byte for the API
|
// Convert string content to []byte for the API
|
||||||
contentBytes := []byte(content)
|
contentBytes := []byte(content)
|
||||||
titleBytes := []byte("PicoClaw")
|
titleBytes := []byte(c.botName)
|
||||||
|
|
||||||
// Send markdown formatted reply
|
// Send markdown formatted reply
|
||||||
err := replier.SimpleReplyMarkdown(
|
err := replier.SimpleReplyMarkdown(
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ func (m *Manager) initChannels() error {
|
||||||
|
|
||||||
if m.config.Channels.DingTalk.Enabled && m.config.Channels.DingTalk.ClientID != "" {
|
if m.config.Channels.DingTalk.Enabled && m.config.Channels.DingTalk.ClientID != "" {
|
||||||
logger.DebugC("channels", "Attempting to initialize DingTalk channel")
|
logger.DebugC("channels", "Attempting to initialize DingTalk channel")
|
||||||
dingtalk, err := NewDingTalkChannel(m.config.Channels.DingTalk, m.bus)
|
dingtalk, err := NewDingTalkChannel(m.config.Channels.DingTalk, m.bus, m.config.Agents.Defaults.BotName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorCF("channels", "Failed to initialize DingTalk channel", map[string]interface{}{
|
logger.ErrorCF("channels", "Failed to initialize DingTalk channel", map[string]interface{}{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,13 @@ func (c *cmd) Help(ctx context.Context, message telego.Message) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmd) Start(ctx context.Context, message telego.Message) error {
|
func (c *cmd) Start(ctx context.Context, message telego.Message) error {
|
||||||
|
botName := c.config.Agents.Defaults.BotName
|
||||||
|
if botName == "" {
|
||||||
|
botName = "PicoClaw"
|
||||||
|
}
|
||||||
_, err := c.bot.SendMessage(ctx, &telego.SendMessageParams{
|
_, err := c.bot.SendMessage(ctx, &telego.SendMessageParams{
|
||||||
ChatID: telego.ChatID{ID: message.Chat.ID},
|
ChatID: telego.ChatID{ID: message.Chat.ID},
|
||||||
Text: "Hello! I am PicoClaw 🦞",
|
Text: fmt.Sprintf("Hello! I am %s 🦞", botName),
|
||||||
ReplyParameters: &telego.ReplyParameters{
|
ReplyParameters: &telego.ReplyParameters{
|
||||||
MessageID: message.MessageID,
|
MessageID: message.MessageID,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ type AgentDefaults struct {
|
||||||
MaxTokens int `json:"max_tokens" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_TOKENS"`
|
MaxTokens int `json:"max_tokens" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_TOKENS"`
|
||||||
Temperature float64 `json:"temperature" env:"PICOCLAW_AGENTS_DEFAULTS_TEMPERATURE"`
|
Temperature float64 `json:"temperature" env:"PICOCLAW_AGENTS_DEFAULTS_TEMPERATURE"`
|
||||||
MaxToolIterations int `json:"max_tool_iterations" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_TOOL_ITERATIONS"`
|
MaxToolIterations int `json:"max_tool_iterations" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_TOOL_ITERATIONS"`
|
||||||
|
BotName string `json:"bot_name" env:"PICOCLAW_AGENTS_DEFAULTS_BOT_NAME"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChannelsConfig struct {
|
type ChannelsConfig struct {
|
||||||
|
|
@ -226,6 +227,7 @@ func DefaultConfig() *Config {
|
||||||
MaxTokens: 8192,
|
MaxTokens: 8192,
|
||||||
Temperature: 0.7,
|
Temperature: 0.7,
|
||||||
MaxToolIterations: 20,
|
MaxToolIterations: 20,
|
||||||
|
BotName: "PicoClaw",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Channels: ChannelsConfig{
|
Channels: ChannelsConfig{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue