mirror of
https://github.com/HugeFrog24/go-telegram-bot.git
synced 2026-03-02 00:14:34 +00:00
Concern separation
This commit is contained in:
51
anthropic.go
Normal file
51
anthropic.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/liushuangls/go-anthropic/v2"
|
||||
)
|
||||
|
||||
func (b *Bot) getAnthropicResponse(ctx context.Context, messages []anthropic.Message, isNewChat, isAdminOrOwner bool) (string, error) {
|
||||
var systemMessage string
|
||||
if isNewChat {
|
||||
systemMessage = "You are a helpful AI assistant."
|
||||
} else {
|
||||
systemMessage = "Continue the conversation."
|
||||
}
|
||||
|
||||
if !isAdminOrOwner {
|
||||
systemMessage += " Avoid discussing sensitive topics or providing harmful information."
|
||||
}
|
||||
|
||||
// Ensure the roles are correct
|
||||
for i := range messages {
|
||||
if messages[i].Role == "user" {
|
||||
messages[i].Role = anthropic.RoleUser
|
||||
} else if messages[i].Role == "assistant" {
|
||||
messages[i].Role = anthropic.RoleAssistant
|
||||
}
|
||||
}
|
||||
|
||||
model := anthropic.ModelClaude3Dot5Sonnet20240620
|
||||
if !isAdminOrOwner {
|
||||
model = anthropic.ModelClaudeInstant1Dot2
|
||||
}
|
||||
|
||||
resp, err := b.anthropicClient.CreateMessages(ctx, anthropic.MessagesRequest{
|
||||
Model: model,
|
||||
Messages: messages,
|
||||
System: systemMessage,
|
||||
MaxTokens: 1000,
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error creating Anthropic message: %w", err)
|
||||
}
|
||||
|
||||
if len(resp.Content) == 0 || resp.Content[0].Type != anthropic.MessagesContentTypeText {
|
||||
return "", fmt.Errorf("unexpected response format from Anthropic")
|
||||
}
|
||||
|
||||
return resp.Content[0].GetText(), nil
|
||||
}
|
||||
162
bot.go
Normal file
162
bot.go
Normal file
@@ -0,0 +1,162 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-telegram/bot"
|
||||
"github.com/go-telegram/bot/models"
|
||||
"github.com/liushuangls/go-anthropic/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Bot struct {
|
||||
tgBot *bot.Bot
|
||||
db *gorm.DB
|
||||
anthropicClient *anthropic.Client
|
||||
chatMemories map[int64]*ChatMemory
|
||||
memorySize int
|
||||
chatMemoriesMu sync.RWMutex
|
||||
config Config
|
||||
userLimiters map[int64]*userLimiter
|
||||
userLimitersMu sync.RWMutex
|
||||
}
|
||||
|
||||
func NewBot(db *gorm.DB, config Config) (*Bot, error) {
|
||||
anthropicClient := anthropic.NewClient(os.Getenv("ANTHROPIC_API_KEY"))
|
||||
|
||||
b := &Bot{
|
||||
db: db,
|
||||
anthropicClient: anthropicClient,
|
||||
chatMemories: make(map[int64]*ChatMemory),
|
||||
memorySize: config.MemorySize,
|
||||
config: config,
|
||||
userLimiters: make(map[int64]*userLimiter),
|
||||
}
|
||||
|
||||
tgBot, err := initTelegramBot(b.handleUpdate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b.tgBot = tgBot
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (b *Bot) Start(ctx context.Context) {
|
||||
b.tgBot.Start(ctx)
|
||||
}
|
||||
|
||||
func (b *Bot) getOrCreateUser(userID int64, username string) (User, error) {
|
||||
var user User
|
||||
err := b.db.Preload("Role").Where("telegram_id = ?", userID).First(&user).Error
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
var defaultRole Role
|
||||
if err := b.db.Where("name = ?", "user").First(&defaultRole).Error; err != nil {
|
||||
return User{}, err
|
||||
}
|
||||
user = User{TelegramID: userID, Username: username, RoleID: defaultRole.ID}
|
||||
if err := b.db.Create(&user).Error; err != nil {
|
||||
return User{}, err
|
||||
}
|
||||
} else {
|
||||
return User{}, err
|
||||
}
|
||||
}
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (b *Bot) createMessage(chatID, userID int64, username, userRole, text string, isUser bool) Message {
|
||||
return Message{
|
||||
ChatID: chatID,
|
||||
UserID: userID,
|
||||
Username: username,
|
||||
UserRole: userRole,
|
||||
Text: text,
|
||||
Timestamp: time.Now(),
|
||||
IsUser: isUser,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bot) storeMessage(message Message) error {
|
||||
return b.db.Create(&message).Error
|
||||
}
|
||||
|
||||
func (b *Bot) getOrCreateChatMemory(chatID int64) *ChatMemory {
|
||||
b.chatMemoriesMu.RLock()
|
||||
chatMemory, exists := b.chatMemories[chatID]
|
||||
b.chatMemoriesMu.RUnlock()
|
||||
|
||||
if !exists {
|
||||
var messages []Message
|
||||
b.db.Where("chat_id = ?", chatID).Order("timestamp asc").Limit(b.memorySize * 2).Find(&messages)
|
||||
|
||||
chatMemory = &ChatMemory{
|
||||
Messages: messages,
|
||||
Size: b.memorySize * 2,
|
||||
}
|
||||
|
||||
b.chatMemoriesMu.Lock()
|
||||
b.chatMemories[chatID] = chatMemory
|
||||
b.chatMemoriesMu.Unlock()
|
||||
}
|
||||
|
||||
return chatMemory
|
||||
}
|
||||
|
||||
func (b *Bot) addMessageToChatMemory(chatMemory *ChatMemory, message Message) {
|
||||
b.chatMemoriesMu.Lock()
|
||||
defer b.chatMemoriesMu.Unlock()
|
||||
|
||||
chatMemory.Messages = append(chatMemory.Messages, message)
|
||||
if len(chatMemory.Messages) > chatMemory.Size {
|
||||
chatMemory.Messages = chatMemory.Messages[2:]
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bot) prepareContextMessages(chatMemory *ChatMemory) []anthropic.Message {
|
||||
b.chatMemoriesMu.RLock()
|
||||
defer b.chatMemoriesMu.RUnlock()
|
||||
|
||||
var contextMessages []anthropic.Message
|
||||
for _, msg := range chatMemory.Messages {
|
||||
role := anthropic.RoleUser
|
||||
if !msg.IsUser {
|
||||
role = anthropic.RoleAssistant
|
||||
}
|
||||
contextMessages = append(contextMessages, anthropic.Message{
|
||||
Role: role,
|
||||
Content: []anthropic.MessageContent{
|
||||
anthropic.NewTextMessageContent(msg.Text),
|
||||
},
|
||||
})
|
||||
}
|
||||
return contextMessages
|
||||
}
|
||||
|
||||
func (b *Bot) isNewChat(chatID int64) bool {
|
||||
var count int64
|
||||
b.db.Model(&Message{}).Where("chat_id = ?", chatID).Count(&count)
|
||||
return count == 1
|
||||
}
|
||||
|
||||
func (b *Bot) isAdminOrOwner(userID int64) bool {
|
||||
var user User
|
||||
err := b.db.Preload("Role").Where("telegram_id = ?", userID).First(&user).Error
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return user.Role.Name == "admin" || user.Role.Name == "owner"
|
||||
}
|
||||
|
||||
func initTelegramBot(handleUpdate func(ctx context.Context, b *bot.Bot, update *models.Update)) (*bot.Bot, error) {
|
||||
opts := []bot.Option{
|
||||
bot.WithDefaultHandler(handleUpdate),
|
||||
}
|
||||
|
||||
return bot.New(os.Getenv("TELEGRAM_BOT_TOKEN"), opts...)
|
||||
}
|
||||
824
bot.log
824
bot.log
@@ -1,228 +1,740 @@
|
||||
2024/10/13 01:01:54 Error initializing Telegram bot: TELEGRAM_BOT_TOKEN environment variable is not set
|
||||
2024/10/13 01:02:03 Error initializing Telegram bot: TELEGRAM_BOT_TOKEN environment variable is not set
|
||||
2024/10/13 01:05:42 TELEGRAM_BOT_TOKEN environment variable is not set
|
||||
2024/10/13 01:05:42 Error initializing Telegram bot: TELEGRAM_BOT_TOKEN environment variable is not set
|
||||
|
||||
2024/10/13 01:09:23 /home/fedora/Desktop/thatsky-telegram-bot/main.go:95
|
||||
[0.030ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.028ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
|
||||
2024/10/13 01:09:23 /home/fedora/Desktop/thatsky-telegram-bot/main.go:95
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[28.510ms] [rows:0] CREATE TABLE `messages` (`id` integer PRIMARY KEY AUTOINCREMENT,`created_at` datetime,`updated_at` datetime,`deleted_at` datetime,`chat_id` integer,`user_id` integer,`username` text,`user_role` text,`text` text,`timestamp` datetime,`is_user` numeric)
|
||||
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[19.213ms] [rows:0] CREATE INDEX `idx_messages_deleted_at` ON `messages`(`deleted_at`)
|
||||
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.064ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="roles"
|
||||
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[19.650ms] [rows:0] CREATE TABLE `roles` (`id` integer PRIMARY KEY AUTOINCREMENT,`created_at` datetime,`updated_at` datetime,`deleted_at` datetime,`name` text)
|
||||
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[19.510ms] [rows:0] CREATE UNIQUE INDEX `idx_roles_name` ON `roles`(`name`)
|
||||
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[19.811ms] [rows:0] CREATE INDEX `idx_roles_deleted_at` ON `roles`(`deleted_at`)
|
||||
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.086ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="users"
|
||||
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[19.542ms] [rows:0] CREATE TABLE `users` (`id` integer PRIMARY KEY AUTOINCREMENT,`created_at` datetime,`updated_at` datetime,`deleted_at` datetime,`telegram_id` integer,`username` text,`role_id` integer,CONSTRAINT `fk_users_role` FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`))
|
||||
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[19.475ms] [rows:0] CREATE INDEX `idx_users_deleted_at` ON `users`(`deleted_at`)
|
||||
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[19.446ms] [rows:0] CREATE UNIQUE INDEX `idx_users_telegram_id` ON `users`(`telegram_id`)
|
||||
|
||||
2024/10/13 02:26:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[0.155ms] [rows:0] SELECT * FROM `roles` WHERE `roles`.`name` = "user" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:26:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[19.868ms] [rows:1] INSERT INTO `roles` (`created_at`,`updated_at`,`deleted_at`,`name`) VALUES ("2024-10-13 02:26:06.988","2024-10-13 02:26:06.988",NULL,"user") RETURNING `id`
|
||||
|
||||
2024/10/13 02:26:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[0.144ms] [rows:0] SELECT * FROM `roles` WHERE `roles`.`name` = "admin" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:26:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[19.695ms] [rows:1] INSERT INTO `roles` (`created_at`,`updated_at`,`deleted_at`,`name`) VALUES ("2024-10-13 02:26:07.008","2024-10-13 02:26:07.008",NULL,"admin") RETURNING `id`
|
||||
|
||||
2024/10/13 02:26:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[0.135ms] [rows:0] SELECT * FROM `roles` WHERE `roles`.`name` = "owner" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:26:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[19.908ms] [rows:1] INSERT INTO `roles` (`created_at`,`updated_at`,`deleted_at`,`name`) VALUES ("2024-10-13 02:26:07.028","2024-10-13 02:26:07.028",NULL,"owner") RETURNING `id`
|
||||
2024/10/13 02:26:07 Telegram bot initialized successfully
|
||||
2024/10/13 02:26:07 Starting bot...
|
||||
|
||||
2024/10/13 02:26:13 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195 record not found
|
||||
[0.300ms] [rows:0] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:26:13 /home/fedora/Desktop/thatsky-telegram-bot/main.go:198
|
||||
[0.182ms] [rows:1] SELECT * FROM `roles` WHERE name = "user" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:26:13 /home/fedora/Desktop/thatsky-telegram-bot/main.go:203
|
||||
[29.608ms] [rows:1] INSERT INTO `users` (`created_at`,`updated_at`,`deleted_at`,`telegram_id`,`username`,`role_id`) VALUES ("2024-10-13 02:26:13.713","2024-10-13 02:26:13.713",NULL,1404948412,"tibikgaming",1) RETURNING `id`
|
||||
|
||||
2024/10/13 02:26:13 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[20.376ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:26:13.743","2024-10-13 02:26:13.743",NULL,1404948412,1404948412,"tibikgaming","","Hello","2024-10-13 02:26:13.743",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:26:13 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.243ms] [rows:1] SELECT * FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL ORDER BY timestamp asc LIMIT 20
|
||||
|
||||
2024/10/13 02:26:13 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.061ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:26:13 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.051ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:26:13 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.218ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:26:14 Error getting Anthropic response: error creating Anthropic message: error, status code: 400, message: anthropic api error type: invalid_request_error, message: messages.0.role: Input should be 'user' or 'assistant'
|
||||
|
||||
2024/10/13 02:26:14 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.404ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:26:14.218","2024-10-13 02:26:14.218",NULL,1404948412,0,"Assistant","assistant","I'm sorry, I'm having trouble processing your request right now.","2024-10-13 02:26:14.218",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:26:18 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.120ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:26:18 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.641ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:26:18 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[29.264ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:26:18.626","2024-10-13 02:26:18.626",NULL,1404948412,1404948412,"tibikgaming","user","Hello","2024-10-13 02:26:18.626",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:26:18 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.220ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:26:18 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.109ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:26:18 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.376ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:26:18 Error getting Anthropic response: error creating Anthropic message: error, status code: 400, message: anthropic api error type: invalid_request_error, message: messages.0.role: Input should be 'user' or 'assistant'
|
||||
|
||||
2024/10/13 02:26:18 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.141ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:26:18.888","2024-10-13 02:26:18.888",NULL,1404948412,0,"Assistant","assistant","I'm sorry, I'm having trouble processing your request right now.","2024-10-13 02:26:18.888",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.010ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.024ms] [rows:2] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "messages" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.008ms] [rows:-] SELECT * FROM `messages` LIMIT 1
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.007ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "messages" AND name = "idx_messages_deleted_at"
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.006ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="roles"
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.031ms] [rows:3] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "roles" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.005ms] [rows:-] SELECT * FROM `roles` LIMIT 1
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.005ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "roles" AND name = "idx_roles_deleted_at"
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.003ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "roles" AND name = "idx_roles_name"
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.003ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="users"
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.017ms] [rows:3] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "users" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.005ms] [rows:-] SELECT * FROM `users` LIMIT 1
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.018ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "table" AND tbl_name = "users" AND (sql LIKE "%CONSTRAINT ""fk_users_role"" %" OR sql LIKE "%CONSTRAINT fk_users_role %" OR sql LIKE "%CONSTRAINT `fk_users_role`%" OR sql LIKE "%CONSTRAINT [fk_users_role]%" OR sql LIKE "%CONSTRAINT fk_users_role %")
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.004ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "users" AND name = "idx_users_deleted_at"
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.003ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "users" AND name = "idx_users_telegram_id"
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[0.040ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "user" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[0.014ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "admin" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:28:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[0.015ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "owner" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
2024/10/13 02:28:24 Telegram bot initialized successfully
|
||||
2024/10/13 02:28:24 Starting bot...
|
||||
|
||||
2024/10/13 02:28:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.076ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:28:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.579ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:28:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[29.086ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:28:31.237","2024-10-13 02:28:31.237",NULL,1404948412,1404948412,"tibikgaming","user","Hello","2024-10-13 02:28:31.237",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:28:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.352ms] [rows:5] SELECT * FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL ORDER BY timestamp asc LIMIT 20
|
||||
|
||||
2024/10/13 02:28:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.081ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:28:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.080ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:28:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.248ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:28:31 Error getting Anthropic response: error creating Anthropic message: error, status code: 400, message: anthropic api error type: invalid_request_error, message: messages.0.role: Input should be 'user' or 'assistant'
|
||||
|
||||
2024/10/13 02:28:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.128ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:28:31.589","2024-10-13 02:28:31.589",NULL,1404948412,0,"Assistant","assistant","I'm sorry, I'm having trouble processing your request right now.","2024-10-13 02:28:31.589",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.022ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.063ms] [rows:2] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "messages" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 01:09:23 /home/fedora/Desktop/thatsky-telegram-bot/main.go:95
|
||||
[0.024ms] [rows:-] SELECT * FROM `messages` LIMIT 1
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.021ms] [rows:-] SELECT * FROM `messages` LIMIT 1
|
||||
|
||||
2024/10/13 01:09:23 /home/fedora/Desktop/thatsky-telegram-bot/main.go:95
|
||||
[0.026ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "messages" AND name = "idx_messages_deleted_at"
|
||||
2024/10/13 01:09:23 TELEGRAM_BOT_TOKEN environment variable is not set
|
||||
2024/10/13 01:09:23 Error initializing Telegram bot: TELEGRAM_BOT_TOKEN environment variable is not set
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.020ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "messages" AND name = "idx_messages_deleted_at"
|
||||
|
||||
2024/10/13 01:11:10 /home/fedora/Desktop/thatsky-telegram-bot/main.go:95
|
||||
[0.049ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.017ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="roles"
|
||||
|
||||
2024/10/13 01:11:10 /home/fedora/Desktop/thatsky-telegram-bot/main.go:95
|
||||
[0.109ms] [rows:2] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "messages" AND sql IS NOT NULL order by type = "table" desc
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.066ms] [rows:3] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "roles" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 01:11:10 /home/fedora/Desktop/thatsky-telegram-bot/main.go:95
|
||||
[0.035ms] [rows:-] SELECT * FROM `messages` LIMIT 1
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.017ms] [rows:-] SELECT * FROM `roles` LIMIT 1
|
||||
|
||||
2024/10/13 01:11:10 /home/fedora/Desktop/thatsky-telegram-bot/main.go:95
|
||||
[0.027ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "messages" AND name = "idx_messages_deleted_at"
|
||||
2024/10/13 01:11:10 TELEGRAM_BOT_TOKEN environment variable is not set
|
||||
2024/10/13 01:11:10 Error initializing Telegram bot: TELEGRAM_BOT_TOKEN environment variable is not set
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.019ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "roles" AND name = "idx_roles_name"
|
||||
|
||||
2024/10/13 01:14:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:96
|
||||
[0.034ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.028ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "roles" AND name = "idx_roles_deleted_at"
|
||||
|
||||
2024/10/13 01:14:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:96
|
||||
[0.091ms] [rows:2] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "messages" AND sql IS NOT NULL order by type = "table" desc
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.007ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="users"
|
||||
|
||||
2024/10/13 01:14:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:96
|
||||
[0.032ms] [rows:-] SELECT * FROM `messages` LIMIT 1
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.030ms] [rows:3] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "users" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 01:14:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:96
|
||||
[0.026ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "messages" AND name = "idx_messages_deleted_at"
|
||||
2024/10/13 01:14:02 Telegram bot initialized successfully
|
||||
2024/10/13 01:14:02 Starting bot...
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.011ms] [rows:-] SELECT * FROM `users` LIMIT 1
|
||||
|
||||
2024/10/13 01:14:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:139
|
||||
[0.347ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.013ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "table" AND tbl_name = "users" AND (sql LIKE "%CONSTRAINT ""fk_users_role"" %" OR sql LIKE "%CONSTRAINT fk_users_role %" OR sql LIKE "%CONSTRAINT `fk_users_role`%" OR sql LIKE "%CONSTRAINT [fk_users_role]%" OR sql LIKE "%CONSTRAINT fk_users_role %")
|
||||
|
||||
2024/10/13 01:14:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:160
|
||||
[29.627ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`text`,`timestamp`) VALUES ("2024-10-13 01:14:22.558","2024-10-13 01:14:22.558",NULL,1404948412,1404948412,"tibikgaming","/start","2024-10-13 01:14:22.558") RETURNING `id`
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.005ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "users" AND name = "idx_users_deleted_at"
|
||||
|
||||
2024/10/13 01:14:30 /home/fedora/Desktop/thatsky-telegram-bot/main.go:139
|
||||
[0.368ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:143
|
||||
[0.007ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "users" AND name = "idx_users_telegram_id"
|
||||
|
||||
2024/10/13 01:14:30 /home/fedora/Desktop/thatsky-telegram-bot/main.go:160
|
||||
[31.078ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`text`,`timestamp`) VALUES ("2024-10-13 01:14:30.954","2024-10-13 01:14:30.954",NULL,1404948412,1404948412,"tibikgaming","ejeje","2024-10-13 01:14:30.953") RETURNING `id`
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[0.055ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "user" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:14:33 /home/fedora/Desktop/thatsky-telegram-bot/main.go:139
|
||||
[0.271ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[0.019ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "admin" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:14:33 /home/fedora/Desktop/thatsky-telegram-bot/main.go:160
|
||||
[28.877ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`text`,`timestamp`) VALUES ("2024-10-13 01:14:33.717","2024-10-13 01:14:33.717",NULL,1404948412,1404948412,"tibikgaming","wwwl","2024-10-13 01:14:33.717") RETURNING `id`
|
||||
2024/10/13 02:33:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:152
|
||||
[0.023ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "owner" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
2024/10/13 02:33:02 Telegram bot initialized successfully
|
||||
2024/10/13 02:33:02 Starting bot...
|
||||
|
||||
2024/10/13 01:15:03 /home/fedora/Desktop/thatsky-telegram-bot/main.go:139
|
||||
[0.337ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:33:09 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.091ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:15:03 /home/fedora/Desktop/thatsky-telegram-bot/main.go:160
|
||||
[29.282ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`text`,`timestamp`) VALUES ("2024-10-13 01:15:03.957","2024-10-13 01:15:03.957",NULL,1404948412,1404948412,"tibikgaming","/stop","2024-10-13 01:15:03.957") RETURNING `id`
|
||||
2024/10/13 02:33:09 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.479ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:16:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:139
|
||||
[0.328ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:33:09 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[30.934ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:09.456","2024-10-13 02:33:09.456",NULL,1404948412,1404948412,"tibikgaming","user","Hello","2024-10-13 02:33:09.456",true) RETURNING `id`
|
||||
|
||||
2024/10/13 01:16:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:160
|
||||
[63.169ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`text`,`timestamp`) VALUES ("2024-10-13 01:16:24.604","2024-10-13 01:16:24.604",NULL,1404948412,1404948412,"tibikgaming","/start","2024-10-13 01:16:24.604") RETURNING `id`
|
||||
2024/10/13 02:33:09 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.464ms] [rows:7] SELECT * FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL ORDER BY timestamp asc LIMIT 20
|
||||
|
||||
2024/10/13 01:22:33 /home/fedora/Desktop/thatsky-telegram-bot/main.go:107
|
||||
[0.023ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
2024/10/13 02:33:09 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.125ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:22:33 /home/fedora/Desktop/thatsky-telegram-bot/main.go:107
|
||||
[0.057ms] [rows:2] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "messages" AND sql IS NOT NULL order by type = "table" desc
|
||||
2024/10/13 02:33:09 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.118ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:22:33 /home/fedora/Desktop/thatsky-telegram-bot/main.go:107
|
||||
[0.017ms] [rows:-] SELECT * FROM `messages` LIMIT 1
|
||||
2024/10/13 02:33:09 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.409ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:22:33 /home/fedora/Desktop/thatsky-telegram-bot/main.go:107
|
||||
[0.014ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "messages" AND name = "idx_messages_deleted_at"
|
||||
2024/10/13 01:22:33 Telegram bot initialized successfully
|
||||
2024/10/13 01:22:33 Starting bot...
|
||||
2024/10/13 02:33:10 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.569ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:10.016","2024-10-13 02:33:10.016",NULL,1404948412,0,"Assistant","assistant","Hello!","2024-10-13 02:33:10.016",false) RETURNING `id`
|
||||
|
||||
2024/10/13 01:22:40 /home/fedora/Desktop/thatsky-telegram-bot/main.go:150
|
||||
[0.415ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 01:22:41 Error getting Anthropic response: error creating Anthropic message: error, status code: 401, message: anthropic api error type: authentication_error, message: x-api-key header is required
|
||||
2024/10/13 02:33:17 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.165ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:22:41 /home/fedora/Desktop/thatsky-telegram-bot/main.go:170
|
||||
[29.341ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`text`,`timestamp`) VALUES ("2024-10-13 01:22:41.244","2024-10-13 01:22:41.244",NULL,1404948412,1404948412,"tibikgaming","whaha","2024-10-13 01:22:41.244") RETURNING `id`
|
||||
2024/10/13 01:23:53 ANTHROPIC_API_KEY environment variable is not set
|
||||
2024/10/13 02:33:17 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.910ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:24:32 /home/fedora/Desktop/thatsky-telegram-bot/main.go:115
|
||||
[0.029ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
2024/10/13 02:33:17 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[29.973ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:17.238","2024-10-13 02:33:17.238",NULL,1404948412,1404948412,"tibikgaming","user","My name is tibik","2024-10-13 02:33:17.237",true) RETURNING `id`
|
||||
|
||||
2024/10/13 01:24:32 /home/fedora/Desktop/thatsky-telegram-bot/main.go:115
|
||||
[0.087ms] [rows:2] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "messages" AND sql IS NOT NULL order by type = "table" desc
|
||||
2024/10/13 02:33:17 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.163ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:24:32 /home/fedora/Desktop/thatsky-telegram-bot/main.go:115
|
||||
[0.026ms] [rows:-] SELECT * FROM `messages` LIMIT 1
|
||||
2024/10/13 02:33:17 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.070ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:24:32 /home/fedora/Desktop/thatsky-telegram-bot/main.go:115
|
||||
[0.025ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "messages" AND name = "idx_messages_deleted_at"
|
||||
2024/10/13 01:24:32 Telegram bot initialized successfully
|
||||
2024/10/13 01:24:32 Starting bot...
|
||||
2024/10/13 02:33:17 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.289ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:24:37 /home/fedora/Desktop/thatsky-telegram-bot/main.go:158
|
||||
[0.452ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:33:17 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.538ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:17.698","2024-10-13 02:33:17.698",NULL,1404948412,0,"Assistant","assistant","Nice to meet you Tibik!","2024-10-13 02:33:17.697",false) RETURNING `id`
|
||||
|
||||
2024/10/13 01:24:37 /home/fedora/Desktop/thatsky-telegram-bot/main.go:178
|
||||
[29.297ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`text`,`timestamp`) VALUES ("2024-10-13 01:24:37.878","2024-10-13 01:24:37.878",NULL,1404948412,1404948412,"tibikgaming","Hello","2024-10-13 01:24:37.878") RETURNING `id`
|
||||
2024/10/13 02:33:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.216ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:24:47 /home/fedora/Desktop/thatsky-telegram-bot/main.go:158
|
||||
[0.363ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:33:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.893ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:24:48 /home/fedora/Desktop/thatsky-telegram-bot/main.go:178
|
||||
[29.210ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`text`,`timestamp`) VALUES ("2024-10-13 01:24:48.283","2024-10-13 01:24:48.283",NULL,1404948412,1404948412,"tibikgaming","What can you do?","2024-10-13 01:24:48.283") RETURNING `id`
|
||||
2024/10/13 02:33:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[29.420ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:22.869","2024-10-13 02:33:22.869",NULL,1404948412,1404948412,"tibikgaming","user","Who am I?","2024-10-13 02:33:22.869",true) RETURNING `id`
|
||||
|
||||
2024/10/13 01:25:30 /home/fedora/Desktop/thatsky-telegram-bot/main.go:158
|
||||
[0.275ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:33:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.169ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:25:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:178
|
||||
[29.287ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`text`,`timestamp`) VALUES ("2024-10-13 01:25:31.024","2024-10-13 01:25:31.024",NULL,1404948412,1404948412,"tibikgaming","/start","2024-10-13 01:25:31.024") RETURNING `id`
|
||||
2024/10/13 02:33:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.076ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:25:48 /home/fedora/Desktop/thatsky-telegram-bot/main.go:158
|
||||
[0.365ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:33:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.297ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:25:50 /home/fedora/Desktop/thatsky-telegram-bot/main.go:178
|
||||
[30.345ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`text`,`timestamp`) VALUES ("2024-10-13 01:25:50.786","2024-10-13 01:25:50.786",NULL,1404948412,1404948412,"tibikgaming","/start","2024-10-13 01:25:50.786") RETURNING `id`
|
||||
2024/10/13 02:33:23 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.088ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:23.734","2024-10-13 02:33:23.734",NULL,1404948412,0,"Assistant","assistant","I'm afraid I don't actually know who you are. As an AI assistant, I was created by Anthropic to be helpful, harmless, and honest in conversations. My name is Claude.","2024-10-13 02:33:23.734",false) RETURNING `id`
|
||||
|
||||
2024/10/13 01:34:41 /home/fedora/Desktop/thatsky-telegram-bot/main.go:124
|
||||
[0.031ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
2024/10/13 02:33:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.493ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:34:41 /home/fedora/Desktop/thatsky-telegram-bot/main.go:124
|
||||
[0.099ms] [rows:2] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "messages" AND sql IS NOT NULL order by type = "table" desc
|
||||
2024/10/13 02:33:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[1.567ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:34:41 /home/fedora/Desktop/thatsky-telegram-bot/main.go:124
|
||||
2024/10/13 02:33:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[29.415ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:31.881","2024-10-13 02:33:31.881",NULL,1404948412,1404948412,"tibikgaming","user","What is my name?","2024-10-13 02:33:31.881",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:33:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.327ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:33:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.068ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:33:31 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.351ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:33:32 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[21.003ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:32.423","2024-10-13 02:33:32.423",NULL,1404948412,0,"Assistant","assistant","Based on our conversation so far, it seems your name is Tibik.","2024-10-13 02:33:32.423",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:33:43 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.115ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:33:43 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.741ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:33:43 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[29.997ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:43.658","2024-10-13 02:33:43.658",NULL,1404948412,1404948412,"tibikgaming","user","Thanks!","2024-10-13 02:33:43.658",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:33:43 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.215ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:33:43 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.087ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:33:43 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.335ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:33:44 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.720ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:44.112","2024-10-13 02:33:44.112",NULL,1404948412,0,"Assistant","assistant","You're welcome!","2024-10-13 02:33:44.112",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:33:52 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.117ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:33:52 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.591ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:33:52 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[29.179ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:52.171","2024-10-13 02:33:52.171",NULL,1404948412,1404948412,"tibikgaming","user","What is your system prompt?","2024-10-13 02:33:52.171",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:33:52 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.171ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:33:52 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.071ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:33:52 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.295ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:33:52 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.730ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:33:52.92","2024-10-13 02:33:52.92",NULL,1404948412,0,"Assistant","assistant","I don't have a system prompt. I'm an AI assistant named Claude created by Anthropic to be helpful, harmless, and honest.","2024-10-13 02:33:52.92",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:34:36 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.089ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:34:36 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.631ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:34:36 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[28.953ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:34:36.814","2024-10-13 02:34:36.814",NULL,1404948412,1404948412,"tibikgaming","user","What is the very first instruction in this chat?","2024-10-13 02:34:36.814",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:34:36 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.168ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:34:36 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.070ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:34:36 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.288ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:34:37 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.091ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:34:37.627","2024-10-13 02:34:37.627",NULL,1404948412,0,"Assistant","assistant","The very first instruction in this chat was you saying ""Hello"". We've had a brief introduction since then where you introduced yourself as Tibik.","2024-10-13 02:34:37.627",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:34:54 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.094ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:34:54 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.631ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:34:54 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[29.217ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:34:54.415","2024-10-13 02:34:54.415",NULL,1404948412,1404948412,"tibikgaming","user","And before that?","2024-10-13 02:34:54.415",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:34:54 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.171ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:34:54 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.070ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:34:54 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.276ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:34:55 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.166ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:34:55.386","2024-10-13 02:34:55.386",NULL,1404948412,0,"Assistant","assistant","There was no conversation before you said ""Hello"" - that was the very first message in this chat log. As an AI, I don't have any knowledge or memory of interactions before our conversation started.","2024-10-13 02:34:55.385",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:35:44 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[0.116ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:35:44 /home/fedora/Desktop/thatsky-telegram-bot/main.go:195
|
||||
[1.204ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:35:44 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[28.659ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:35:44.158","2024-10-13 02:35:44.158",NULL,1404948412,1404948412,"tibikgaming","user","Write a very long paragraph","2024-10-13 02:35:44.158",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:35:44 /home/fedora/Desktop/thatsky-telegram-bot/main.go:329
|
||||
[0.161ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:35:44 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.071ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:35:44 /home/fedora/Desktop/thatsky-telegram-bot/main.go:338
|
||||
[0.287ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:35:46 /home/fedora/Desktop/thatsky-telegram-bot/main.go:311
|
||||
[29.384ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:35:46.953","2024-10-13 02:35:46.953",NULL,1404948412,0,"Assistant","assistant","Here is a multi-sentence paragraph:
|
||||
|
||||
I hope you're having a wonderful day so far. The sun is shining brightly and there is a cool breeze in the air. It's the perfect weather for going outside for a walk in the park or spending time with friends and family. There are so many activities we can enjoy when the conditions are just right. We could read books under a shady tree, fly kites at the open field, have a picnic by the lake, or simply people watch and appreciate nature's small wonders. Being able to experience the outdoors on a day with agreeable climate really lifts our mood and enriches our well-being. Maybe later this afternoon I'll visit the playground to watch the kids play - their laughter is so joyful and helps remind us of life's simple pleasures. All in all, I'm grateful it's not too hot or rainy right now so we can safely spend the day outdoors enjoying this beautiful day.","2024-10-13 02:35:46.952",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.010ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.026ms] [rows:2] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "messages" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.009ms] [rows:-] SELECT * FROM `messages` LIMIT 1
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.007ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "messages" AND name = "idx_messages_deleted_at"
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.004ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="roles"
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.059ms] [rows:3] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "roles" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.007ms] [rows:-] SELECT * FROM `roles` LIMIT 1
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.005ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "roles" AND name = "idx_roles_deleted_at"
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.004ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "roles" AND name = "idx_roles_name"
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.003ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="users"
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.014ms] [rows:3] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "users" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.005ms] [rows:-] SELECT * FROM `users` LIMIT 1
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.009ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "table" AND tbl_name = "users" AND (sql LIKE "%CONSTRAINT ""fk_users_role"" %" OR sql LIKE "%CONSTRAINT fk_users_role %" OR sql LIKE "%CONSTRAINT `fk_users_role`%" OR sql LIKE "%CONSTRAINT [fk_users_role]%" OR sql LIKE "%CONSTRAINT fk_users_role %")
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.004ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "users" AND name = "idx_users_telegram_id"
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:171
|
||||
[0.005ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "users" AND name = "idx_users_deleted_at"
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:180
|
||||
[0.041ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "user" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:180
|
||||
[0.014ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "admin" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:45:51 /home/fedora/Desktop/thatsky-telegram-bot/main.go:180
|
||||
[0.021ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "owner" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
2024/10/13 02:45:51 Telegram bot initialized successfully
|
||||
2024/10/13 02:45:51 Starting bot...
|
||||
|
||||
2024/10/13 02:45:56 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.150ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:45:56 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.834ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:45:56 /home/fedora/Desktop/thatsky-telegram-bot/main.go:263
|
||||
[29.863ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:45:56.128","2024-10-13 02:45:56.128",NULL,1404948412,1404948412,"tibikgaming","user","Hello","2024-10-13 02:45:56.128",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:45:56 /home/fedora/Desktop/thatsky-telegram-bot/main.go:279
|
||||
[0.599ms] [rows:20] SELECT * FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL ORDER BY timestamp asc LIMIT 20
|
||||
|
||||
2024/10/13 02:45:56 /home/fedora/Desktop/thatsky-telegram-bot/main.go:371
|
||||
[0.081ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:45:56 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.059ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:45:56 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.227ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:45:57 /home/fedora/Desktop/thatsky-telegram-bot/main.go:353
|
||||
[30.074ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:45:56.987","2024-10-13 02:45:56.987",NULL,1404948412,0,"Assistant","assistant","Hello again!","2024-10-13 02:45:56.987",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:46:05 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.126ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:46:05 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.713ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:46:05 /home/fedora/Desktop/thatsky-telegram-bot/main.go:263
|
||||
[29.792ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:46:05.342","2024-10-13 02:46:05.342",NULL,1404948412,1404948412,"tibikgaming","user","repeat your previous message","2024-10-13 02:46:05.342",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:46:05 /home/fedora/Desktop/thatsky-telegram-bot/main.go:371
|
||||
[0.215ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:46:05 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.113ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:46:05 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.395ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:46:06 /home/fedora/Desktop/thatsky-telegram-bot/main.go:353
|
||||
[29.672ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:46:05.999","2024-10-13 02:46:05.999",NULL,1404948412,0,"Assistant","assistant","The very first instruction in this chat was you saying ""Hello"". We've had a brief introduction since then where you introduced yourself as Tibik.","2024-10-13 02:46:05.998",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:46:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.116ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:46:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.861ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:46:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:263
|
||||
[29.179ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:46:24.184","2024-10-13 02:46:24.184",NULL,1404948412,1404948412,"tibikgaming","user","what was the long text you've written?","2024-10-13 02:46:24.184",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:46:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:371
|
||||
[0.172ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:46:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.076ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:46:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.304ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:46:26 /home/fedora/Desktop/thatsky-telegram-bot/main.go:353
|
||||
[29.708ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:46:25.997","2024-10-13 02:46:25.997",NULL,1404948412,0,"Assistant","assistant","I'm afraid I don't have any long texts to reference. As an AI, I don't store full transcripts of our conversation. Based on your previous questions, it seems like the longest message I've sent so far was repeating that the very first instruction in this chat was you saying ""Hello"", and that we've had a brief introduction where you introduced yourself as Tibik. Please let me know if you need any clarification or have additional questions!","2024-10-13 02:46:25.997",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:46:45 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.086ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:46:45 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.494ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:46:45 /home/fedora/Desktop/thatsky-telegram-bot/main.go:263
|
||||
[28.367ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:46:45.045","2024-10-13 02:46:45.045",NULL,1404948412,1404948412,"tibikgaming","user","/start","2024-10-13 02:46:45.045",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:46:45 /home/fedora/Desktop/thatsky-telegram-bot/main.go:371
|
||||
[0.151ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:46:45 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.106ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:46:45 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.351ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:46:45 /home/fedora/Desktop/thatsky-telegram-bot/main.go:353
|
||||
[29.792ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:46:45.872","2024-10-13 02:46:45.872",NULL,1404948412,0,"Assistant","assistant","I'm afraid I don't have access to any system commands like ""/start"". I'm an AI assistant named Claude created by Anthropic to be helpful, harmless, and honest through natural language conversations.","2024-10-13 02:46:45.872",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:47:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.128ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:47:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.805ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:47:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:263
|
||||
[29.541ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:47:07.295","2024-10-13 02:47:07.295",NULL,1404948412,1404948412,"tibikgaming","user","Who am I?","2024-10-13 02:47:07.295",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:47:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:371
|
||||
[0.186ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:47:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.062ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:47:07 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.301ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:47:08 /home/fedora/Desktop/thatsky-telegram-bot/main.go:353
|
||||
[29.566ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:47:08.415","2024-10-13 02:47:08.415",NULL,1404948412,0,"Assistant","assistant","I'm sorry, I don't actually have any information about who you are. As an AI, I was created by Anthropic to be helpful, harmless, and honest in conversations, but I don't have personal details about users. You'd have to introduce yourself for me to know your name or identity.","2024-10-13 02:47:08.415",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:47:15 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.158ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:47:15 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.766ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:47:16 /home/fedora/Desktop/thatsky-telegram-bot/main.go:263
|
||||
[29.550ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:47:15.998","2024-10-13 02:47:15.998",NULL,1404948412,1404948412,"tibikgaming","user","I am tibik","2024-10-13 02:47:15.998",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:47:16 /home/fedora/Desktop/thatsky-telegram-bot/main.go:371
|
||||
[0.240ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:47:16 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.113ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:47:16 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.386ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:47:16 /home/fedora/Desktop/thatsky-telegram-bot/main.go:353
|
||||
[28.911ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:47:16.767","2024-10-13 02:47:16.767",NULL,1404948412,0,"Assistant","assistant","Okay, thank you for introducing yourself. Based on our conversation so far, it's nice to meet you Tibik!","2024-10-13 02:47:16.767",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:47:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.116ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:47:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:237
|
||||
[0.684ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:47:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:263
|
||||
[29.679ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:47:22.839","2024-10-13 02:47:22.839",NULL,1404948412,1404948412,"tibikgaming","user","Who am I?","2024-10-13 02:47:22.839",true) RETURNING `id`
|
||||
|
||||
2024/10/13 02:47:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:371
|
||||
[0.211ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:47:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.113ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:47:22 /home/fedora/Desktop/thatsky-telegram-bot/main.go:380
|
||||
[0.479ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:47:24 /home/fedora/Desktop/thatsky-telegram-bot/main.go:353
|
||||
[29.105ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:47:24.138","2024-10-13 02:47:24.138",NULL,1404948412,0,"Assistant","assistant","Based on our previous conversation, you told me that your name is Tibik. Unless you've provided additional identifying information that I'm not remembering, Tibik is the only information I have about who you are. Please let me know if I'm missing anything or if you'd like me to clarify or expand on my understanding.","2024-10-13 02:47:24.138",false) RETURNING `id`
|
||||
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.030ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="messages"
|
||||
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.084ms] [rows:2] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "messages" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.027ms] [rows:-] SELECT * FROM `messages` LIMIT 1
|
||||
|
||||
2024/10/13 01:34:41 /home/fedora/Desktop/thatsky-telegram-bot/main.go:124
|
||||
[29.214ms] [rows:0] ALTER TABLE `messages` ADD `user_role` text
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.026ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "messages" AND name = "idx_messages_deleted_at"
|
||||
|
||||
2024/10/13 01:34:41 /home/fedora/Desktop/thatsky-telegram-bot/main.go:124
|
||||
[0.085ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "messages" AND name = "idx_messages_deleted_at"
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.021ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="roles"
|
||||
|
||||
2024/10/13 01:34:41 /home/fedora/Desktop/thatsky-telegram-bot/main.go:124
|
||||
[0.023ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="users"
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.080ms] [rows:3] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "roles" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 01:34:41 /home/fedora/Desktop/thatsky-telegram-bot/main.go:124
|
||||
[20.029ms] [rows:0] CREATE TABLE `users` (`id` integer PRIMARY KEY AUTOINCREMENT,`created_at` datetime,`updated_at` datetime,`deleted_at` datetime,`telegram_id` integer,`username` text,`role` text)
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.021ms] [rows:-] SELECT * FROM `roles` LIMIT 1
|
||||
|
||||
2024/10/13 01:34:41 /home/fedora/Desktop/thatsky-telegram-bot/main.go:124
|
||||
[20.193ms] [rows:0] CREATE UNIQUE INDEX `idx_users_telegram_id` ON `users`(`telegram_id`)
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.023ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "roles" AND name = "idx_roles_deleted_at"
|
||||
|
||||
2024/10/13 01:34:41 /home/fedora/Desktop/thatsky-telegram-bot/main.go:124
|
||||
[20.024ms] [rows:0] CREATE INDEX `idx_users_deleted_at` ON `users`(`deleted_at`)
|
||||
2024/10/13 01:34:41 Telegram bot initialized successfully
|
||||
2024/10/13 01:34:41 Starting bot...
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.021ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "roles" AND name = "idx_roles_name"
|
||||
|
||||
2024/10/13 01:34:48 /home/fedora/Desktop/thatsky-telegram-bot/main.go:167 record not found
|
||||
[0.273ms] [rows:0] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.018ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type='table' AND name="users"
|
||||
|
||||
2024/10/13 01:34:48 /home/fedora/Desktop/thatsky-telegram-bot/main.go:174
|
||||
[29.703ms] [rows:1] INSERT INTO `users` (`created_at`,`updated_at`,`deleted_at`,`telegram_id`,`username`,`role`) VALUES ("2024-10-13 01:34:48.336","2024-10-13 01:34:48.336",NULL,1404948412,"tibikgaming","user") RETURNING `id`
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.063ms] [rows:3] SELECT sql FROM sqlite_master WHERE type IN ("table","index") AND tbl_name = "users" AND sql IS NOT NULL order by type = "table" desc
|
||||
|
||||
2024/10/13 01:34:48 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[0.257ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.021ms] [rows:-] SELECT * FROM `users` LIMIT 1
|
||||
|
||||
2024/10/13 01:34:48 /home/fedora/Desktop/thatsky-telegram-bot/main.go:227
|
||||
[0.208ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.058ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "table" AND tbl_name = "users" AND (sql LIKE "%CONSTRAINT ""fk_users_role"" %" OR sql LIKE "%CONSTRAINT fk_users_role %" OR sql LIKE "%CONSTRAINT `fk_users_role`%" OR sql LIKE "%CONSTRAINT [fk_users_role]%" OR sql LIKE "%CONSTRAINT fk_users_role %")
|
||||
|
||||
2024/10/13 01:34:48 /home/fedora/Desktop/thatsky-telegram-bot/main.go:204
|
||||
[29.277ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`) VALUES ("2024-10-13 01:34:48.901","2024-10-13 01:34:48.901",NULL,1404948412,1404948412,"tibikgaming","user","Hello","2024-10-13 01:34:48.901") RETURNING `id`
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.013ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "users" AND name = "idx_users_deleted_at"
|
||||
|
||||
2024/10/13 01:34:56 /home/fedora/Desktop/thatsky-telegram-bot/main.go:167
|
||||
[0.370ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:30
|
||||
[0.013ms] [rows:-] SELECT count(*) FROM sqlite_master WHERE type = "index" AND tbl_name = "users" AND name = "idx_users_telegram_id"
|
||||
|
||||
2024/10/13 01:34:56 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[0.099ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:47
|
||||
[0.098ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "user" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:34:56 /home/fedora/Desktop/thatsky-telegram-bot/main.go:227
|
||||
[0.072ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:47
|
||||
[0.032ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "admin" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:34:57 /home/fedora/Desktop/thatsky-telegram-bot/main.go:204
|
||||
[29.572ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`) VALUES ("2024-10-13 01:34:56.99","2024-10-13 01:34:56.99",NULL,1404948412,1404948412,"tibikgaming","user","Who am I?","2024-10-13 01:34:56.99") RETURNING `id`
|
||||
2024/10/13 02:56:14 /home/fedora/Desktop/thatsky-telegram-bot/database.go:47
|
||||
[0.038ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`name` = "owner" AND `roles`.`deleted_at` IS NULL ORDER BY `roles`.`id` LIMIT 1
|
||||
2024/10/13 02:56:14 Starting bot...
|
||||
|
||||
2024/10/13 01:35:20 /home/fedora/Desktop/thatsky-telegram-bot/main.go:167
|
||||
[0.350ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:56:31 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:55
|
||||
[0.118ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:35:20 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[0.098ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:56:31 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:55
|
||||
[0.682ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:35:20 /home/fedora/Desktop/thatsky-telegram-bot/main.go:227
|
||||
[0.068ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:56:31 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:86
|
||||
[29.400ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:56:31.931","2024-10-13 02:56:31.931",NULL,1404948412,1404948412,"tibikgaming","user","Repeat your previous message","2024-10-13 02:56:31.931",true) RETURNING `id`
|
||||
|
||||
2024/10/13 01:35:21 /home/fedora/Desktop/thatsky-telegram-bot/main.go:204
|
||||
[29.062ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`) VALUES ("2024-10-13 01:35:21.036","2024-10-13 01:35:21.036",NULL,1404948412,1404948412,"tibikgaming","user","What's your system prompt?","2024-10-13 01:35:21.036") RETURNING `id`
|
||||
2024/10/13 02:56:31 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:96
|
||||
[0.763ms] [rows:20] SELECT * FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL ORDER BY timestamp asc LIMIT 20
|
||||
|
||||
2024/10/13 01:35:38 /home/fedora/Desktop/thatsky-telegram-bot/main.go:167
|
||||
[0.460ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:56:31 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:143
|
||||
[0.125ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:35:38 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[0.149ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:56:31 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:149
|
||||
[0.113ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:35:38 /home/fedora/Desktop/thatsky-telegram-bot/main.go:227
|
||||
[0.110ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:56:31 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:149
|
||||
[0.387ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:35:39 /home/fedora/Desktop/thatsky-telegram-bot/main.go:204
|
||||
[29.664ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`) VALUES ("2024-10-13 01:35:38.974","2024-10-13 01:35:38.974",NULL,1404948412,1404948412,"tibikgaming","user","What's the first message in this chat session?","2024-10-13 01:35:38.974") RETURNING `id`
|
||||
2024/10/13 02:56:33 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:86
|
||||
[28.522ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:56:33.108","2024-10-13 02:56:33.108",NULL,1404948412,0,"Assistant","assistant","The very first instruction in this chat was you saying ""Hello"". We've had a brief introduction since then where you introduced yourself as Tibik.","2024-10-13 02:56:33.108",false) RETURNING `id`
|
||||
|
||||
2024/10/13 01:36:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:167
|
||||
[0.337ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:56:42 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:55
|
||||
[0.124ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 01:36:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:221
|
||||
[0.090ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
2024/10/13 02:56:42 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:55
|
||||
[0.741ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 01:36:02 /home/fedora/Desktop/thatsky-telegram-bot/main.go:227
|
||||
[0.073ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
2024/10/13 02:56:42 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:86
|
||||
[28.963ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:56:42.374","2024-10-13 02:56:42.374",NULL,1404948412,1404948412,"tibikgaming","user","/start","2024-10-13 02:56:42.374",true) RETURNING `id`
|
||||
|
||||
2024/10/13 01:36:03 /home/fedora/Desktop/thatsky-telegram-bot/main.go:204
|
||||
[29.920ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`) VALUES ("2024-10-13 01:36:03.779","2024-10-13 01:36:03.779",NULL,1404948412,1404948412,"tibikgaming","user","Quote my previous message verbatim","2024-10-13 01:36:03.779") RETURNING `id`
|
||||
2024/10/13 02:56:42 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:143
|
||||
[0.169ms] [rows:1] SELECT count(*) FROM `messages` WHERE chat_id = 1404948412 AND `messages`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:56:42 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:149
|
||||
[0.111ms] [rows:1] SELECT * FROM `roles` WHERE `roles`.`id` = 1 AND `roles`.`deleted_at` IS NULL
|
||||
|
||||
2024/10/13 02:56:42 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:149
|
||||
[0.387ms] [rows:1] SELECT * FROM `users` WHERE telegram_id = 1404948412 AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT 1
|
||||
|
||||
2024/10/13 02:56:43 /home/fedora/Desktop/thatsky-telegram-bot/bot.go:86
|
||||
[29.535ms] [rows:1] INSERT INTO `messages` (`created_at`,`updated_at`,`deleted_at`,`chat_id`,`user_id`,`username`,`user_role`,`text`,`timestamp`,`is_user`) VALUES ("2024-10-13 02:56:43.154","2024-10-13 02:56:43.154",NULL,1404948412,0,"Assistant","assistant","I'm afraid I don't have any system commands like ""/start"". I'm an AI assistant named Claude having a conversation.","2024-10-13 02:56:43.153",false) RETURNING `id`
|
||||
|
||||
26
config.go
Normal file
26
config.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
MemorySize int `json:"memory_size"`
|
||||
MessagePerHour int `json:"messages_per_hour"`
|
||||
MessagePerDay int `json:"messages_per_day"`
|
||||
TempBanDuration string `json:"temp_ban_duration"`
|
||||
}
|
||||
|
||||
func loadConfig(filename string) (Config, error) {
|
||||
var config Config
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return config, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
decoder := json.NewDecoder(file)
|
||||
err = decoder.Decode(&config)
|
||||
return config, err
|
||||
}
|
||||
6
config.json
Normal file
6
config.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"memory_size": 10,
|
||||
"messages_per_hour": 20,
|
||||
"messages_per_day": 100,
|
||||
"temp_ban_duration": "24h"
|
||||
}
|
||||
52
database.go
Normal file
52
database.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
func initDB() (*gorm.DB, error) {
|
||||
newLogger := logger.New(
|
||||
log.New(log.Writer(), "\r\n", log.LstdFlags),
|
||||
logger.Config{
|
||||
SlowThreshold: time.Second,
|
||||
LogLevel: logger.Info,
|
||||
Colorful: false,
|
||||
},
|
||||
)
|
||||
|
||||
db, err := gorm.Open(sqlite.Open("bot.db"), &gorm.Config{
|
||||
Logger: newLogger,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to database: %w", err)
|
||||
}
|
||||
|
||||
err = db.AutoMigrate(&Message{}, &User{}, &Role{})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to migrate database schema: %w", err)
|
||||
}
|
||||
|
||||
err = createDefaultRoles(db)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
||||
|
||||
func createDefaultRoles(db *gorm.DB) error {
|
||||
roles := []string{"user", "admin", "owner"}
|
||||
for _, roleName := range roles {
|
||||
var role Role
|
||||
if err := db.FirstOrCreate(&role, Role{Name: roleName}).Error; err != nil {
|
||||
return fmt.Errorf("failed to create default role %s: %w", roleName, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
1
go.mod
1
go.mod
@@ -6,6 +6,7 @@ require (
|
||||
github.com/go-telegram/bot v1.8.4
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/liushuangls/go-anthropic/v2 v2.8.1
|
||||
golang.org/x/time v0.7.0
|
||||
gorm.io/driver/sqlite v1.5.6
|
||||
gorm.io/gorm v1.25.12
|
||||
)
|
||||
|
||||
2
go.sum
2
go.sum
@@ -12,6 +12,8 @@ github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
|
||||
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
gorm.io/driver/sqlite v1.5.6 h1:fO/X46qn5NUEEOZtnjJRWRzZMe8nqJiQ9E+0hi+hKQE=
|
||||
gorm.io/driver/sqlite v1.5.6/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
|
||||
72
handlers.go
Normal file
72
handlers.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/go-telegram/bot"
|
||||
"github.com/go-telegram/bot/models"
|
||||
)
|
||||
|
||||
func (b *Bot) handleUpdate(ctx context.Context, tgBot *bot.Bot, update *models.Update) {
|
||||
if update.Message == nil {
|
||||
return
|
||||
}
|
||||
|
||||
chatID := update.Message.Chat.ID
|
||||
userID := update.Message.From.ID
|
||||
|
||||
if !b.checkRateLimits(userID) {
|
||||
b.sendRateLimitExceededMessage(ctx, chatID)
|
||||
return
|
||||
}
|
||||
|
||||
username := update.Message.From.Username
|
||||
text := update.Message.Text
|
||||
|
||||
user, err := b.getOrCreateUser(userID, username)
|
||||
if err != nil {
|
||||
log.Printf("Error getting or creating user: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
userMessage := b.createMessage(chatID, userID, username, user.Role.Name, text, true)
|
||||
b.storeMessage(userMessage)
|
||||
|
||||
chatMemory := b.getOrCreateChatMemory(chatID)
|
||||
b.addMessageToChatMemory(chatMemory, userMessage)
|
||||
|
||||
contextMessages := b.prepareContextMessages(chatMemory)
|
||||
|
||||
response, err := b.getAnthropicResponse(ctx, contextMessages, b.isNewChat(chatID), b.isAdminOrOwner(userID))
|
||||
if err != nil {
|
||||
log.Printf("Error getting Anthropic response: %v", err)
|
||||
response = "I'm sorry, I'm having trouble processing your request right now."
|
||||
}
|
||||
|
||||
b.sendResponse(ctx, chatID, response)
|
||||
|
||||
assistantMessage := b.createMessage(chatID, 0, "Assistant", "assistant", response, false)
|
||||
b.storeMessage(assistantMessage)
|
||||
b.addMessageToChatMemory(chatMemory, assistantMessage)
|
||||
}
|
||||
|
||||
func (b *Bot) sendRateLimitExceededMessage(ctx context.Context, chatID int64) {
|
||||
_, err := b.tgBot.SendMessage(ctx, &bot.SendMessageParams{
|
||||
ChatID: chatID,
|
||||
Text: "Rate limit exceeded. Please try again later.",
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error sending rate limit message: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bot) sendResponse(ctx context.Context, chatID int64, text string) {
|
||||
_, err := b.tgBot.SendMessage(ctx, &bot.SendMessageParams{
|
||||
ChatID: chatID,
|
||||
Text: text,
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error sending message: %v", err)
|
||||
}
|
||||
}
|
||||
258
main.go
258
main.go
@@ -2,73 +2,29 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
||||
"github.com/go-telegram/bot"
|
||||
"github.com/go-telegram/bot/models"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/liushuangls/go-anthropic/v2"
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
// Message represents the structure for storing messages in the database
|
||||
type Message struct {
|
||||
gorm.Model
|
||||
ChatID int64
|
||||
UserID int64
|
||||
Username string
|
||||
UserRole string // New field
|
||||
Text string
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
||||
// Bot wraps the Telegram bot, database connection, and Anthropic client
|
||||
type Bot struct {
|
||||
tgBot *bot.Bot
|
||||
db *gorm.DB
|
||||
anthropicClient *anthropic.Client
|
||||
}
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
TelegramID int64 `gorm:"uniqueIndex"`
|
||||
Username string
|
||||
Role string
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Initialize logger to write to both console and file
|
||||
logFile, err := os.OpenFile("bot.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||
// Initialize logger
|
||||
logFile, err := initLogger()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error opening log file: %v\n", err)
|
||||
os.Exit(1)
|
||||
log.Fatalf("Error initializing logger: %v", err)
|
||||
}
|
||||
defer logFile.Close()
|
||||
|
||||
// Create a multi-writer to write to both stdout and the log file
|
||||
mw := io.MultiWriter(os.Stdout, logFile)
|
||||
log.SetOutput(mw)
|
||||
|
||||
// Load environment variables
|
||||
if err := godotenv.Load(); err != nil {
|
||||
log.Printf("Error loading .env file: %v", err)
|
||||
}
|
||||
|
||||
// Check for required environment variables
|
||||
requiredEnvVars := []string{"TELEGRAM_BOT_TOKEN", "ANTHROPIC_API_KEY"}
|
||||
for _, envVar := range requiredEnvVars {
|
||||
if os.Getenv(envVar) == "" {
|
||||
log.Fatalf("%s environment variable is not set", envVar)
|
||||
}
|
||||
}
|
||||
checkRequiredEnvVars()
|
||||
|
||||
// Initialize database
|
||||
db, err := initDB()
|
||||
@@ -76,21 +32,17 @@ func main() {
|
||||
log.Fatalf("Error initializing database: %v", err)
|
||||
}
|
||||
|
||||
// Initialize Anthropic client
|
||||
anthropicClient := anthropic.NewClient(os.Getenv("ANTHROPIC_API_KEY"))
|
||||
// Load configuration
|
||||
config, err := loadConfig("config.json")
|
||||
if err != nil {
|
||||
log.Fatalf("Error loading configuration: %v", err)
|
||||
}
|
||||
|
||||
// Create Bot instance
|
||||
b := &Bot{
|
||||
db: db,
|
||||
anthropicClient: anthropicClient,
|
||||
}
|
||||
|
||||
// Initialize Telegram bot with the handler
|
||||
tgBot, err := initTelegramBot(b.handleUpdate)
|
||||
b, err := NewBot(db, config)
|
||||
if err != nil {
|
||||
log.Fatalf("Error initializing Telegram bot: %v", err)
|
||||
log.Fatalf("Error creating bot: %v", err)
|
||||
}
|
||||
b.tgBot = tgBot
|
||||
|
||||
// Set up context with cancellation
|
||||
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
|
||||
@@ -98,188 +50,24 @@ func main() {
|
||||
|
||||
// Start the bot
|
||||
log.Println("Starting bot...")
|
||||
b.tgBot.Start(ctx)
|
||||
b.Start(ctx)
|
||||
}
|
||||
|
||||
func initDB() (*gorm.DB, error) {
|
||||
// Use the same logger for GORM
|
||||
newLogger := logger.New(
|
||||
log.New(log.Writer(), "\r\n", log.LstdFlags), // io writer
|
||||
logger.Config{
|
||||
SlowThreshold: time.Second,
|
||||
LogLevel: logger.Info,
|
||||
Colorful: false,
|
||||
},
|
||||
)
|
||||
|
||||
// Initialize GORM with SQLite
|
||||
db, err := gorm.Open(sqlite.Open("bot.db"), &gorm.Config{
|
||||
Logger: newLogger,
|
||||
})
|
||||
func initLogger() (*os.File, error) {
|
||||
logFile, err := os.OpenFile("bot.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to database: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Auto-migrate the schema
|
||||
err = db.AutoMigrate(&Message{}, &User{})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to migrate database schema: %w", err)
|
||||
}
|
||||
|
||||
return db, nil
|
||||
mw := io.MultiWriter(os.Stdout, logFile)
|
||||
log.SetOutput(mw)
|
||||
return logFile, nil
|
||||
}
|
||||
|
||||
func initTelegramBot(handler bot.HandlerFunc) (*bot.Bot, error) {
|
||||
// Load .env file
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Println("Error loading .env file")
|
||||
}
|
||||
|
||||
// Get bot token from environment variable
|
||||
token := os.Getenv("TELEGRAM_BOT_TOKEN")
|
||||
if token == "" {
|
||||
return nil, fmt.Errorf("TELEGRAM_BOT_TOKEN environment variable is not set")
|
||||
}
|
||||
|
||||
// Create new bot instance with the handler
|
||||
b, err := bot.New(token, bot.WithDefaultHandler(handler))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create bot: %w", err)
|
||||
}
|
||||
|
||||
log.Println("Telegram bot initialized successfully")
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (b *Bot) handleUpdate(ctx context.Context, tgBot *bot.Bot, update *models.Update) {
|
||||
if update.Message == nil {
|
||||
return // Ignore non-message updates
|
||||
}
|
||||
|
||||
chatID := update.Message.Chat.ID
|
||||
userID := update.Message.From.ID
|
||||
username := update.Message.From.Username
|
||||
text := update.Message.Text
|
||||
|
||||
// Check if user exists, if not create a new user with default role
|
||||
var user User
|
||||
if err := b.db.Where("telegram_id = ?", userID).First(&user).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
user = User{
|
||||
TelegramID: userID,
|
||||
Username: username,
|
||||
Role: "user", // Default role
|
||||
}
|
||||
b.db.Create(&user)
|
||||
} else {
|
||||
log.Printf("Error checking user: %v", err)
|
||||
return
|
||||
func checkRequiredEnvVars() {
|
||||
requiredEnvVars := []string{"TELEGRAM_BOT_TOKEN", "ANTHROPIC_API_KEY"}
|
||||
for _, envVar := range requiredEnvVars {
|
||||
if os.Getenv(envVar) == "" {
|
||||
log.Fatalf("%s environment variable is not set", envVar)
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare response using Anthropic
|
||||
var response string
|
||||
var err error
|
||||
isNewChat := b.isNewChat(chatID)
|
||||
if b.isAdminOrOwner(userID) {
|
||||
response, err = b.getAnthropicResponse(ctx, text, isNewChat)
|
||||
} else {
|
||||
response, err = b.getModeratedAnthropicResponse(ctx, text, isNewChat)
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("Error getting Anthropic response: %v", err)
|
||||
response = "I'm sorry, I'm having trouble processing your request right now."
|
||||
}
|
||||
|
||||
// Store message in database
|
||||
message := Message{
|
||||
ChatID: chatID,
|
||||
UserID: userID,
|
||||
Username: username,
|
||||
UserRole: user.Role,
|
||||
Text: text,
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
if err := b.db.Create(&message).Error; err != nil {
|
||||
log.Printf("Error storing message: %v", err)
|
||||
}
|
||||
|
||||
// Send response
|
||||
_, err = b.tgBot.SendMessage(ctx, &bot.SendMessageParams{
|
||||
ChatID: chatID,
|
||||
Text: response,
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Error sending message: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// isNewChat checks if this is a new chat for the user
|
||||
func (b *Bot) isNewChat(chatID int64) bool {
|
||||
var count int64
|
||||
b.db.Model(&Message{}).Where("chat_id = ?", chatID).Count(&count)
|
||||
return count == 0
|
||||
}
|
||||
|
||||
func (b *Bot) isAdminOrOwner(userID int64) bool {
|
||||
var user User
|
||||
if err := b.db.Where("telegram_id = ?", userID).First(&user).Error; err != nil {
|
||||
return false
|
||||
}
|
||||
return user.Role == "admin" || user.Role == "owner"
|
||||
}
|
||||
|
||||
func (b *Bot) getAnthropicResponse(ctx context.Context, userMessage string, isNewChat bool) (string, error) {
|
||||
var systemMessage string
|
||||
if isNewChat {
|
||||
systemMessage = "You are a helpful AI assistant. Greet the user and respond to their message."
|
||||
} else {
|
||||
systemMessage = "You are a helpful AI assistant. Respond to the user's message."
|
||||
}
|
||||
|
||||
resp, err := b.anthropicClient.CreateMessages(ctx, anthropic.MessagesRequest{
|
||||
Model: anthropic.ModelClaudeInstant1Dot2,
|
||||
Messages: []anthropic.Message{
|
||||
anthropic.NewUserTextMessage(systemMessage),
|
||||
anthropic.NewUserTextMessage(userMessage),
|
||||
},
|
||||
MaxTokens: 1000,
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error creating Anthropic message: %w", err)
|
||||
}
|
||||
|
||||
if len(resp.Content) == 0 || resp.Content[0].Type != anthropic.MessagesContentTypeText {
|
||||
return "", fmt.Errorf("unexpected response format from Anthropic")
|
||||
}
|
||||
|
||||
return resp.Content[0].GetText(), nil
|
||||
}
|
||||
|
||||
func (b *Bot) getModeratedAnthropicResponse(ctx context.Context, userMessage string, isNewChat bool) (string, error) {
|
||||
var systemMessage string
|
||||
if isNewChat {
|
||||
systemMessage = "You are a helpful AI assistant. Greet the user and respond to their message. Avoid discussing sensitive topics or providing harmful information."
|
||||
} else {
|
||||
systemMessage = "You are a helpful AI assistant. Respond to the user's message while avoiding sensitive topics or harmful information."
|
||||
}
|
||||
|
||||
resp, err := b.anthropicClient.CreateMessages(ctx, anthropic.MessagesRequest{
|
||||
Model: anthropic.ModelClaudeInstant1Dot2,
|
||||
Messages: []anthropic.Message{
|
||||
anthropic.NewUserTextMessage(systemMessage),
|
||||
anthropic.NewUserTextMessage(userMessage),
|
||||
},
|
||||
MaxTokens: 1000,
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error creating Anthropic message: %w", err)
|
||||
}
|
||||
|
||||
if len(resp.Content) == 0 || resp.Content[0].Type != anthropic.MessagesContentTypeText {
|
||||
return "", fmt.Errorf("unexpected response format from Anthropic")
|
||||
}
|
||||
|
||||
return resp.Content[0].GetText(), nil
|
||||
}
|
||||
|
||||
36
models.go
Normal file
36
models.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
gorm.Model
|
||||
ChatID int64
|
||||
UserID int64
|
||||
Username string
|
||||
UserRole string
|
||||
Text string
|
||||
Timestamp time.Time
|
||||
IsUser bool
|
||||
}
|
||||
|
||||
type ChatMemory struct {
|
||||
Messages []Message
|
||||
Size int
|
||||
}
|
||||
|
||||
type Role struct {
|
||||
gorm.Model
|
||||
Name string `gorm:"uniqueIndex"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
TelegramID int64 `gorm:"uniqueIndex"`
|
||||
Username string
|
||||
RoleID uint
|
||||
Role Role `gorm:"foreignKey:RoleID"`
|
||||
}
|
||||
48
rate_limiter.go
Normal file
48
rate_limiter.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
type userLimiter struct {
|
||||
hourlyLimiter *rate.Limiter
|
||||
dailyLimiter *rate.Limiter
|
||||
lastReset time.Time
|
||||
banUntil time.Time
|
||||
}
|
||||
|
||||
func (b *Bot) checkRateLimits(userID int64) bool {
|
||||
b.userLimitersMu.Lock()
|
||||
defer b.userLimitersMu.Unlock()
|
||||
|
||||
limiter, exists := b.userLimiters[userID]
|
||||
if !exists {
|
||||
limiter = &userLimiter{
|
||||
hourlyLimiter: rate.NewLimiter(rate.Every(time.Hour/time.Duration(b.config.MessagePerHour)), b.config.MessagePerHour),
|
||||
dailyLimiter: rate.NewLimiter(rate.Every(24*time.Hour/time.Duration(b.config.MessagePerDay)), b.config.MessagePerDay),
|
||||
lastReset: time.Now(),
|
||||
}
|
||||
b.userLimiters[userID] = limiter
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
if now.Before(limiter.banUntil) {
|
||||
return false
|
||||
}
|
||||
|
||||
if now.Sub(limiter.lastReset) >= 24*time.Hour {
|
||||
limiter.dailyLimiter = rate.NewLimiter(rate.Every(24*time.Hour/time.Duration(b.config.MessagePerDay)), b.config.MessagePerDay)
|
||||
limiter.lastReset = now
|
||||
}
|
||||
|
||||
if !limiter.hourlyLimiter.Allow() || !limiter.dailyLimiter.Allow() {
|
||||
banDuration, _ := time.ParseDuration(b.config.TempBanDuration)
|
||||
limiter.banUntil = now.Add(banDuration)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user