diff --git a/package.json b/package.json index 9718062..b92ca37 100644 --- a/package.json +++ b/package.json @@ -21,17 +21,17 @@ "lib" ], "dependencies": { - "epicfail": "^2.0.0", - "masterchat": "^0.8.0", + "epicfail": "^3.0.0", + "masterchat": "^0.9.0", "vm2": "^3.9.3" }, "devDependencies": { "@types/jest": "^27.0.1", - "@types/node": "^16.7.6", + "@types/node": "^16.9.0", "execa": "^5.1.1", "husky": "^7.0.2", - "jest": "^27.1.0", - "prettier": "^2.3.2", + "jest": "^27.1.1", + "prettier": "^2.4.0", "pretty-quick": "^3.1.1", "shx": "^0.3.3", "ts-jest": "^27.0.5", @@ -52,6 +52,6 @@ "youtube" ], "engines": { - "node": ">= 12.18.3" + "node": ">= 14" } } diff --git a/src/cli.ts b/src/cli.ts index 33f4747..df4b73b 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -2,9 +2,9 @@ import yargs from "yargs"; import { inspectChat } from "./commands/liveChat"; -import epicfail from "epicfail"; +import { epicfail } from "epicfail"; -epicfail(); +epicfail(require.main?.filename!); const argv = yargs(process.argv.slice(2)) .scriptName("masterchat") diff --git a/src/commands/liveChat.ts b/src/commands/liveChat.ts index 0b35c49..1514782 100644 --- a/src/commands/liveChat.ts +++ b/src/commands/liveChat.ts @@ -1,11 +1,6 @@ import chalk from "chalk"; +import { Action, Masterchat, normalizeVideoId, runsToString } from "masterchat"; import fs from "node:fs"; -import { - Action, - convertRunsToString, - Masterchat, - normalizeVideoId, -} from "masterchat"; import { VM, VMScript } from "vm2"; export function stringifyActions( @@ -28,7 +23,7 @@ export function stringifyActions( } text += action.rawMessage - ? convertRunsToString(action.rawMessage) + ? runsToString(action.rawMessage) : ""; text += ` (${action.superchat.amount} ${action.superchat.currency})`; @@ -64,7 +59,7 @@ export function stringifyActions( text += ": "; } - text += convertRunsToString(action.rawMessage); + text += runsToString(action.rawMessage); simpleChat.push(text); break; @@ -129,7 +124,7 @@ export async function inspectChat(argv: any) { // get web player context const mc = await Masterchat.init(videoId); - console.log("title:", mc.metadata.title); + console.log("title:", mc.title); let chatQueue: string[] = []; let wait = 0; @@ -145,12 +140,7 @@ export async function inspectChat(argv: any) { } }); - for await (const response of mc.iterateChat(type)) { - if (response.error) { - const { error } = response; - console.log(`Error(${error.status}): ${error.message}`); - break; - } + for await (const response of mc.iterate({ topChat: type === "top" })) { const { actions, continuation } = response; const delay = continuation?.timeoutMs || 0; @@ -177,7 +167,7 @@ export async function inspectChat(argv: any) { isSuperchat: action.type === "addSuperChatItemAction", message: "rawMessage" in action && action.rawMessage - ? convertRunsToString(action.rawMessage) + ? runsToString(action.rawMessage) : "", }; return filter(filterContext);