File tree Expand file tree Collapse file tree 4 files changed +26
-11
lines changed Expand file tree Collapse file tree 4 files changed +26
-11
lines changed Original file line number Diff line number Diff line change 1+ import { getMessageBody } from "@agents/helper" ;
12import { Agent , getTestUrl , logDetails } from "@agents/versions" ;
23import { APP_VERSION } from "@helpers/client" ;
34import { getSDKVersionInfo } from "@helpers/versions" ;
@@ -15,13 +16,12 @@ const agent = await Agent.createFromEnv({
1516} ) ;
1617
1718agent . on ( "text" , async ( ctx ) => {
19+ const messageBody1 = await getMessageBody ( ctx ) ;
1820 if ( ctx . isDm ( ) ) {
19- const messageContent = ctx . message . content ;
20- const senderAddress = await ctx . getSenderAddress ( ) ;
21- console . log ( `Received message: ${ messageContent } by ${ senderAddress } ` ) ;
22- await ctx . sendText ( "gm local " + ctx . conversation . id ) ;
23- } else if ( ctx . isGroup ( ) && ctx . message . content . includes ( "@gm" ) )
24- await ctx . sendText ( "gm local " + ctx . conversation . id ) ;
21+ await ctx . sendText ( messageBody1 ) ;
22+ } else if ( ctx . isGroup ( ) && ctx . message . content . includes ( "@gm" ) ) {
23+ await ctx . sendText ( messageBody1 ) ;
24+ }
2525} ) ;
2626
2727agent . on ( "start" , ( ) => {
Original file line number Diff line number Diff line change 1+ import { getMessageBody } from "@agents/helper" ;
12import {
23 ActionBuilder ,
34 initializeAppFromConfig ,
@@ -332,17 +333,15 @@ appConfig.menus["load-test-menu"].actions.forEach((action: MenuAction) => {
332333initializeAppFromConfig ( appConfig ) ;
333334
334335agent . on ( "text" , async ( ctx ) => {
335- console . log (
336- `Received text message in group (${ ctx . conversation . id } ): ${ ctx . message . content } by ${ await ctx . getSenderAddress ( ) } ` ,
337- ) ;
338-
336+ const messageBody1 = await getMessageBody ( ctx ) ;
339337 const message = ctx . message ;
340338 const content = message . content ;
341339 const isTagged =
342340 content . trim ( ) . startsWith ( "@kc" ) ||
343341 content . trim ( ) . startsWith ( "/kc" ) ||
344342 content . trim ( ) . startsWith ( "@key-check.eth" ) ;
345343 if ( isTagged ) {
344+ await ctx . sendText ( messageBody1 ) ;
346345 await showMenu ( ctx , appConfig , "main-menu" ) ;
347346 return ;
348347 }
Original file line number Diff line number Diff line change 11import { type DecodedMessage } from "@helpers/versions" ;
2+ import type { MessageContext } from "@xmtp/agent-sdk" ;
23
34/**
45 * Agent configuration interface
@@ -18,6 +19,21 @@ export interface AgentConfig {
1819 live : boolean ;
1920}
2021
22+ export async function getMessageBody ( ctx : MessageContext ) {
23+ try {
24+ const messageContent = ctx . message . content as string ;
25+ const senderAddress = ( await ctx . getSenderAddress ( ) ) as string ;
26+
27+ const messageBody1 = `replying content: ${ messageContent } sent by ${ senderAddress } on ${ ctx . message . sentAt . toISOString ( ) } on converstion ${ ctx . conversation . id } ` ;
28+
29+ console . log ( messageBody1 ) ;
30+ return messageBody1 ;
31+ } catch ( error ) {
32+ console . error ( "Error getting message body" , error ) ;
33+ return "Error getting message body" ;
34+ }
35+ }
36+
2137/**
2238 * Options for waitForResponse function
2339 */
Original file line number Diff line number Diff line change 1- {"deployedAt" : " 2025-11-25T17:15:39Z" , "version" : " 0.5.0 " }
1+ {"deployedAt" : " 2025-11-25T17:15:39Z" , "version" : " 0.5.1 " }
You can’t perform that action at this time.
0 commit comments