halbot 1989.6.8 → 1989.6.10

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.
Files changed (2) hide show
  1. package/README.md +77 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,19 +5,34 @@
5
5
 
6
6
  Just another `ChatGPT`/`Bing Chat` Telegram bob, which is simple design, easy to use, extendable and fun.
7
7
 
8
- Features
8
+ ## Features
9
9
 
10
- - Telegram Bot (`Telegram Bot` token required)
11
- - ChatGPT (`OpenAI` API key required)
12
- - Bing Chat (`Bing Chat` user token required)
13
- - Speech-to-text (`Google Cloud` API key required)
14
- - Text-to-speech (`Google Cloud` API key required)
10
+ - Telegram Bot (`Telegram Bot` token required);
11
+ - ChatGPT (`OpenAI` API key required);
12
+ - Bing Chat (`Bing Chat` user token required);
13
+ - Speech-to-text (`Google Cloud` API key required, or your own engine);
14
+ - Text-to-speech (`Google Cloud` API key required, or your own engine);
15
+ - Support `private` and `public` mode, with multiple authenticate methods;
16
+ - `Middleware` style workflow, easy to extend;
15
17
 
16
18
  ## How to use
17
19
 
18
- Make the `halbot` json config file and put it in this path `~/.halbot.json`:
20
+ ### Config
21
+
22
+ Make the `halbot` json config file and put it in this path `~/.halbot.json`.
23
+
24
+ #### Basic config demo
19
25
 
20
26
  ```json
27
+ {
28
+ "telegramToken": "[[Telegram Bot API Token]]",
29
+ "chatGptKey": "[[ChatGPT API Key]]",
30
+ }
31
+ ```
32
+
33
+ #### All supported configuration fields
34
+
35
+ ```js
21
36
  {
22
37
  // REQUIRED, string.
23
38
  "telegramToken": "[[Telegram Bot API Token]]",
@@ -35,6 +50,9 @@ Make the `halbot` json config file and put it in this path `~/.halbot.json`:
35
50
  // To restrict the bot to PRIVATE, set chat/group/channel ids in this array.
36
51
  "private": ["[[CHAT_ID]]", "[[GROUP_ID]]", "[[CHANNEL_ID]]", ...],
37
52
  // OPTIONAL, string.
53
+ // Set this field if you want to use a `magic word` to authenticate the bot.
54
+ "magicWord": "[[Your Magic Word here]]",
55
+ // OPTIONAL, string.
38
56
  // Use a HOME GROUP to authentication users.
39
57
  // Anyone in this group can access the bot.
40
58
  "homeGroup": "[[GROUP_ID]]",
@@ -47,19 +65,68 @@ Make the `halbot` json config file and put it in this path `~/.halbot.json`:
47
65
  }
48
66
  ```
49
67
 
50
- Then, run the bot:
68
+ ### Run it
69
+
70
+ Run it in peace of mind.
51
71
 
52
72
  ```bash
53
73
  $ npx halbot
54
74
  ```
55
75
 
56
- ## Integrate to your project
76
+ ### Integrate to your project
57
77
 
58
78
  ```bash
59
79
  $ npm i halbot
60
80
  ```
61
81
 
62
82
  ```js
63
- const { halbot } = require('halbot');
83
+ import halbot from 'halbot';
84
+
85
+ const config = {
86
+ // ...[[ALL THE CONFIG FIELDS SUPPORTED ABOVE]]],
87
+
88
+ // OPTIONAL, function.
89
+ // Your own authentication logic.
90
+ // return true if the user is authenticated.
91
+ // return false if the user is not authenticated.
92
+ auth: async (ctx) => {
93
+ // ctx is the `telegraf` context object: https://telegraf.js.org/#context-class
94
+ // It has been extended: https://github.com/Leask/utilitas/blob/master/lib/bot.mjs
95
+ return true;
96
+ },
97
+
98
+ // OPTIONAL, object (key renderd as name) or array (name ignored).
99
+ ai: {
100
+ [[aiNameA]]: [[aiClientA]]
101
+ [[aiNameB]]: [[aiClientB]],
102
+ },
103
+
104
+ // OPTIONAL, object.
105
+ // Your own speech-to-text and text-to-speech engine.
106
+ speech: {
107
+ stt: [[sttClient]],
108
+ tts: [[ttsClient]]]],
109
+ },
110
+
111
+ // OPTIONAL, string.
112
+ // Path to your own middlewares.
113
+ // ./skills
114
+ // |- skill_a.mjs
115
+ // | const action = async (bot) => {
116
+ // | bot.use(async (ctx, next) => {
117
+ // | ctx.reply('42');
118
+ // | await next();
119
+ // | });
120
+ // | };
121
+ // |
122
+ // | export const { run, priority, func } = {
123
+ // | run: true,
124
+ // | priority: 100,
125
+ // | func: action,
126
+ // | };
127
+ skillPath: './skills',
128
+
129
+ };
64
130
 
131
+ await halbot(config);
65
132
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "halbot",
3
3
  "description": "Just another ChatGPT/Bing Telegram bob.",
4
- "version": "1989.6.8",
4
+ "version": "1989.6.10",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",