mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-28 17:49:07 +00:00
* bots: SimpleX Calculator demo bot * refactor * use local server in test * simplify * icon * simplify * expression * replies * improve * log * update name in bot address * @simplex-chat/type: 0.12.0 * simplex-chat nodejs: 7.1.0-beta.4.2 * update dependencies * option to add domain to bot address --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
18 lines
591 B
JavaScript
18 lines
591 B
JavaScript
(async () => {
|
|
const {bot} = await import("../dist/index.js")
|
|
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, chat) => {
|
|
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)
|
|
}
|
|
})
|
|
})()
|