@alemonjs/telegram 0.2.1 → 0.2.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/lib/index.js +11 -8
- package/package.json +15 -9
package/lib/index.js
CHANGED
|
@@ -4,18 +4,19 @@ 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
|
}
|
|
11
13
|
});
|
|
12
14
|
const platform = 'telegram';
|
|
13
15
|
var index = defineBot(() => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//
|
|
16
|
+
let value = getConfigValue();
|
|
17
|
+
if (!value)
|
|
18
|
+
value = {};
|
|
19
|
+
const config = value[platform];
|
|
19
20
|
const client = new TelegramClient(config.token, {
|
|
20
21
|
polling: true,
|
|
21
22
|
baseApiUrl: config?.base_api_url ?? '',
|
|
@@ -133,6 +134,7 @@ var index = defineBot(() => {
|
|
|
133
134
|
else if (event?.chat.type == 'private') {
|
|
134
135
|
// 定义消
|
|
135
136
|
const e = {
|
|
137
|
+
name: 'private.message.create',
|
|
136
138
|
// 事件类型
|
|
137
139
|
Platform: platform,
|
|
138
140
|
// 用户Id
|
|
@@ -197,6 +199,7 @@ var index = defineBot(() => {
|
|
|
197
199
|
};
|
|
198
200
|
// 定义消
|
|
199
201
|
const e = {
|
|
202
|
+
naem: 'member.add',
|
|
200
203
|
// 事件类型
|
|
201
204
|
Platform: platform,
|
|
202
205
|
// guild
|
|
@@ -212,8 +215,8 @@ var index = defineBot(() => {
|
|
|
212
215
|
IsBot: false,
|
|
213
216
|
// message
|
|
214
217
|
MessageId: String(event?.message_id),
|
|
215
|
-
MessageText: event?.text,
|
|
216
|
-
OpenId: String(event?.chat?.id),
|
|
218
|
+
// MessageText: event?.text,
|
|
219
|
+
// OpenId: String(event?.chat?.id),
|
|
217
220
|
CreateAt: Date.now(),
|
|
218
221
|
// othder
|
|
219
222
|
tag: 'txt',
|
package/package.json
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alemonjs/telegram",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
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
|
-
"devDependencies": {
|
|
15
|
-
"@types/node-telegram-bot-api": "^0.64.7"
|
|
16
|
-
},
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
19
|
"import": "./lib/index.js",
|
|
20
20
|
"types": "./lib/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./package": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"alemonjs": {
|
|
25
|
+
"desktop": {
|
|
26
|
+
"platform": [
|
|
27
|
+
{
|
|
28
|
+
"name": "telegram"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
21
31
|
}
|
|
22
32
|
},
|
|
23
33
|
"keywords": [
|
|
24
|
-
"alemonjs"
|
|
25
|
-
"telegram",
|
|
26
|
-
"telegram-bot",
|
|
27
|
-
"bot",
|
|
28
|
-
"chat-bot"
|
|
34
|
+
"alemonjs"
|
|
29
35
|
],
|
|
30
36
|
"publishConfig": {
|
|
31
37
|
"registry": "https://registry.npmjs.org",
|