mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-03-31 16:15:55 +00:00
18 lines
614 B
JavaScript
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)
|
|
}
|
|
})
|
|
})()
|