@@ -201,7 +201,7 @@ await context.Response.WriteAsJsonAsync(new
201201
202202 logger . LogInformation ( "启动异步任务处理群聊消息" ) ;
203203 await Task . Factory . StartNew ( async ( ) =>
204- await Handler ( input . Event . message . content , input . Event . message . message_id , chatId , warehouse ,
204+ await Handler ( input . Event . message . message_id , input . Event . message . content , chatId , warehouse ,
205205 document , "chat_id" ) ) ;
206206 return ;
207207 }
@@ -229,7 +229,7 @@ private async Task Handler(string messageId, string content, string sessionId,
229229 logger . LogInformation ( "消息解析成功,IsText: {IsText}" , userInput ? . IsText ) ;
230230
231231 var history = new ChatHistory ( ) ;
232-
232+
233233 // 解析仓库的目录结构
234234 var path = document . GitPath ;
235235
@@ -376,7 +376,11 @@ private async Task Handler(string messageId, string content, string sessionId,
376376 sb = new StringBuilder ( Regex . Replace ( sb . ToString ( ) , @"<thinking>.*?<\/thinking>" , "" ,
377377 RegexOptions . IgnoreCase | RegexOptions . Singleline ) ) ;
378378
379- await SendMessages ( sessionId , sb . ToString ( ) , type ) ;
379+ // 解析sb的#标题
380+ var titleMatch = Regex . Match ( sb . ToString ( ) , @"#\s*(.+)" ) ;
381+ var title = titleMatch . Success ? titleMatch . Groups [ 1 ] . Value . Trim ( ) : "OpenDeepWiki 回复" ;
382+
383+ await SendRichMessage ( sessionId , title , sb . ToString ( ) , type ) ;
380384 logger . LogInformation ( "已发送回复消息给用户: {SessionId}" , sessionId ) ;
381385 }
382386 catch ( Exception exception )
@@ -397,6 +401,31 @@ await feiShuClient.SendMessages(
397401 sessionId ) , receiveIdType ) ;
398402 }
399403
404+ public async Task SendRichMessage ( string sessionId , string title , string text ,
405+ string receiveIdType = "open_id" )
406+ {
407+ await feiShuClient . SendMessages (
408+ new SendMessageInput ( JsonSerializer . Serialize ( new
409+ {
410+ zh_cn = new
411+ {
412+ title ,
413+ content = new object [ ]
414+ {
415+ new object [ ]
416+ {
417+ new
418+ {
419+ tag = "text" ,
420+ text ,
421+ }
422+ }
423+ }
424+ }
425+ } , JsonSerializerOptions . Web ) , "post" ,
426+ sessionId ) , receiveIdType ) ;
427+ }
428+
400429 public async Task SendImageMessages ( string sessionId , byte [ ] bytes , string receiveIdType = "open_id" )
401430 {
402431 await feiShuClient . SendImageAsync ( bytes , sessionId , receiveIdType ) ;
0 commit comments