Skip to content

Commit

Permalink
feat: 评论消息展示
Browse files Browse the repository at this point in the history
  • Loading branch information
shanmite committed Apr 15, 2021
1 parent 6dc6fda commit 0cfc602
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/live_flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class LiveFlow extends ServerInfo {
break;
case WS.OP_CONNECT_SUCCESS:
if (body[0].code === WS.AUTH_OK) {
log.ok('live_flow -> connect success');
log.ok('live_flow -> connect success' + `(roomid: ${this.roomid})`);
msg.type = 'CONNECT_SUCCESS';
this.connectState = true;
this.heartBeat = this._heartBeat();
Expand Down
10 changes: 7 additions & 3 deletions lib/message_handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ function messageHandle(t) {
break;
case "DANMU_MSG":
console.log(
t.info[2][1] +
chalk.grey(': ') +
t.info[1]
(t.info[3].length ? chalk.hex(['#5CC05C', '#5896DE', '#A068F1', '#FF86B2', '#F6BE18', '#AFC1AF', '#B7C9DE', '#D8C9F0', '#FFE5F0', '#F5E8C1'][~~(t.info[3][0] / 4)])('[' + t.info[3][1] + ']') : '')
+
chalk.hex(['#969696', '#61c05a', '#5896de', '#a068f1', '#ff86b2', '#ff9f3d'][~~(t.info[4][0] / 10)])(t.info[2][1])
+
chalk.grey(': ')
+
chalk.hex(t.info[2][7] || '#FFFFFF')(t.info[1])
);
break;
case "USER_TOAST_MSG":
Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { messageHandle } = require("./lib/message_handle");
(function () {
const live_flow = new LiveFlow();
live_flow
.setRoomId(80397)
.setRoomId(Number(process.argv[2]) || 1)
.setMessageHandle((msg) => msg.type === 'MESSAGE' && msg.inner.forEach(messageHandle))
.run();

Expand Down

0 comments on commit 0cfc602

Please sign in to comment.