Skip to content

Commit

Permalink
Merge pull request #4 from d2n0s4ur/release/1.2.3
Browse files Browse the repository at this point in the history
Release/1.2.3
  • Loading branch information
d2n0s4ur authored Mar 1, 2024
2 parents d4b7ea2 + 5e3ffb8 commit 4f606da
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 6 deletions.
52 changes: 50 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@d2n0s4ur/chzzk-chat",
"version": "1.2.2",
"version": "1.2.3",
"description": "chzzk-chat: node.js 개발자를 위한 chzzk 채팅 & 후원 비공식 라이브러리",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
Expand Down Expand Up @@ -38,7 +38,11 @@
},
"homepage": "https://github.com/d2n0s4ur/chzzk-chat#readme",
"devDependencies": {
"@types/ws": "^8.5.10",
"typescript": "^5.3.3"
},
"type": "module"
"type": "module",
"dependencies": {
"ws": "^8.16.0"
}
}
10 changes: 8 additions & 2 deletions src/lib/chzzkChat.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CloseEvent, Event, MessageEvent, WebSocket } from "ws";

export type messageHandler = (
badges: string[],
nick: string,
Expand Down Expand Up @@ -120,7 +122,9 @@ export class ChzzkChat {
case 93101: // default message
if (!this.messageHandler) return;
this.messageHandler(
this.parseBadgeUrl(profile ? profile.activityBadges : undefined),
this.parseBadgeUrl(
profile ? profile.activityBadges : undefined
),
profile.nickname,
msg.msgStatusType === "CBOTBLIND"
? "클린봇에 의해 삭제된 메시지입니다."
Expand All @@ -131,7 +135,9 @@ export class ChzzkChat {
const extras = JSON.parse(data.bdy[0].extras);
if (!this.donationHandler) return;
this.donationHandler(
this.parseBadgeUrl(profile ? profile.activityBadges : undefined),
this.parseBadgeUrl(
profile ? profile.activityBadges : undefined
),
msg.uid !== "anonymous" ? profile.nickname : "익명의 후원자",
msg.msg,
msg.uid === "anonymous",
Expand Down
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ChzzkChat } from '../dist/lib/chzzkChat.js';

function main() {
const chzzkChat = new ChzzkChat("bdc57cc4217173f0e89f63fba2f1c6e5");

chzzkChat.addMessageHandler((badges, nick, message) => {
console.log(`${nick}: ${message}`);
});
}

main();

0 comments on commit 4f606da

Please sign in to comment.