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:
Atharva 2026-02-16 17:12:16 +05:30
parent e7f15afdd4
commit e808fb0831
4 changed files with 16 additions and 4 deletions

View file

@ -23,6 +23,7 @@ type DingTalkChannel struct {
config config.DingTalkConfig
clientID string
clientSecret string
botName string
streamClient *client.StreamClient
ctx context.Context
cancel context.CancelFunc
@ -31,11 +32,15 @@ type DingTalkChannel struct {
}
// 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 == "" {
return nil, fmt.Errorf("dingtalk client_id and client_secret are required")
}
if botName == "" {
botName = "PicoClaw"
}
base := NewBaseChannel("dingtalk", cfg, messageBus, cfg.AllowFrom)
return &DingTalkChannel{
@ -43,6 +48,7 @@ func NewDingTalkChannel(cfg config.DingTalkConfig, messageBus *bus.MessageBus) (
config: cfg,
clientID: cfg.ClientID,
clientSecret: cfg.ClientSecret,
botName: botName,
}, nil
}
@ -175,7 +181,7 @@ func (c *DingTalkChannel) SendDirectReply(ctx context.Context, sessionWebhook, c
// Convert string content to []byte for the API
contentBytes := []byte(content)
titleBytes := []byte("PicoClaw")
titleBytes := []byte(c.botName)
// Send markdown formatted reply
err := replier.SimpleReplyMarkdown(

View file

@ -126,7 +126,7 @@ func (m *Manager) initChannels() error {
if m.config.Channels.DingTalk.Enabled && m.config.Channels.DingTalk.ClientID != "" {
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 {
logger.ErrorCF("channels", "Failed to initialize DingTalk channel", map[string]interface{}{
"error": err.Error(),

View file

@ -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 {
botName := c.config.Agents.Defaults.BotName
if botName == "" {
botName = "PicoClaw"
}
_, err := c.bot.SendMessage(ctx, &telego.SendMessageParams{
ChatID: telego.ChatID{ID: message.Chat.ID},
Text: "Hello! I am PicoClaw 🦞",
Text: fmt.Sprintf("Hello! I am %s 🦞", botName),
ReplyParameters: &telego.ReplyParameters{
MessageID: message.MessageID,
},

View file

@ -66,6 +66,7 @@ type AgentDefaults struct {
MaxTokens int `json:"max_tokens" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_TOKENS"`
Temperature float64 `json:"temperature" env:"PICOCLAW_AGENTS_DEFAULTS_TEMPERATURE"`
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 {
@ -226,6 +227,7 @@ func DefaultConfig() *Config {
MaxTokens: 8192,
Temperature: 0.7,
MaxToolIterations: 20,
BotName: "PicoClaw",
},
},
Channels: ChannelsConfig{