@aulynk/bot-api 0.1.6 → 0.1.7-ci.0
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/README.md +98 -98
- package/package.json +39 -39
package/README.md
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
# @aulynk/bot-api
|
|
2
|
-
|
|
3
|
-
Bot API SDK for [Aulynk](https://aulynk.ru) self-hosted messenger.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @aulynk/bot-api
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { AulynkBot, Keyboard } from '@aulynk/bot-api';
|
|
15
|
-
|
|
16
|
-
const bot = new AulynkBot('bot_your_token_here', {
|
|
17
|
-
server: 'https://aulynk.example.com',
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Handle all messages
|
|
21
|
-
bot.onMessage((msg) => {
|
|
22
|
-
console.log(`${msg.author.name}: ${msg.text}`);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Handle commands
|
|
26
|
-
bot.onCommand('/help', (msg) => {
|
|
27
|
-
bot.sendMessage(msg.chatId, {
|
|
28
|
-
text: '**Commands:**\n- /help\n- /status\n- /deploy',
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Inline buttons
|
|
33
|
-
bot.onCommand('/deploy', (msg) => {
|
|
34
|
-
bot.sendMessage(msg.chatId, {
|
|
35
|
-
text: 'Select environment:',
|
|
36
|
-
buttons: Keyboard.inline([
|
|
37
|
-
[Keyboard.button('Production', 'deploy:prod')],
|
|
38
|
-
[Keyboard.button('Staging', 'deploy:staging')],
|
|
39
|
-
]),
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Handle button press
|
|
44
|
-
bot.onCallback('deploy:*', async (cb) => {
|
|
45
|
-
const env = cb.data.split(':')[1];
|
|
46
|
-
await bot.editMessage(cb.chatId, cb.messageId, {
|
|
47
|
-
text: `Deploying to ${env}...`,
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Error handling
|
|
52
|
-
bot.onError((err) => console.error('Bot error:', err));
|
|
53
|
-
|
|
54
|
-
// Start polling
|
|
55
|
-
bot.start();
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## API
|
|
59
|
-
|
|
60
|
-
### `new AulynkBot(token, options)`
|
|
61
|
-
|
|
62
|
-
| Option | Type | Default | Description |
|
|
63
|
-
|--------|------|---------|-------------|
|
|
64
|
-
| `server` | `string` | required | Server URL |
|
|
65
|
-
| `pollingInterval` | `number` | `300` | Polling interval (ms) |
|
|
66
|
-
| `pollingTimeout` | `number` | `30` | Long polling timeout (sec) |
|
|
67
|
-
|
|
68
|
-
### Event Handlers
|
|
69
|
-
|
|
70
|
-
- `bot.onMessage(handler)` — all incoming messages
|
|
71
|
-
- `bot.onCommand('/cmd', handler)` — specific command
|
|
72
|
-
- `bot.onCallback('pattern:*', handler)` — callback button press (glob)
|
|
73
|
-
- `bot.onError(handler)` — error handler
|
|
74
|
-
|
|
75
|
-
### Actions
|
|
76
|
-
|
|
77
|
-
- `bot.sendMessage(chatId, { text, buttons?, silent? })` — send message
|
|
78
|
-
- `bot.editMessage(chatId, messageId, { text?, buttons? })` — edit message
|
|
79
|
-
- `bot.deleteMessage(chatId, messageId)` — delete message
|
|
80
|
-
- `bot.getMe()` — bot info
|
|
81
|
-
- `bot.getChat(chatId)` — chat info
|
|
82
|
-
- `bot.getChatMembers(chatId)` — chat members
|
|
83
|
-
|
|
84
|
-
### Keyboard Helper
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
import { Keyboard } from '@aulynk/bot-api';
|
|
88
|
-
|
|
89
|
-
Keyboard.button('Text', 'callback_data') // callback button
|
|
90
|
-
Keyboard.url('Text', 'https://...') // URL button
|
|
91
|
-
Keyboard.inline([[btn1, btn2], [btn3]]) // layout
|
|
92
|
-
Keyboard.row(btn1, btn2) // single row
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## License
|
|
96
|
-
|
|
97
|
-
MIT
|
|
1
|
+
# @aulynk/bot-api
|
|
2
|
+
|
|
3
|
+
Bot API SDK for [Aulynk](https://aulynk.ru) self-hosted messenger.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @aulynk/bot-api
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { AulynkBot, Keyboard } from '@aulynk/bot-api';
|
|
15
|
+
|
|
16
|
+
const bot = new AulynkBot('bot_your_token_here', {
|
|
17
|
+
server: 'https://aulynk.example.com',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Handle all messages
|
|
21
|
+
bot.onMessage((msg) => {
|
|
22
|
+
console.log(`${msg.author.name}: ${msg.text}`);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Handle commands
|
|
26
|
+
bot.onCommand('/help', (msg) => {
|
|
27
|
+
bot.sendMessage(msg.chatId, {
|
|
28
|
+
text: '**Commands:**\n- /help\n- /status\n- /deploy',
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Inline buttons
|
|
33
|
+
bot.onCommand('/deploy', (msg) => {
|
|
34
|
+
bot.sendMessage(msg.chatId, {
|
|
35
|
+
text: 'Select environment:',
|
|
36
|
+
buttons: Keyboard.inline([
|
|
37
|
+
[Keyboard.button('Production', 'deploy:prod')],
|
|
38
|
+
[Keyboard.button('Staging', 'deploy:staging')],
|
|
39
|
+
]),
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Handle button press
|
|
44
|
+
bot.onCallback('deploy:*', async (cb) => {
|
|
45
|
+
const env = cb.data.split(':')[1];
|
|
46
|
+
await bot.editMessage(cb.chatId, cb.messageId, {
|
|
47
|
+
text: `Deploying to ${env}...`,
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Error handling
|
|
52
|
+
bot.onError((err) => console.error('Bot error:', err));
|
|
53
|
+
|
|
54
|
+
// Start polling
|
|
55
|
+
bot.start();
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
### `new AulynkBot(token, options)`
|
|
61
|
+
|
|
62
|
+
| Option | Type | Default | Description |
|
|
63
|
+
|--------|------|---------|-------------|
|
|
64
|
+
| `server` | `string` | required | Server URL |
|
|
65
|
+
| `pollingInterval` | `number` | `300` | Polling interval (ms) |
|
|
66
|
+
| `pollingTimeout` | `number` | `30` | Long polling timeout (sec) |
|
|
67
|
+
|
|
68
|
+
### Event Handlers
|
|
69
|
+
|
|
70
|
+
- `bot.onMessage(handler)` — all incoming messages
|
|
71
|
+
- `bot.onCommand('/cmd', handler)` — specific command
|
|
72
|
+
- `bot.onCallback('pattern:*', handler)` — callback button press (glob)
|
|
73
|
+
- `bot.onError(handler)` — error handler
|
|
74
|
+
|
|
75
|
+
### Actions
|
|
76
|
+
|
|
77
|
+
- `bot.sendMessage(chatId, { text, buttons?, silent? })` — send message
|
|
78
|
+
- `bot.editMessage(chatId, messageId, { text?, buttons? })` — edit message
|
|
79
|
+
- `bot.deleteMessage(chatId, messageId)` — delete message
|
|
80
|
+
- `bot.getMe()` — bot info
|
|
81
|
+
- `bot.getChat(chatId)` — chat info
|
|
82
|
+
- `bot.getChatMembers(chatId)` — chat members
|
|
83
|
+
|
|
84
|
+
### Keyboard Helper
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { Keyboard } from '@aulynk/bot-api';
|
|
88
|
+
|
|
89
|
+
Keyboard.button('Text', 'callback_data') // callback button
|
|
90
|
+
Keyboard.url('Text', 'https://...') // URL button
|
|
91
|
+
Keyboard.inline([[btn1, btn2], [btn3]]) // layout
|
|
92
|
+
Keyboard.row(btn1, btn2) // single row
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|
|
98
98
|
|
|
99
99
|
## Releases
|
|
100
100
|
|
|
101
101
|
Run `npm version patch` (or use `minor` or `major`), then push the commit and version tag with `git push --follow-tags`. The tag must match the version in `package.json`. GitHub Actions publishes stable versions to npm and prereleases under the `next` dist-tag.
|
|
102
102
|
|
|
103
|
-
For the initial setup, publish the first version from an npm account with write access to the `@aulynk` scope. Then configure a GitHub Actions Trusted Publisher in the npm package settings. Use the `Aulynk` organization, this repository, and the `publish.yml` workflow. Enable direct publishing.
|
|
103
|
+
For the initial setup, publish the first version from an npm account with write access to the `@aulynk` scope. Then configure a GitHub Actions Trusted Publisher in the npm package settings. Use the `Aulynk` organization, this repository, and the `publish.yml` workflow. Enable direct publishing.
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@aulynk/bot-api",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Bot API SDK for Aulynk messenger",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "tsc",
|
|
12
|
-
"dev": "tsc --watch",
|
|
13
|
-
"prepublishOnly": "npm run build"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"aulynk",
|
|
17
|
-
"bot",
|
|
18
|
-
"api",
|
|
19
|
-
"messenger",
|
|
20
|
-
"chat"
|
|
21
|
-
],
|
|
22
|
-
"author": "Aulynk",
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"publishConfig": {
|
|
25
|
-
"registry": "https://registry.npmjs.org/",
|
|
26
|
-
"access": "public"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/node": "^25.6.0",
|
|
30
|
-
"typescript": "^5.5.0"
|
|
31
|
-
},
|
|
32
|
-
"repository": {
|
|
33
|
-
"type": "git",
|
|
34
|
-
"url": "git+https://github.com/Aulynk/aulynk-bot-api.git"
|
|
35
|
-
},
|
|
36
|
-
"bugs": {
|
|
37
|
-
"url": "https://github.com/Aulynk/aulynk-bot-api/issues"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@aulynk/bot-api",
|
|
3
|
+
"version": "0.1.7-ci.0",
|
|
4
|
+
"description": "Bot API SDK for Aulynk messenger",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"aulynk",
|
|
17
|
+
"bot",
|
|
18
|
+
"api",
|
|
19
|
+
"messenger",
|
|
20
|
+
"chat"
|
|
21
|
+
],
|
|
22
|
+
"author": "Aulynk",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"registry": "https://registry.npmjs.org/",
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^25.6.0",
|
|
30
|
+
"typescript": "^5.5.0"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/Aulynk/aulynk-bot-api.git"
|
|
35
|
+
},
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/Aulynk/aulynk-bot-api/issues"
|
|
38
|
+
}
|
|
39
|
+
}
|