@alemonjs/telegram 0.0.1 → 0.0.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 CHANGED
@@ -1,4 +1,4 @@
1
- # [https://lemonade-lab.github.io/alemonjs.com/](https://lemonade-lab.github.io/alemonjs.com/)
1
+ # [https://alemonjs.com/](https://alemonjs.com/)
2
2
 
3
3
  跨平台开发的事件驱动机器人
4
4
 
@@ -14,14 +14,14 @@ yarn add @alemonjs/telegram
14
14
 
15
15
  ```sh
16
16
  telegram:
17
- # 令牌
17
+ # 令牌 (必填)
18
18
  token: ''
19
- # 主人
19
+ # 主人编号
20
20
  master_id: null
21
- # 前缀(非必填)
22
- intent: null
23
- # 活动 非必填)
24
- shard: null
21
+ base_api_url: null
22
+ # 代理地址
23
+ # proxy: 'http://127.0.0.1:7890'
24
+ proxy: null
25
25
  ```
26
26
 
27
27
  ## Community
package/lib/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import * as alemonjs from 'alemonjs';
2
-
3
- declare const _default: (_: alemonjs.ConfigType, __: any) => typeof global.alemonjs;
1
+ declare const _default: () => typeof global.alemonjs;
4
2
 
5
3
  export { _default as default };
package/lib/index.js CHANGED
@@ -1,18 +1,23 @@
1
- import { defineBot, Text, OnProcessor, useParse } from 'alemonjs';
1
+ import { defineBot, getConfig, Text, OnProcessor, useParse } from 'alemonjs';
2
2
  import Client from 'node-telegram-bot-api';
3
3
 
4
- var index = defineBot(config => {
4
+ var index = defineBot(() => {
5
+ const cfg = getConfig();
6
+ const config = cfg.value?.['telegram'];
7
+ if (!config)
8
+ return;
5
9
  //
6
10
  const client = new Client(config.token, {
7
11
  polling: true,
8
12
  baseApiUrl: '',
9
13
  request: {
10
14
  url: '',
11
- proxy: 'http://127.0.0.1:7890'
15
+ proxy: config?.proxy ?? 'http://127.0.0.1:7890'
12
16
  }
13
17
  });
14
- // channel_post 消息
15
- client.on('channel_post', event => {
18
+ //
19
+ //
20
+ client.on('message', event => {
16
21
  // 定义消
17
22
  const e = {
18
23
  // 事件类型
@@ -47,7 +52,7 @@ var index = defineBot(config => {
47
52
  }
48
53
  });
49
54
  // 处理消息
50
- OnProcessor(e, 'message.create');
55
+ OnProcessor(e, 'private.message.create');
51
56
  });
52
57
  // const eventKeys: string[] = [
53
58
  // 'message',
@@ -116,6 +121,7 @@ var index = defineBot(config => {
116
121
  // console.log(key, event)
117
122
  // })
118
123
  // }
124
+ //
119
125
  return {
120
126
  api: {
121
127
  use: {
package/package.json CHANGED
@@ -1,27 +1,26 @@
1
1
  {
2
2
  "name": "@alemonjs/telegram",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "telegram-bot",
5
- "author": "ningmengchongshui",
5
+ "author": "lemonade",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "lib/index.js",
9
+ "types": "lib",
9
10
  "dependencies": {
10
11
  "chat-space": "^0.0.4",
11
12
  "grammy": "^1.30.0",
12
13
  "node-telegram-bot-api": "^0.66.0"
13
14
  },
14
- "types": "lib",
15
+ "devDependencies": {
16
+ "@types/node-telegram-bot-api": "^0.64.7"
17
+ },
15
18
  "exports": {
16
19
  ".": {
17
20
  "import": "./lib/index.js",
18
21
  "types": "./lib/index.d.ts"
19
22
  }
20
23
  },
21
- "publishConfig": {
22
- "access": "public",
23
- "registry": "https://registry.npmjs.org"
24
- },
25
24
  "keywords": [
26
25
  "alemonjs",
27
26
  "telegram",
@@ -29,7 +28,12 @@
29
28
  "bot",
30
29
  "chat-bot"
31
30
  ],
32
- "devDependencies": {
33
- "@types/node-telegram-bot-api": "^0.64.7"
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org"
33
+ },
34
+ "bugs": "https://github.com/ningmengchongshui/alemonjs/issues",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/ningmengchongshui/alemonjs.git"
34
38
  }
35
39
  }