mirror of
https://github.com/HugeFrog24/go-telegram-bot.git
synced 2026-03-02 08:24:34 +00:00
Per-bot API keys implemented
This commit is contained in:
5
bot.go
5
bot.go
@@ -5,7 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -76,8 +75,8 @@ func NewBot(db *gorm.DB, config BotConfig, clock Clock, tgClient TelegramClient)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Anthropic client
|
// Use the per-bot Anthropic API key
|
||||||
anthropicClient := anthropic.NewClient(os.Getenv("ANTHROPIC_API_KEY"))
|
anthropicClient := anthropic.NewClient(config.AnthropicAPIKey)
|
||||||
|
|
||||||
b := &Bot{
|
b := &Bot{
|
||||||
db: db,
|
db: db,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ type BotConfig struct {
|
|||||||
SystemPrompts map[string]string `json:"system_prompts"`
|
SystemPrompts map[string]string `json:"system_prompts"`
|
||||||
Active bool `json:"active"` // New field to control bot activity
|
Active bool `json:"active"` // New field to control bot activity
|
||||||
OwnerTelegramID int64 `json:"owner_telegram_id"`
|
OwnerTelegramID int64 `json:"owner_telegram_id"`
|
||||||
|
AnthropicAPIKey string `json:"anthropic_api_key"` // Add this line
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom unmarshalling to handle anthropic.Model
|
// Custom unmarshalling to handle anthropic.Model
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"active": false,
|
"active": false,
|
||||||
"telegram_token": "YOUR_TELEGRAM_BOT_TOKEN",
|
"telegram_token": "YOUR_TELEGRAM_BOT_TOKEN",
|
||||||
"owner_telegram_id": 111111111,
|
"owner_telegram_id": 111111111,
|
||||||
|
"anthropic_api_key": "YOUR_SPECIFIC_ANTHROPIC_API_KEY",
|
||||||
"memory_size": 10,
|
"memory_size": 10,
|
||||||
"messages_per_hour": 20,
|
"messages_per_hour": 20,
|
||||||
"messages_per_day": 100,
|
"messages_per_day": 100,
|
||||||
|
|||||||
Reference in New Issue
Block a user