Files
simplex-chat/packages/simplex-chat-nodejs/examples/squaring-bot-readme.js
T
sh 42dd36bf09 simplex-chat-nodejs: typed DbConfig (#6875)
* simplex-chat-nodejs: typed DbConfig for ChatApi.init and BotDbOpts

* simplex-chat-nodejs: regenerate typedoc docs for DbConfig

* simplex-chat-nodejs: rename DbConfig.kind to .type
2026-04-24 16:43:43 +01:00

18 lines
617 B
JavaScript

(async () => {
const {bot} = await import("../dist/index.js")
const [chat, _user, _address] = await bot.run({
profile: {displayName: "Squaring bot example", fullName: ""},
dbOpts: {type: "sqlite", filePrefix: "./squaring_bot"},
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)
}
})
})()