@@ -201,7 +201,7 @@ func detectImageExtension(inputPath string) string {
201201}
202202
203203// FetchBotCommand executes the configured command and returns a string to post.
204- func FetchBotCommand (ctx context.Context , c * BotCommand , linkstashURL string , ev * event.Event , matrixClient * mautrix.Client , groqAPIKey string ) (string , error ) {
204+ func FetchBotCommand (ctx context.Context , c * BotCommand , linkstashURL string , ev * event.Event , matrixClient * mautrix.Client , groqAPIKey string , replyLabel string ) (string , error ) {
205205 if c .Response != "" {
206206 return c .Response , nil
207207 }
@@ -212,7 +212,7 @@ func FetchBotCommand(ctx context.Context, c *BotCommand, linkstashURL string, ev
212212 case "exec" :
213213 return handleExecCommand (ctx , ev , matrixClient , c )
214214 case "ai" :
215- return handleAiCommand (ctx , ev , matrixClient , c , groqAPIKey )
215+ return handleAiCommand (ctx , ev , matrixClient , c , groqAPIKey , replyLabel )
216216 default :
217217 return "" , fmt .Errorf ("unknown command type: %s" , c .Type )
218218 }
@@ -524,7 +524,7 @@ func handleExecCommand(ctx context.Context, ev *event.Event, matrixClient *mautr
524524}
525525
526526// handleAiCommand handles AI-based commands using Groq
527- func handleAiCommand (ctx context.Context , ev * event.Event , matrixClient * mautrix.Client , c * BotCommand , groqAPIKey string ) (string , error ) {
527+ func handleAiCommand (ctx context.Context , ev * event.Event , matrixClient * mautrix.Client , c * BotCommand , groqAPIKey string , replyLabel string ) (string , error ) {
528528 var targetText string
529529 // Track replied-to event ID if present so we can reply to the original
530530 var originalEventID id.EventID
@@ -740,9 +740,15 @@ func handleAiCommand(ctx context.Context, ev *event.Event, matrixClient *mautrix
740740 response := groqResp .Choices [0 ].Message .Content
741741 // If we fetched a replied-to event earlier, send the response directly as a reply to that event
742742 if originalEventID != "" {
743+ // Prefix reply with the configured label (fallback to "> ")
744+ label := replyLabel
745+ if label == "" {
746+ label = "> "
747+ }
748+ body := label + response
743749 content := event.MessageEventContent {
744750 MsgType : event .MsgText ,
745- Body : response ,
751+ Body : body ,
746752 RelatesTo : & event.RelatesTo {InReplyTo : & event.InReplyTo {EventID : originalEventID }},
747753 }
748754 _ , err := matrixClient .SendMessageEvent (ctx , ev .RoomID , event .EventMessage , & content )
0 commit comments