Bots Home
|
Create an App
Stats
Author:
rainydio_bc
Description
Source Code
Launch Bot
Current Users
Created by:
Rainydio_Bc
(function (cb) { 'use strict'; cb = cb && cb.hasOwnProperty('default') ? cb['default'] : cb; const timeago = (delta) => { const s = Math.ceil(delta / 1000); const seconds = s % 60; const minutes = Math.floor(s / 60) % 60; const hours = Math.floor(s / 3600); if (hours) { return `${hours}h${minutes}m${seconds}s`; } if (minutes) { return `${minutes}m${seconds}s`; } return `${seconds}s`; }; const timestamps = { }; cb.onEnter((evt) => { const timestamp = Date.now(); const username = evt["user"]; timestamps[username] = timestamp; }); cb.onLeave((evt) => { const username = evt["user"]; delete timestamps[username]; }); cb.onMessage((evt) => { const username = evt["user"]; const message = evt["m"]; if (username === cb.room_slug && message.toLowerCase() === "/stats") { const sorted = Object.keys(timestamps) .map(k => timestamps[k]) .sort(); const slice = sorted.slice(Math.floor(sorted.length / 2)); if (slice.length !== 0) { const delta = Date.now() - slice[0]; cb.sendNotice(`Median online time ${timeago(delta)}`, cb.room_slug); } evt["X-Spam"] = true; } }); }(cb));
© Copyright Chaturbate 2011- 2024. All Rights Reserved.