You've already forked grok
Compare commits
2 Commits
96bee15bf3
...
260d38aae8
| Author | SHA1 | Date | |
|---|---|---|---|
| 260d38aae8 | |||
| bab5bae279 |
18
main.go
18
main.go
@@ -71,6 +71,8 @@ func (a *App) handleMessage(ctx context.Context, msg *tgbotapi.Message) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
question := msg.Text[len("@grok"):]
|
||||
|
||||
select {
|
||||
case a.sema <- struct{}{}:
|
||||
default:
|
||||
@@ -79,14 +81,24 @@ func (a *App) handleMessage(ctx context.Context, msg *tgbotapi.Message) error {
|
||||
}
|
||||
defer func() { <-a.sema }()
|
||||
|
||||
a.log.Info("message passed all guards", "text", msg.Text)
|
||||
a.log.Info(
|
||||
"message passed all guards",
|
||||
"og_text", msg.Text,
|
||||
"transformed_text", question,
|
||||
)
|
||||
|
||||
response, err := a.proompter.Prompt(ctx, msg.Text)
|
||||
response, err := a.proompter.Prompt(ctx, question)
|
||||
if err != nil {
|
||||
return fmt.Errorf("prompting: %w", err)
|
||||
}
|
||||
|
||||
_, err = a.bot.Send(tgbotapi.NewMessage(chatID, response.Text))
|
||||
_, err = a.bot.Send(tgbotapi.MessageConfig{
|
||||
BaseChat: tgbotapi.BaseChat{
|
||||
ChatID: chatID,
|
||||
ReplyToMessageID: msg.MessageID,
|
||||
},
|
||||
Text: response.Text,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("responding: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user