UNPKG

chzzk

Version:

네이버 라이브 스트리밍 서비스 CHZZK의 비공식 API 라이브러리

41 lines (40 loc) 2.36 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.notice = exports.profileCard = exports.accessToken = void 0; function accessToken(client, chatChannelId) { var _a; return __awaiter(this, void 0, void 0, function* () { const r = yield client.fetch(`${client.options.baseUrls.gameBaseUrl}/v1/chats/access-token?channelId=${chatChannelId}&chatType=STREAMING`); const data = yield r.json(); return (_a = data['content']) !== null && _a !== void 0 ? _a : null; }); } exports.accessToken = accessToken; function profileCard(client, chatChannelId, userIdHash) { var _a; return __awaiter(this, void 0, void 0, function* () { const r = yield client.fetch(`${client.options.baseUrls.gameBaseUrl}/v1/chats/${chatChannelId}/users/${userIdHash}/profile-card?chatType=STREAMING`); const data = yield r.json(); return (_a = data['content']) !== null && _a !== void 0 ? _a : null; }); } exports.profileCard = profileCard; function notice(client, chatChannelId, options) { return __awaiter(this, void 0, void 0, function* () { return client.fetch(`${client.options.baseUrls.gameBaseUrl}/v1/chats/notices`, { method: options ? "POST" : "DELETE", headers: { "Content-Type": "application/json" }, body: JSON.stringify(Object.assign(Object.assign({ channelId: chatChannelId, chatType: "STREAMING" }, (options || {})), { extras: (options === null || options === void 0 ? void 0 : options.extras) ? (typeof options.extras === "string" ? options.extras : JSON.stringify(options.extras)) : null })) }); }); } exports.notice = notice;