momocow / node-cq-websocket Goto Github PK
View Code? Open in Web Editor NEWA Node SDK for developing QQ chatbots based on WebSocket, which is depending on CoolQ and CQHTTP API plugin.
Home Page: https://cq-websocket.js.org/
License: MIT License
A Node SDK for developing QQ chatbots based on WebSocket, which is depending on CoolQ and CQHTTP API plugin.
Home Page: https://cq-websocket.js.org/
License: MIT License
For example,
Events emitted in series when the bot is @-ed.
[email protected]
(event, context)
message.group.@
(event, context)
message.group
(event, context)
message
(event, context)
In another hand, if a group message is received without any @ tags including the bot.
message.group.@
(event, context, atTags)
message.group
(event, context, atTags)
message
(event, context, atTags)
And normal messages without any @ tag.
message.group
(event, context)
message
(event, context)
Extract baseUrl
, host
and port
from CQWebSocketOption
, change the declaration of CQWebSocketFactory
to the one as below.
type CQWebSocketFactory<T = any> = {
// use default protocol, host and port
new (opt?: Partial<CQWebSocketOption>): CQWebSocket
// provide your own <host [port]> or <base_url>
new (baseUrlOrHost: string, opt?: Partial<CQWebSocketOption>): CQWebSocket
new (host: string, port: number, opt?: Partial<CQWebSocketOption>): CQWebSocket
}
If baseUrlOrHost
starts with a valid protocol name (http://
, https://
, ws://
, wss://
), the param is used as the baseUrl
; otherwise, it is treated as host
and will automatically be prefixed with ws://
.
我查阅了文档,可以在message.group
事件中回复群组消息。
有没有什么方法能在别的地方发送群组消息呢?
用 base URL 讓SDK用戶自訂位址, 以更進一步支援例如反向代理的網路環境。
原先 URL 組成
ws://{host}:{port}/<event|api>[?access_token={token}]
變更為
ws://{baseUrl}/<event|api>[?access_token={token}]
Clean all files that match src/**/*.d.ts
and src/**/*.js
and the .dist
folder (which contains local builds).
npm run clean
Following semantic commit message via commitizen
.
npm run commit
tslint
+ tslint-config-standard
npm run lint
Compile all .ts files in place.
Since the main
field in package.json
is configured to be src/index
, either typescript or javascript projects can find their corresponding entry files.
tsc
npm run build
Generate the cq-websocket.min.js
and cq-websocket.kaomojified.js
as the legacy work did. The output directory is dist
on CI servers and .dist
at local.
webpack
npm run webpack
Run semantic-release
.
This will do actual release if it is master branch and there is any commit that causes version changed.
npm run release
Run tests with AVA with ts-node/register enabled.
For nyc
to correctly report the coverage, in tsconfig.json
inlineSourceMap
is set to true
and source-map-support
is installed.
npm test
Coverage will be reported to coveralls.
npm run coverage
API references are generated using Typedoc with typedoc-plugin-external-module-name under /docs/api
folder.
npm run docs
Parse all tsdoc comment blocks under src
folder and update CQHTTP version in the CQHTTP document URL according to the minimal version specified by engines.cqhttp
field in package.json
.
gulp docs:update-cqhttp-version
在文档中列出了string | Promise <string> | void
,我认为应该也支持Promise<void>
Your environment has been set up for using Node.js 10.15.1 (ia32) and npm.
C:\Users\zaoqi>cd bot
C:\Users\zaoqi\bot>node bot.js
[/event] 建立連線中, 請稍後...
[/api] 建立連線中, 請稍後...
/event { SocketError: Failed to establish the websocket connection.
at W3CWebSocket._sock.addEventListener (C:\Users\zaoqi\node_modules\cq-websocket\src\index.js:479:70)
at W3CWebSocket._dispatchEvent [as dispatchEvent] (C:\Users\zaoqi\node_modules\yaeti\lib\EventTarget.js:115:12)
at W3CWebSocket.onConnectFailed (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:217:14)
at WebSocketClient. (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:59:25)
at WebSocketClient.emit (events.js:189:13)
at ClientRequest.handleRequestError (C:\Users\zaoqi\node_modules\websocket\lib\WebSocketClient.js:227:14)
at ClientRequest.emit (events.js:189:13)
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8) name: 'SocketError' }
[/event] 連線失敗 。・゚・(つд゚)・゚・ [丑1] 對噗起 [/event] 連線關閉(1006: connection failed) /api { SocketError: Failed to establish the websocket connection. at W3CWebSocket._sock.addEventListener (C:\Users\zaoqi\node_modules\cq-websocket\src\index.js:479:70) at W3CWebSocket._dispatchEvent [as dispatchEvent] (C:\Users\zaoqi\node_modules\yaeti\lib\EventTarget.js:115:12) at W3CWebSocket.onConnectFailed (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:217:14) at WebSocketClient.<anonymous> (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:59:25) at WebSocketClient.emit (events.js:189:13) at ClientRequest.handleRequestError (C:\Users\zaoqi\node_modules\websocket\lib\WebSocketClient.js:227:14) at ClientRequest.emit (events.js:189:13) at Socket.socketErrorListener (_http_client.js:392:9) at Socket.emit (events.js:189:13) at emitErrorNT (internal/streams/destroy.js:82:8) name: 'SocketError' } [/api] 連線失敗 。・゚・(つд
゚)・゚・ [丑1] 對噗起
[/api] 連線關閉(1006: connection failed)
[/event] 建立連線中, 請稍後...
[/api] 建立連線中, 請稍後...
/event { SocketError: Failed to establish the websocket connection.
at W3CWebSocket._sock.addEventListener (C:\Users\zaoqi\node_modules\cq-websocket\src\index.js:479:70)
at W3CWebSocket._dispatchEvent [as dispatchEvent] (C:\Users\zaoqi\node_modules\yaeti\lib\EventTarget.js:115:12)
at W3CWebSocket.onConnectFailed (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:217:14)
at WebSocketClient. (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:59:25)
at WebSocketClient.emit (events.js:189:13)
at ClientRequest.handleRequestError (C:\Users\zaoqi\node_modules\websocket\lib\WebSocketClient.js:227:14)
at ClientRequest.emit (events.js:189:13)
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8) name: 'SocketError' }
[/event] 連線失敗 。・゚・(つд゚)・゚・ [丑2] 對噗起 [/event] 連線關閉(1006: connection failed) /api { SocketError: Failed to establish the websocket connection. at W3CWebSocket._sock.addEventListener (C:\Users\zaoqi\node_modules\cq-websocket\src\index.js:479:70) at W3CWebSocket._dispatchEvent [as dispatchEvent] (C:\Users\zaoqi\node_modules\yaeti\lib\EventTarget.js:115:12) at W3CWebSocket.onConnectFailed (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:217:14) at WebSocketClient.<anonymous> (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:59:25) at WebSocketClient.emit (events.js:189:13) at ClientRequest.handleRequestError (C:\Users\zaoqi\node_modules\websocket\lib\WebSocketClient.js:227:14) at ClientRequest.emit (events.js:189:13) at Socket.socketErrorListener (_http_client.js:392:9) at Socket.emit (events.js:189:13) at emitErrorNT (internal/streams/destroy.js:82:8) name: 'SocketError' } [/api] 連線失敗 。・゚・(つд
゚)・゚・ [丑2] 對噗起
[/api] 連線關閉(1006: connection failed)
[/event] 建立連線中, 請稍後...
[/api] 建立連線中, 請稍後...
/event { SocketError: Failed to establish the websocket connection.
at W3CWebSocket._sock.addEventListener (C:\Users\zaoqi\node_modules\cq-websocket\src\index.js:479:70)
at W3CWebSocket._dispatchEvent [as dispatchEvent] (C:\Users\zaoqi\node_modules\yaeti\lib\EventTarget.js:115:12)
at W3CWebSocket.onConnectFailed (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:217:14)
at WebSocketClient. (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:59:25)
at WebSocketClient.emit (events.js:189:13)
at ClientRequest.handleRequestError (C:\Users\zaoqi\node_modules\websocket\lib\WebSocketClient.js:227:14)
at ClientRequest.emit (events.js:189:13)
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8) name: 'SocketError' }
[/event] 連線失敗 。・゚・(つд゚)・゚・ [丑3] 對噗起 [/event] 連線關閉(1006: connection failed) /api { SocketError: Failed to establish the websocket connection. at W3CWebSocket._sock.addEventListener (C:\Users\zaoqi\node_modules\cq-websocket\src\index.js:479:70) at W3CWebSocket._dispatchEvent [as dispatchEvent] (C:\Users\zaoqi\node_modules\yaeti\lib\EventTarget.js:115:12) at W3CWebSocket.onConnectFailed (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:217:14) at WebSocketClient.<anonymous> (C:\Users\zaoqi\node_modules\websocket\lib\W3CWebSocket.js:59:25) at WebSocketClient.emit (events.js:189:13) at ClientRequest.handleRequestError (C:\Users\zaoqi\node_modules\websocket\lib\WebSocketClient.js:227:14) at ClientRequest.emit (events.js:189:13) at Socket.socketErrorListener (_http_client.js:392:9) at Socket.emit (events.js:189:13) at emitErrorNT (internal/streams/destroy.js:82:8) name: 'SocketError' } [/api] 連線失敗 。・゚・(つд
゚)・゚・ [丑3] 對噗起
[/api] 連線關閉(1006: connection failed)
^C
C:\Users\zaoqi\bot>
Too messy current README.md
is, docs refactoring is in plan.
监听request.group.invite
时,我试着邀请机器人入群,而得到的监听器参数context
为undefined
原先使用 message
字段, 但格式受 post_message_format
設定所影響
須改用 raw_message
以確保為 string
1 test failed
connection › connection › manually reconnect after a normal connection closure
Error: `t.end()` was never called
Then the SDK can be used to develope a Vue app (or Vue components), with this.$bot
or syntaxes like this.
Make the class CQWebSocket
exported via module.exports.default
; hence, the API should be ES6-module friendly.
CQWebSocket browser version is still in v1.5.1
.
我在使用typescript写事件监听时,希望监听一下元事件的心跳连接,但在编辑器中提示 类型“"meta_event.heartbeat"”的参数不能赋给类型“"socket.connecting" | "socket.failed" | "socket.reconnecting" | "socket.reconnect" | "socket.reconnect_failed" | "socket.max_reconnect"”的参数
查阅源码后发现并未对元事件进行d.ts类型声明
虽然编译成js之后依旧可以执行,但是会对使用ts编写的用户有所困扰,希望修复一下
For test snippets, see performance/leakage/once.test.js.
Within the test for CQWebSocket#once()
, memory grows about 342KB after 180 iterations.
[node-cq-websocket] # npm run perf
> [email protected] perf /workspace
> tape performance/**/*.test.js
TAP version 13
# EventEmitter#once()
ok 1 should be equivalent
# CQWebSocket#once()
/workspace/node_modules/leakage/lib/index.js:66
throw heapError
^
MemoryLeakError: Heap grew on 6 subsequent garbage collections (180 of 180 iterations) by 342 kB.
Iterations between GCs: 30
Final GC details:
[ 25.7 kB] [+ 181x] [- 1x] Array
[ 7.68 kB] [+ 120x] [- 0x] system / Context
[ 6.48 kB] [+ 90x] [- 0x] Closure
[ 5.28 kB] [+ 60x] [- 0x] Promise
... (5 more)
at testConstantHeapSize (/workspace/node_modules/leakage/lib/testConstantHeapSize.js:24:12)
at iterate (/workspace/node_modules/leakage/lib/index.js:64:21)
at Test.<anonymous> (/workspace/performance/leak.test.js:23:3)
at Test.bound [as _cb] (/workspace/node_modules/tape/lib/test.js:77:32)
at Test.run (/workspace/node_modules/tape/lib/test.js:96:10)
at Test.bound [as run] (/workspace/node_modules/tape/lib/test.js:77:32)
at Immediate.next [as _onImmediate] (/workspace/node_modules/tape/lib/results.js:75:19)
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)
需 debouncing 機制, 並且維護一個內部的狀態值
內部狀態總共 6 個值, 分別對應以下事件
disabled
(對應事件: 無)init
(對應事件: 無)connecting
(對應事件: socket.connecting
)connected
(對應事件: socket.connect
)closing
(對應事件: socket.closing
)closed
(對應事件: socket.close
)init
或 closed
狀態可以呼叫 connectconnected
可以呼叫 disconnectinit
, connected
或 closed
可以呼叫 reconnectdisabled
呼叫任何連線方法均沒有效果Here is my situation:
Host: 192.168.102.24,
Docker: 192.168.102.24:8888,
cqHttp:
"host": "192.168.102.24",
"port": 5700,
"use_http": true,
"ws_host": "192.168.102.24",
"ws_port": 6700,
"use_ws": true,
node-cq-webscoket
port: 6700,
host: '127.0.0.1',//0.0.0.0 || 192.168.102.24
still cannot establish connect to cqHttp server,is there something wrong?
please tell me more details if you are convience.
Thanks!
steps to reproduce:
nodejs: v11.15.0, v12.11.1
docker run -ti --rm --name cqhttp-test \
-v $(pwd)/data:/home/user/coolq \
-p 9000:9000 \
-p 9001:9001 \
-p 5700:5700 \
-e COOLQ_ACCOUNT=<my_qq_id> \
-e CQHTTP_SERVE_DATA_FILES=yes \
-e VNC_PASSWD=12345678 \
richardchien/cqhttp:latest
login in noVNC
update echobot.js L:23
const CQWebsocket = require('../')
-->
const CQWebsocket = require('../').default
node echobot.js --port 9001
console output:
[/event] 建立連線中, 請稍後...
[/api] 建立連線中, 請稍後...
[/event] 連線成功 ヽ(✿゚▽゚)ノ 蛆蛆1個嘗試
[/api] 連線成功 ヽ(✿゚▽゚)ノ 蛆蛆1個嘗試
今天又是複讀複讀的一天 。:.゚ヽ(*´∀`)ノ゚.:。
[/api] 連線關閉(1003: Unsupported: Unknown opcode 0x01)
[/api] 建立連線中, 請稍後...
[/api] 連線成功 ヽ(✿゚▽゚)ノ 蛆蛆1個嘗試
今天又是複讀複讀的一天 。:.゚ヽ(*´∀`)ノ゚.:。
[/api] 連線關閉(1003: Unsupported: Unknown opcode 0x01)
[/api] 建立連線中, 請稍後...
[/api] 連線成功 ヽ(✿゚▽゚)ノ 蛆蛆1個嘗試
今天又是複讀複讀的一天 。:.゚ヽ(*´∀`)ノ゚.:。
[/api] 連線關閉(1003: Unsupported: Unknown opcode 0x01)
[/api] 建立連線中, 請稍後...
container output:
172.17.0.1 - - [07/Oct/2019 20:06:00] 172.17.0.1: Plain non-SSL (ws://) WebSocket connection
172.17.0.1 - - [07/Oct/2019 20:06:00] 172.17.0.1: Path: '/event'
172.17.0.1 - - [07/Oct/2019 20:06:00] connecting to: 127.0.0.1:5911
172.17.0.1 - - [07/Oct/2019 20:06:00] 172.17.0.1: Plain non-SSL (ws://) WebSocket connection
172.17.0.1 - - [07/Oct/2019 20:06:00] 172.17.0.1: Path: '/api'
172.17.0.1 - - [07/Oct/2019 20:06:00] connecting to: 127.0.0.1:5911
172.17.0.1 - - [07/Oct/2019 20:06:06] 172.17.0.1: Plain non-SSL (ws://) WebSocket connection
172.17.0.1 - - [07/Oct/2019 20:06:06] 172.17.0.1: Path: '/event'
172.17.0.1 - - [07/Oct/2019 20:06:06] connecting to: 127.0.0.1:5911
172.17.0.1 - - [07/Oct/2019 20:06:06] 172.17.0.1: Plain non-SSL (ws://) WebSocket connection
172.17.0.1 - - [07/Oct/2019 20:06:06] 172.17.0.1: Path: '/api'
172.17.0.1 - - [07/Oct/2019 20:06:06] connecting to: 127.0.0.1:5911
172.17.0.1 - - [07/Oct/2019 20:06:07] 172.17.0.1: Plain non-SSL (ws://) WebSocket connection
172.17.0.1 - - [07/Oct/2019 20:06:07] 172.17.0.1: Path: '/api'
172.17.0.1 - - [07/Oct/2019 20:06:07] connecting to: 127.0.0.1:5911
错误提示为:
Uncaught TypeError: $WebsocketClient is not a constructor
定位在: https://github.com/momocow/node-cq-websocket/blob/master/src/index.js#L31
这可能是我试图直接在js中使用这个nodejs包导致的
想在网页中使用通知,需要https连接,此时无法使用websocket协议
能否改用wss://进行传输?
我实际使用时发现,当在消息中at机器人之前含有图片,则该消息将会被message.x
捕获,跳过了[email protected]
例如:
# 以下消息可以被 [email protected] 捕获(先at再图片,或是at前只有文字没有图片)
[CQ:at,qq=123] [CQ:image,file=123,url=123]
123123[CQ:at,qq=123]
# 以下消息会跳过 [email protected] (先图片再at,并且与之间或者之前是否有文字无关)
[CQ:image,file=123,url=123][CQ:at,qq=123]
[CQ:image,file=123,url=123] [CQ:at,qq=123]
[CQ:image,file=123,url=123] aaa [CQ:at,qq=123]
aaa[CQ:image,file=123,url=123][CQ:at,qq=123]
感谢作者做这个nice的库,
想问下如何付费?
没有看到怎么收费,还有收费标准、付费服务内容啥的?
No need for "allowSyntheticDefaultImports": true
in the tsconfig.json
anymore after this implementation.
I'm running multiple(more than 5) CQWebsocket instances in my program.
Sometimes one or two instances were not reconnected after reconnect() method called, while other instances did reconnect as expected.
Since there is no internal trace, I've no idea what happened and can only restart my program to restore the connections.
Could you add an "internal trace" feature in the current or next version?
Thanks.
因為註冊單次監聽器時, 使用一個 wrapper 包裝該監聽器後才呼叫 on() 進行註冊。
但若需要呼叫 off() 移除該監聽器, 因為沒有 wrapper 的參照, 故無法移除。
找出哪個環節有 Promise 沒有處理好, 看起來會是 websocket 的東西。
const CQWebsocket = require('../..')
const bot = new CQWebsocket()
bot.on('socket.connecting', function (wsType, attempts) {
console.log('[%s] 嘗試第 %d 次連線 _(:з」∠)_', wsType, attempts)
}).on('socket.connect', function (wsType, sock, attempts) {
console.log('[%s] 第 %d 次連線嘗試成功 ヽ(✿゚▽゚)ノ', wsType, attempts)
}).on('socket.failed', function (wsType, attempts) {
console.log('[%s] 第 %d 次連線嘗試失敗 。・゚・(つд`゚)・゚・', wsType, attempts)
})
bot.connect()
[/event] 第 1 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10652) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[/api] 第 1 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
[/event] 第 2 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
[/api] 第 2 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
[/event] 第 3 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)
[/api] 第 3 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)
[/event] 第 4 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 7)
[/api] 第 4 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)
[/event] 第 5 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 9)
[/api] 第 5 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 10)
[/event] 第 6 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 11)
[/api] 第 6 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 12)
[/event] 第 7 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 13)
[/api] 第 7 次連線嘗試失敗 。・゚・(つд`゚)・゚・
(node:10652) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6700
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1162:14)
(node:10652) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 14)
That is because the browser bundle is built before semantic-release
which actually bumps the version.
Also need to configure not to bundle irrelevant version of browser files from the dist/
directory to NPM release.
提供 fragment 選項給用戶依照自己的 CQHttp 插件版本決定輸出信息是否採用 fragment
RT.
在現在的做法中
一次性的監聽器實際上是先經過一層封裝 (為了自動移除)
而後才註冊到 event map 中
因此透過一個 Map 對象負責配對原先的監聽器到封裝後的方法
用以輔助 #off(event, listener)
找到正確的封裝方法
並將其移除。
若用戶未主動呼叫#off()
方法, 或者並未有呼叫#off()
方法的需求,
內存中仍有這個 Map 對象配對, 增加 memory leak 風險。
因此改用 WeakMap 可提升這部分的性能,
在現有的慣例中,
所有需要呼叫#off()
方法的用戶自然會握有監聽器的參照,
沒握有參照的就是不需要呼叫#off()
方法。
注意到現在使用的是
this._eventBus.emit('socket.response', WebsocketType.API, JSON.parse(msg.utf8Data))
從而api.response事件不能正確執行
在最新的coolq-http-api中新增了群禁言事件,因此如果触发了群禁言事件就会导致UnexpectedContextError
希望考虑修复
I download the cpk for CoolQ HTTP and install the package for node-cq-websocket,how can I start?
現在已經有 message.*.@me
事件, 當機器人被@時會發布。
新事件 message.*.@
, 任何夾帶 @ 的信息
若對象非此機器人, 則觸發該事件
由此事件可監聽特定用戶是否被 @。
event
-> Event notice
CQWebSocket #isConnected()
-> CQWebSocket #isReady()
CQEvent #cancel()
-> CQEvent #stopPropagation()
message.discuss.@me
-> [email protected]
message.group.@me
-> [email protected]
Updated (2018.10.15)
access_token
-> accessToken
to be continued...
文档中是string | Promise <string> | void
,ts定义文件内为string | void
。
结合
#25 (comment)
我认为应该为string | void | Promise <string | void>
import { CQWebSocket } from 'cq-websocket';
^^^^^^^^^^^
SyntaxError: The requested module 'cq-websocket' does not provide an export named 'CQWebSocket'
暂时用沙雕方式替代
const CQWebSocket = (await import('cq-websocket')).default.default;
It was the misuse of Websocket
in the very first version.
It should follow the conventions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.