Skip to content

Commit

Permalink
fix(api): streamEnd/streamStart trigger relevant module (#3111)
Browse files Browse the repository at this point in the history
Fixes #3110
  • Loading branch information
sogehige committed Dec 18, 2019
1 parent 4c0cd1c commit 14bc9b5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/bot/api.ts
Expand Up @@ -6,6 +6,7 @@ require('moment-precise-range-plugin'); // moment.preciseDiff
import { isMainThread } from './cluster';
import chalk from 'chalk';
import { defaults, filter, get, isNil, isNull, map } from 'lodash';
import path from 'path';

import * as constants from './constants';
import Core from './_interface';
Expand Down Expand Up @@ -1139,11 +1140,9 @@ class API extends Core {
justStarted = true;

for (const event of getFunctionList('streamStart')) {
if (typeof this[event.fName] === 'function') {
this[event.fName]();
} else {
throw new Error(`!!! Event ${event.path} don't have function ${event.fName} !!!`);
}
const pathToModule = path.join(__dirname, ...event.path.split('.'));
const self = (require(pathToModule)).default;
self[event.fName]();
}
}
}
Expand Down Expand Up @@ -1200,7 +1199,9 @@ class API extends Core {
events.fire('number-of-viewers-is-at-least-x', { reset: true });

for (const event of getFunctionList('streamEnd')) {
this[event.fName]();
const pathToModule = path.join(__dirname, ...event.path.split('.'));
const self = (require(pathToModule)).default;
self[event.fName]();
}

this.streamId = null;
Expand Down

0 comments on commit 14bc9b5

Please sign in to comment.