Skip to content

Commit 8606815

Browse files
committed
gm-text abstraction
1 parent 5eed7d0 commit 8606815

File tree

2 files changed

+99
-252
lines changed

2 files changed

+99
-252
lines changed

examples/gm-text/src/index.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
import { xmtpClient, type Message } from "./lib/helper.js";
1+
import { send, xmtpClient, type DecodedMessage } from "./lib/helper.js";
22

33
async function main() {
44
const client = await xmtpClient({
55
walletKey: process.env.WALLET_KEY as string,
6-
onMessage: async (message: Message) => {
7-
console.log(
8-
`Decoded message: ${message.content.text} by ${message.sender.address}`,
9-
);
10-
await client.send({
11-
message: "gm",
12-
originalMessage: message,
13-
});
6+
onMessage: async (message: DecodedMessage) => {
7+
console.log(message);
8+
await send("gm", message.senderInboxId, client);
149
},
1510
});
1611

1712
console.log(
18-
`XMTP agent initialized on ${client.address}\nSend a message on https://converse.xyz/dm/${client.address}`,
13+
`XMTP agent initialized on ${client.accountAddress}\nSend a message on https://xmtp.chat/dm/${client.accountAddress}`,
1914
);
2015
}
2116

0 commit comments

Comments
 (0)