test
This commit is contained in:
parent
2d48f06ea2
commit
209c0acf8a
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules
|
56
index.js
Normal file
56
index.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
const { createOpenAPI, createWebsocket } = require('qq-guild-bot');
|
||||||
|
|
||||||
|
const testConfig = {
|
||||||
|
appID: '102011802', // 申请机器人时获取到的机器人 BotAppID
|
||||||
|
token: 'YPwwxVTwbOy9ULfvsKpmax2PC4xXr74x', // 申请机器人时获取到的机器人 BotToken
|
||||||
|
intents: ['GUILD_MESSAGES','MESSAGE_AUDIT'], // 事件订阅,用于开启可接收的消息类型
|
||||||
|
sandbox: true, // 沙箱支持,可选,默认false. v2.7.0+
|
||||||
|
};
|
||||||
|
|
||||||
|
// 创建 client
|
||||||
|
const client = createOpenAPI(testConfig);
|
||||||
|
|
||||||
|
// 创建 websocket 连接
|
||||||
|
const ws = createWebsocket(testConfig);
|
||||||
|
// 消息监听
|
||||||
|
ws.on('READY', (wsdata) => {
|
||||||
|
console.log('[READY] 事件接收 :', wsdata);
|
||||||
|
});
|
||||||
|
ws.on('ERROR', (data) => {
|
||||||
|
console.log('[ERROR] 事件接收 :', data);
|
||||||
|
});
|
||||||
|
ws.on('GUILDS', (data) => {
|
||||||
|
console.log('[GUILDS] 事件接收 :', data);
|
||||||
|
});
|
||||||
|
ws.on('GUILD_MEMBERS', (data) => {
|
||||||
|
console.log('[GUILD_MEMBERS] 事件接收 :', data);
|
||||||
|
});
|
||||||
|
ws.on('GUILD_MESSAGES', (data) => {
|
||||||
|
console.log('[GUILD_MESSAGES] 事件接收 :', JSON.stringify(data));
|
||||||
|
client.messageApi.deleteMessage(data.msg.channel_id, data.msg.id, false ).then(({d})=>{
|
||||||
|
console.log(d)
|
||||||
|
}).catch((err)=>{
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
ws.on('GUILD_MESSAGE_REACTIONS', (data) => {
|
||||||
|
console.log('[GUILD_MESSAGE_REACTIONS] 事件接收 :', data);
|
||||||
|
});
|
||||||
|
ws.on('DIRECT_MESSAGE', (data) => {
|
||||||
|
console.log('[DIRECT_MESSAGE] 事件接收 :', data);
|
||||||
|
});
|
||||||
|
ws.on('INTERACTION', (data) => {
|
||||||
|
console.log('[INTERACTION] 事件接收 :', data);
|
||||||
|
});
|
||||||
|
ws.on('MESSAGE_AUDIT', (data) => {
|
||||||
|
console.log('[MESSAGE_AUDIT] 事件接收 :', data);
|
||||||
|
});
|
||||||
|
ws.on('FORUMS_EVENT', (data) => {
|
||||||
|
console.log('[FORUMS_EVENT] 事件接收 :', data);
|
||||||
|
});
|
||||||
|
ws.on('AUDIO_ACTION', (data) => {
|
||||||
|
console.log('[AUDIO_ACTION] 事件接收 :', data);
|
||||||
|
});
|
||||||
|
ws.on('PUBLIC_GUILD_MESSAGES', (data) => {
|
||||||
|
console.log('[PUBLIC_GUILD_MESSAGES] 事件接收 :', data);
|
||||||
|
});
|
@ -2,5 +2,11 @@
|
|||||||
"name": "qqbot",
|
"name": "qqbot",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"qq-guild-bot": "^2.9.4"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start":"node ./index.js"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
80
yarn.lock
Normal file
80
yarn.lock
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
asynckit@^0.4.0:
|
||||||
|
version "0.4.0"
|
||||||
|
resolved "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
|
||||||
|
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
|
||||||
|
|
||||||
|
axios@>=0.21.1:
|
||||||
|
version "0.27.2"
|
||||||
|
resolved "https://registry.npmmirror.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
|
||||||
|
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
|
||||||
|
dependencies:
|
||||||
|
follow-redirects "^1.14.9"
|
||||||
|
form-data "^4.0.0"
|
||||||
|
|
||||||
|
combined-stream@^1.0.8:
|
||||||
|
version "1.0.8"
|
||||||
|
resolved "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
|
||||||
|
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
|
||||||
|
dependencies:
|
||||||
|
delayed-stream "~1.0.0"
|
||||||
|
|
||||||
|
delayed-stream@~1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
|
||||||
|
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==
|
||||||
|
|
||||||
|
follow-redirects@^1.14.9:
|
||||||
|
version "1.15.1"
|
||||||
|
resolved "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5"
|
||||||
|
integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==
|
||||||
|
|
||||||
|
form-data@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.npmmirror.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
|
||||||
|
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
|
||||||
|
dependencies:
|
||||||
|
asynckit "^0.4.0"
|
||||||
|
combined-stream "^1.0.8"
|
||||||
|
mime-types "^2.1.12"
|
||||||
|
|
||||||
|
loglevel@^1.8.0:
|
||||||
|
version "1.8.0"
|
||||||
|
resolved "https://registry.npmmirror.com/loglevel/-/loglevel-1.8.0.tgz#e7ec73a57e1e7b419cb6c6ac06bf050b67356114"
|
||||||
|
integrity sha512-G6A/nJLRgWOuuwdNuA6koovfEV1YpqqAG4pRUlFaz3jj2QNZ8M4vBqnVA+HBTmU/AMNUtlOsMmSpF6NyOjztbA==
|
||||||
|
|
||||||
|
mime-db@1.52.0:
|
||||||
|
version "1.52.0"
|
||||||
|
resolved "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
|
||||||
|
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
|
||||||
|
|
||||||
|
mime-types@^2.1.12:
|
||||||
|
version "2.1.35"
|
||||||
|
resolved "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
|
||||||
|
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
|
||||||
|
dependencies:
|
||||||
|
mime-db "1.52.0"
|
||||||
|
|
||||||
|
qq-guild-bot@^2.9.4:
|
||||||
|
version "2.9.4"
|
||||||
|
resolved "https://registry.npmmirror.com/qq-guild-bot/-/qq-guild-bot-2.9.4.tgz#5c697746fa9402a3c4537dd983571444ba497b1d"
|
||||||
|
integrity sha512-PaiWGyyFOVjJP5aBXufB1z2CLox4VUNZTuXK+P8iDdMmpQxer2gKEa0Um+xR+yosv47w07Z/WO5CGcJczVQxgw==
|
||||||
|
dependencies:
|
||||||
|
loglevel "^1.8.0"
|
||||||
|
resty-client "0.0.5"
|
||||||
|
ws "^7.4.4"
|
||||||
|
|
||||||
|
resty-client@0.0.5:
|
||||||
|
version "0.0.5"
|
||||||
|
resolved "https://registry.npmmirror.com/resty-client/-/resty-client-0.0.5.tgz#f98e143fd824e5844d46c47e11c81567e58fac07"
|
||||||
|
integrity sha512-uMaqtdPv1jHM5c9aJenXNGY5IZvGlhdNs7H6FNWIPTUT+pstWlrYTaR0CTp0PkcYaCQ4BiCLlEpx+EdF+Eo1iQ==
|
||||||
|
dependencies:
|
||||||
|
axios ">=0.21.1"
|
||||||
|
|
||||||
|
ws@^7.4.4:
|
||||||
|
version "7.5.8"
|
||||||
|
resolved "https://registry.npmmirror.com/ws/-/ws-7.5.8.tgz#ac2729881ab9e7cbaf8787fe3469a48c5c7f636a"
|
||||||
|
integrity sha512-ri1Id1WinAX5Jqn9HejiGb8crfRio0Qgu8+MtL36rlTA6RLsMdWt1Az/19A2Qij6uSHUMphEFaTKa4WG+UNHNw==
|
Loading…
Reference in New Issue
Block a user