@alemonjs/telegram 0.2.1 → 0.2.2
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/lib/index.js +4 -5
- package/package.json +12 -7
- package/lib/index.d.ts +0 -9
package/lib/index.js
CHANGED
|
@@ -4,7 +4,9 @@ import TelegramClient from 'node-telegram-bot-api';
|
|
|
4
4
|
const client = new Proxy({}, {
|
|
5
5
|
get: (_, prop) => {
|
|
6
6
|
if (prop in global.client) {
|
|
7
|
-
|
|
7
|
+
const original = global.client[prop];
|
|
8
|
+
// 防止函数内this丢失
|
|
9
|
+
return typeof original === 'function' ? original.bind(global.client) : original;
|
|
8
10
|
}
|
|
9
11
|
return undefined;
|
|
10
12
|
}
|
|
@@ -12,10 +14,7 @@ const client = new Proxy({}, {
|
|
|
12
14
|
const platform = 'telegram';
|
|
13
15
|
var index = defineBot(() => {
|
|
14
16
|
const value = getConfigValue();
|
|
15
|
-
const config = value
|
|
16
|
-
if (!config)
|
|
17
|
-
return;
|
|
18
|
-
//
|
|
17
|
+
const config = value[platform];
|
|
19
18
|
const client = new TelegramClient(config.token, {
|
|
20
19
|
polling: true,
|
|
21
20
|
baseApiUrl: config?.base_api_url ?? '',
|
package/package.json
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alemonjs/telegram",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "telegram-bot",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"types": "lib",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "node bundle.js"
|
|
12
|
+
},
|
|
10
13
|
"dependencies": {
|
|
11
14
|
"grammy": "^1.30.0",
|
|
12
15
|
"node-telegram-bot-api": "^0.66.0"
|
|
13
16
|
},
|
|
14
17
|
"devDependencies": {
|
|
18
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
19
|
+
"lvyjs": "^0.2.13",
|
|
20
|
+
"rollup": "^4.18.1",
|
|
21
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
22
|
+
"tsx": "^4.19.1",
|
|
15
23
|
"@types/node-telegram-bot-api": "^0.64.7"
|
|
16
24
|
},
|
|
17
25
|
"exports": {
|
|
18
26
|
".": {
|
|
19
27
|
"import": "./lib/index.js",
|
|
20
28
|
"types": "./lib/index.d.ts"
|
|
21
|
-
}
|
|
29
|
+
},
|
|
30
|
+
"./package": "./package.json"
|
|
22
31
|
},
|
|
23
32
|
"keywords": [
|
|
24
|
-
"alemonjs"
|
|
25
|
-
"telegram",
|
|
26
|
-
"telegram-bot",
|
|
27
|
-
"bot",
|
|
28
|
-
"chat-bot"
|
|
33
|
+
"alemonjs"
|
|
29
34
|
],
|
|
30
35
|
"publishConfig": {
|
|
31
36
|
"registry": "https://registry.npmjs.org",
|
package/lib/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as alemonjs from 'alemonjs';
|
|
2
|
-
import TelegramClient from 'node-telegram-bot-api';
|
|
3
|
-
|
|
4
|
-
type Client = typeof TelegramClient.prototype;
|
|
5
|
-
declare const client: Client;
|
|
6
|
-
declare const platform = "telegram";
|
|
7
|
-
declare const _default: () => alemonjs.ClientAPI;
|
|
8
|
-
|
|
9
|
-
export { type Client, client, _default as default, platform };
|