bots: SimpleX Calculator demo bot (#7583)

* 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>
This commit is contained in:
Evgeny
2026-09-27 17:20:40 +01:00
committed by GitHub
co-authored by Evgeny @ SimpleX Chat
parent 4cb244441b
commit 643a9afad6
35 changed files with 1075 additions and 49 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ To distinguish SimpleX user profile as a bot, set its `peerType` property to `"b
### Configure bot commands
Bot commands are messages that start from `/` character. Normally, they would consist of lowercase latin letters, but commands can use any letters, digits and underscores. Commands can have parameters.
Bot commands are messages that start from `/` character. Normally, they would consist of lowercase latin letters, but commands can use any characters, including symbols such as `/+` or `/-`. Commands can have parameters.
All commands in messages will be highlighted in the chats with the bot, and when users tap them, they will be instantly sent. If the message has a single line and starts from `/` character, the whole message will be highlighted. Otherwise, if command is included as part of the message, it will be highlighted until the first space after `/` character: e.g., `/list` command in Directory service shows user's groups.
+48
View File
@@ -7,6 +7,7 @@ This file is generated automatically.
- [APIDeleteMyAddress](#apideletemyaddress)
- [APIShowMyAddress](#apishowmyaddress)
- [APISetProfileAddress](#apisetprofileaddress)
- [APISetUserDomain](#apisetuserdomain)
- [APISetAddressSettings](#apisetaddresssettings)
[Message commands](#message-commands)
@@ -246,6 +247,53 @@ ChatCmdError: Command error (only used in WebSockets API).
---
### APISetUserDomain
Set or remove SimpleX name of bot address. The name must be registered with the address short link.
*Network usage*: interactive.
**Parameters**:
- userId: int64
- simplexDomain: string?
**Syntax**:
```
/_set domain <userId>[ <simplexDomain>]
```
```javascript
'/_set domain ' + userId + (simplexDomain ? ' ' + simplexDomain : '') // JavaScript
```
```python
'/_set domain ' + str(userId) + ((' ' + simplexDomain) if simplexDomain is not None else '') # Python
```
**Responses**:
UserProfileUpdated: User profile updated.
- type: "userProfileUpdated"
- user: [User](./TYPES.md#user)
- fromProfile: [Profile](./TYPES.md#profile)
- toProfile: [Profile](./TYPES.md#profile)
- updateSummary: [UserProfileUpdateSummary](./TYPES.md#userprofileupdatesummary)
UserProfileNoChange: User profile was not changed.
- type: "userProfileNoChange"
- user: [User](./TYPES.md#user)
ChatCmdError: Command error (only used in WebSockets API).
- type: "chatCmdError"
- chatError: [ChatError](./TYPES.md#chaterror)
**Errors**:
- SimplexDomainNotReady: The name does not resolve to the address short link.
---
### APISetAddressSettings
Set bot address settings.
+8 -1
View File
@@ -81,6 +81,14 @@ chatCommandsDocsData =
("APIDeleteMyAddress", [], "Delete bot address.", ["CRUserContactLinkDeleted", "CRChatCmdError"], [], Just UNBackground, "/_delete_address " <> Param "userId"),
("APIShowMyAddress", [], "Get bot address and settings.", ["CRUserContactLink", "CRChatCmdError"], [], Nothing, "/_show_address " <> Param "userId"),
("APISetProfileAddress", [], "Add address to bot profile.", ["CRUserProfileUpdated", "CRUserProfileNoChange", "CRChatCmdError"], [], Just UNInteractive, "/_profile_address " <> Param "userId" <> " " <> OnOff "enable"),
( "APISetUserDomain",
[],
"Set or remove SimpleX name of bot address. The name must be registered with the address short link.",
["CRUserProfileUpdated", "CRUserProfileNoChange", "CRChatCmdError"],
[TD "CESimplexDomainNotReady" "The name does not resolve to the address short link"],
Just UNInteractive,
"/_set domain " <> Param "userId" <> Optional "" (" " <> Param "$0") "simplexDomain"
),
("APISetAddressSettings", [], "Set bot address settings.", ["CRUserContactLinkUpdated", "CRChatCmdError"], [], Just UNInteractive, "/_address_settings " <> Param "userId" <> OnOffParam "pq_ratchet" "pqRatchet" Nothing <> " " <> Json "settings")
]
),
@@ -438,7 +446,6 @@ undocumentedCommands =
"APISetServerOperators",
"APISetUserContactReceipts",
"APISetUserGroupReceipts",
"APISetUserDomain",
"APISetUserServers",
"APISetUserUIThemes",
"APIStandaloneFileInfo",