Skip to content

Commit 1f73c53

Browse files
committed
feat: Add agent name to reply
1 parent 50ff42d commit 1f73c53

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/agent/agent.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ func (a *Agent) reactToTweet(ctx context.Context, agentInfo *indexer.AgentInfo,
573573
}
574574

575575
slog.Info("replying to", "agent_address", agentInfo.Address, "prompt_id", promptPaidEvent.PromptID, "tweet_id", promptPaidEvent.TweetID, "reply", reply)
576-
err = a.twitterClient.ReplyToTweet(promptPaidEvent.TweetID, reply)
576+
err = a.twitterClient.ReplyToTweet(promptPaidEvent.TweetID, fmt.Sprintf(":%s: %s", agentInfo.Name, reply))
577577
if err != nil {
578578
slog.Warn("failed to reply to tweet", "agent_address", agentInfo.Address, "prompt_id", promptPaidEvent.PromptID, "tweet_id", promptPaidEvent.TweetID, "error", err)
579579
}
@@ -635,7 +635,7 @@ func (a *Agent) validateTweetText(tweetText, agentName, promptText string) error
635635
fullPattern := `(.*?)\s*@` + regexp.QuoteMeta(a.twitterClientConfig.Username) + `\s*:\s*` + regexp.QuoteMeta(agentName) + `\s*:\s*(.*)`
636636
fullRe := regexp.MustCompile(fullPattern)
637637
matches := fullRe.FindStringSubmatch(tweetText)
638-
if matches == nil {
638+
if len(matches) < 3 {
639639
return fmt.Errorf("tweet text does not match expected format. Expected format: <prompt_left> @%s :%s <prompt_right>", a.twitterClientConfig.Username, agentName)
640640
}
641641

0 commit comments

Comments
 (0)