twitter.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. "use strict";
  2. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  3. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4. return new (P || (P = Promise))(function (resolve, reject) {
  5. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  6. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  7. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  8. step((generator = generator.apply(thisArg, _arguments || [])).next());
  9. });
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. exports.sendPost = exports.getPostOwner = exports.WebshotHelpers = exports.ScreenNameNormalizer = exports.SessionManager = exports.urlSegmentToId = exports.idToUrlSegment = exports.isValidUrlSegment = exports.parseLink = exports.linkBuilder = exports.graphqlLinkBuilder = void 0;
  13. const crypto = require("crypto");
  14. const fs = require("fs");
  15. const http = require("http");
  16. const path = require("path");
  17. const url_1 = require("url");
  18. const util_1 = require("util");
  19. const instagram_id_to_url_segment_1 = require("instagram-id-to-url-segment");
  20. Object.defineProperty(exports, "idToUrlSegment", { enumerable: true, get: function () { return instagram_id_to_url_segment_1.instagramIdToUrlSegment; } });
  21. const instagram_private_api_1 = require("instagram-private-api");
  22. const socks_proxy_agent_1 = require("socks-proxy-agent");
  23. const loggers_1 = require("./loggers");
  24. const utils_1 = require("./utils");
  25. const webshot_1 = require("./webshot");
  26. const parseLink = (link) => {
  27. let match = /instagram\.com\/p\/([A-Za-z0-9\-_]+)/.exec(link);
  28. if (match)
  29. return { postUrlSegment: match[1] };
  30. match =
  31. /instagram\.com\/([^\/?#]+)/.exec(link) ||
  32. /^([^\/?#]+)$/.exec(link);
  33. if (match)
  34. return { userName: ScreenNameNormalizer.normalize(match[1]).split(':')[0] };
  35. return;
  36. };
  37. exports.parseLink = parseLink;
  38. const isValidUrlSegment = (input) => /^[A-Za-z0-9\-_]+$/.test(input);
  39. exports.isValidUrlSegment = isValidUrlSegment;
  40. const linkBuilder = (config) => {
  41. if (config.userName)
  42. return `https://www.instagram.com/${config.userName}/`;
  43. if (config.postUrlSegment)
  44. return `https://www.instagram.com/p/${config.postUrlSegment}/`;
  45. };
  46. exports.linkBuilder = linkBuilder;
  47. const graphqlLinkBuilder = ({ userId, first = '12', after }) => `https://www.instagram.com/graphql/query/\
  48. ?query_id=17888483320059182&id=${userId}&first=${first}${after ? `&after=${after}` : ''}`;
  49. exports.graphqlLinkBuilder = graphqlLinkBuilder;
  50. const urlSegmentToId = (urlSegment) => urlSegment.length <= 28 ?
  51. instagram_id_to_url_segment_1.urlSegmentToInstagramId(urlSegment) : instagram_id_to_url_segment_1.urlSegmentToInstagramId(urlSegment.slice(0, -28));
  52. exports.urlSegmentToId = urlSegmentToId;
  53. class SessionManager {
  54. constructor(client, file, credentials, codeServicePort) {
  55. this.init = () => {
  56. this.ig.state.generateDevice(this.username);
  57. this.ig.request.end$.subscribe(() => { this.save(); });
  58. const filePath = path.resolve(this.lockfile);
  59. if (fs.existsSync(filePath)) {
  60. try {
  61. const serialized = JSON.parse(fs.readFileSync(filePath, 'utf8'));
  62. return this.ig.state.deserialize(serialized).then(() => {
  63. logger.info(`successfully loaded client session cookies for user ${this.username}`);
  64. });
  65. }
  66. catch (err) {
  67. logger.error(`failed to load client session cookies from file ${this.lockfile}: `, err);
  68. return Promise.resolve();
  69. }
  70. }
  71. else {
  72. return this.login().catch((err) => {
  73. logger.error(`error while trying to log in as user ${this.username}, error: ${err}`);
  74. logger.warn('attempting to retry after 1 minute...');
  75. if (fs.existsSync(filePath))
  76. fs.unlinkSync(filePath);
  77. util_1.promisify(setTimeout)(60000).then(this.init);
  78. });
  79. }
  80. };
  81. this.handle2FA = (submitter) => new Promise((resolve, reject) => {
  82. const token = crypto.randomBytes(20).toString('hex');
  83. logger.info('please submit the code with a one-time token from your browser with this path:');
  84. logger.info(`/confirm-2fa?code=<the code you received>&token=${token}`);
  85. let working;
  86. const server = http.createServer((req, res) => {
  87. const { pathname, query } = url_1.parse(req.url, true);
  88. if (!working && pathname === '/confirm-2fa' && query.token === token &&
  89. typeof (query.code) === 'string' && /^\d{6}$/.test(query.code)) {
  90. const code = query.code;
  91. logger.debug(`received code: ${code}`);
  92. working = true;
  93. submitter(code)
  94. .then(response => { res.write('OK'); res.end(); server.close(() => resolve(response)); })
  95. .catch(err => { res.write('Error'); res.end(); reject(err); })
  96. .finally(() => { working = false; });
  97. }
  98. });
  99. server.listen(this.codeServicePort);
  100. });
  101. this.login = () => this.ig.simulate.preLoginFlow()
  102. .then(() => this.ig.account.login(this.username, this.password))
  103. .catch((err) => {
  104. if (err instanceof instagram_private_api_1.IgLoginTwoFactorRequiredError) {
  105. const { two_factor_identifier, totp_two_factor_on } = err.response.body.two_factor_info;
  106. logger.debug(`2FA info: ${JSON.stringify(err.response.body.two_factor_info)}`);
  107. logger.info(`login is requesting two-factor authentication via ${totp_two_factor_on ? 'TOTP' : 'SMS'}`);
  108. return this.handle2FA(code => this.ig.account.twoFactorLogin({
  109. username: this.username,
  110. verificationCode: code,
  111. twoFactorIdentifier: two_factor_identifier,
  112. verificationMethod: totp_two_factor_on ? '0' : '1',
  113. }));
  114. }
  115. throw err;
  116. })
  117. .then(user => new Promise(resolve => {
  118. logger.info(`successfully logged in as ${this.username}`);
  119. process.nextTick(() => resolve(this.ig.simulate.postLoginFlow().then(() => user)));
  120. }));
  121. this.save = () => this.ig.state.serialize()
  122. .then((serialized) => {
  123. delete serialized.constants;
  124. return fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(serialized, null, 2), 'utf-8');
  125. });
  126. this.ig = client;
  127. this.lockfile = file;
  128. [this.username, this.password] = credentials;
  129. this.codeServicePort = codeServicePort;
  130. }
  131. }
  132. exports.SessionManager = SessionManager;
  133. class ScreenNameNormalizer {
  134. static normalizeLive(username) {
  135. return __awaiter(this, void 0, void 0, function* () {
  136. if (this._queryUser) {
  137. return yield this._queryUser(username)
  138. .catch((err) => {
  139. if (!(err instanceof instagram_private_api_1.IgExactUserNotFoundError)) {
  140. logger.warn(`error looking up user: ${err.message}`);
  141. return `${username}:`;
  142. }
  143. return null;
  144. });
  145. }
  146. return this.normalize(username);
  147. });
  148. }
  149. }
  150. exports.ScreenNameNormalizer = ScreenNameNormalizer;
  151. ScreenNameNormalizer.normalize = (username) => `${username.toLowerCase().replace(/^@/, '')}:`;
  152. let browserLogin = (page) => Promise.resolve();
  153. let browserSaveCookies = browserLogin;
  154. let isWaitingForLogin = false;
  155. const acceptCookieConsent = (page) => page.click('button:has-text("すべて許可")', { timeout: 5000 })
  156. .then(() => logger.info('accepted cookie consent'))
  157. .catch((err) => { if (err.name !== 'TimeoutError')
  158. throw err; });
  159. exports.WebshotHelpers = {
  160. handleLogin: browserLogin,
  161. handleCookieConsent: acceptCookieConsent,
  162. get isWaitingForLogin() { return isWaitingForLogin; },
  163. };
  164. let getPostOwner = (segmentId) => Promise.reject();
  165. exports.getPostOwner = getPostOwner;
  166. let sendPost = (segmentId, receiver) => {
  167. throw Error();
  168. };
  169. exports.sendPost = sendPost;
  170. const logger = loggers_1.getLogger('instagram');
  171. const maxTrials = 3;
  172. const retryInterval = 1500;
  173. const ordinal = (n) => {
  174. switch ((Math.trunc(n / 10) % 10 === 1) ? 0 : n % 10) {
  175. case 1:
  176. return `${n}st`;
  177. case 2:
  178. return `${n}nd`;
  179. case 3:
  180. return `${n}rd`;
  181. default:
  182. return `${n}th`;
  183. }
  184. };
  185. const retryOnError = (doWork, onRetry) => new Promise(resolve => {
  186. const retry = (reason, count) => {
  187. setTimeout(() => {
  188. let terminate = false;
  189. onRetry(reason, count, defaultValue => { terminate = true; resolve(defaultValue); });
  190. if (!terminate)
  191. doWork().then(resolve).catch(error => retry(error, count + 1));
  192. }, retryInterval);
  193. };
  194. doWork().then(resolve).catch(error => retry(error, 1));
  195. });
  196. class default_1 {
  197. constructor(opt) {
  198. this.webshotCookies = [];
  199. this.launch = () => {
  200. this.webshot = new webshot_1.default(this.wsUrl, this.mode, () => this.webshotCookies, doOnNewPage => {
  201. this.queryUserMedia = ((userName, targetId) => {
  202. let page;
  203. let url = linkBuilder({ userName }) + '?__a=1';
  204. logger.debug(`pulling ${targetId !== '0' ? `feed ${url} up to ${targetId}` : `top of feed ${url}`}...`);
  205. return doOnNewPage(newPage => {
  206. page = newPage;
  207. const startTime = new Date().getTime();
  208. const getTimerTime = () => new Date().getTime() - startTime;
  209. const getTimeout = () => isWaitingForLogin ? 0 : Math.max(90000, this.webshotDelay - getTimerTime());
  210. return page.context().addCookies(this.webshotCookies)
  211. .then(() => page.goto(url, { waitUntil: 'load', timeout: getTimeout() }))
  212. .then(response => {
  213. const responseHandler = (res) => {
  214. if (res.status() === 302) {
  215. return acceptCookieConsent(page)
  216. .then(() => browserLogin(page))
  217. .catch((err) => {
  218. if (err.name === 'TimeoutError') {
  219. logger.warn('navigation timed out, assuming login has failed');
  220. isWaitingForLogin = false;
  221. }
  222. throw err;
  223. })
  224. .then(() => browserSaveCookies(page))
  225. .then(() => page.goto(url, { waitUntil: 'load', timeout: getTimeout() }))
  226. .then(responseHandler);
  227. }
  228. if (res.status() !== 200) {
  229. const err = new Error(`error navigating to user page, error was: ${res.status()} ${res.statusText()}`);
  230. throw Object.defineProperty(err, 'name', {
  231. value: 'ResponseError',
  232. });
  233. }
  234. return res.json();
  235. };
  236. const jsonHandler = ({ user }) => {
  237. const pageInfo = user.edge_owner_to_timeline_media.page_info;
  238. const itemIds = [];
  239. for (const { node } of user.edge_owner_to_timeline_media.edges) {
  240. if (node.__typename === 'GraphVideo' && node.product_type === 'igtv')
  241. continue;
  242. if (node.id && utils_1.BigNumOps.compare(node.id, targetId) > 0)
  243. itemIds.push(node.id);
  244. else
  245. return itemIds;
  246. }
  247. if (!pageInfo.has_next_page)
  248. return itemIds;
  249. logger.info('unable to find a smaller id than target, trying on next page...');
  250. url = graphqlLinkBuilder({ userId: user.id, after: pageInfo.end_cursor });
  251. return page.goto(url, { waitUntil: 'load', timeout: getTimeout() })
  252. .then(responseHandler)
  253. .then(({ data }) => jsonHandler(data));
  254. };
  255. return responseHandler(response)
  256. .then(({ graphql }) => jsonHandler(graphql));
  257. }).catch((err) => {
  258. if (err.name !== 'TimeoutError' && err.name !== 'ResponseError')
  259. throw err;
  260. if (err.name === 'ResponseError') {
  261. logger.warn(`error while fetching tweets for ${userName}: ${err.message}`);
  262. }
  263. else
  264. logger.warn(`navigation timed out at ${getTimerTime()} ms`);
  265. return [];
  266. }).then(itemIds => util_1.promisify(setTimeout)(getTimeout()).then(() => itemIds.map(id => this.lazyGetMediaById(id))));
  267. }).finally(() => { page.close(); });
  268. });
  269. setTimeout(this.work, this.workInterval * 1000 / this.lock.feed.length);
  270. });
  271. };
  272. this.queryUser = (username) => this.client.user.searchExact(username)
  273. .then(user => `${user.username}:${user.pk}`);
  274. this.workOnMedia = (lazyMediaItems, sendMedia) => this.webshot(lazyMediaItems, sendMedia, this.webshotDelay);
  275. this.urlSegmentToId = urlSegmentToId;
  276. this.lazyGetMediaById = (id) => ({
  277. pk: id,
  278. item: () => this.client.media.info(id).then(media => {
  279. const mediaItem = media.items[0];
  280. logger.debug(`api returned media post ${JSON.stringify(mediaItem)} for query id=${id}`);
  281. return mediaItem;
  282. }),
  283. });
  284. this.getMedia = (segmentId, sender) => this.workOnMedia([this.lazyGetMediaById(urlSegmentToId(segmentId))], sender);
  285. this.sendMedia = (source, ...to) => (msg, text, author) => {
  286. to.forEach(subscriber => {
  287. logger.info(`pushing data${source ? ` of ${source}` : ''} to ${JSON.stringify(subscriber)}`);
  288. retryOnError(() => this.bot.sendTo(subscriber, msg), (_, count, terminate) => {
  289. if (count <= maxTrials) {
  290. logger.warn(`retry sending to ${subscriber.chatID} for the ${ordinal(count)} time...`);
  291. }
  292. else {
  293. logger.warn(`${count - 1} consecutive failures while sending message chain, trying plain text instead...`);
  294. terminate(this.bot.sendTo(subscriber, author + text, true));
  295. }
  296. });
  297. });
  298. };
  299. this.work = () => {
  300. const lock = this.lock;
  301. if (this.workInterval < 1)
  302. this.workInterval = 1;
  303. if (this.isInactiveTime || lock.feed.length === 0) {
  304. setTimeout(this.work, this.workInterval * 1000 / lock.feed.length);
  305. return;
  306. }
  307. lock.feed.forEach((feed, index) => {
  308. if (!lock.threads[feed] ||
  309. !lock.threads[feed].subscribers ||
  310. lock.threads[feed].subscribers.length === 0) {
  311. logger.warn(`nobody subscribes thread ${feed}, removing from feed`);
  312. delete lock.threads[index];
  313. lock.feed.splice(index, 1);
  314. fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(lock));
  315. }
  316. });
  317. const queuedFeeds = lock.feed.slice(0, lock.workon + 1).reverse();
  318. utils_1.chainPromises(utils_1.Arr.chunk(queuedFeeds, 5).map((arr, i) => () => Promise.all(arr.map((currentFeed, j) => {
  319. const workon = (queuedFeeds.length - 1) - (i * 5 + j);
  320. fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(lock));
  321. const promiseDelay = this.workInterval * (Math.random() + j) * 500 / lock.feed.length;
  322. const startTime = new Date().getTime();
  323. const getTimerTime = () => new Date().getTime() - startTime;
  324. const promise = util_1.promisify(setTimeout)(promiseDelay).then(() => {
  325. logger.info(`about to pull from feed #${workon}: ${currentFeed}`);
  326. if (j === arr.length - 1)
  327. logger.info(`timeout for this batch job: ${Math.trunc(promiseDelay * 2)} ms`);
  328. const match = /https:\/\/www\.instagram\.com\/([^\/]+)/.exec(currentFeed);
  329. if (!match) {
  330. logger.error(`current feed "${currentFeed}" is invalid, please remove this feed manually`);
  331. return [];
  332. }
  333. return this.queryUserMedia(match[1], this.lock.threads[currentFeed].offset)
  334. .catch((error) => {
  335. logger.error(`error scraping media off profile page of ${match[1]}, error: ${error}`);
  336. return [];
  337. });
  338. }).then((mediaItems) => {
  339. const currentThread = lock.threads[currentFeed];
  340. const updateDate = () => currentThread.updatedAt = new Date().toString();
  341. if (!mediaItems || mediaItems.length === 0) {
  342. updateDate();
  343. return;
  344. }
  345. const topOfFeed = mediaItems[0].pk;
  346. const updateOffset = () => currentThread.offset = topOfFeed;
  347. if (currentThread.offset === '-1') {
  348. updateOffset();
  349. return;
  350. }
  351. if (currentThread.offset === '0')
  352. mediaItems.splice(1);
  353. return this.workOnMedia(mediaItems, this.sendMedia(`thread ${currentFeed}`, ...currentThread.subscribers))
  354. .then(updateDate).then(updateOffset);
  355. }).then(() => {
  356. lock.workon = (workon || lock.feed.length) - 1;
  357. if (j === arr.length - 1) {
  358. logger.info(`batch job #${workon}-${workon + j} completed after ${getTimerTime()} ms`);
  359. }
  360. fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(lock));
  361. });
  362. return Promise.race([promise, isWaitingForLogin ? utils_1.neverResolves() : util_1.promisify(setTimeout)(promiseDelay * 3)]);
  363. }))))
  364. .then(() => {
  365. let timeout = this.workInterval * 500;
  366. if (timeout < 1000)
  367. timeout = 1000;
  368. fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(lock));
  369. setTimeout(() => {
  370. this.work();
  371. }, timeout);
  372. });
  373. };
  374. this.client = new instagram_private_api_1.IgApiClient();
  375. if (opt.proxyUrl) {
  376. try {
  377. const url = new URL(opt.proxyUrl);
  378. if (!/^socks(?:4a?|5h?)?:$/.test(url.protocol))
  379. throw Error();
  380. if (!url.port)
  381. url.port = '1080';
  382. this.client.request.defaults.agent = new socks_proxy_agent_1.SocksProxyAgent({
  383. hostname: url.hostname,
  384. port: url.port,
  385. userId: url.username,
  386. password: url.password,
  387. });
  388. }
  389. catch (e) {
  390. logger.warn(`invalid socks proxy url: ${opt.proxyUrl}, ignoring`);
  391. }
  392. }
  393. this.session = new SessionManager(this.client, opt.sessionLockfile, opt.credentials, opt.codeServicePort);
  394. this.lockfile = opt.lockfile;
  395. this.webshotCookiesLockfile = opt.webshotCookiesLockfile;
  396. this.lock = opt.lock;
  397. this.inactiveHours = opt.inactiveHours;
  398. this.workInterval = opt.workInterval;
  399. this.bot = opt.bot;
  400. this.webshotDelay = opt.webshotDelay;
  401. this.mode = opt.mode;
  402. this.wsUrl = opt.wsUrl;
  403. const cookiesFilePath = path.resolve(this.webshotCookiesLockfile);
  404. try {
  405. this.webshotCookies = JSON.parse(fs.readFileSync(cookiesFilePath, 'utf8'));
  406. logger.info(`loaded webshot cookies from file ${this.webshotCookiesLockfile}`);
  407. }
  408. catch (err) {
  409. logger.warn(`failed to load webshot cookies from file ${this.webshotCookiesLockfile}: `, err.message);
  410. logger.warn('cookies will be saved to this file when needed');
  411. }
  412. browserLogin = page => page.fill('input[name="username"]', opt.credentials[0], { timeout: 0 })
  413. .then(() => {
  414. if (isWaitingForLogin !== true)
  415. return;
  416. logger.warn('still waiting for login, pausing execution...');
  417. return utils_1.neverResolves();
  418. })
  419. .then(() => { isWaitingForLogin = true; logger.warn('blocked by login dialog, trying to log in manually...'); })
  420. .then(() => page.fill('input[name="password"]', opt.credentials[1], { timeout: 0 }))
  421. .then(() => page.click('button[type="submit"]', { timeout: 0 }))
  422. .then(() => (next => Promise.race([
  423. page.waitForSelector('#verificationCodeDescription', { timeout: 0 }).then(handle => handle.innerText()).then(text => {
  424. logger.info(`login is requesting two-factor authentication via ${/認証アプリ/.test(text) ? 'TOTP' : 'SMS'}`);
  425. return this.session.handle2FA(code => page.fill('input[name="verificationCode"]', code, { timeout: 0 }))
  426. .then(() => page.click('button:has-text("実行")', { timeout: 0 }))
  427. .then(next);
  428. }),
  429. next(),
  430. ]))(() => page.click('button:has-text("情報を保存")', { timeout: 0 }).then(() => { isWaitingForLogin = false; })));
  431. browserSaveCookies = page => page.context().cookies()
  432. .then(cookies => {
  433. this.webshotCookies = cookies;
  434. logger.info('successfully logged in, saving cookies to file...');
  435. fs.writeFileSync(path.resolve(this.webshotCookiesLockfile), JSON.stringify(cookies, null, 2), 'utf-8');
  436. });
  437. exports.WebshotHelpers.handleLogin = page => browserLogin(page)
  438. .then(() => page.waitForSelector('img[data-testid="user-avatar"]', { timeout: this.webshotDelay }))
  439. .then(() => browserSaveCookies(page))
  440. .catch((err) => {
  441. if (err.name === 'TimeoutError') {
  442. logger.warn('navigation timed out, assuming login has failed');
  443. isWaitingForLogin = false;
  444. }
  445. throw err;
  446. });
  447. ScreenNameNormalizer._queryUser = this.queryUser;
  448. const parseMediaError = (err) => {
  449. if (!(err instanceof instagram_private_api_1.IgResponseError && err.text === 'Media not found or unavailable')) {
  450. logger.warn(`error retrieving instagram media: ${err.message}`);
  451. return `获取媒体时出现错误:${err.message}`;
  452. }
  453. return '找不到请求的媒体,它可能已被删除。';
  454. };
  455. exports.getPostOwner = (segmentId) => this.client.media.info(urlSegmentToId(segmentId))
  456. .then(media => media.items[0].user)
  457. .then(user => `${user.username}:${user.pk}`)
  458. .catch((err) => { throw Error(parseMediaError(err)); });
  459. exports.sendPost = (segmentId, receiver) => {
  460. this.getMedia(segmentId, this.sendMedia(`instagram media ${segmentId}`, receiver))
  461. .catch((err) => { this.bot.sendTo(receiver, parseMediaError(err)); });
  462. };
  463. }
  464. get isInactiveTime() {
  465. const timeToEpoch = (h = 0, m = 0) => new Date().setHours(h, m, 0, 0);
  466. return this.inactiveHours
  467. .map(rangeStr => ((start, end) => ({ start, end }))(...rangeStr.split('-', 2).map(timeStr => timeToEpoch(...timeStr.split(':', 2).map(Number)))))
  468. .some(range => (now => now >= range.start && now < range.end)(Date.now()));
  469. }
  470. }
  471. exports.default = default_1;