@@ -44,6 +44,7 @@ import "@std/dotenv/load";
4444import { encodeBase64 } from "@std/encoding/base64" ;
4545import { join } from "@std/path/join" ;
4646import { AsyncLocalStorage } from "node:async_hooks" ;
47+ import { detect } from "tinyld" ;
4748import { FilterXSS } from "xss" ;
4849import metadata from "./deno.json" with { type : "json" } ;
4950
@@ -106,9 +107,11 @@ bot.onFollow = async (session, actor) => {
106107 await getIntroMessage ( session , actor , await getFollowPrompt ( actor ) ) ,
107108 ] ) ;
108109 const message = response . content . toString ( ) ;
110+ const language = detect ( message ) ;
109111 const md : Text < "block" , void > = markdown ( message ) ;
110112 await session . publish (
111113 await mentions ( session , md , actor ) ? md : text `${ mention ( actor ) } \n\n${ md } ` ,
114+ { language } ,
112115 ) ;
113116} ;
114117
@@ -121,9 +124,11 @@ bot.onMention = async (session, msg) => {
121124 await getHumanMessage ( msg ) ,
122125 ] ) ;
123126 const message = response . content . toString ( ) ;
127+ const language = detect ( message ) ;
124128 const md : Text < "block" , void > = markdown ( message ) ;
125129 await msg . reply (
126130 await mentions ( session , md , actor ) ? md : text `${ mention ( actor ) } \n\n${ md } ` ,
131+ { language } ,
127132 ) ;
128133} ;
129134
@@ -150,11 +155,13 @@ bot.onReply = async (session, msg) => {
150155 }
151156 const response = await llm . invoke ( messages ) ;
152157 const message = response . content . toString ( ) ;
158+ const language = detect ( message ) ;
153159 const md : Text < "block" , void > = markdown ( message ) ;
154160 await msg . reply (
155161 await mentions ( session , md , msg . actor )
156162 ? md
157163 : text `${ mention ( msg . actor ) } \n\n${ md } ` ,
164+ { language } ,
158165 ) ;
159166} ;
160167
0 commit comments