@riseonly/sdk 0.1.1 → 0.1.3
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 +51 -9
- package/dist/index.cjs +350 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +84 -35
- package/dist/index.d.ts +84 -35
- package/dist/index.js +350 -81
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -15,14 +15,13 @@ import { RiseonlyBot } from '@riseonly/sdk';
|
|
|
15
15
|
|
|
16
16
|
const bot = new RiseonlyBot(process.env.BOT_TOKEN, { polling: true });
|
|
17
17
|
|
|
18
|
-
bot.
|
|
19
|
-
|
|
20
|
-
await bot.sendMessage({
|
|
21
|
-
chat_id: message.chat.id,
|
|
22
|
-
text: 'welcome to riseonly',
|
|
23
|
-
});
|
|
24
|
-
}
|
|
18
|
+
bot.command('start', async (message) => {
|
|
19
|
+
await bot.reply(message, 'Welcome to Riseonly');
|
|
25
20
|
});
|
|
21
|
+
|
|
22
|
+
bot.hears(/hello/i, (message) => bot.reply(message, 'Hi!'));
|
|
23
|
+
bot.action(/^track:/, (query) => bot.answer(query, 'Loading track…'));
|
|
24
|
+
bot.catch((error) => console.error('Bot handler failed', error));
|
|
26
25
|
```
|
|
27
26
|
|
|
28
27
|
## Bot API client
|
|
@@ -37,7 +36,8 @@ const api = new ApiClient(process.env.BOT_TOKEN, {
|
|
|
37
36
|
});
|
|
38
37
|
|
|
39
38
|
const me = await api.getMe();
|
|
40
|
-
|
|
39
|
+
console.log(`Connected as @${me.username}`);
|
|
40
|
+
await api.sendMessage({ chat_id: 'chat-id', text: 'hello' });
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## Webhooks
|
|
@@ -65,7 +65,49 @@ await bot.startWebhook({
|
|
|
65
65
|
});
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Webhook handlers return a retryable HTTP 500 when your application handler fails. Updates are acknowledged only after handlers finish successfully.
|
|
69
|
+
|
|
70
|
+
## Configure from code
|
|
71
|
+
|
|
72
|
+
Keep bot commands and delivery configuration in source control instead of repeating setup by hand:
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
await bot.setup({
|
|
76
|
+
name: 'Music Bot',
|
|
77
|
+
description: 'Find and preview music',
|
|
78
|
+
profilePhoto: { url: 'https://cdn.example.com/music-bot.jpg' },
|
|
79
|
+
commands: [
|
|
80
|
+
{ command: 'start', description: 'Start the bot' },
|
|
81
|
+
{ command: 'help', description: 'Show help' },
|
|
82
|
+
],
|
|
83
|
+
webhook: false,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
await bot.launch();
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Use `webhook: { url, secret_token }` to configure webhook delivery instead. `bot.stop()` gracefully stops polling and the built-in webhook server.
|
|
90
|
+
|
|
91
|
+
Profile settings written by `setup()` use the same backend source of truth as the Riseonly owner settings screen, so changes are immediately visible in the app. Individual `setMyName`, `getMyName`, `setMyDescription`, `getMyDescription`, `setMyProfilePhoto`, and `removeMyProfilePhoto` methods are also available.
|
|
92
|
+
|
|
93
|
+
## Media metadata
|
|
94
|
+
|
|
95
|
+
Remote HTTPS media can include metadata used by Riseonly clients:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
await bot.sendAudio({
|
|
99
|
+
url: 'https://cdn.example.com/song.mp3',
|
|
100
|
+
file_name: 'Artist - Song.mp3',
|
|
101
|
+
mime_type: 'audio/mpeg',
|
|
102
|
+
thumbnail_url: 'https://cdn.example.com/cover.jpg',
|
|
103
|
+
duration: 180,
|
|
104
|
+
}, {
|
|
105
|
+
chat_id: 'chat-id',
|
|
106
|
+
caption: 'Artist — Song',
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Express / Fastify webhook adapter
|
|
69
111
|
|
|
70
112
|
```js
|
|
71
113
|
import express from 'express';
|