Merge pull request #1 from danilotitato/develop
Random Hour implementation
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
// Happy Hour
|
// Happy Hour
|
||||||
var happy_hour = true // set to true or false, to enable/disable the happy hours function
|
var happy_hour = true // set to true or false, to enable/disable the happy hours function
|
||||||
|
var random_hour = true
|
||||||
var randHappy = false // only works if happy_hour = true
|
var randHappy = false // only works if happy_hour = true
|
||||||
var scheduleHappy = false // only works if happy_hour = true
|
var scheduleHappy = false // only works if happy_hour = true
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ var bulk_enabled = false
|
|||||||
//Shortcuts
|
//Shortcuts
|
||||||
var pauseShort = "ctrl+alt+p"
|
var pauseShort = "ctrl+alt+p"
|
||||||
var happyHourShort = "ctrl+alt+h"
|
var happyHourShort = "ctrl+alt+h"
|
||||||
|
var randomHourShort = "ctrl+alt+r"
|
||||||
|
|
||||||
// Login Data
|
// Login Data
|
||||||
var twitch_channel_name = ""
|
var twitch_channel_name = ""
|
||||||
@@ -59,24 +61,16 @@ var seconds_added_per_chests = 30
|
|||||||
|
|
||||||
|
|
||||||
// General Twitch, Streamlabs And StreamElements Config for Happy Hour
|
// General Twitch, Streamlabs And StreamElements Config for Happy Hour
|
||||||
var seconds_added_per_sub_prime_happy = 85
|
var factor_t1 = 1.5
|
||||||
var seconds_added_per_sub_tier1_happy = 85
|
var factor_t2 = 1.75
|
||||||
var seconds_added_per_sub_tier2_happy = 300
|
var factor_t3 = 2.0
|
||||||
var seconds_added_per_sub_tier3_happy = 960
|
var factor_bits = 1.5
|
||||||
|
var factor_donations = 1.5
|
||||||
|
|
||||||
var seconds_added_per_resub_prime_happy = 85
|
|
||||||
var seconds_added_per_resub_tier1_happy = 85
|
|
||||||
var seconds_added_per_resub_tier2_happy = 300
|
|
||||||
var seconds_added_per_resub_tier3_happy = 960
|
|
||||||
|
|
||||||
var seconds_added_per_giftsub_tier1_happy = 85
|
// General Twitch, Streamlabs And StreamElements Config for Random Hour
|
||||||
var seconds_added_per_giftsub_tier2_happy = 300
|
var range_t1 = [0.5, 2]
|
||||||
var seconds_added_per_giftsub_tier3_happy = 960
|
var range_t2 = [1.0, 3]
|
||||||
|
var range_t3 = [2.0, 5]
|
||||||
var seconds_added_per_bits_happy = 60
|
var range_bits = [0.5, 2]
|
||||||
|
var range_donations = [0.5, 2]
|
||||||
// Streamlabs And StreamElements Config
|
|
||||||
var seconds_added_per_donation_happy = 60
|
|
||||||
|
|
||||||
// Streamloots Config
|
|
||||||
var seconds_added_per_chests_happy = 60
|
|
||||||
|
|||||||
+3
-3
@@ -44,9 +44,9 @@ body {
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
#HappyHourText {
|
#SpecialHourText {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
font-size: 2.8rem;
|
font-size: 2.5rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -71,7 +71,7 @@ body {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
#HappyHourHTML {
|
#SpecialHourHTML {
|
||||||
top:-200px;
|
top:-200px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -23,10 +23,10 @@
|
|||||||
<div id="textDiv">
|
<div id="textDiv">
|
||||||
<p id="timeText">00:00:00</p>
|
<p id="timeText">00:00:00</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="HappyHourHTML">
|
<div id="SpecialHourHTML">
|
||||||
<p id="HappyHourText">Happy Hour Activated!</p>
|
<p id="SpecialHourText">Happy Hour Activated!</p>
|
||||||
<!-- <p id="HappyHourDeactive">Happy Hour Deactivated :(</p>
|
<!-- <p id="SpecialHourDeactive">Happy Hour Deactivated :(</p>
|
||||||
<p id="HappyHourError">Happy Hour not available D:</p> -->
|
<p id="SpecialHourError">Happy Hour not available D:</p> -->
|
||||||
</div>
|
</div>
|
||||||
<canvas id="canvas"></canvas>
|
<canvas id="canvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+33
-109
@@ -34,59 +34,65 @@ if (streamelements_token !== "") {
|
|||||||
|
|
||||||
function onEvent(data) {
|
function onEvent(data) {
|
||||||
logObject("StreamElements", data);
|
logObject("StreamElements", data);
|
||||||
if (!countdownEnded && !happy_hour_active) {
|
if (!countdownEnded) {
|
||||||
|
let factor_t1_local = (happy_hour_active ? factor_t1 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t1): 1);
|
||||||
|
let factor_t2_local = (happy_hour_active ? factor_t2 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t2): 1);
|
||||||
|
let factor_t3_local = (happy_hour_active ? factor_t3 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t3): 1);
|
||||||
|
let factor_bits_local = (happy_hour_active ? factor_bits : 1) * (random_hour_active ? randomInRangeNoRounding(...range_bits): 1);
|
||||||
|
let factor_donations_local = (happy_hour_active ? factor_donations : 1) * (random_hour_active ? randomInRangeNoRounding(...range_donations): 1);
|
||||||
|
|
||||||
if ((data['listener'] === "subscriber-latest") && subEnable) {
|
if ((data['listener'] === "subscriber-latest") && subEnable) {
|
||||||
if (data['event']['gifted'] || data['event']['bulkGifted']) {
|
if (data['event']['gifted'] || data['event']['bulkGifted']) {
|
||||||
let amount;
|
let amount;
|
||||||
if (data['event']['gifted']) amount = 1;
|
if (data['event']['gifted']) amount = 1;
|
||||||
else amount = data['event']['amount'];
|
else amount = data['event']['amount'];
|
||||||
if (data['event']['tier'] == "prime" || data['event']['tier'] == "1000") {
|
if (data['event']['tier'] == "prime" || data['event']['tier'] == "1000") {
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier1 * amount);
|
addTime(endingTime, seconds_added_per_giftsub_tier1 * amount * factor_t1_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_giftsub_tier1 * amount} Seconds Because ${data['event']['name']} Gifted ${amount} Tier 1 Subs`);
|
logMessage("StreamElements", `Added ${seconds_added_per_giftsub_tier1 * amount * factor_t1_local} Seconds Because ${data['event']['name']} Gifted ${amount} Tier 1 Subs`);
|
||||||
}
|
}
|
||||||
else if (data['event']['tier'] == "2000") {
|
else if (data['event']['tier'] == "2000") {
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier2 * amount);
|
addTime(endingTime, seconds_added_per_giftsub_tier2 * amount * factor_t2_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_giftsub_tier2 * amount} Seconds Because ${data['event']['name']} Gifted ${amount} Tier 2 Subs`);
|
logMessage("StreamElements", `Added ${seconds_added_per_giftsub_tier2 * amount * factor_t2_local} Seconds Because ${data['event']['name']} Gifted ${amount} Tier 2 Subs`);
|
||||||
}
|
}
|
||||||
else if (data['event']['tier'] == "3000") {
|
else if (data['event']['tier'] == "3000") {
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier3 * amount);
|
addTime(endingTime, seconds_added_per_giftsub_tier3 * amount * factor_t3_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_giftsub_tier3 * amount} Seconds Because ${data['event']['name']} Gifted ${amount} Tier 3 Subs`);
|
logMessage("StreamElements", `Added ${seconds_added_per_giftsub_tier3 * amount * factor_t3_local} Seconds Because ${data['event']['name']} Gifted ${amount} Tier 3 Subs`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (data['event']['amount'] != "1") {
|
else if (data['event']['amount'] != "1") {
|
||||||
if (data['event']['tier'] == "prime") {
|
if (data['event']['tier'] == "prime") {
|
||||||
addTime(endingTime, seconds_added_per_resub_prime);
|
addTime(endingTime, seconds_added_per_resub_prime * factor_t1_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_resub_prime} Seconds Because ${data['event']['name']} ReSubscribed With Prime`);
|
logMessage("StreamElements", `Added ${seconds_added_per_resub_prime * factor_t1_local} Seconds Because ${data['event']['name']} ReSubscribed With Prime`);
|
||||||
}
|
}
|
||||||
else if (data['event']['tier'] == "1000") {
|
else if (data['event']['tier'] == "1000") {
|
||||||
addTime(endingTime, seconds_added_per_resub_tier1);
|
addTime(endingTime, seconds_added_per_resub_tier1 * factor_t1_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_resub_tier1} Seconds Because ${data['event']['name']} ReSubscribed With Tier 1`);
|
logMessage("StreamElements", `Added ${seconds_added_per_resub_tier1 * factor_t1_local} Seconds Because ${data['event']['name']} ReSubscribed With Tier 1`);
|
||||||
}
|
}
|
||||||
else if (data['event']['tier'] == "2000") {
|
else if (data['event']['tier'] == "2000") {
|
||||||
addTime(endingTime, seconds_added_per_resub_tier2);
|
addTime(endingTime, seconds_added_per_resub_tier2 * factor_t2_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_resub_tier2} Seconds Because ${data['event']['name']} ReSubscribed With Tier 2`);
|
logMessage("StreamElements", `Added ${seconds_added_per_resub_tier2 * factor_t2_local} Seconds Because ${data['event']['name']} ReSubscribed With Tier 2`);
|
||||||
}
|
}
|
||||||
else if (data['event']['tier'] == "3000") {
|
else if (data['event']['tier'] == "3000") {
|
||||||
addTime(endingTime, seconds_added_per_resub_tier3);
|
addTime(endingTime, seconds_added_per_resub_tier3 * factor_t3_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_resub_tier3} Seconds Because ${data['event']['name']} ReSubscribed With Tier 3`);
|
logMessage("StreamElements", `Added ${seconds_added_per_resub_tier3 * factor_t3_local} Seconds Because ${data['event']['name']} ReSubscribed With Tier 3`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (data['event']['tier'] == "prime") {
|
if (data['event']['tier'] == "prime") {
|
||||||
addTime(endingTime, seconds_added_per_sub_prime);
|
addTime(endingTime, seconds_added_per_sub_prime * factor_t1_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_sub_prime} Seconds Because ${data['event']['name']} Subscribed With Prime`);
|
logMessage("StreamElements", `Added ${seconds_added_per_sub_prime * factor_t1_local} Seconds Because ${data['event']['name']} Subscribed With Prime`);
|
||||||
}
|
}
|
||||||
else if (data['event']['tier'] == "1000") {
|
else if (data['event']['tier'] == "1000") {
|
||||||
addTime(endingTime, seconds_added_per_sub_tier1);
|
addTime(endingTime, seconds_added_per_sub_tier1 * factor_t1_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_sub_tier1} Seconds Because ${data['event']['name']} Subscribed With Tier 1`);
|
logMessage("StreamElements", `Added ${seconds_added_per_sub_tier1 * factor_t1_local} Seconds Because ${data['event']['name']} Subscribed With Tier 1`);
|
||||||
}
|
}
|
||||||
else if (data['event']['tier'] == "2000") {
|
else if (data['event']['tier'] == "2000") {
|
||||||
addTime(endingTime, seconds_added_per_sub_tier2);
|
addTime(endingTime, seconds_added_per_sub_tier2 * factor_t2_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_sub_tier2} Seconds Because ${data['event']['name']} Subscribed With Tier 2`);
|
logMessage("StreamElements", `Added ${seconds_added_per_sub_tier2 * factor_t2_local} Seconds Because ${data['event']['name']} Subscribed With Tier 2`);
|
||||||
}
|
}
|
||||||
else if (data['event']['tier'] == "3000") {
|
else if (data['event']['tier'] == "3000") {
|
||||||
addTime(endingTime, seconds_added_per_sub_tier3);
|
addTime(endingTime, seconds_added_per_sub_tier3 * factor_t3_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_sub_tier3} Seconds Because ${data['event']['name']} Subscribed With Tier 3`);
|
logMessage("StreamElements", `Added ${seconds_added_per_sub_tier3 * factor_t3_local} Seconds Because ${data['event']['name']} Subscribed With Tier 3`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!users.includes(data['event']['name'])) {
|
if (!users.includes(data['event']['name'])) {
|
||||||
@@ -97,8 +103,8 @@ if (streamelements_token !== "") {
|
|||||||
else if ((data['listener'] === "cheer-latest") && bitEnable) {
|
else if ((data['listener'] === "cheer-latest") && bitEnable) {
|
||||||
if (data['event']['amount'] >= min_amount_of_bits) {
|
if (data['event']['amount'] >= min_amount_of_bits) {
|
||||||
let times = Math.floor(data['event']['amount']/min_amount_of_bits);
|
let times = Math.floor(data['event']['amount']/min_amount_of_bits);
|
||||||
addTime(endingTime, seconds_added_per_bits * times);
|
addTime(endingTime, seconds_added_per_bits * times * factor_bits_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_bits * times} Seconds Because ${data['event']['name']} Donated ${data['event']['amount']} Bits`);
|
logMessage("StreamElements", `Added ${seconds_added_per_bits * times * factor_bits_local} Seconds Because ${data['event']['name']} Donated ${data['event']['amount']} Bits`);
|
||||||
if (!users.includes(data['event']['name'])) {
|
if (!users.includes(data['event']['name'])) {
|
||||||
users.push(data['event']['name']);
|
users.push(data['event']['name']);
|
||||||
}
|
}
|
||||||
@@ -108,90 +114,8 @@ if (streamelements_token !== "") {
|
|||||||
else if ((data['listener'] === "tip-latest") && donationEnable) {
|
else if ((data['listener'] === "tip-latest") && donationEnable) {
|
||||||
if (data['event']['amount'] >= min_donation_amount) {
|
if (data['event']['amount'] >= min_donation_amount) {
|
||||||
let times = Math.floor(data['event']['amount']/min_donation_amount);
|
let times = Math.floor(data['event']['amount']/min_donation_amount);
|
||||||
addTime(endingTime, seconds_added_per_donation * times);
|
addTime(endingTime, seconds_added_per_donation * times * factor_donations_local);
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_donation * times} Seconds Because ${data['event']['name']} Donated ${data['event']['amount']}$`);
|
logMessage("StreamElements", `Added ${seconds_added_per_donation * times * factor_donations_local} Seconds Because ${data['event']['name']} Donated ${data['event']['amount']}$`);
|
||||||
if (!users.includes(data['event']['name'])) {
|
|
||||||
users.push(data['event']['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!countdownEnded && happy_hour_active) {
|
|
||||||
if ((data['listener'] === "subscriber-latest") && subEnable) {
|
|
||||||
if (data['event']['gifted'] || data['event']['bulkGifted']) {
|
|
||||||
let amount;
|
|
||||||
if (data['event']['gifted']) amount = 1;
|
|
||||||
else amount = data['event']['amount'];
|
|
||||||
if (data['event']['tier'] == "prime" || data['event']['tier'] == "1000") {
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier1_happy * amount);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_giftsub_tier1_happy * amount} Seconds Because ${data['event']['name']} Gifted ${amount} Tier 1 Subs`);
|
|
||||||
}
|
|
||||||
else if (data['event']['tier'] == "2000") {
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier2_happy * amount);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_giftsub_tier2_happy * amount} Seconds Because ${data['event']['name']} Gifted ${amount} Tier 2 Subs`);
|
|
||||||
}
|
|
||||||
else if (data['event']['tier'] == "3000") {
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier3_happy * amount);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_giftsub_tier3_happy * amount} Seconds Because ${data['event']['name']} Gifted ${amount} Tier 3 Subs`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (data['event']['amount'] != "1") {
|
|
||||||
if (data['event']['tier'] == "prime") {
|
|
||||||
addTime(endingTime, seconds_added_per_resub_prime_happy);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_resub_prime_happy} Seconds Because ${data['event']['name']} ReSubscribed With Prime`);
|
|
||||||
}
|
|
||||||
else if (data['event']['tier'] == "1000") {
|
|
||||||
addTime(endingTime, seconds_added_per_resub_tier1_happy);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_resub_tier1_happy} Seconds Because ${data['event']['name']} ReSubscribed With Tier 1`);
|
|
||||||
}
|
|
||||||
else if (data['event']['tier'] == "2000") {
|
|
||||||
addTime(endingTime, seconds_added_per_resub_tier2_happy);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_resub_tier2_happy} Seconds Because ${data['event']['name']} ReSubscribed With Tier 2`);
|
|
||||||
}
|
|
||||||
else if (data['event']['tier'] == "3000") {
|
|
||||||
addTime(endingTime, seconds_added_per_resub_tier3_happy);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_resub_tier3_happy} Seconds Because ${data['event']['name']} ReSubscribed With Tier 3`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (data['event']['tier'] == "prime") {
|
|
||||||
addTime(endingTime, seconds_added_per_sub_prime_happy);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_sub_prime_happy} Seconds Because ${data['event']['name']} Subscribed With Prime`);
|
|
||||||
}
|
|
||||||
else if (data['event']['tier'] == "1000") {
|
|
||||||
addTime(endingTime, seconds_added_per_sub_tier1_happy);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_sub_tier1_happy} Seconds Because ${data['event']['name']} Subscribed With Tier 1`);
|
|
||||||
}
|
|
||||||
else if (data['event']['tier'] == "2000") {
|
|
||||||
addTime(endingTime, seconds_added_per_sub_tier2_happy);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_sub_tier2_happy} Seconds Because ${data['event']['name']} Subscribed With Tier 2`);
|
|
||||||
}
|
|
||||||
else if (data['event']['tier'] == "3000") {
|
|
||||||
addTime(endingTime, seconds_added_per_sub_tier3_happy);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_sub_tier3_happy} Seconds Because ${data['event']['name']} Subscribed With Tier 3`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!users.includes(data['event']['name'])) {
|
|
||||||
users.push(data['event']['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if ((data['listener'] === "cheer-latest") && bitEnable) {
|
|
||||||
if (data['event']['amount'] >= min_amount_of_bits) {
|
|
||||||
let times = Math.floor(data['event']['amount']/min_amount_of_bits);
|
|
||||||
addTime(endingTime, seconds_added_per_bits_happy * times);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_bits_happy * times} Seconds Because ${data['event']['name']} Donated ${data['event']['amount']} Bits`);
|
|
||||||
if (!users.includes(data['event']['name'])) {
|
|
||||||
users.push(data['event']['name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if ((data['listener'] === "tip-latest") && donationEnable) {
|
|
||||||
if (data['event']['amount'] >= min_donation_amount) {
|
|
||||||
let times = Math.floor(data['event']['amount']/min_donation_amount);
|
|
||||||
addTime(endingTime, seconds_added_per_donation_happy * times);
|
|
||||||
logMessage("StreamElements", `Added ${seconds_added_per_donation_happy * times} Seconds Because ${data['event']['name']} Donated ${data['event']['amount']}$`);
|
|
||||||
if (!users.includes(data['event']['name'])) {
|
if (!users.includes(data['event']['name'])) {
|
||||||
users.push(data['event']['name']);
|
users.push(data['event']['name']);
|
||||||
}
|
}
|
||||||
|
|||||||
+68
-162
@@ -7,171 +7,90 @@ if (streamlabs_token !== "") {
|
|||||||
|
|
||||||
socket.on("event", (event) => {
|
socket.on("event", (event) => {
|
||||||
logObject("Streamlabs", event);
|
logObject("Streamlabs", event);
|
||||||
|
let factor_t1_local = (happy_hour_active ? factor_t1 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t1): 1);
|
||||||
|
let factor_t2_local = (happy_hour_active ? factor_t2 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t2): 1);
|
||||||
|
let factor_t3_local = (happy_hour_active ? factor_t3 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t3): 1);
|
||||||
|
let factor_bits_local = (happy_hour_active ? factor_bits : 1) * (random_hour_active ? randomInRangeNoRounding(...range_bits): 1);
|
||||||
|
let factor_donations_local = (happy_hour_active ? factor_donations : 1) * (random_hour_active ? randomInRangeNoRounding(...range_donations): 1);
|
||||||
|
|
||||||
if (event.type == "subscription" && !event.message[0].gifter) {
|
if (event.type == "subscription" && !event.message[0].gifter) {
|
||||||
if (!countdownEnded && subEnable) {
|
if (!countdownEnded && subEnable) {
|
||||||
if(!happy_hour_active){
|
if (event.message[0].sub_plan == "1000") {
|
||||||
if (event.message[0].sub_plan == "1000") {
|
addTime(endingTime, seconds_added_per_sub_tier1 * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_sub_tier1);
|
logMessage("Streamlabs", `Added ${seconds_added_per_sub_tier1 * factor_t1_local} Seconds Because ${event.message[0].name} Subscribed With Tier 1`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_sub_tier1} Seconds Because ${event.message[0].name} Subscribed With Tier 1`);
|
|
||||||
}
|
|
||||||
else if (event.message[0].sub_plan == "2000") {
|
|
||||||
addTime(endingTime, seconds_added_per_sub_tier2);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_sub_tier2} Seconds Because ${event.message[0].name} Subscribed With Tier 2`);
|
|
||||||
}
|
|
||||||
else if (event.message[0].sub_plan == "3000") {
|
|
||||||
addTime(endingTime, seconds_added_per_sub_tier3);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_sub_tier3} Seconds Because ${event.message[0].name} Subscribed With Tier 3`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addTime(endingTime, seconds_added_per_sub_prime);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_sub_prime} Seconds Because ${event.message[0].name} Subscribed With Prime`);
|
|
||||||
}
|
|
||||||
if (!users.includes(event.message[0].name)) {
|
|
||||||
users.push(event.message[0].name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(!happy_hour_active){
|
else if (event.message[0].sub_plan == "2000") {
|
||||||
if (event.message[0].sub_plan == "1000") {
|
addTime(endingTime, seconds_added_per_sub_tier2 * factor_t2_local);
|
||||||
addTime(endingTime, seconds_added_per_sub_tier1_happy);
|
logMessage("Streamlabs", `Added ${seconds_added_per_sub_tier2 * factor_t2_local} Seconds Because ${event.message[0].name} Subscribed With Tier 2`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_sub_tier1_happy} Seconds Because ${event.message[0].name} Subscribed With Tier 1`);
|
}
|
||||||
}
|
else if (event.message[0].sub_plan == "3000") {
|
||||||
else if (event.message[0].sub_plan == "2000") {
|
addTime(endingTime, seconds_added_per_sub_tier3 * factor_t3_local);
|
||||||
addTime(endingTime, seconds_added_per_sub_tier2_happy);
|
logMessage("Streamlabs", `Added ${seconds_added_per_sub_tier3 * factor_t3_local} Seconds Because ${event.message[0].name} Subscribed With Tier 3`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_sub_tier2_happy} Seconds Because ${event.message[0].name} Subscribed With Tier 2`);
|
}
|
||||||
}
|
else {
|
||||||
else if (event.message[0].sub_plan == "3000") {
|
addTime(endingTime, seconds_added_per_sub_prime * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_sub_tier3_happy);
|
logMessage("Streamlabs", `Added ${seconds_added_per_sub_prime * factor_t1_local} Seconds Because ${event.message[0].name} Subscribed With Prime`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_sub_tier3_happy} Seconds Because ${event.message[0].name} Subscribed With Tier 3`);
|
}
|
||||||
}
|
if (!users.includes(event.message[0].name)) {
|
||||||
else {
|
users.push(event.message[0].name);
|
||||||
addTime(endingTime, seconds_added_per_sub_prime_happy);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_sub_prime_happy} Seconds Because ${event.message[0].name} Subscribed With Prime`);
|
|
||||||
}
|
|
||||||
if (!users.includes(event.message[0].name)) {
|
|
||||||
users.push(event.message[0].name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (event.type == "resub" && !event.message[0].gifter) {
|
else if (event.type == "resub" && !event.message[0].gifter) {
|
||||||
if (!countdownEnded && subEnable) {
|
if (!countdownEnded && subEnable) {
|
||||||
if(!happy_hour_active){
|
if (event.message[0].sub_plan == "1000") {
|
||||||
if (event.message[0].sub_plan == "1000") {
|
addTime(endingTime, seconds_added_per_resub_tier1 * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_resub_tier1);
|
logMessage("Streamlabs", `Added ${seconds_added_per_resub_tier1 * factor_t1_local} Seconds Because ${event.message[0].name} ReSubscribed With Tier 1`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_resub_tier1} Seconds Because ${event.message[0].name} ReSubscribed With Tier 1`);
|
|
||||||
}
|
|
||||||
else if (event.message[0].sub_plan == "2000") {
|
|
||||||
addTime(endingTime, seconds_added_per_resub_tier2);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_resub_tier2} Seconds Because ${event.message[0].name} ReSubscribed With Tier 2`);
|
|
||||||
}
|
|
||||||
else if (event.message[0].sub_plan == "3000") {
|
|
||||||
addTime(endingTime, seconds_added_per_resub_tier3);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_resub_tier3} Seconds Because ${event.message[0].name} ReSubscribed With Tier 3`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addTime(endingTime, seconds_added_per_resub_prime);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_resub_prime} Seconds Because ${event.message[0].name} ReSubscribed With Prime`);
|
|
||||||
}
|
|
||||||
if (!users.includes(event.message[0].name)) {
|
|
||||||
users.push(event.message[0].name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(!happy_hour_active){
|
else if (event.message[0].sub_plan == "2000") {
|
||||||
if (event.message[0].sub_plan == "1000") {
|
addTime(endingTime, seconds_added_per_resub_tier2 * factor_t2_local);
|
||||||
addTime(endingTime, seconds_added_per_resub_tier1_happy);
|
logMessage("Streamlabs", `Added ${seconds_added_per_resub_tier2 * factor_t2_local} Seconds Because ${event.message[0].name} ReSubscribed With Tier 2`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_resub_tier1_happy} Seconds Because ${event.message[0].name} ReSubscribed With Tier 1`);
|
}
|
||||||
}
|
else if (event.message[0].sub_plan == "3000") {
|
||||||
else if (event.message[0].sub_plan == "2000") {
|
addTime(endingTime, seconds_added_per_resub_tier3 * factor_t3_local);
|
||||||
addTime(endingTime, seconds_added_per_resub_tier2_happy);
|
logMessage("Streamlabs", `Added ${seconds_added_per_resub_tier3 * factor_t3_local} Seconds Because ${event.message[0].name} ReSubscribed With Tier 3`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_resub_tier2_happy} Seconds Because ${event.message[0].name} ReSubscribed With Tier 2`);
|
}
|
||||||
}
|
else {
|
||||||
else if (event.message[0].sub_plan == "3000") {
|
addTime(endingTime, seconds_added_per_resub_prime * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_resub_tier3_happy);
|
logMessage("Streamlabs", `Added ${seconds_added_per_resub_prime * factor_t1_local} Seconds Because ${event.message[0].name} ReSubscribed With Prime`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_resub_tier3_happy} Seconds Because ${event.message[0].name} ReSubscribed With Tier 3`);
|
}
|
||||||
}
|
if (!users.includes(event.message[0].name)) {
|
||||||
else {
|
users.push(event.message[0].name);
|
||||||
addTime(endingTime, seconds_added_per_resub_prime_happy);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_resub_prime_happy} Seconds Because ${event.message[0].name} ReSubscribed With Prime`);
|
|
||||||
}
|
|
||||||
if (!users.includes(event.message[0].name)) {
|
|
||||||
users.push(event.message[0].name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (event.message[0].gifter) {
|
else if (event.message[0].gifter) {
|
||||||
if (!countdownEnded && subEnable) {
|
if (!countdownEnded && subEnable) {
|
||||||
if(!happy_hour_active){
|
if (event.message[0].sub_plan == "1000") {
|
||||||
if (event.message[0].sub_plan == "1000") {
|
addTime(endingTime, seconds_added_per_giftsub_tier1 * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier1);
|
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier1 * factor_t1_local} Seconds Because ${event.message[0].gifter} Gifted A Tier 1 Sub`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier1} Seconds Because ${event.message[0].gifter} Gifted A Tier 1 Sub`);
|
|
||||||
}
|
|
||||||
else if (event.message[0].sub_plan == "2000") {
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier2);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier2} Seconds Because ${event.message[0].gifter} Gifted A Tier 2 Sub`);
|
|
||||||
}
|
|
||||||
else if (event.message[0].sub_plan == "3000") {
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier3);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier3} Seconds Because ${event.message[0].gifter} Gifted A Tier 3 Sub`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier1);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier1} Seconds Because ${event.message[0].gifter} Gifted A Tier 1 Sub`);
|
|
||||||
}
|
|
||||||
if (!users.includes(event.message[0].name)) {
|
|
||||||
users.push(event.message[0].name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(happy_hour_active){
|
else if (event.message[0].sub_plan == "2000") {
|
||||||
if (event.message[0].sub_plan == "1000") {
|
addTime(endingTime, seconds_added_per_giftsub_tier2 * factor_t2_local);
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier1_happy);
|
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier2 * factor_t2_local} Seconds Because ${event.message[0].gifter} Gifted A Tier 2 Sub`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier1_happy} Seconds Because ${event.message[0].gifter} Gifted A Tier 1 Sub`);
|
}
|
||||||
}
|
else if (event.message[0].sub_plan == "3000") {
|
||||||
else if (event.message[0].sub_plan == "2000") {
|
addTime(endingTime, seconds_added_per_giftsub_tier3 * factor_t3_local);
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier2_happy);
|
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier3 * factor_t3_local} Seconds Because ${event.message[0].gifter} Gifted A Tier 3 Sub`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier2_happy} Seconds Because ${event.message[0].gifter} Gifted A Tier 2 Sub`);
|
}
|
||||||
}
|
if (!users.includes(event.message[0].name)) {
|
||||||
else if (event.message[0].sub_plan == "3000") {
|
users.push(event.message[0].name);
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier3_happy);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier3_happy} Seconds Because ${event.message[0].gifter} Gifted A Tier 3 Sub`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier1_happy);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_giftsub_tier1_happy} Seconds Because ${event.message[0].gifter} Gifted A Tier 1 Sub`);
|
|
||||||
}
|
|
||||||
if (!users.includes(event.message[0].name)) {
|
|
||||||
users.push(event.message[0].name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (event.type == "donation") {
|
else if (event.type == "donation") {
|
||||||
if (!countdownEnded && donationEnable) {
|
if (!countdownEnded && donationEnable) {
|
||||||
if(!happy_hour_active){
|
let dono = parseInt(event.message[0].amount);
|
||||||
let dono = parseInt(event.message[0].amount);
|
let currency = event.message[0].currency;
|
||||||
let currency = event.message[0].currency;
|
if (dono >= min_donation_amount) {
|
||||||
if (dono >= min_donation_amount) {
|
let times = Math.floor(dono/min_donation_amount);
|
||||||
let times = Math.floor(dono/min_donation_amount);
|
addTime(endingTime, seconds_added_per_donation * times * factor_donations_local);
|
||||||
addTime(endingTime, seconds_added_per_donation * times);
|
logMessage("Streamlabs", `Added ${seconds_added_per_donation * times} Seconds Because ${event.message[0].name} Donated ${dono} ${currency}`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_donation * times} Seconds Because ${event.message[0].name} Donated ${dono} ${currency}`);
|
if (!users.includes(event.message[0].name)) {
|
||||||
if (!users.includes(event.message[0].name)) {
|
users.push(event.message[0].name);
|
||||||
users.push(event.message[0].name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(happy_hour_active){
|
|
||||||
let dono = parseInt(event.message[0].amount);
|
|
||||||
let currency = event.message[0].currency;
|
|
||||||
if (dono >= min_donation_amount) {
|
|
||||||
let times = Math.floor(dono/min_donation_amount);
|
|
||||||
addTime(endingTime, seconds_added_per_donation_happy * times);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_donation_happy * times} Seconds Because ${event.message[0].name} Donated ${dono} ${currency}`);
|
|
||||||
if (!users.includes(event.message[0].name)) {
|
|
||||||
users.push(event.message[0].name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,26 +98,13 @@ if (streamlabs_token !== "") {
|
|||||||
|
|
||||||
else if (event.type == "bits") {
|
else if (event.type == "bits") {
|
||||||
if (!countdownEnded && donationEnable) {
|
if (!countdownEnded && donationEnable) {
|
||||||
if(!happy_hour_active){
|
let bits = parseInt(event.message[0].amount);
|
||||||
let bits = parseInt(event.message[0].amount);
|
if (bits >= min_amount_of_bits) {
|
||||||
if (bits >= min_amount_of_bits) {
|
let times = Math.floor(bits/min_amount_of_bits);
|
||||||
let times = Math.floor(bits/min_amount_of_bits);
|
addTime(endingTime, seconds_added_per_bits * times);
|
||||||
addTime(endingTime, seconds_added_per_bits * times);
|
logMessage("Streamlabs", `Added ${seconds_added_per_bits * times * factor_bits_local} Seconds Because ${event.message[0].name} Donated ${bits} Bits`);
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_bits * times} Seconds Because ${event.message[0].name} Donated ${bits} Bits`);
|
if (!users.includes(event.message[0].name)) {
|
||||||
if (!users.includes(event.message[0].name)) {
|
users.push(event.message[0].name);
|
||||||
users.push(event.message[0].name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(happy_hour_active){
|
|
||||||
let bits = parseInt(event.message[0].amount);
|
|
||||||
if (bits >= min_amount_of_bits) {
|
|
||||||
let times = Math.floor(bits/min_amount_of_bits);
|
|
||||||
addTime(endingTime, seconds_added_per_bits_happy * times);
|
|
||||||
logMessage("Streamlabs", `Added ${seconds_added_per_bits_happy * times} Seconds Because ${event.message[0].name} Donated ${bits} Bits`);
|
|
||||||
if (!users.includes(event.message[0].name)) {
|
|
||||||
users.push(event.message[0].name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+71
-135
@@ -12,45 +12,27 @@ if (twitch_channel_name !== "") {
|
|||||||
|
|
||||||
client.on('subscription', (channel, username, methods, message, userstate) => {
|
client.on('subscription', (channel, username, methods, message, userstate) => {
|
||||||
if (!countdownEnded && subEnable) {
|
if (!countdownEnded && subEnable) {
|
||||||
if(!happy_hour_active){
|
let factor_t1_local = (happy_hour_active ? factor_t1 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t1): 1);
|
||||||
switch (methods['plan']) {
|
let factor_t2_local = (happy_hour_active ? factor_t2 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t2): 1);
|
||||||
case "Prime":
|
let factor_t3_local = (happy_hour_active ? factor_t3 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t3): 1);
|
||||||
addTime(endingTime, seconds_added_per_sub_prime);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_sub_prime} Seconds Because ${username} Subscribed With Prime`);
|
switch (methods['plan']) {
|
||||||
break;
|
case "Prime":
|
||||||
case "1000":
|
addTime(endingTime, seconds_added_per_sub_prime * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_sub_tier1);
|
logMessage("Twitch", `Added ${seconds_added_per_sub_prime * factor_t1_local} Seconds Because ${username} Subscribed With Prime`);
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_sub_tier1} Seconds Because ${username} Subscribed With Tier 1`);
|
break;
|
||||||
break;
|
case "1000":
|
||||||
case "2000":
|
addTime(endingTime, seconds_added_per_sub_tier1 * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_sub_tier2);
|
logMessage("Twitch", `Added ${seconds_added_per_sub_tier1 * factor_t1_local} Seconds Because ${username} Subscribed With Tier 1`);
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_sub_tier2} Seconds Because ${username} Subscribed With Tier 2`);
|
break;
|
||||||
break;
|
case "2000":
|
||||||
case "3000":
|
addTime(endingTime, seconds_added_per_sub_tier2 * factor_t2_local);
|
||||||
addTime(endingTime, seconds_added_per_sub_tier3);
|
logMessage("Twitch", `Added ${seconds_added_per_sub_tier2 * factor_t2_local} Seconds Because ${username} Subscribed With Tier 2`);
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_sub_tier3} Seconds Because ${username} Subscribed With Tier 3`);
|
break;
|
||||||
break;
|
case "3000":
|
||||||
}
|
addTime(endingTime, seconds_added_per_sub_tier3 * factor_t3_local);
|
||||||
}
|
logMessage("Twitch", `Added ${seconds_added_per_sub_tier3 * factor_t3_local} Seconds Because ${username} Subscribed With Tier 3`);
|
||||||
else if(happy_hour_active){
|
break;
|
||||||
switch (methods['plan']) {
|
|
||||||
case "Prime":
|
|
||||||
addTime(endingTime, seconds_added_per_sub_prime_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_sub_prime_happy} Seconds Because ${username} Subscribed With Prime`);
|
|
||||||
break;
|
|
||||||
case "1000":
|
|
||||||
addTime(endingTime, seconds_added_per_sub_tier1_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_sub_tier1_happy} Seconds Because ${username} Subscribed With Tier 1`);
|
|
||||||
break;
|
|
||||||
case "2000":
|
|
||||||
addTime(endingTime, seconds_added_per_sub_tier2_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_sub_tier2_happy} Seconds Because ${username} Subscribed With Tier 2`);
|
|
||||||
break;
|
|
||||||
case "3000":
|
|
||||||
addTime(endingTime, seconds_added_per_sub_tier3_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_sub_tier3_happy} Seconds Because ${username} Subscribed With Tier 3`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!users.includes(username)) {
|
if (!users.includes(username)) {
|
||||||
users.push(username);
|
users.push(username);
|
||||||
@@ -60,45 +42,27 @@ if (twitch_channel_name !== "") {
|
|||||||
|
|
||||||
client.on('resub', (channel, username, months, message, userstate, methods) => {
|
client.on('resub', (channel, username, months, message, userstate, methods) => {
|
||||||
if (!countdownEnded && subEnable) {
|
if (!countdownEnded && subEnable) {
|
||||||
if(!happy_hour_active){
|
let factor_t1_local = (happy_hour_active ? factor_t1 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t1): 1);
|
||||||
switch (methods['plan']) {
|
let factor_t2_local = (happy_hour_active ? factor_t2 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t2): 1);
|
||||||
case "Prime":
|
let factor_t3_local = (happy_hour_active ? factor_t3 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t3): 1);
|
||||||
addTime(endingTime, seconds_added_per_resub_prime);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_resub_prime} Seconds Because ${username} ReSubscribed With Prime`);
|
switch (methods['plan']) {
|
||||||
break;
|
case "Prime":
|
||||||
case "1000":
|
addTime(endingTime, seconds_added_per_resub_prime * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_resub_tier1);
|
logMessage("Twitch", `Added ${seconds_added_per_resub_prime * factor_t1_local} Seconds Because ${username} ReSubscribed With Prime`);
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_resub_tier1} Seconds Because ${username} ReSubscribed With Tier 1`);
|
break;
|
||||||
break;
|
case "1000":
|
||||||
case "2000":
|
addTime(endingTime, seconds_added_per_resub_tier1 * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_resub_tier2);
|
logMessage("Twitch", `Added ${seconds_added_per_resub_tier1 * factor_t1_local} Seconds Because ${username} ReSubscribed With Tier 1`);
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_resub_tier2} Seconds Because ${username} ReSubscribed With Tier 2`);
|
break;
|
||||||
break;
|
case "2000":
|
||||||
case "3000":
|
addTime(endingTime, seconds_added_per_resub_tier2 * factor_t2_local);
|
||||||
addTime(endingTime, seconds_added_per_resub_tier3);
|
logMessage("Twitch", `Added ${seconds_added_per_resub_tier2 * factor_t2_local} Seconds Because ${username} ReSubscribed With Tier 2`);
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_resub_tier3} Seconds Because ${username} ReSubscribed With Tier 3`);
|
break;
|
||||||
break;
|
case "3000":
|
||||||
}
|
addTime(endingTime, seconds_added_per_resub_tier3 * factor_t3_local);
|
||||||
}
|
logMessage("Twitch", `Added ${seconds_added_per_resub_tier3 * factor_t3_local} Seconds Because ${username} ReSubscribed With Tier 3`);
|
||||||
else if(happy_hour_active){
|
break;
|
||||||
switch (methods['plan']) {
|
|
||||||
case "Prime":
|
|
||||||
addTime(endingTime, seconds_added_per_resub_prime_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_resub_prime_happy} Seconds Because ${username} ReSubscribed With Prime`);
|
|
||||||
break;
|
|
||||||
case "1000":
|
|
||||||
addTime(endingTime, seconds_added_per_resub_tier1_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_resub_tier1_happy} Seconds Because ${username} ReSubscribed With Tier 1`);
|
|
||||||
break;
|
|
||||||
case "2000":
|
|
||||||
addTime(endingTime, seconds_added_per_resub_tier2_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_resub_tier2_happy} Seconds Because ${username} ReSubscribed With Tier 2`);
|
|
||||||
break;
|
|
||||||
case "3000":
|
|
||||||
addTime(endingTime, seconds_added_per_resub_tier3_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_resub_tier3_happy} Seconds Because ${username} ReSubscribed With Tier 3`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!users.includes(username)) {
|
if (!users.includes(username)) {
|
||||||
users.push(username);
|
users.push(username);
|
||||||
@@ -108,45 +72,27 @@ if (twitch_channel_name !== "") {
|
|||||||
|
|
||||||
client.on('subgift', (channel, username, months, recipient, methods, userstate) => {
|
client.on('subgift', (channel, username, months, recipient, methods, userstate) => {
|
||||||
if (!countdownEnded && subEnable) {
|
if (!countdownEnded && subEnable) {
|
||||||
if(!happy_hour_active){
|
let factor_t1_local = (happy_hour_active ? factor_t1 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t1): 1);
|
||||||
switch (methods['plan']) {
|
let factor_t2_local = (happy_hour_active ? factor_t2 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t2): 1);
|
||||||
case "Prime":
|
let factor_t3_local = (happy_hour_active ? factor_t3 : 1) * (random_hour_active ? randomInRangeNoRounding(...range_t3): 1);
|
||||||
addTime(endingTime, seconds_added_per_giftsub_prime);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_giftsub_prime} Seconds Because ${username} gifted Sub With Prime`);
|
switch (methods['plan']) {
|
||||||
break;
|
case "Prime":
|
||||||
case "1000":
|
addTime(endingTime, seconds_added_per_giftsub_prime * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier1);
|
logMessage("Twitch", `Added ${seconds_added_per_giftsub_prime * factor_t1_local} Seconds Because ${username} gifted Sub With Prime`);
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_giftsub_tier1} Seconds Because ${username} gifted Sub With Tier 1`);
|
break;
|
||||||
break;
|
case "1000":
|
||||||
case "2000":
|
addTime(endingTime, seconds_added_per_giftsub_tier1 * factor_t1_local);
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier2);
|
logMessage("Twitch", `Added ${seconds_added_per_giftsub_tier1 * factor_t1_local} Seconds Because ${username} gifted Sub With Tier 1`);
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_giftsub_tier2} Seconds Because ${username} gifted Sub With Tier 2`);
|
break;
|
||||||
break;
|
case "2000":
|
||||||
case "3000":
|
addTime(endingTime, seconds_added_per_giftsub_tier2 * factor_t2_local);
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier3);
|
logMessage("Twitch", `Added ${seconds_added_per_giftsub_tier2 * factor_t2_local} Seconds Because ${username} gifted Sub With Tier 2`);
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_giftsub_tier3} Seconds Because ${username} gifted Sub With Tier 3`);
|
break;
|
||||||
break;
|
case "3000":
|
||||||
}
|
addTime(endingTime, seconds_added_per_giftsub_tier3 * factor_t3_local);
|
||||||
}
|
logMessage("Twitch", `Added ${seconds_added_per_giftsub_tier3 * factor_t3_local} Seconds Because ${username} gifted Sub With Tier 3`);
|
||||||
else if(happy_hour_active){
|
break;
|
||||||
switch (methods['plan']) {
|
|
||||||
case "Prime":
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_prime_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_giftsub_prime_happy} Seconds Because ${username} gifted Sub With Prime`);
|
|
||||||
break;
|
|
||||||
case "1000":
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier1_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_giftsub_tier1_happy} Seconds Because ${username} gifted Sub With Tier 1`);
|
|
||||||
break;
|
|
||||||
case "2000":
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier2_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_giftsub_tier2_happy} Seconds Because ${username} gifted Sub With Tier 2`);
|
|
||||||
break;
|
|
||||||
case "3000":
|
|
||||||
addTime(endingTime, seconds_added_per_giftsub_tier3_happy);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_giftsub_tier3_happy} Seconds Because ${username} gifted Sub With Tier 3`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!users.includes(username)) {
|
if (!users.includes(username)) {
|
||||||
users.push(username);
|
users.push(username);
|
||||||
@@ -156,24 +102,14 @@ if (twitch_channel_name !== "") {
|
|||||||
|
|
||||||
client.on('cheer', (channel, userstate, message) => {
|
client.on('cheer', (channel, userstate, message) => {
|
||||||
if (!countdownEnded && bitEnable) {
|
if (!countdownEnded && bitEnable) {
|
||||||
if(!happy_hour_active){
|
let factor_bits_local = (happy_hour_active ? factor_bits : 1) * (random_hour_active ? randomInRangeNoRounding(...range_bits): 1);
|
||||||
if (userstate.bits >= min_amount_of_bits) {
|
|
||||||
let times = Math.floor(userstate.bits/min_amount_of_bits);
|
if (userstate.bits >= min_amount_of_bits) {
|
||||||
addTime(endingTime, seconds_added_per_bits * times);
|
let times = Math.floor(userstate.bits/min_amount_of_bits);
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_bits * times} Seconds Because ${userstate['display-name']} Donated ${userstate.bits} Bits`);
|
addTime(endingTime, seconds_added_per_bits * times * factor_bits_local);
|
||||||
if (!users.includes(userstate['display-name'])) {
|
logMessage("Twitch", `Added ${seconds_added_per_bits * times} Seconds Because ${userstate['display-name']} Donated ${userstate.bits} Bits`);
|
||||||
users.push(userstate['display-name']);
|
if (!users.includes(userstate['display-name'])) {
|
||||||
}
|
users.push(userstate['display-name']);
|
||||||
}
|
|
||||||
}
|
|
||||||
if(happy_hour_active){
|
|
||||||
if (userstate.bits >= min_amount_of_bits) {
|
|
||||||
let times = Math.floor(userstate.bits/min_amount_of_bits);
|
|
||||||
addTime(endingTime, seconds_added_per_bits_happy * times);
|
|
||||||
logMessage("Twitch", `Added ${seconds_added_per_bits_happy * times} Seconds Because ${userstate['display-name']} Donated ${userstate.bits} Bits`);
|
|
||||||
if (!users.includes(userstate['display-name'])) {
|
|
||||||
users.push(userstate['display-name']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ const randomInRange = (min, max) => {
|
|||||||
return Math.floor(Math.random() * (max - min)) + min;
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const randomInRangeNoRounding = (min, max) => {
|
||||||
|
return Math.random() * (max - min) + min;
|
||||||
|
};
|
||||||
|
|
||||||
const logMessage = (module, message) => {
|
const logMessage = (module, message) => {
|
||||||
console.log(`[${module}]: ${message}`);
|
console.log(`[${module}]: ${message}`);
|
||||||
};
|
};
|
||||||
@@ -13,3 +17,5 @@ const logMessage = (module, message) => {
|
|||||||
const logObject = (module, object) => {
|
const logObject = (module, object) => {
|
||||||
console.log(`[${module}]: `, object);
|
console.log(`[${module}]: `, object);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+52
-46
@@ -5,6 +5,7 @@ var initialMinutes;
|
|||||||
var initialSeconds;
|
var initialSeconds;
|
||||||
var paused = false;
|
var paused = false;
|
||||||
var happy_hour_active = false;
|
var happy_hour_active = false;
|
||||||
|
var random_hour_active = false;
|
||||||
|
|
||||||
var initialHoursLocal = window.localStorage.getItem('initialHours')
|
var initialHoursLocal = window.localStorage.getItem('initialHours')
|
||||||
if(initialHoursLocal !== null) {
|
if(initialHoursLocal !== null) {
|
||||||
@@ -96,52 +97,56 @@ Mousetrap.bind(pauseShort, function(e) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Mousetrap.bind(happyHourShort, async function(e){
|
Mousetrap.bind(happyHourShort, async function(e){
|
||||||
if(happy_hour){
|
specialHourHandler('Happy');
|
||||||
happyHourFunc()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logMessage("Core", "Happy Hour is not available")
|
|
||||||
document.getElementById("HappyHourText").innerHTML = "Happy Hour error";
|
|
||||||
document.getElementById("HappyHourText").animate({opacity: [ 0, 1 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
|
||||||
document.getElementById("HappyHourText").style.opacity = "1";
|
|
||||||
document.getElementById("HappyHourHTML").animate({top: [ "-200px", "-250px" ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
|
||||||
document.getElementById("HappyHourHTML").style.top = "-250px";
|
|
||||||
await sleep(5000)
|
|
||||||
document.getElementById("HappyHourText").animate({opacity: [ 1, 0 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
|
||||||
document.getElementById("HappyHourText").style.opacity = "0";
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function happyHourFunc(){
|
Mousetrap.bind(randomHourShort, async function(e){
|
||||||
if(!happy_hour_active){
|
specialHourHandler('Random');
|
||||||
logMessage("Core","Happy Hour activated");
|
});
|
||||||
happy_hour_active = true;
|
|
||||||
document.getElementById("HappyHourText").innerHTML = "Happy Hour Activated!";
|
async function specialHourHandler(type){
|
||||||
document.getElementById("HappyHourText").animate({opacity: [ 0, 1 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
if((type === 'Happy' && happy_hour) || (type === 'Random' && random_hour)){
|
||||||
document.getElementById("HappyHourText").style.opacity = "1";
|
specialHourFunc(type)
|
||||||
document.getElementById("HappyHourHTML").animate({top: [ "-200px", "-250px" ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
|
||||||
document.getElementById("HappyHourHTML").style.top = "-250px";
|
|
||||||
document.getElementById("container").style.backgroundImage = "-webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, .1) 33%, rgba(0,0, 0, .1) 66%, transparent 66%), -webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25)), url(https://drive.google.com/uc?id=1oduFlPg84O1DliM5FsLvJJsnwZ4m1Vpm), -webkit-linear-gradient(left, #0074cc, #a700cc)";
|
|
||||||
await sleep(10000)
|
|
||||||
document.getElementById("HappyHourText").animate({opacity: [ 1, 0 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
|
||||||
document.getElementById("HappyHourText").style.opacity = "0";
|
|
||||||
}
|
}
|
||||||
else if(happy_hour_active){
|
else {
|
||||||
logMessage("Core", "Happy Hour deactivated")
|
logMessage("Core", `${type} Hour is not available`)
|
||||||
clearTimeout(happyHourFunc)
|
document.getElementById("SpecialHourText").innerHTML = `${type} Hour error`;
|
||||||
happy_hour_active = false;
|
document.getElementById("SpecialHourText").animate({opacity: [ 0, 1 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
||||||
document.getElementById("HappyHourText").innerHTML = "Happy Hour Deactivated";
|
document.getElementById("SpecialHourText").style.opacity = "1";
|
||||||
document.getElementById("HappyHourText").animate({opacity: [ 0, 1 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
document.getElementById("SpecialHourHTML").animate({top: [ "-200px", "-250px" ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
||||||
document.getElementById("HappyHourText").style.opacity = "1";
|
document.getElementById("SpecialHourHTML").style.top = "-250px";
|
||||||
document.getElementById("HappyHourHTML").animate({top: [ "-200px", "-250px" ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
|
||||||
document.getElementById("HappyHourHTML").style.top = "-250px";
|
|
||||||
document.getElementById("container").style.backgroundImage = "-webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, .1) 33%, rgba(0,0, 0, .1) 66%, transparent 66%), -webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25)), -webkit-linear-gradient(left, #0074cc, #a700cc)";
|
|
||||||
await sleep(5000)
|
await sleep(5000)
|
||||||
document.getElementById("HappyHourText").animate({opacity: [ 1, 0 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
document.getElementById("SpecialHourText").animate({opacity: [ 1, 0 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
||||||
document.getElementById("HappyHourText").style.opacity = "0";
|
document.getElementById("SpecialHourText").style.opacity = "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function specialHourFunc(type){
|
||||||
|
let activate = ((type === 'Happy' && !happy_hour_active) || (type === 'Random' && !random_hour_active));
|
||||||
|
let toggleText = activate ? 'Activated' : 'Deactivated';
|
||||||
|
|
||||||
|
logMessage("Core", `${type} Hour ${toggleText}`);
|
||||||
|
|
||||||
|
if (type === 'Happy') happy_hour_active = activate;
|
||||||
|
if (type === 'Random') random_hour_active = activate;
|
||||||
|
|
||||||
|
let animation = (happy_hour_active || random_hour_active) ? ', url(https://drive.google.com/uc?id=1oduFlPg84O1DliM5FsLvJJsnwZ4m1Vpm)' : '';
|
||||||
|
|
||||||
|
document.getElementById("SpecialHourText").innerHTML = `${type} Hour ${toggleText}!`;
|
||||||
|
document.getElementById("SpecialHourText").animate({opacity: [ 0, 1 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
||||||
|
document.getElementById("SpecialHourText").style.opacity = "1";
|
||||||
|
|
||||||
|
document.getElementById("SpecialHourHTML").animate({top: [ "-200px", "-250px" ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
||||||
|
document.getElementById("SpecialHourHTML").style.top = "-250px";
|
||||||
|
|
||||||
|
document.getElementById("container").style.backgroundImage = `-webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, .1) 33%, rgba(0,0, 0, .1) 66%, transparent 66%), -webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25))${animation}, -webkit-linear-gradient(left, #0074cc, #a700cc)`;
|
||||||
|
|
||||||
|
await sleep(activate ? 5000 : 10000);
|
||||||
|
|
||||||
|
document.getElementById("SpecialHourText").animate({opacity: [ 1, 0 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
|
||||||
|
document.getElementById("SpecialHourText").style.opacity = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let countdownEnded = false;
|
let countdownEnded = false;
|
||||||
let users = [];
|
let users = [];
|
||||||
@@ -198,8 +203,8 @@ function randomHappy(){
|
|||||||
if(!happy_hour_active){
|
if(!happy_hour_active){
|
||||||
if((getRandomInt(0,10000) == 127)){
|
if((getRandomInt(0,10000) == 127)){
|
||||||
logMessage("RandomHappy","It's not rigged!")
|
logMessage("RandomHappy","It's not rigged!")
|
||||||
happyHourFunc()
|
specialHourFunc()
|
||||||
setTimeout(happyHourFunc, 3600000)
|
setTimeout(specialHourFunc, 3600000)
|
||||||
}
|
}
|
||||||
setTimeout(randomHappy,1000)
|
setTimeout(randomHappy,1000)
|
||||||
}
|
}
|
||||||
@@ -211,8 +216,8 @@ function scheduleHappyFunc(){
|
|||||||
if(now.getUTCHours() == scheduleHappyHour){
|
if(now.getUTCHours() == scheduleHappyHour){
|
||||||
if(now.getUTCMinutes() == 00){
|
if(now.getUTCMinutes() == 00){
|
||||||
logMessage("Schedule","It's time!")
|
logMessage("Schedule","It's time!")
|
||||||
happyHourFunc()
|
specialHourFunc()
|
||||||
setTimeout(happyHourFunc, 3600000)
|
setTimeout(specialHourFunc, 3600000)
|
||||||
setTimeout(scheduleHappyFunc, 36000000)
|
setTimeout(scheduleHappyFunc, 36000000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,18 +230,19 @@ var addedTimeCounter;
|
|||||||
var timeoutID;
|
var timeoutID;
|
||||||
|
|
||||||
const addTime = async (time, s) => {
|
const addTime = async (time, s) => {
|
||||||
|
let addedTime = Math.floor(s);
|
||||||
if(!bulk_enabled) {
|
if(!bulk_enabled) {
|
||||||
endingTimeBeforeCounter = time;
|
endingTimeBeforeCounter = time;
|
||||||
addedTimeCounter = s;
|
addedTimeCounter = addedTime;
|
||||||
addTimeInternal();
|
addTimeInternal();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(firstSub) {
|
if(firstSub) {
|
||||||
firstSub = false;
|
firstSub = false;
|
||||||
endingTimeBeforeCounter = time;
|
endingTimeBeforeCounter = time;
|
||||||
addedTimeCounter = s;
|
addedTimeCounter = addedTime;
|
||||||
} else {
|
} else {
|
||||||
addedTimeCounter += s;
|
addedTimeCounter += addedTime;
|
||||||
window.clearTimeout(timeoutID);
|
window.clearTimeout(timeoutID);
|
||||||
}
|
}
|
||||||
timeoutID = window.setTimeout(addTimeInternal, 1000);
|
timeoutID = window.setTimeout(addTimeInternal, 1000);
|
||||||
|
|||||||
Reference in New Issue
Block a user