@shhhum/simplex-chat 0.0.0-stage → 7.1.0-beta.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +129 -2
- package/dist/api.d.ts +439 -0
- package/dist/api.js +911 -0
- package/dist/api.js.map +1 -0
- package/dist/bot.d.ts +34 -0
- package/dist/bot.js +194 -0
- package/dist/bot.js.map +1 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +46 -0
- package/dist/cli.js.map +1 -0
- package/dist/core.d.ts +138 -0
- package/dist/core.js +144 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/libs.d.ts +12 -0
- package/dist/libs.js +210 -0
- package/dist/libs.js.map +1 -0
- package/dist/release.d.ts +5 -0
- package/dist/release.js +20 -0
- package/dist/release.js.map +1 -0
- package/dist/simplex.d.ts +12 -0
- package/dist/simplex.js +22 -0
- package/dist/util.d.ts +15 -0
- package/dist/util.js +91 -0
- package/dist/util.js.map +1 -0
- package/docs/Namespace.api.md +33 -0
- package/docs/Namespace.bot.md +24 -0
- package/docs/Namespace.core.md +50 -0
- package/docs/Namespace.util.md +25 -0
- package/docs/README.md +12 -0
- package/docs/api.Class.ChatApi.md +1851 -0
- package/docs/api.Class.ChatCommandError.md +205 -0
- package/docs/api.Enumeration.ConnReqType.md +27 -0
- package/docs/api.Interface.BotAddressSettings.md +60 -0
- package/docs/api.TypeAlias.DbConfig.md +62 -0
- package/docs/api.TypeAlias.EventSubscriberFunc.md +31 -0
- package/docs/api.TypeAlias.EventSubscribers.md +11 -0
- package/docs/api.Variable.defaultBotAddressSettings.md +11 -0
- package/docs/bot.Function.run.md +21 -0
- package/docs/bot.Function.subscribeChatItems.md +27 -0
- package/docs/bot.Interface.BotConfig.md +87 -0
- package/docs/bot.Interface.BotOptions.md +81 -0
- package/docs/bot.TypeAlias.BotDbOpts.md +21 -0
- package/docs/core.Class.ChatAPIError.md +205 -0
- package/docs/core.Class.ChatInitError.md +205 -0
- package/docs/core.DBMigrationError.Interface.ErrorMigration.md +41 -0
- package/docs/core.DBMigrationError.Interface.ErrorNotADatabase.md +33 -0
- package/docs/core.DBMigrationError.Interface.ErrorSQL.md +41 -0
- package/docs/core.DBMigrationError.Interface.InvalidConfirmation.md +25 -0
- package/docs/core.DBMigrationError.Interface.InvalidQueueSize.md +25 -0
- package/docs/core.DBMigrationError.TypeAlias.Tag.md +11 -0
- package/docs/core.Enumeration.MigrationConfirmation.md +43 -0
- package/docs/core.Function.chatCloseStore.md +23 -0
- package/docs/core.Function.chatDecryptFile.md +31 -0
- package/docs/core.Function.chatEncryptFile.md +31 -0
- package/docs/core.Function.chatMigrateInit.md +37 -0
- package/docs/core.Function.chatReadFile.md +27 -0
- package/docs/core.Function.chatRecvMsgWait.md +27 -0
- package/docs/core.Function.chatSendCmd.md +27 -0
- package/docs/core.Function.chatWriteFile.md +31 -0
- package/docs/core.Function.loadLibrary.md +24 -0
- package/docs/core.Interface.APIResult.md +31 -0
- package/docs/core.Interface.CryptoArgs.md +27 -0
- package/docs/core.Interface.UpMigration.md +25 -0
- package/docs/core.MTRError.Interface.MTREDifferent.md +33 -0
- package/docs/core.MTRError.Interface.MTRENoDown.md +33 -0
- package/docs/core.MTRError.TypeAlias.Tag.md +11 -0
- package/docs/core.MigrationError.Interface.MEDowngrade.md +33 -0
- package/docs/core.MigrationError.Interface.MEUpgrade.md +33 -0
- package/docs/core.MigrationError.Interface.MigrationError.md +33 -0
- package/docs/core.MigrationError.TypeAlias.Tag.md +11 -0
- package/docs/core.Namespace.DBMigrationError.md +19 -0
- package/docs/core.Namespace.MTRError.md +16 -0
- package/docs/core.Namespace.MigrationError.md +17 -0
- package/docs/core.TypeAlias.Backend.md +11 -0
- package/docs/core.TypeAlias.DBMigrationError.md +11 -0
- package/docs/core.TypeAlias.MTRError.md +11 -0
- package/docs/core.TypeAlias.MigrationError.md +11 -0
- package/docs/util.Function.botAddressSettings.md +21 -0
- package/docs/util.Function.chatInfoName.md +21 -0
- package/docs/util.Function.chatInfoRef.md +21 -0
- package/docs/util.Function.ciBotCommand.md +21 -0
- package/docs/util.Function.ciContentText.md +21 -0
- package/docs/util.Function.contactAddressStr.md +21 -0
- package/docs/util.Function.fromLocalProfile.md +21 -0
- package/docs/util.Function.reactionText.md +21 -0
- package/docs/util.Function.senderName.md +25 -0
- package/docs/util.Interface.BotCommand.md +25 -0
- package/examples/squaring-bot-readme.js +17 -0
- package/examples/squaring-bot.ts +42 -0
- package/package.json +55 -4
- package/src/api.ts +997 -0
- package/src/bot.ts +221 -0
- package/src/cli.ts +42 -0
- package/src/core.ts +240 -0
- package/src/index.ts +22 -0
- package/src/libs.ts +202 -0
- package/src/release.ts +19 -0
- package/src/simplex.d.ts +12 -0
- package/src/simplex.js +22 -0
- package/src/util.ts +92 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[**simplex-chat**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[simplex-chat](README.md) / [util](Namespace.util.md) / contactAddressStr
|
|
6
|
+
|
|
7
|
+
# Function: contactAddressStr()
|
|
8
|
+
|
|
9
|
+
> **contactAddressStr**(`link`): `string`
|
|
10
|
+
|
|
11
|
+
Defined in: [src/util.ts:44](../src/util.ts#L44)
|
|
12
|
+
|
|
13
|
+
## Parameters
|
|
14
|
+
|
|
15
|
+
### link
|
|
16
|
+
|
|
17
|
+
`CreatedConnLink`
|
|
18
|
+
|
|
19
|
+
## Returns
|
|
20
|
+
|
|
21
|
+
`string`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[**simplex-chat**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[simplex-chat](README.md) / [util](Namespace.util.md) / fromLocalProfile
|
|
6
|
+
|
|
7
|
+
# Function: fromLocalProfile()
|
|
8
|
+
|
|
9
|
+
> **fromLocalProfile**(`__namedParameters`): `Profile`
|
|
10
|
+
|
|
11
|
+
Defined in: [src/util.ts:56](../src/util.ts#L56)
|
|
12
|
+
|
|
13
|
+
## Parameters
|
|
14
|
+
|
|
15
|
+
### \_\_namedParameters
|
|
16
|
+
|
|
17
|
+
`LocalProfile`
|
|
18
|
+
|
|
19
|
+
## Returns
|
|
20
|
+
|
|
21
|
+
`Profile`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[**simplex-chat**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[simplex-chat](README.md) / [util](Namespace.util.md) / reactionText
|
|
6
|
+
|
|
7
|
+
# Function: reactionText()
|
|
8
|
+
|
|
9
|
+
> **reactionText**(`reaction`): `string`
|
|
10
|
+
|
|
11
|
+
Defined in: [src/util.ts:89](../src/util.ts#L89)
|
|
12
|
+
|
|
13
|
+
## Parameters
|
|
14
|
+
|
|
15
|
+
### reaction
|
|
16
|
+
|
|
17
|
+
`ACIReaction`
|
|
18
|
+
|
|
19
|
+
## Returns
|
|
20
|
+
|
|
21
|
+
`string`
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[**simplex-chat**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[simplex-chat](README.md) / [util](Namespace.util.md) / senderName
|
|
6
|
+
|
|
7
|
+
# Function: senderName()
|
|
8
|
+
|
|
9
|
+
> **senderName**(`cInfo`, `chatDir`): `string`
|
|
10
|
+
|
|
11
|
+
Defined in: [src/util.ts:37](../src/util.ts#L37)
|
|
12
|
+
|
|
13
|
+
## Parameters
|
|
14
|
+
|
|
15
|
+
### cInfo
|
|
16
|
+
|
|
17
|
+
`ChatInfo`
|
|
18
|
+
|
|
19
|
+
### chatDir
|
|
20
|
+
|
|
21
|
+
`CIDirection`
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`string`
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[**simplex-chat**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[simplex-chat](README.md) / [util](Namespace.util.md) / BotCommand
|
|
6
|
+
|
|
7
|
+
# Interface: BotCommand
|
|
8
|
+
|
|
9
|
+
Defined in: [src/util.ts:72](../src/util.ts#L72)
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### keyword
|
|
14
|
+
|
|
15
|
+
> **keyword**: `string`
|
|
16
|
+
|
|
17
|
+
Defined in: [src/util.ts:73](../src/util.ts#L73)
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### params
|
|
22
|
+
|
|
23
|
+
> **params**: `string`
|
|
24
|
+
|
|
25
|
+
Defined in: [src/util.ts:74](../src/util.ts#L74)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
(async () => {
|
|
2
|
+
const {bot} = await import("../dist/index.js")
|
|
3
|
+
await bot.run({
|
|
4
|
+
profile: {displayName: "Squaring bot example", fullName: ""},
|
|
5
|
+
dbOpts: {type: "sqlite", filePrefix: "./squaring_bot"},
|
|
6
|
+
options: {
|
|
7
|
+
addressSettings: {welcomeMessage: "Send a number, I will square it."},
|
|
8
|
+
},
|
|
9
|
+
onMessage: async (ci, content, chat) => {
|
|
10
|
+
const n = +content.text
|
|
11
|
+
const reply = typeof n === "number" && !isNaN(n)
|
|
12
|
+
? `${n} * ${n} = ${n * n}`
|
|
13
|
+
: `this is not a number`
|
|
14
|
+
await chat.apiSendTextReply(ci, reply)
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
})()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {T} from "@simplex-chat/types"
|
|
2
|
+
import {bot, util} from "../dist"
|
|
3
|
+
|
|
4
|
+
(async () => {
|
|
5
|
+
const welcomeMessage = "Hello! I am a simple squaring bot.\n\nIf you send me a number, I will calculate its square."
|
|
6
|
+
await bot.run({
|
|
7
|
+
profile: {displayName: "Squaring bot example", fullName: ""},
|
|
8
|
+
dbOpts: {type: "sqlite", filePrefix: "./squaring_bot"},
|
|
9
|
+
options: {
|
|
10
|
+
addressSettings: {autoAccept: true, welcomeMessage, businessAddress: false},
|
|
11
|
+
commands: [ // commands to show in client UI
|
|
12
|
+
{type: "command", keyword: "help", label: "Send welcome message"},
|
|
13
|
+
{type: "command", keyword: "info", label: "More information (not implemented)"}
|
|
14
|
+
],
|
|
15
|
+
logContacts: true,
|
|
16
|
+
logNetwork: false
|
|
17
|
+
},
|
|
18
|
+
onMessage: async (ci, content, chat) => {
|
|
19
|
+
const n = +content.text
|
|
20
|
+
const reply = typeof n === "number" && !isNaN(n)
|
|
21
|
+
? `${n} * ${n} = ${n * n}`
|
|
22
|
+
: `this is not a number`
|
|
23
|
+
await chat.apiSendTextReply(ci, reply)
|
|
24
|
+
},
|
|
25
|
+
onCommands: { // command handlers can be different from commands to be shown in client UI
|
|
26
|
+
"help": async (ci: T.AChatItem, _cmd: util.BotCommand, chat) => {
|
|
27
|
+
await chat.apiSendTextMessage(ci.chatInfo, welcomeMessage)
|
|
28
|
+
},
|
|
29
|
+
// fallback handler that will be called for all other commands
|
|
30
|
+
"": async (ci: T.AChatItem, _cmd: util.BotCommand, chat) => {
|
|
31
|
+
await chat.apiSendTextReply(ci, "This command is not supported")
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
// If you use `onMessage` and subscribe to "newChatItems" event, exclude content messages from processing
|
|
35
|
+
// If you use `onCommands` and subscribe to "newChatItems" event, exclude commands from processing
|
|
36
|
+
events: {
|
|
37
|
+
"chatItemReaction": ({added, reaction}) => {
|
|
38
|
+
console.log(`${util.senderName(reaction.chatInfo, reaction.chatReaction.chatDir)} ${added ? "added" : "removed"} reaction ${util.reactionText(reaction)}`)
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
})()
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shhhum/simplex-chat",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "7.1.0-beta.6.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"bin": {
|
|
7
|
+
"simplex-chat": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"dist",
|
|
12
|
+
"tsconfig.json",
|
|
13
|
+
"docs",
|
|
14
|
+
"examples"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"install-tools": "npm install -g node-gyp",
|
|
18
|
+
"configure": "node-gyp configure",
|
|
19
|
+
"build": "node-gyp rebuild && tsc && cp ./src/simplex.* ./dist",
|
|
20
|
+
"run": "node src/index.js",
|
|
21
|
+
"build-run": "node-gyp build && node src/index.js",
|
|
22
|
+
"test": "jest",
|
|
23
|
+
"docs": "typedoc"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@simplex-chat/types": "npm:@shhhum/types@^0.12.1",
|
|
27
|
+
"extract-zip": "^2.0.1",
|
|
28
|
+
"fast-deep-equal": "^3.1.3"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/jest": "^30.0.0",
|
|
32
|
+
"@types/node": "^25.0.5",
|
|
33
|
+
"jest": "^30.2.0",
|
|
34
|
+
"node-addon-api": "^8.5.0",
|
|
35
|
+
"ts-jest": "^29.4.6",
|
|
36
|
+
"typedoc": "^0.28.15",
|
|
37
|
+
"typedoc-plugin-markdown": "^4.9.0",
|
|
38
|
+
"typescript": "^5.9.3"
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/shumvgolove/sx.git"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"messenger",
|
|
46
|
+
"chat",
|
|
47
|
+
"privacy",
|
|
48
|
+
"security"
|
|
49
|
+
],
|
|
50
|
+
"author": "SimpleX Chat",
|
|
51
|
+
"license": "AGPL-3.0",
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/simplex-chat/simplex-chat/issues"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://github.com/simplex-chat/simplex-chat/tree/stable/packages/simplex-chat-nodejs#readme",
|
|
56
|
+
"description": "SimpleX Chat Node.js library for chat bots"
|
|
57
|
+
}
|