Files
simplex-chat/packages/simplex-chat-nodejs/examples/squaring-bot-readme.js
2026-01-15 17:17:38 +00:00

18 lines
614 B
JavaScript

(async () => {
const {bot} = await import("../dist/index.js")
const [chat, _user, _address] = await bot.run({
profile: {displayName: "Squaring bot example", fullName: ""},
dbOpts: {dbFilePrefix: "./squaring_bot", dbKey: ""},
options: {
addressSettings: {welcomeMessage: "Send a number, I will square it."},
},
onMessage: async (ci, content) => {
const n = +content.text
const reply = typeof n === "number" && !isNaN(n)
? `${n} * ${n} = ${n * n}`
: `this is not a number`
await chat.apiSendTextReply(ci, reply)
}
})
})()