@alemonjs/qq-bot 0.0.19 → 0.0.21

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 (48) hide show
  1. package/README.md +6 -10
  2. package/lib/index.d.ts +2 -2
  3. package/lib/index.group.js +6 -203
  4. package/lib/index.guild.js +25 -298
  5. package/lib/index.js +42 -403
  6. package/lib/index.webhook.js +26 -0
  7. package/lib/register.d.ts +3 -0
  8. package/lib/register.js +405 -0
  9. package/lib/sdk/api.d.ts +5 -10
  10. package/lib/sdk/api.js +5 -10
  11. package/lib/sdk/client.websoket.js +221 -0
  12. package/lib/sdk/intents.js +12 -23
  13. package/lib/send/index.js +417 -366
  14. package/lib/sends.js +576 -0
  15. package/package.json +1 -1
  16. package/lib/api.d.ts +0 -975
  17. package/lib/api.js +0 -1188
  18. package/lib/client.d.ts +0 -26
  19. package/lib/client.js +0 -212
  20. package/lib/config.js +0 -3
  21. package/lib/from.js +0 -37
  22. package/lib/message/AT_MESSAGE_CREATE.d.ts +0 -37
  23. package/lib/message/C2C_MESSAGE_CREATE.d.ts +0 -11
  24. package/lib/message/CHANNEL_CREATE.d.ts +0 -17
  25. package/lib/message/CHANNEL_DELETE.d.ts +0 -22
  26. package/lib/message/CHANNEL_UPDATE.d.ts +0 -22
  27. package/lib/message/DIRECT_MESSAGE_CREATE.d.ts +0 -36
  28. package/lib/message/DIRECT_MESSAGE_DELETE.d.ts +0 -24
  29. package/lib/message/ERROR.d.ts +0 -3
  30. package/lib/message/GROUP_AT_MESSAGE_CREATE.d.ts +0 -16
  31. package/lib/message/GUILD_CREATE.d.ts +0 -22
  32. package/lib/message/GUILD_DELETE.d.ts +0 -22
  33. package/lib/message/GUILD_MEMBER_ADD.d.ts +0 -21
  34. package/lib/message/GUILD_MEMBER_REMOVE.d.ts +0 -21
  35. package/lib/message/GUILD_MEMBER_UPDATE.d.ts +0 -21
  36. package/lib/message/GUILD_UPDATE.d.ts +0 -22
  37. package/lib/message/INTERACTION_CREATE.d.ts +0 -8
  38. package/lib/message/MESSAGE_CREATE.d.ts +0 -11
  39. package/lib/message/MESSAGE_DELETE.d.ts +0 -11
  40. package/lib/message/MESSAGE_REACTION_ADD.d.ts +0 -15
  41. package/lib/message/MESSAGE_REACTION_REMOVE.d.ts +0 -15
  42. package/lib/message/PUBLIC_MESSAGE_DELETE.d.ts +0 -21
  43. package/lib/message/READY.d.ts +0 -11
  44. package/lib/message.d.ts +0 -49
  45. package/lib/typing.d.ts +0 -73
  46. package/lib/webhook.js +0 -51
  47. /package/lib/sdk/{websoket.group.js → client.websoket.group.js} +0 -0
  48. /package/lib/sdk/{websoket.guild.js → client.websoket.guild.js} +0 -0
@@ -1,21 +0,0 @@
1
- /**
2
- * 公域
3
- * @param event
4
- */
5
- type PUBLIC_MESSAGE_DELETE_TYPE = {
6
- message: {
7
- author: {
8
- bot: false
9
- id: string
10
- username: string
11
- }
12
- channel_id: string
13
- guild_id: string
14
- id: string
15
- }
16
- op_user: {
17
- id: string
18
- }
19
- }
20
-
21
- export type { PUBLIC_MESSAGE_DELETE_TYPE }
@@ -1,11 +0,0 @@
1
- /**
2
- * 登录
3
- */
4
- type READY_TYPE = {
5
- user: {
6
- id: string
7
- name: string
8
- }
9
- }
10
-
11
- export type { READY_TYPE }
package/lib/message.d.ts DELETED
@@ -1,49 +0,0 @@
1
- import { C2C_MESSAGE_CREATE_TYPE } from './message/C2C_MESSAGE_CREATE.js'
2
- import { GROUP_AT_MESSAGE_CREATE_TYPE } from './message/GROUP_AT_MESSAGE_CREATE.js'
3
- import { AT_MESSAGE_CREATE_TYPE } from './message/AT_MESSAGE_CREATE.js'
4
- import { CHANNEL_CREATE_TYPE } from './message/CHANNEL_CREATE.js'
5
- import { CHANNEL_DELETE_TYPE } from './message/CHANNEL_DELETE.js'
6
- import { CHANNEL_UPDATE_TYPE } from './message/CHANNEL_UPDATE.js'
7
- import { DIRECT_MESSAGE_CREATE_TYPE } from './message/DIRECT_MESSAGE_CREATE.js'
8
- import { DIRECT_MESSAGE_DELETE_TYPE } from './message/DIRECT_MESSAGE_DELETE.js'
9
- import { GUILD_CREATE_TYPE } from './message/GUILD_CREATE.js'
10
- import { GUILD_DELETE_TYPE } from './message/GUILD_DELETE.js'
11
- import { GUILD_MEMBER_ADD_TYPE } from './message/GUILD_MEMBER_ADD.js'
12
- import { GUILD_MEMBER_REMOVE_TYPE } from './message/GUILD_MEMBER_REMOVE.js'
13
- import { GUILD_MEMBER_UPDATE_TYPE } from './message/GUILD_MEMBER_UPDATE.js'
14
- import { GUILD_UPDATE_TYPE } from './message/GUILD_UPDATE.js'
15
- import { INTERACTION_CREATE_TYPE } from './message/INTERACTION_CREATE.js'
16
- import { MESSAGE_CREATE_TYPE } from './message/MESSAGE_CREATE.js'
17
- import { MESSAGE_DELETE_TYPE } from './message/MESSAGE_DELETE.js'
18
- import { MESSAGE_REACTION_ADD_TYPE } from './message/MESSAGE_REACTION_ADD.js'
19
- import { MESSAGE_REACTION_REMOVE_TYPE } from './message/MESSAGE_REACTION_REMOVE.js'
20
- import { PUBLIC_MESSAGE_DELETE_TYPE } from './message/PUBLIC_MESSAGE_DELETE.js'
21
- import { READY_TYPE } from './message/READY.js'
22
- import { ERROR_TYPE } from './message/ERROR.js'
23
-
24
- type QQBotEventMap = {
25
- AT_MESSAGE_CREATE: AT_MESSAGE_CREATE_TYPE
26
- CHANNEL_CREATE: CHANNEL_CREATE_TYPE
27
- CHANNEL_DELETE: CHANNEL_DELETE_TYPE
28
- CHANNEL_UPDATE: CHANNEL_UPDATE_TYPE
29
- DIRECT_MESSAGE_CREATE: DIRECT_MESSAGE_CREATE_TYPE
30
- DIRECT_MESSAGE_DELETE: DIRECT_MESSAGE_DELETE_TYPE
31
- GUILD_CREATE: GUILD_CREATE_TYPE
32
- GUILD_DELETE: GUILD_DELETE_TYPE
33
- GUILD_MEMBER_ADD: GUILD_MEMBER_ADD_TYPE
34
- GUILD_MEMBER_REMOVE: GUILD_MEMBER_REMOVE_TYPE
35
- GUILD_MEMBER_UPDATE: GUILD_MEMBER_UPDATE_TYPE
36
- GUILD_UPDATE: GUILD_UPDATE_TYPE
37
- INTERACTION_CREATE: INTERACTION_CREATE_TYPE
38
- MESSAGE_CREATE: MESSAGE_CREATE_TYPE
39
- MESSAGE_DELETE: MESSAGE_DELETE_TYPE
40
- MESSAGE_REACTION_ADD: MESSAGE_REACTION_ADD_TYPE
41
- MESSAGE_REACTION_REMOVE: MESSAGE_REACTION_REMOVE_TYPE
42
- PUBLIC_MESSAGE_DELETE: PUBLIC_MESSAGE_DELETE_TYPE
43
- READY: READY_TYPE
44
- C2C_MESSAGE_CREATE: C2C_MESSAGE_CREATE_TYPE
45
- GROUP_AT_MESSAGE_CREATE: GROUP_AT_MESSAGE_CREATE_TYPE
46
- ERROR: ERROR_TYPE
47
- }
48
-
49
- export type { QQBotEventMap }
package/lib/typing.d.ts DELETED
@@ -1,73 +0,0 @@
1
- type MessageType = 0 | 1 | 2 | 3 | 4 | 7
2
- type FileType = 1 | 2 | 3 | 4
3
- interface ButtonType {
4
- id: string
5
- render_data: {
6
- label: string
7
- visited_label: string
8
- style: number
9
- }
10
- action: {
11
- type: number
12
- permission: {
13
- type: number
14
- }
15
- reply?: boolean
16
- enter?: boolean
17
- unsupport_tips: string
18
- data: string
19
- }
20
- }
21
- interface KeyboardType {
22
- id?: string
23
- content?: {
24
- rows: {
25
- buttons: ButtonType[]
26
- }[]
27
- }
28
- }
29
- interface MarkdownType {
30
- /** markdown 模版id,申请模版后获得 */
31
- custom_template_id: string
32
- /** 原生 markdown 文本内容(内邀使用) */
33
- content?: string
34
- /** 模版内变量与填充值的kv映射 */
35
- params?: Array<{
36
- key: string
37
- values: string[]
38
- }>
39
- }
40
- interface ApiRequestData {
41
- content?: string
42
- msg_type: MessageType
43
- markdown?: MarkdownType
44
- keyboard?: KeyboardType
45
- media?: {
46
- file_info: string
47
- }
48
- ark?: any
49
- image?: any
50
- message_reference?: any
51
- event_id?: any
52
- msg_id?: string
53
- msg_seq?: number
54
- }
55
- interface Options {
56
- secret: string
57
- app_id: string
58
- token: string
59
- sandbox?: boolean
60
- route?: string
61
- port?: string
62
- ws?: string
63
- }
64
-
65
- export type {
66
- ApiRequestData,
67
- ButtonType,
68
- FileType,
69
- KeyboardType,
70
- MarkdownType,
71
- MessageType,
72
- Options
73
- }
package/lib/webhook.js DELETED
@@ -1,51 +0,0 @@
1
- import { ed25519 } from '@noble/curves/ed25519'
2
-
3
- class WebhookAPI {
4
- config
5
- constructor(config) {
6
- this.config = config
7
- }
8
- /**
9
- * 验证签名
10
- * @param ts
11
- * @param body
12
- * @param sign
13
- * @returns
14
- */
15
- validSign(ts, body, sign) {
16
- const { publicKey } = this.getKey()
17
- const sig = Buffer.isBuffer(sign) ? sign : Buffer.from(sign, 'hex')
18
- const httpBody = Buffer.from(body)
19
- const msg = Buffer.from(ts + httpBody)
20
- return ed25519.verify(sig, msg, publicKey)
21
- }
22
- /**
23
- * 生成签名
24
- * @param eventTs
25
- * @param plainToken
26
- * @returns
27
- */
28
- getSign(eventTs, plainToken) {
29
- const { privateKey } = this.getKey()
30
- const msg = Buffer.from(eventTs + plainToken)
31
- const signature = Buffer.from(ed25519.sign(msg, privateKey)).toString('hex')
32
- return signature
33
- }
34
- /**
35
- * 获取 key
36
- * @returns
37
- */
38
- getKey() {
39
- let seed = this.config.secret
40
- if (!seed) throw new Error("secret not set, can't calc ed25519 key")
41
- while (seed.length < 32) seed = seed.repeat(2) // Ed25519 的种子大小是 32 字节
42
- seed = seed.slice(0, 32) // 修剪到 32 字节
43
- const privateKey = Buffer.from(seed)
44
- return {
45
- privateKey,
46
- publicKey: ed25519.getPublicKey(privateKey)
47
- }
48
- }
49
- }
50
-
51
- export { WebhookAPI }