jaidbot
Version:
Personal chat bot for my Twitch stream.
7 lines • 620 kB
JavaScript
#!/usr/bin/env node
/*!
*** jaidbot 6.3.0
*** Copyright © 2019, Jaid <jaid.jsx@gmail.com> (https://github.com/Jaid)
*** @license MIT
*** See https://twitch.tv/jaidchen
!*/!function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=239)}([function(t,e,r){"use strict";r.d(e,"a",(function(){return u})),r.d(e,"c",(function(){return c}));var n=r(206),i=r.n(n),o=r(207),s=r.n(o);const a=new i.a({name:"Jaidbot",version:"6.3.0",insecurePort:17441,database:!0,useGot:!0,configSetup:{defaults:s(),secretKeys:["adminPassword","twitchBotAccessToken","twitchBotRefreshToken","databasePassword","githubAppPemFilePath","githubAppWebhookSecret","githubToken","serverPassword","twitchStreamerAccessToken","twitchStreamerRefreshToken","travisToken","twitchClientId","twitchClientSecret","twitterAccessSecret","twitterAccessToken","twitterConsumerKey","twitterConsumerSecret","youtubeClientAccessToken","youtubeClientId","youtubeClientRefreshToken","youtubeClientSecret"]}}),u=a.config,c=a.logger;e.b=a},function(t,e){t.exports=require("sequelize")},function(t,e,r){"use strict";r.r(e);var n=r(21),i=r.n(n),o=r(0),s=r(6),a=r(22),u=r(19),c=t=>/^\d+$/.test(t),l=r(212),h=r.n(l),p=r(213),f=r.n(p),d=r(74),m=r.n(d),y=r(46),g=r.n(y),D=r(4),v=r(214),b=r.n(v),E=r(66),w=r.n(E),x=r(68),A=r.n(x),C=r(69),S=r.n(C),F=r(215),k=r.n(F),T=r(216),O=r.n(T),I=r(8),N=r(40),P=r.n(N);const B=/^(?<prefix>!)(?<commandName>[\da-z]+)(?<afterCommandName>\s*(?<commandArguments>.*))?/i,_=r(288);class j extends i.a{constructor(){super(),this.commands=_.keys().reduce((t,e)=>{return t[e.match(/\.\/(?<key>[\da-z]+)\//i).groups.key]=_(e).default,t},{}),this.commandUsages=[];for(const[t,e]of Object.entries(this.commands)){const n=r(321)(`./${t}/help.yml`);if(Object(D.isEmpty)(n))continue;const i=P()(n);for(const r of i){const n={command:t,description:r.description};if(r.param){const e=P()(r.param);n.params=e,n.usage=`!${t} ${e.join(" ")}`}else n.usage=`!${t}`;r.example&&(n.example=P()(r.example)),Object.assign(n,A()(e,"permission","needsDesktopClient","requiredArguments")),this.commandUsages.push(n)}}}async handleMessage(t){var e;const r=B.exec(t.text);if(null===r)return;const n=r.groups.commandName.toLowerCase();let i,s;var a,u;r.groups.commandArguments&&(u=r.groups.commandArguments,a=k()(u),s=(i=O()(a))._);const c=await $.getNickname(t.sender.id),l=this.commands[n];if(l){if(!t.sender.isBroadcaster){if("subOrVip"===l.permission&&!t.sender.isVip&&!t.sender.isSub&&!t.sender.isMod)return void $.say(`${c}, für diesen Befehl musst du Moderator, Subscriber oder VIP sein!`);if("mod"===l.permission&&!t.sender.hasElevatedPermission)return void $.say(`${c}, für diesen Befehl musst du Moderator sein!`)}if(!l.needsDesktopClient||I.default.hasClient()){if(l.requiredArguments){if(!i)return void $.say(`${c}, dieser Befehl kann nicht ohne Arguments verwendet werden!`);const t=s.length;if(l.requiredArguments>t)return void $.say(`${c}, dieser Befehl benötigt ${l.requiredArguments} Arguments!`)}l.handle({...t,commandArguments:i,senderName:c,positionalArguments:s||[],combinedArguments:null==r?void 0:null===(e=r.groups)||void 0===e?void 0:e.commandArguments}).then(t=>{var e;e=t,S()(e)&&$.say(t)}).catch(e=>{o.c.error('Error at execution of "%s": %s',t.text,e),$.say(`Oh, ${c}, da hat irgendetwas nicht geklappt. Muss sich ${$.streamerUser.getDisplayName()} drum kümmern.`)})}else $.say(`Es besteht gerade keine Verbindung zum Computer von ${$.streamerUser.getDisplayName()}. ResidentSleeper`)}else $.say(`Verstehe ich jetzt nicht, ${c}! Alle Befehle sind in den Panels unter dem Stream beschrieben.`)}}function M(t){return t.replace(/^\s*\[.*]\s*/,"")}r.d(e,"removeTitlePrefix",(function(){return M}));class L extends i.a{constructor(...t){super(...t),this.isInAdLoop=!1,this.currentTitle=null,this.isReady=!1,this.currentTitle=null}handleConfig(t){this.nicknames=t.nicknames||{},this.streamerLogin=t.twitchStreamerLogin,this.botLogin=t.twitchBotLogin,this.predefinedStreamerAccessToken=t.twitchStreamerAccessToken,this.predefinedStreamerRefreshToken=t.twitchStreamerRefreshToken,this.predefinedBotAccessToken=t.twitchBotAccessToken,this.predefinedBotRefreshToken=t.twitchBotRefreshToken,this.clientId=t.twitchClientId,this.clientSecret=t.twitchClientSecret,this.tickMs=1e3*t.twitchTickSeconds,this.nicknameCache=new h.a({stdTTL:86400})}async init(){await g()(1e4),this.apiClient=await w.a.withClientCredentials(this.clientId,this.clientSecret);const t=["streamer","bot"];for(const e of t){const t=b()(e),r=this[`${e}Login`];o.c.info("Preparing %s Twitch account (%s)",e,r);const n=await a.default.findOrRegisterByLogin(r);if(!n.accessToken&&this[`predefined${t}AccessToken`]&&(n.accessToken=this[`predefined${t}AccessToken`],o.c.info("Set Twitch %s accessToken from config",e)),!n.refreshToken&&this[`predefined${t}RefreshToken`]&&(n.refreshToken=this[`predefined${t}RefreshToken`],o.c.info("Set Twitch %s refreshToken from config",e)),await n.save(),!(null==n?void 0:n.accessToken))return o.c.warn("No user auth found for requested streamer user %s",this.streamerLogin),!1;this[`${e}User`]=n,this[e]=await n.toTwitchClientWithChat(),this[`${e}Client`]=this[e].apiClient}const e=await this.streamerClient.kraken.channels.getMyChannel();this.streamerTwitchId=e.id,this.currentTitle=e.status;const r=M(this.currentTitle);this.currentTitle!==r&&(o.c.debug("The initial stream title had a prefix, removing it because it is most likely outdated"),this.setTitle(r)),o.c.info("Initial stream title: %s",this.currentTitle),this.streamerChatClient=this.streamer.chatClient,this.chatClient=this.bot.chatClient,await this.chatClient.join(this.streamerLogin),o.c.info("Connected bot"),this.chatBot=new j,this.chatClient.onPrivmsg(async(t,e,r,n)=>{const i={text:r.trim(),bits:n.totalBits||0,sender:{id:n.userInfo.userId,name:n.userInfo.userName,isBroadcaster:"1"===n.userInfo.badges.get("broadcaster"),isVip:"1"===n.userInfo.badges.get("vip"),isMod:n.userInfo.isMod,isSub:n.userInfo.isSubscriber,color:n.userInfo.color}};i.sender.displayName=n.userInfo.displayName||i.sender.name,i.sender.hasElevatedPermission=Boolean(n.userInfo.userType)||i.sender.isBroadcaster,n.userInfo._userData.has("tmi-sent-ts")&&(i.sentDate=new Date(Number(n.userInfo._userData.get("tmi-sent-ts")))),o.c.debug(`${i.sender.displayName}: ${i.text}`),this.emit("chat",i),await this.chatBot.handleMessage(i)}),this.isReady=!0,this.say("TBAngel Da bin ich!")}async userNameToDisplayName(t){const e=await this.apiClient.helix.users.getUserByName(t);return(null==e?void 0:e.displayName)||(null==e?void 0:e.name)||t}async getNickname(t){try{var e,r;const n=String(t).trim().toLowerCase(),i=this.nicknameCache.get(n);if(i)return i;const o=this.nicknames[n];if(o)return this.nicknameCache.set(n,o),o;let s,a;if(c(t)&&(a=await this.apiClient.helix.users.getUserById(n))){s=a.name;const t=this.nicknames[s];if(t)return this.nicknameCache.set(s,t),t}a||(s=n,a=await this.apiClient.helix.users.getUserByName(s));const u=(null===(e=a)||void 0===e?void 0:e.displayName)||(null===(r=a)||void 0===r?void 0:r.name)||n;return this.nicknameCache.set(s,u),u}catch(e){return o.c.error(`Could not fetch nickname for "${t}"\n%s`,e),"(?)"}}async playAd(t=30){const e=async()=>{await this.streamerClient.kraken.channels.startChannelCommercial(this.streamerUser.twitchId,t)};try{await f()(e,{maxTimeout:5e3,minTimeout:100}),o.c.debug("Started %s ad",m()(1e3*t))}catch(e){o.c.error("Could not play %ss ad\n%s",t,e)}}async startAdLoop(){for(this.isInAdLoop=!0;this.isInAdLoop;)await this.playAd(180),await g()(48e4)}async stopAdLoop(){this.isInAdLoop=!1}async getFollowMoment(t){const e=await this.apiClient.helix.users.getUserByName(t),r=await e.getFollowTo(this.streamerUser.twitchId);return null!==r&&Object(s.a)(r.followDate)}async getMyStream(){return this.streamerClient.kraken.streams.getStreamByChannel(this.streamerUser.twitchId)}async setCategory(t){await this.streamerClient.kraken.channels.updateChannel(this.streamerUser.twitchId,{game:t})}async getUserInfoByTwitchId(t){return await this.apiClient.helix.users.getUserById(t)}async getUserInfoByTwitchLogin(t){return await this.apiClient.helix.users.getUserByName(t)}async setTitle(t){const e=String(t).trim();e!==this.currentTitle?(this.currentTitle=e,o.c.info("New stream title: %s",e),await this.streamerClient.kraken.channels.updateChannel(this.streamerUser.twitchId,{status:e})):o.c.debug("Not overwriting stream title, it has not changed")}say(t){this.chatClient?this.chatClient.say(this.streamerUser.loginName,t):o.c.warn('Tried to say "%s", but chatClient was %s',t,this.chatClient)}isPlayingGame(t){return!!u.default.currentStatus&&(!Object(D.isEmpty)(u.default.currentStatus.game)&&u.default.currentStatus.game.toLowerCase()===t.toLowerCase())}isLastGame(t){return!!u.default.lastTwitchStatus&&(!Object(D.isEmpty)(u.default.lastTwitchStatus.game)&&u.default.lastTwitchStatus.game.toLowerCase()===t.toLowerCase())}notifyIfGame(t,e){this.isLastGame(t)&&this.say(`HumbleLife ${e}`)}notifyIfGameLive(t,e){this.isPlayingGame(t)&&this.say(`HumbleLife ${e}`)}ready(){this.tickMs?this.tickInterval=setInterval(this.tick.bind(this),this.tickMs):o.c.warn("Not starting Twitch ticking, because config.twitchTickSeconds is not given")}getTitleWithoutPrefix(){return M(this.currentTitle)}async tick(){const t=Date.now();try{const e=Date.now(),r=await this.botClient.unsupported.getChatters(this.streamerLogin);o.c.debug("Fetched %s chatters in %s",r.allChatters.length,m()(Date.now()-e));for(const[t,e]of r.allChattersWithStatus.entries()){const r=await a.default.findOrRegisterByLogin(t,{defaults:{chatterRole:e}});r.chatterRole!==e&&(o.c.info("Changed chatter role of %s from %s to %s",r.getDisplayName(),r.chatterRole,e),r.chatterRole=e),await r.save()}o.c.debug("Twitch tick done in %s",m()(Date.now()-t))}catch(t){o.c.error("Twitch tick failed: %s",t)}}}var $=e.default=new L},function(t,e,r){"use strict";r.r(e),r.d(e,"schema",(function(){return v})),r.d(e,"indexes",(function(){return b}));var n=r(68),i=r.n(n),o=r(69),s=r.n(o),a=r(1),u=r.n(a),c=r(0),l=r(8),h=r(217),p=r.n(h),f=r(6),d=r(22),m=r(27),y=r.n(m),g=r(2);class D extends u.a.Model{static associate(t){D.belongsTo(t.TwitchUser,{as:"Requester",foreignKey:"RequesterId"})}static start(){l.default.on("gotClient",t=>{c.c.debug("Received gotClient in Video model handler"),t.on("videoDownloaded",D.handleVideoDownloaded),t.on("vlcState",D.handleVlcState),t.on("setInfoFile",D.handleSetInfoFile),t.on("getDownloadJobs",t=>D.handleGetDownloadJobs(t))})}static setCurrentVideo(t){D.currentVideoHeartbeatTimestamp=Date.now(),D.currentVideo=t}static async handleVideoDownloaded({videoId:t,bytes:e,videoFile:r,infoFile:n}){try{await D.update({bytes:e,videoFile:r,infoFile:n,downloadedAt:new Date},{where:{id:t}})}catch(t){c.c.error("Error at videoDownloaded handler: %s",t)}}static async handleVlcState(t){try{var e;D.currentVideoHeartbeatTimestamp=Date.now();const r=(null===(e=D.currentVideo)||void 0===e?void 0:e.videoFile)!==t.file;if(!r&&D.currentVideo.hasBeenWatched())return;await c.b.database.transaction(async e=>{if(r){const r=await D.findOne({transaction:e,where:{videoFile:t.file}});if(!r)return void(D.currentVideo&&(c.c.info("Video.currentVideo will be set to null, because current video is not found in database"),D.currentVideo=null));if(c.c.info(`Current video set to #${r.id}`),D.currentVideo=r,r.hasBeenWatched())return void c.c.debug("Not applying any changes on video, because it has already been watched")}const n=D.currentVideo,i=["timestamp"];n.vlcDuration||(n.vlcDuration=t.durationMs,i.push("vlcDuration")),n.timestamp=t.timestampMs;const o=t.durationMs-t.timestampMs;1e4>o&&(n.watchedAt=Object(f.a)().add(o,"ms").toDate(),i.push("watchedAt"),c.c.debug("Video #%s will be marked as watched",n.id)),await n.save({transaction:e,fields:i})})}catch(t){c.c.error("Error at vlcState handler: %s",t)}}static async handleSetInfoFile({videoId:t,infoFile:e}){try{await D.update({infoFile:e},{where:{id:t}}),c.c.debug("Got info file path for video #%s",t)}catch(t){c.c.error("Error at setInfoFile handler: %s",t)}}static async handleGetDownloadJobs(t){try{return void t(await D.findAll({where:{videoFile:{[a.Op.eq]:null}},raw:!0,attributes:["id","downloadFormat","info"]}))}catch(e){return c.c.error("Error at getDownloadJobs handler: %s",e),void t(!1)}}static async queueByUrl(t,e){let r,n;try{var i;i=(r=await p()(c.a.youtubeDlPath,["--no-color","--ignore-config","--abort-on-error","--netrc","--format",c.a.youtubeDlFormat,"--cookies",c.a.youtubeDlCookieFile,"--dump-single-json",t])).stdout,n=JSON.parse(i)}catch(e){var o,s;c.c.error("Could not use youtube-dl to fetch media information of url %s: %s\ncommand: %s\nstd: %s",t,e,(null===(o=r)||void 0===o?void 0:o.command)||(null==e?void 0:e.command),(null===(s=r)||void 0===s?void 0:s.all)||(null==e?void 0:e.all))}if(!n&&l.default.hasClient()&&(c.c.warn("Could not fetch info for %s, trying on Desktop instead",t),n=await y.a.withDefaultTimeout(l.default.client,"fetchVideoInfo",t)),n)return D.queueByInfo(n,{requestUrl:t,...e});throw new Error(`Could not fetch info for video URL ${t}`)}static async queueByInfo(t,e){var r;const n=t.release_date||t.upload_date;let i;r=n,s()(r)&&(i=Object(f.a)(n,"YYYYMMDD").toDate());const o={title:t.title||t.webpage_url,duration:1e3*t.duration,views:t.view_count,likes:t.like_count,dislikes:t.dislike_count,publishedAt:i,format:t.format,extractor:t.extractor||t.extractor_key,width:t.width,height:t.height,webUrl:t.webpage_url||t.channel_url||t.uploader_url,audioCodec:t.acodec,videoCodec:t.vcodec,formatId:t.format_id,fileExtension:t.ext,description:t.description,thumbnailUrl:t.thumbnail,channelUrl:t.channel_url||t.uploader_url,audioBitrate:t.abr,videoBitrate:t.vbr,mediaId:t.id,ageLimit:t.age_limit,publisher:t.uploader||t.uploader_id,publisherId:t.uploader_id,info:t,downloadFormat:c.a.youtubeDlFormat};if(void 0!==e.priority&&(o.priority=e.priority),e.requesterTwitchId){const t=await d.default.getByTwitchId(e.requesterTwitchId);o.RequesterId=t.id}e.requestUrl&&(o.requestUrl=e.requestUrl);const[a,u]=await D.findOrCreate({where:{extractor:o.extractor,mediaId:o.mediaId},defaults:o});return u?(c.c.info('Requested video #%s "%s" with priority %s',a.id,a.title,a.priority),l.default.hasClient()&&l.default.client.emit("queueInfo",{videoInfo:t,videoId:a.id,downloadFormat:a.downloadFormat})):(await a.update({...o,priority:a.priority+10}),c.c.info('Video #%s "%s" got requested again, increased priority from %s to %s',a.id,a.title,a.priority-10,a.priority)),a}static getCurrentVideo(t=1e4){return D.currentVideo?Date.now()-D.currentVideoHeartbeatTimestamp>t?null:D.currentVideo:null}static getCurrentYoutubeVideo(t){const e=this.getCurrentVideo(t);return e?"youtube"===e.extractor?e:void g.default.say("Beim abgespielten Video scheint es sich nicht um ein YouTube-Video zu handeln."):null}static async getVlcState(){if(!l.default.hasClient())return void g.default.say("Ich habe keine Verbindung zum Computer von Jaidchen und kann somit auch das Kino nicht kontaktieren!");const t=await y.a.withDefaultTimeout(l.default.client,"getVlcState");if("noVlc"!==t)return t;g.default.say("Kein Lebenszeichen aus dem Kino, sorry!")}static async sendVlcCommand(t,e){if(!l.default.hasClient())return void g.default.say("Ich habe keine Verbindung zum Computer von Jaidchen und kann somit auch das Kino nicht kontaktieren!");const r={command:t,...e},n=await y.a.withDefaultTimeout(l.default.client,"sendVlcCommand",r);if("noVlc"!==n){if("commandFailed"!==n)return n;g.default.say("Die Anweisung ans Kino hat jetzt nicht so richtig geklappt.")}else g.default.say("Kein Lebenszeichen aus dem Kino, sorry!")}hasBeenWatched(){return null!==this.watchedAt}async play(){return l.default.hasClient()?this.videoFile?y.a.withDefaultTimeout(l.default.client,"playVideo",i()(this.get(),"videoFile","timestamp")):(c.c.warn("Tried to play video #%s on desktop, but videoFile is not defined",this.id),!1):(c.c.warn("Couldn't play video #%s, not connected to desktop",this.id),!1)}getDurationMs(){return this.vlcDuration||this.duration}getDurationSeconds(){return Math.floor(this.getDurationMs()/1e3)}}D.currentVideo=null,D.currentVideoHeartbeatTimestamp=null;const v={title:{allowNull:!1,type:u.a.STRING},duration:u.a.INTEGER,views:u.a.BIGINT,likes:u.a.INTEGER,dislikes:u.a.INTEGER,publishedAt:u.a.DATE,format:u.a.STRING,extractor:u.a.STRING,width:u.a.SMALLINT,height:u.a.SMALLINT,webUrl:u.a.TEXT,audioCodec:u.a.STRING,videoCodec:u.a.STRING,formatId:u.a.STRING,fileExtension:u.a.STRING,description:u.a.TEXT,thumbnailUrl:u.a.TEXT,channelUrl:u.a.TEXT,audioBitrate:u.a.SMALLINT,videoBitrate:u.a.INTEGER,mediaId:u.a.STRING,ageLimit:u.a.SMALLINT,publisher:u.a.STRING,publisherId:u.a.STRING,info:u.a.JSONB,priority:{allowNull:!1,type:u.a.SMALLINT,defaultValue:100},timestamp:u.a.INTEGER,watchedAt:u.a.DATE,skipped:{allowNull:!1,type:u.a.BOOLEAN,defaultValue:!1},liked:u.a.BOOLEAN,frozenUntil:{type:u.a.DATE,allowNull:!1,defaultValue:0},requestUrl:u.a.TEXT,infoFile:u.a.STRING,videoFile:u.a.STRING,bytes:u.a.BIGINT,downloadedAt:u.a.DATE,vlcDuration:u.a.INTEGER,downloadFormat:u.a.STRING},b=[{unique:!0,fields:["extractor","mediaId"]}];e.default=D},function(t,e){t.exports=require("has-content")},function(t,e){t.exports=require("path")},function(t,e,r){"use strict";var n=r(73),i=r.n(n),o=r(208);r.n(o)()(i.a),i.a.locale("de"),e.a=i.a},function(t,e,r){var n,i,o=r(16),s=r(358),a=r(360),u=r(361),c=r(20);"function"==typeof Symbol&&"function"==typeof Symbol.for?(n=Symbol.for("graceful-fs.queue"),i=Symbol.for("graceful-fs.previous")):(n="___graceful-fs.queue",i="___graceful-fs.previous");var l=function(){};if(c.debuglog?l=c.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(l=function(){var t=c.format.apply(c,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),!global[n]){var h=[];Object.defineProperty(global,n,{get:function(){return h}}),o.close=function(t){function e(e,r){return t.call(o,e,(function(t){t||d(),"function"==typeof r&&r.apply(this,arguments)}))}return Object.defineProperty(e,i,{value:t}),e}(o.close),o.closeSync=function(t){function e(e){t.apply(o,arguments),d()}return Object.defineProperty(e,i,{value:t}),e}(o.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",(function(){l(global[n]),r(30).equal(global[n].length,0)}))}function p(t){s(t),t.gracefulify=p,t.createReadStream=function(e,r){return new t.ReadStream(e,r)},t.createWriteStream=function(e,r){return new t.WriteStream(e,r)};var e=t.readFile;t.readFile=function(t,r,n){"function"==typeof r&&(n=r,r=null);return function t(r,n,i){return e(r,n,(function(e){!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?("function"==typeof i&&i.apply(this,arguments),d()):f([t,[r,n,i]])}))}(t,r,n)};var r=t.writeFile;t.writeFile=function(t,e,n,i){"function"==typeof n&&(i=n,n=null);return function t(e,n,i,o){return r(e,n,i,(function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?("function"==typeof o&&o.apply(this,arguments),d()):f([t,[e,n,i,o]])}))}(t,e,n,i)};var n=t.appendFile;n&&(t.appendFile=function(t,e,r,i){"function"==typeof r&&(i=r,r=null);return function t(e,r,i,o){return n(e,r,i,(function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?("function"==typeof o&&o.apply(this,arguments),d()):f([t,[e,r,i,o]])}))}(t,e,r,i)});var i=t.readdir;function o(e){return i.apply(t,e)}if(t.readdir=function(t,e,r){var n=[t];"function"!=typeof e?n.push(e):r=e;return n.push((function(t,e){e&&e.sort&&e.sort();!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?("function"==typeof r&&r.apply(this,arguments),d()):f([o,[n]])})),o(n)},"v0.8"===process.version.substr(0,4)){var u=a(t);h=u.ReadStream,m=u.WriteStream}var c=t.ReadStream;c&&(h.prototype=Object.create(c.prototype),h.prototype.open=function(){var t=this;g(t.path,t.flags,t.mode,(function(e,r){e?(t.autoClose&&t.destroy(),t.emit("error",e)):(t.fd=r,t.emit("open",r),t.read())}))});var l=t.WriteStream;function h(t,e){return this instanceof h?(c.apply(this,arguments),this):h.apply(Object.create(h.prototype),arguments)}function m(t,e){return this instanceof m?(l.apply(this,arguments),this):m.apply(Object.create(m.prototype),arguments)}l&&(m.prototype=Object.create(l.prototype),m.prototype.open=function(){var t=this;g(t.path,t.flags,t.mode,(function(e,r){e?(t.destroy(),t.emit("error",e)):(t.fd=r,t.emit("open",r))}))}),Object.defineProperty(t,"ReadStream",{get:function(){return h},set:function(t){h=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return m},set:function(t){m=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FileReadStream",{get:function(){return h},set:function(t){h=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FileWriteStream",{get:function(){return m},set:function(t){m=t},enumerable:!0,configurable:!0});var y=t.open;function g(t,e,r,n){return"function"==typeof r&&(n=r,r=null),function t(e,r,n,i){return y(e,r,n,(function(o,s){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?("function"==typeof i&&i.apply(this,arguments),d()):f([t,[e,r,n,i]])}))}(t,e,r,n)}return t.open=g,t}function f(t){l("ENQUEUE",t[0].name,t[1]),global[n].push(t)}function d(){var t=global[n].shift();t&&(l("RETRY",t[0].name,t[1]),t[0].apply(null,t[1]))}t.exports=p(u(o)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!o.__patched&&(t.exports=p(o),o.__patched=!0)},function(t,e,r){"use strict";r.r(e);var n=r(21),i=r.n(n),o=r(0),s=r(2),a=r(224);var u=new(r.n(a).a)({logger:o.c}),c=r(225),l=r.n(c);class h extends i.a{async init(){this.socketServer=l()(o.b.insecureServer),this.socketServer.on("connection",t=>t.handshake.query.password!==o.a.serverPassword?(o.c.warn("Received wrong password from client %s, disconnecting",t.handshake.address),void t.disconnect()):this.hasClient()?(o.c.warn("Client %s tried to connect, but another client is already here",t.handshake.address),void t.disconnect()):(this.client=t,t.on("disconnect",()=>{delete this.client,o.c.info("Client %s has disconnected",t.handshake.address),s.default.say("Uff, ich habe die Verbindung zum Computer von Jaidchen verloren.")}),this.emit("gotClient",t),void s.default.say("Ich bin jetzt mit dem Computer von Jaidchen verbunden!"))),u.enhanceServer(this.socketServer)}hasClient(){return Boolean(this.client)}}e.default=new h},function(t,e){(function(){t.exports={Element:1,Attribute:2,Text:3,CData:4,EntityReference:5,EntityDeclaration:6,ProcessingInstruction:7,Comment:8,Document:9,DocType:10,DocumentFragment:11,NotationDeclaration:12,Declaration:201,Raw:202,AttributeDeclaration:203,ElementDeclaration:204,Dummy:205}}).call(this)},function(t,e,r){"use strict";var n=r(43),i=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],o=["scalar","sequence","mapping"];t.exports=function(t,e){var r,s;if(e=e||{},Object.keys(e).forEach((function(e){if(-1===i.indexOf(e))throw new n('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.defaultStyle=e.defaultStyle||null,this.styleAliases=(r=e.styleAliases||null,s={},null!==r&&Object.keys(r).forEach((function(t){r[t].forEach((function(e){s[String(e)]=t}))})),s),-1===o.indexOf(this.kind))throw new n('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')}},function(t,e,r){"use strict";r.r(e);e.default=new class{constructor(){this.currentProject=null,this.currentProjectRepo=null,this.projectSetDate=null}setProject(t,e=null){this.currentProject=t,this.currentProjectRepo=e,this.projectSetDate=Date.now()}clearProject(){this.currentProject=null}collectModels(){const t={},e=r(299);for(const r of e.keys()){t[r.match(/\.\/(?<key>[\da-z]+)\./i).groups.key]=e(r)}return t}}},function(t,e,r){"use strict";e.fromCallback=function(t){return Object.defineProperty((function(){if("function"!=typeof arguments[arguments.length-1])return new Promise((e,r)=>{arguments[arguments.length]=(t,n)=>{if(t)return r(t);e(n)},arguments.length++,t.apply(this,arguments)});t.apply(this,arguments)}),"name",{value:t.name})},e.fromPromise=function(t){return Object.defineProperty((function(){const e=arguments[arguments.length-1];if("function"!=typeof e)return t.apply(this,arguments);t.apply(this,arguments).then(t=>e(null,t),e)}),"name",{value:t.name})}},function(t,e,r){"use strict";const n=(0,r(12).fromCallback)(r(363)),i=r(364);t.exports={mkdirs:n,mkdirsSync:i,mkdirp:n,mkdirpSync:i,ensureDir:n,ensureDirSync:i}},function(t,e,r){(function(){var e,n,i,o,s,a,u,c,l,h,p,f,d,m,y,g,D,v={}.hasOwnProperty;D=r(25),g=D.isObject,y=D.isFunction,m=D.isEmpty,d=D.getValue,c=null,i=null,o=null,s=null,a=null,p=null,f=null,h=null,u=null,n=null,l=null,e=null,t.exports=function(){function t(t){this.parent=t,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),this.value=null,this.children=[],this.baseURI=null,c||(c=r(89),i=r(91),o=r(92),s=r(93),a=r(94),p=r(99),f=r(100),h=r(101),u=r(183),n=r(9),l=r(415),r(90),e=r(416))}return Object.defineProperty(t.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(t.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(t.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(t.prototype,"childNodes",{get:function(){return this.childNodeList&&this.childNodeList.nodes||(this.childNodeList=new l(this.children)),this.childNodeList}}),Object.defineProperty(t.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(t.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(t.prototype,"previousSibling",{get:function(){var t;return t=this.parent.children.indexOf(this),this.parent.children[t-1]||null}}),Object.defineProperty(t.prototype,"nextSibling",{get:function(){var t;return t=this.parent.children.indexOf(this),this.parent.children[t+1]||null}}),Object.defineProperty(t.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(t.prototype,"textContent",{get:function(){var t,e,r,i,o;if(this.nodeType===n.Element||this.nodeType===n.DocumentFragment){for(o="",e=0,r=(i=this.children).length;r>e;e++)(t=i[e]).textContent&&(o+=t.textContent);return o}return null},set:function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),t.prototype.setParent=function(t){var e,r,n,i,o;for(this.parent=t,t&&(this.options=t.options,this.stringify=t.stringify),o=[],r=0,n=(i=this.children).length;n>r;r++)e=i[r],o.push(e.setParent(this));return o},t.prototype.element=function(t,e,r){var n,i,o,s,a,u,c,l,h,p,f;if(u=null,null===e&&null==r&&(e=(h=[{},null])[0],r=h[1]),null==e&&(e={}),e=d(e),g(e)||(r=(p=[e,r])[0],e=p[1]),null!=t&&(t=d(t)),Array.isArray(t))for(o=0,c=t.length;c>o;o++)i=t[o],u=this.element(i);else if(y(t))u=this.element(t.apply());else if(g(t)){for(a in t)if(v.call(t,a))if(f=t[a],y(f)&&(f=f.apply()),!this.options.ignoreDecorators&&this.stringify.convertAttKey&&0===a.indexOf(this.stringify.convertAttKey))u=this.attribute(a.substr(this.stringify.convertAttKey.length),f);else if(!this.options.separateArrayItems&&Array.isArray(f)&&m(f))u=this.dummy();else if(g(f)&&m(f))u=this.element(a);else if(this.options.keepNullNodes||null!=f)if(!this.options.separateArrayItems&&Array.isArray(f))for(s=0,l=f.length;l>s;s++)i=f[s],(n={})[a]=i,u=this.element(n);else g(f)?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===a.indexOf(this.stringify.convertTextKey)?u=this.element(f):(u=this.element(a)).element(f):u=this.element(a,f);else u=this.dummy()}else u=this.options.keepNullNodes||null!==r?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===t.indexOf(this.stringify.convertTextKey)?this.text(r):!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&0===t.indexOf(this.stringify.convertCDataKey)?this.cdata(r):!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&0===t.indexOf(this.stringify.convertCommentKey)?this.comment(r):!this.options.ignoreDecorators&&this.stringify.convertRawKey&&0===t.indexOf(this.stringify.convertRawKey)?this.raw(r):!this.options.ignoreDecorators&&this.stringify.convertPIKey&&0===t.indexOf(this.stringify.convertPIKey)?this.instruction(t.substr(this.stringify.convertPIKey.length),r):this.node(t,e,r):this.dummy();if(null==u)throw new Error("Could not create any elements with: "+t+". "+this.debugInfo());return u},t.prototype.insertBefore=function(t,e,r){var n,i,o,s,a;if(null!=t?t.type:void 0)return s=e,(o=t).setParent(this),s?(i=children.indexOf(s),a=children.splice(i),children.push(o),Array.prototype.push.apply(children,a)):children.push(o),o;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(t));return i=this.parent.children.indexOf(this),a=this.parent.children.splice(i),n=this.parent.element(t,e,r),Array.prototype.push.apply(this.parent.children,a),n},t.prototype.insertAfter=function(t,e,r){var n,i,o;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(t));return i=this.parent.children.indexOf(this),o=this.parent.children.splice(i+1),n=this.parent.element(t,e,r),Array.prototype.push.apply(this.parent.children,o),n},t.prototype.remove=function(){var t;if(this.isRoot)throw new Error("Cannot remove the root element. "+this.debugInfo());return t=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[t,t-t+1].concat([])),this.parent},t.prototype.node=function(t,e,r){var n,i;return null!=t&&(t=d(t)),e||(e={}),e=d(e),g(e)||(r=(i=[e,r])[0],e=i[1]),n=new c(this,t,e),null!=r&&n.text(r),this.children.push(n),n},t.prototype.text=function(t){var e;return g(t)&&this.element(t),e=new f(this,t),this.children.push(e),this},t.prototype.cdata=function(t){var e;return e=new i(this,t),this.children.push(e),this},t.prototype.comment=function(t){var e;return e=new o(this,t),this.children.push(e),this},t.prototype.commentBefore=function(t){var e,r;return e=this.parent.children.indexOf(this),r=this.parent.children.splice(e),this.parent.comment(t),Array.prototype.push.apply(this.parent.children,r),this},t.prototype.commentAfter=function(t){var e,r;return e=this.parent.children.indexOf(this),r=this.parent.children.splice(e+1),this.parent.comment(t),Array.prototype.push.apply(this.parent.children,r),this},t.prototype.raw=function(t){var e;return e=new p(this,t),this.children.push(e),this},t.prototype.dummy=function(){return new u(this)},t.prototype.instruction=function(t,e){var r,n,i,o,s;if(null!=t&&(t=d(t)),null!=e&&(e=d(e)),Array.isArray(t))for(o=0,s=t.length;s>o;o++)r=t[o],this.instruction(r);else if(g(t))for(r in t)v.call(t,r)&&(n=t[r],this.instruction(r,n));else y(e)&&(e=e.apply()),i=new h(this,t,e),this.children.push(i);return this},t.prototype.instructionBefore=function(t,e){var r,n;return r=this.parent.children.indexOf(this),n=this.parent.children.splice(r),this.parent.instruction(t,e),Array.prototype.push.apply(this.parent.children,n),this},t.prototype.instructionAfter=function(t,e){var r,n;return r=this.parent.children.indexOf(this),n=this.parent.children.splice(r+1),this.parent.instruction(t,e),Array.prototype.push.apply(this.parent.children,n),this},t.prototype.declaration=function(t,e,r){var i,o;return i=this.document(),o=new s(i,t,e,r),0===i.children.length?i.children.unshift(o):i.children[0].type===n.Declaration?i.children[0]=o:i.children.unshift(o),i.root()||i},t.prototype.dtd=function(t,e){var r,i,o,s,u,c,l,h,p;for(r=this.document(),i=new a(r,t,e),o=s=0,c=(h=r.children).length;c>s;o=++s)if(h[o].type===n.DocType)return r.children[o]=i,i;for(o=u=0,l=(p=r.children).length;l>u;o=++u)if(p[o].isRoot)return r.children.splice(o,0,i),i;return r.children.push(i),i},t.prototype.up=function(){if(this.isRoot)throw new Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},t.prototype.root=function(){var t;for(t=this;t;){if(t.type===n.Document)return t.rootObject;if(t.isRoot)return t;t=t.parent}},t.prototype.document=function(){var t;for(t=this;t;){if(t.type===n.Document)return t;t=t.parent}},t.prototype.end=function(t){return this.document().end(t)},t.prototype.prev=function(){var t;if(1>(t=this.parent.children.indexOf(this)))throw new Error("Already at the first node. "+this.debugInfo());return this.parent.children[t-1]},t.prototype.next=function(){var t;if(-1===(t=this.parent.children.indexOf(this))||t===this.parent.children.length-1)throw new Error("Already at the last node. "+this.debugInfo());return this.parent.children[t+1]},t.prototype.importDocument=function(t){var e;return(e=t.root().clone()).parent=this,e.isRoot=!1,this.children.push(e),this},t.prototype.debugInfo=function(t){var e,r;return null!=(t=t||this.name)||(null!=(e=this.parent)?e.name:void 0)?null==t?"parent: <"+this.parent.name+">":(null!=(r=this.parent)?r.name:void 0)?"node: <"+t+">, parent: <"+this.parent.name+">":"node: <"+t+">":""},t.prototype.ele=function(t,e,r){return this.element(t,e,r)},t.prototype.nod=function(t,e,r){return this.node(t,e,r)},t.prototype.txt=function(t){return this.text(t)},t.prototype.dat=function(t){return this.cdata(t)},t.prototype.com=function(t){return this.comment(t)},t.prototype.ins=function(t,e){return this.instruction(t,e)},t.prototype.doc=function(){return this.document()},t.prototype.dec=function(t,e,r){return this.declaration(t,e,r)},t.prototype.e=function(t,e,r){return this.element(t,e,r)},t.prototype.n=function(t,e,r){return this.node(t,e,r)},t.prototype.t=function(t){return this.text(t)},t.prototype.d=function(t){return this.cdata(t)},t.prototype.c=function(t){return this.comment(t)},t.prototype.r=function(t){return this.raw(t)},t.prototype.i=function(t,e){return this.instruction(t,e)},t.prototype.u=function(){return this.up()},t.prototype.importXMLBuilder=function(t){return this.importDocument(t)},t.prototype.replaceChild=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.removeChild=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.appendChild=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.hasChildNodes=function(){return 0!==this.children.length},t.prototype.cloneNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.normalize=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.isSupported=function(t,e){return!0},t.prototype.hasAttributes=function(){return 0!==this.attribs.length},t.prototype.compareDocumentPosition=function(t){var r;return this,this===t?0:this.document()!==t.document()?(r=e.Disconnected|e.ImplementationSpecific,.5>Math.random()?r|=e.Preceding:r|=e.Following,r):this.isAncestor(t)?e.Contains|e.Preceding:this.isDescendant(t)?e.Contains|e.Following:this.isPreceding(t)?e.Preceding:e.Following},t.prototype.isSameNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.lookupPrefix=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.isDefaultNamespace=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.lookupNamespaceURI=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.isEqualNode=function(t){var e,r,n;if(t.nodeType!==this.nodeType)return!1;if(t.children.length!==this.children.length)return!1;for(e=r=0,n=this.children.length-1;0>n?r>=n:n>=r;e=0>n?--r:++r)if(!this.children[e].isEqualNode(t.children[e]))return!1;return!0},t.prototype.getFeature=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.setUserData=function(t,e,r){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.getUserData=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.contains=function(t){return!!t&&(t===this||this.isDescendant(t))},t.prototype.isDescendant=function(t){var e,r,n,i;for(r=0,n=(i=this.children).length;n>r;r++){if(t===(e=i[r]))return!0;if(e.isDescendant(t))return!0}return!1},t.prototype.isAncestor=function(t){return t.isDescendant(this)},t.prototype.isPreceding=function(t){var e,r;return e=this.treePosition(t),r=this.treePosition(this),-1!==e&&-1!==r&&r>e},t.prototype.isFollowing=function(t){var e,r;return e=this.treePosition(t),r=this.treePosition(this),-1!==e&&-1!==r&&e>r},t.prototype.treePosition=function(t){var e,r;return r=0,e=!1,this.foreachTreeNode(this.document(),(function(n){if(r++,!e&&n===t)return e=!0})),e?r:-1},t.prototype.foreachTreeNode=function(t,e){var r,n,i,o,s;for(t||(t=this.document()),n=0,i=(o=t.children).length;i>n;n++){if(s=e(r=o[n]))return s;if(s=this.foreachTreeNode(r,e))return s}},t}()}).call(this)},function(t,e){t.exports=require("zahl")},function(t,e){t.exports=require("fs")},function(t,e){var r=Array.isArray;t.exports=r},function(t,e,r){"use strict";r.d(e,"b",(function(){return o}));var n=r(48),i=r.n(n);const o=i.a.humanizer({language:"de",conjunction:" und ",serialComma:!1,maxDecimalPoints:0,units:["h","m"]});e.a=i.a.humanizer({language:"de",conjunction:" und dann noch mal ",serialComma:!1,maxDecimalPoints:0})},function(t,e,r){"use strict";r.r(e),r.d(e,"schema",(function(){return l}));var n=r(67),i=r.n(n),o=r(1),s=r.n(o),a=r(211),u=r(2);class c extends s.a.Model{static start(){u.default.isReady&&setInterval(c.tick,6e4)}static async tick(){const t=Object(a.measureTime)(),e={},r=i.a.freemem(),n=i.a.totalmem(),o=n-r,s=await u.default.getMyStream();s&&(c.lastTwitchStatus={averageFps:s.averageFPS,delay:s.delay,viewers:s.viewers,game:s.game,videoHeight:s.videoHeight,streamType:s.type,streamStartedAt:s.startDate,language:s.channel.broadcasterLanguage,isMature:s.channel.isMature,followers:s.channel.followers,streamTitle:s.channel.status},Object.assign(e,c.lastTwitchStatus)),e.ramUsage=Math.floor(o/n*100),e.executionTime=t().milliseconds,await c.create(e),c.currentStatus=e}}c.currentStatus=void 0,c.lastTwitchStatus=void 0;const l={averageFps:s.a.SMALLINT,delay:s.a.SMALLINT,game:s.a.STRING,videoHeight:s.a.SMALLINT,streamType:s.a.STRING(16),streamStartedAt:s.a.DATE,isMature:s.a.BOOLEAN,followers:s.a.INTEGER,streamTitle:s.a.STRING,language:s.a.STRING,viewers:s.a.INTEGER,ramUsage:{allowNull:!1,type:s.a.SMALLINT},executionTime:{allowNull:!1,type:s.a.INTEGER}};e.default=c},function(t,e){t.exports=require("util")},function(t,e){t.exports=require("events")},function(t,e,r){"use strict";r.r(e),r.d(e,"schema",(function(){return g}));var n=r(1),i=r.n(n),o=r(66),s=r.n(o),a=r(2),u=r(0),c=r(45),l=r(209),h=r.n(l),p=r(210),f=r.n(p),d=r(108),m=r(109);class y extends i.a.Model{static associate(t){y.hasMany(t.ChatMessage,{foreignKey:{allowNull:!1}}),y.hasMany(t.Video,{as:"RequestedVideos",foreignKey:"RequesterId"}),y.belongsTo(t.User,{foreignKey:{allowNull:!1}})}static async getByTwitchId(t){return await y.findOne({where:{twitchId:t}})}static async getByTwitchLogin(t){return await y.findOne({where:{loginName:t.toLowerCase()}})}static async findOrRegisterById(t,e){return y.findOrRegister({...e,key:"twitchId",value:t})}static async findOrRegisterByLogin(t,e){return y.findOrRegister({...e,key:"twitchLogin",value:t})}static async findOrRegister({key:t="twitchLogin",value:e,attributes:r,defaults:n}){const i={twitchLogin:{searchColumn:"loginName",fetchUser:t=>a.default.getUserInfoByTwitchLogin(t)},twitchId:{searchColumn:"twitchId",fetchUser:t=>a.default.getUserInfoByTwitchId(t)}},o=await y.findOne({where:{[i[t].searchColumn]:e},attributes:r});if(o)return o;const s=await i[t].fetchUser(e),c=s.name.toLowerCase(),l=s.displayName||c;u.c.info("New Twitch user %s",l);const h=await d.default.isSlugInUse(c);return h&&u.c.warn("Can not use %s for user slug, because is it already in use, generating one instead",c),await y.create({displayName:l,twitchId:s.id,description:s.description,loginName:c,offlineImageUrl:s.offlinePlaceholderUrl,avatarUrl:s.profilePictureUrl,viewCount:s.views,broadcasterType:s.broadcasterType,User:{title:l,color:null==n?void 0:n.nameColor,slug:h?f()():c},...n},{include:"User"})}static start(){m.default.afterCreate(async t=>{const e=await y.findByPk(t.TwitchUserId,{attributes:["id","nameColor"]});!e.nameColor&&t.nameColor?(u.c.info("Received name color of %s for the first time",t.senderDisplayName),e.nameColor=t.nameColor):e.nameColor!==t.nameColor&&(u.c.info("%s seems to have changed the name color from %s to %s",t.senderDisplayName,e.nameColor,t.nameColor),e.nameColor=t.nameColor),await e.save()})}async toTwitchClient(){const t=await s.a.withCredentials(u.a.twitchClientId,this.accessToken,c.a,{clientSecret:u.a.twitchClientSecret,refreshToken:this.refreshToken,onRefresh:t=>this.updateToken(t),expiry:this.tokenExpiryDate},{preAuth:!0,initialScopes:c.a});return this.tokenExpiryDate||(u.c.info("Initial expiry date not set for user %s. Forcing access token refresh.",this.loginName),await t.refreshAccessToken()),u.c.info("Created client for user %s",this.loginName),t}async toTwitchClientWithChat(){const t=await this.toTwitchClient(),e=await h.a.forTwitchClient(t);return await e.connect(),await e.waitForRegistration(),{apiClient:t,chatClient:e}}async updateToken(t){u.c.info("Refresh token of user %s",this.loginName),this.accessToken=t.accessToken,this.refreshToken=t.refreshToken,this.tokenExpiryDate=t.expiryDate,await this.save({fields:["accessToken","refreshToken","tokenExpiryDate"]})}getDisplayName(){return this.displayName||this.loginName||this.twitchId}}const g={broadcasterType:i.a.STRING(16),description:i.a.STRING,twitchId:{type:i.a.STRING(16),unique:!0,allowNull:!1},nameColor:i.a.STRING,displayName:i.a.STRING(64),loginName:{allowNull:!1,type:i.a.STRING(64)},offlineImageUrl:i.a.TEXT,avatarUrl:i.a.TEXT,viewCount:{allowNull:!1,type:i.a.INTEGER},accessToken:i.a.STRING,refreshToken:i.a.STRING,followDate:i.a.DATE,tokenExpiryDate:i.a.DATE,chatterRole:{allowNull:!1,type:i.a.STRING,defaultValue:"viewers"},offlineTimeMinutes:{type:i.a.INTEGER,defaultValue:0,allowNull:!1},liveWatchTimeMinutes:{type:i.a.INTEGER,defaultValue:0,allowNull:!1},vodcastWatchTimeMinutes:{type:i.a.INTEGER,defaultValue:0,allowNull:!1}};e.default=y},function(t,e,r){"use strict";var n=r(21),i=r.n(n),o=r(6),s=r(18),a=r(2),u=r(8);const c=2;class l extends i.a{constructor(){super(),this.afkMessage=null,this.afkStart=null,this.afkEnd=null,this.title=null,setInterval(()=>{this.isAfk()&&this.updateTitle()},3e4)}isAfk(){return null!==this.afkMessage}getRemainingTime(){return this.afkEnd-Date.now()}getTitlePrefix(){if(!this.isAfk())return"";const t=this.getRemainingTime();if(-6e4>t){return`[Schon ${o.a.duration(-t,"ms").format("h[h] m[m]")} länger weg als angesagt] `}if(t>6e4){return`[In ${o.a.duration(t,"ms").format("h[h] m[m]")} wieder da] `}return"[Demnächst zurück] "}async updateTitle(){const t=Object(a.removeTitlePrefix)(a.default.currentTitle);await a.default.setTitle(`${this.getTitlePrefix()}${t}`)}async activate(t,e){var r,n;this.afkStart=Date.now(),this.afkEnd=this.afkStart+1e3*t,this.afkMessage=e,null===(r=u.default.client)||void 0===r||r.emit("startAfk",{start:this.afkStart,end:this.afkEnd,message:this.afkMessage}),await this.updateTitle(),a.default.startAdLoop(),a.default.say(`Jaidchen geht jetzt mal weg für etwa ${n=1e3*t,Object(s.a)(n)}. Als Nachricht hat er lediglich ein "${e}" hinterlassen.`)}async deactivate(){const t=this.getRemainingTime(),e=(()=>{var e,r,n;return t>6e4*c?`Oh, der ist ja schon wieder da, ${e=t,Object(s.a)(e)} früher als angekündigt! KomodoHype`:t>-6e4*c?"Da ist er ja wieder! TPFufun":`"${this.afkMessage}", ja ja. Du wolltest doch eigentlich schon seit ${n=t,r=Math.abs(n),Object(s.a)(r)} wieder da sein. Jaidchen, wo bist du gewesen? PunOko`})();this.afkStart=null,this.afkEnd=null,this.afkMessage=null,await this.updateTitle(),a.default.stopAdLoop(),a.default.say(e)}}e.a=new l},function(t,e,r){"use strict";const n=r(12).fromPromise,i=r(171);t.exports={pathExists:n((function(t){return i.access(t).then(()=>!0).catch(()=>!1)})),pathExistsSync:i.existsSync}},function(t,e){(function(){var e,r,n,i,o,s,a,u=[].slice,c={}.hasOwnProperty;e=function(){var t,e,r,n,i,s;if(s=arguments[0],i=2>arguments.length?[]:u.call(arguments,1),o(Object.assign))Object.assign.apply(null,arguments);else for(t=0,r=i.length;r>t;t++)if(null!=(n=i[t]))for(e in n)c.call(n,e)&&(s[e]=n[e]);return s},o=function(t){return!!t&&"[object Function]"===Object.prototype.toString.call(t)},s=function(t){var e;return!!t&&("function"==(e=typeof t)||"object"===e)},n=function(t){return o(Array.isArray)?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},i=function(t){var e;if(n(t))return!t.length;for(e in t)if(c.call(t,e))return!1;return!0},a=function(t){var e,r;return s(t)&&(r=Object.getPrototypeOf(t))&&(e=r.constructor)&&"function"==typeof e&&e instanceof e&&Function.prototype.toString.call(e)===Function.prototype.toString.call(Object)},r=function(t){return o(t.valueOf)?t.valueOf():t},t.exports.assign=e,t.exports.isFunction=o,t.exports.isObject=s,t.exports.isArray=n,t.exports.isEmpty=i,t.exports.isPlainObject=a,t.exports.getValue=r}).call(this)},function(t,e,r){"use strict";r.r(e),r.d(e,"schema",(function(){return c}));var n=r(1),i=r.n(n),o=r(2),s=r(47),a=r.n(s);class u extends i.a.Model{static async addForDate(t,e){(await u.create({date:t,message:e})).schedule()}static async addForDelay(t,e){await u.addForDate(new Date(Date.now()+t),e)}static async start(){const t=await u.getPendingMessages();for(const e of t)e.schedule()}static async getPendingMessages(){return u.findAll({where:{date:{[n.Op.gt]:Date.now()}},attributes:["id","date","message"]})}schedule(){a.a.scheduleJob(this.date,async()=>{o.default.say(this.message),await this.update({isSent:!0})})}}const c={date:{allowNull:!1,type:i.a.DATE},message:{allowNull:!1,type:i.a.STRING},isSent:{allowNull:!1,type:i.a.BOOLEAN,defaultValue:!1}};e.default=u},function(t,e){t.exports=require("emit-promise")},function(t,e,r){var n=r(52),i=r(245),o=r(246),s="[object Null]",a="[object Undefined]",u=n?n.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?a:s:u&&u in Object(t)?i(t):o(t)}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e){t.exports=require("assert")},function(t,e,r){"use strict";var n,i=Object.getOwnPropertyDescriptor?function(){return Object.getOwnPropertyDescriptor(arguments,"callee").get}():function(){throw new TypeError},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,s=Object.getPrototypeOf||function(t){return t.__proto__},a=n,u="undefined"==typeof Uint8Array?n:s(Uint8Array),c={"$ %Array%":Array,"$ %ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"$ %ArrayBufferPrototype%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer.prototype,"$ %ArrayIteratorPrototype%":o?s([][Symbol.iterator]()):n,"$ %ArrayPrototype%":Array.prototype,"$ %ArrayProto_entries%":Array.prototype.entries,"$ %ArrayProto_forEach%":Array.prototype.forEach,"$ %ArrayProto_keys%":Array.prototype.keys,"$ %ArrayProto_values%":Array.prototype.values,"$ %AsyncFromSyncIteratorPrototype%":n,"$ %AsyncFunction%":n,"$ %AsyncFunctionPrototype%":n,"$ %AsyncGenerator%":n,"$ %AsyncGeneratorFunction%":n,"$ %AsyncGeneratorPrototype%":n,"$ %AsyncIteratorPrototype%":a&&o&&Symbol.asyncIterator?a[Symbol.asyncIterator]():n,"$ %Atomics%":"undefined"==typeof Atomics?n:Atomics,"$ %Boolean%":Boolean,"$ %BooleanPrototype%":Boolean.prototype,"$ %DataView%":"undefined"==typeof DataView?n:DataView,"$ %DataViewPrototype%":"undefined"==typeof DataView?n:DataView.prototype,"$ %Date%":Date,"$ %DatePrototype%":Date.prototype,"$ %decodeURI%":decodeURI,"$ %decodeURIComponent%":decodeURIComponent,"$ %encodeURI%":encodeURI,"$ %encodeURIComponent%":encodeURIComponent,"$ %Error%":Error,"$ %ErrorPrototype%":Error.prototype,"$ %eval%":eval,"$ %EvalError%":EvalError,"$ %EvalErrorPrototype%":EvalError.prototype,"$ %Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"$ %Float32ArrayPrototype%":"undefined"==typeof Float32Array?n:Float32Array.prototype,"$ %Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"$ %Float64ArrayPrototype%":"undefined"==typeof Float64Array?n:Float64Array.prototype,"$ %Function%":Function,"$ %FunctionPrototype%":Function.prototype,"$ %Generator%":n,"$ %GeneratorFunction%":n,"$ %GeneratorPrototype%":n,"$ %Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"$ %Int8ArrayPrototype%":"undefined"==typeof Int8Array?n:Int8Array.prototype,"$ %Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"$ %Int16ArrayPrototype%":"undefined"==typeof Int16Array?n:Int8Array.prototype,"$ %Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"$ %Int32ArrayPrototype%":"undefined"==typeof Int32Array?n:Int32Array.prototype,"$ %isFinite%":isFinite,"$ %isNaN%":isNaN,"$ %IteratorPrototype%":o?s(s([][Symbol.iterator]())):n,"$ %JSON%":JSON,"$ %JSONParse%":JSON.parse,"$