Skip to content

Use communityGiftPurchase Activity to add time from bulk gifts #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions subathon/widget-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,29 @@ window.widget.serviceModules.registerServiceModuleProvider({
let str = "";
// Update subathon end timestamp
switch (activity.type) {
case 'communityGiftPurchase':
switch (activity.data.tier) {
case "1000":
str = managedData.timeAdditions.t1[1];
if (isInt(str) && managedData.timeAdditions.t1[0]) addTime(parseInt(str, 10) * activity.data.amount);
break;
case "2000":
str = managedData.timeAdditions.t2[1];
if (isInt(str) && managedData.timeAdditions.t2[0]) addTime(parseInt(str, 10) * activity.data.amount);
break;
case "3000":
str = managedData.timeAdditions.t3[1];
if (isInt(str) && managedData.timeAdditions.t3[0]) addTime(parseInt(str, 10) * activity.data.amount);
break;
}
break;
case 'subscriber':
if (activity.bulkGifted) { // Ignore gifting event and count only real subs
return;
}
if (activity.activityGroup) { // Ignore community gifted subs because we used the communityGiftPurchase Activity to add time for these
return;
}
switch (activity.data.tier) {
case "1000":
str = managedData.timeAdditions.t1[1];
Expand Down