Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
870 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const { events } = require("../../../../stores"); | ||
const api = require("./getUserInfoVars"); | ||
|
||
const eventsWithUserVars = [ | ||
"onCommand", | ||
"onBits", | ||
"onRedemption", | ||
"onAction", | ||
"onBitsBadgeUpgrade", | ||
"onCommunityPayForward", | ||
"onCommunitySub", | ||
"onGiftPaidUpgrade", | ||
"onMessage", | ||
"onPrimeCommunityGift", | ||
"onPrimePaidUpgrade", | ||
"onRaid", | ||
"onResub", | ||
"onRewardGift", | ||
"onRitual", | ||
"onStandardPayForward", | ||
"onSub", | ||
"onSubExtend", | ||
"onSubGift", | ||
]; | ||
|
||
module.exports = function getEvents() { | ||
const userVars = api.getDefaultVars(); | ||
return events.get("events").map((event) => { | ||
if (eventsWithUserVars.includes(event.name)) { | ||
event.tags = { | ||
...event.tags, | ||
...userVars, | ||
}; | ||
} | ||
return event; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const getConnectedUser = require("./getConnectedUser"); | ||
const twitch = require("../index"); | ||
|
||
function getDefaultVars() { | ||
return { | ||
isBroadcaster: "0", | ||
isMod: "0", | ||
isVip: "0", | ||
isSubscriber: "0", | ||
// timestamp: Date.now(), | ||
}; | ||
} | ||
|
||
function getChatUserInfoVars(data) { | ||
const { isBroadcaster, isMod, isSubscriber, isVip } = data.userInfo; | ||
|
||
return { | ||
...getDefaultVars(), | ||
isBroadcaster, | ||
isMod, | ||
isVip, | ||
isSubscriber, | ||
}; | ||
} | ||
|
||
async function getPubSubUserInfoVars(user) { | ||
const broadcaster = await getConnectedUser(); | ||
const isBroadcaster = broadcaster.login === user.login; | ||
|
||
const isSubscriber = | ||
isBroadcaster || | ||
!!(await twitch.api.helix.subscriptions.getSubscriptionForUser( | ||
broadcaster.id, | ||
user.id | ||
)); | ||
|
||
let isMod = false; | ||
let isVip = false; | ||
|
||
if (!isBroadcaster) { | ||
const mods = await twitch.chat.getMods(broadcaster.login); | ||
const vips = await twitch.chat.getVips(broadcaster.login); | ||
isMod = mods.includes(user.login); | ||
isVip = vips.includes(user.login); | ||
} | ||
|
||
return { | ||
...getDefaultVars(), | ||
isBroadcaster, | ||
isMod, | ||
isVip, | ||
isSubscriber, | ||
}; | ||
} | ||
|
||
module.exports = { | ||
getDefaultVars, | ||
getChatUserInfoVars, | ||
getPubSubUserInfoVars, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const { events } = require("../../../../stores"); | ||
|
||
module.exports = function setEvent(event) { | ||
events.set( | ||
"events", | ||
events.get("events").map((e) => { | ||
return e.name === event.name ? { ...e, ...event } : e; | ||
}) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
const pushActions = require("../../pushActions"); | ||
const api = require("../../api/getUserInfoVars"); | ||
|
||
module.exports = function onAction(channel, user, message) { | ||
const date = new Intl.DateTimeFormat("fr-FR").format(Date.now()); | ||
pushActions("onAction", { user, message, date }); | ||
module.exports = function onAction(channel, user, message, data) { | ||
const userVars = api.getChatUserInfoVars(data); | ||
pushActions("onAction", { user, message, ...userVars }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
const pushActions = require("../../pushActions"); | ||
const api = require("../../api/getUserInfoVars"); | ||
|
||
module.exports = function onBitsBadgeUpgrade(channel, user, upgradeInfo) { | ||
module.exports = function onBitsBadgeUpgrade(channel, user, upgradeInfo, data) { | ||
const userVars = api.getChatUserInfoVars(data); | ||
const { displayName, threshold } = upgradeInfo; | ||
pushActions("onBitsBadgeUpgrade", { user: displayName, threshold }); | ||
pushActions("onBitsBadgeUpgrade", { | ||
user: displayName, | ||
threshold, | ||
...userVars, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
const pushActions = require("../../pushActions"); | ||
const api = require("../../api/getUserInfoVars"); | ||
|
||
module.exports = function onCommunityPayForward(channel, user, forwardInfo) { | ||
module.exports = function onCommunityPayForward( | ||
channel, | ||
user, | ||
forwardInfo, | ||
data | ||
) { | ||
const userVars = api.getChatUserInfoVars(data); | ||
const { displayName, originalGifterDisplayName } = forwardInfo; | ||
pushActions("onCommunityPayForward", { | ||
fromUser: originalGifterDisplayName, | ||
toUser: displayName, | ||
...userVars, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
const pushActions = require("../../pushActions"); | ||
const api = require("../../api/getUserInfoVars"); | ||
|
||
module.exports = function onCommunitySub(channel, user, subInfo) { | ||
module.exports = function onCommunitySub(channel, user, subInfo, data) { | ||
const userVars = api.getChatUserInfoVars(data); | ||
const { count, gifter, gifterGiftCount, plan } = subInfo; | ||
pushActions("onCommunitySub", { | ||
user: gifter, | ||
count, | ||
total: gifterGiftCount, | ||
tiers: plan, | ||
...userVars, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
const pushActions = require("../../pushActions"); | ||
const api = require("../../api/getUserInfoVars"); | ||
|
||
module.exports = function onGiftPaidUpgrade(channel, user, subInfo) { | ||
module.exports = function onGiftPaidUpgrade(channel, user, subInfo, data) { | ||
const userVars = api.getChatUserInfoVars(data); | ||
const { gifter, displayName, plan } = subInfo; | ||
pushActions("onGiftPaidUpgrade", { | ||
fromUser: gifter, | ||
toUser: displayName, | ||
tiers: plan, | ||
...userVars, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
const pushActions = require("../../pushActions"); | ||
const api = require("../../api/getUserInfoVars"); | ||
|
||
module.exports = function onPrimeCommunityGift(channel, user, subInfo) { | ||
const { gifter } = subInfo; | ||
pushActions("onPrimeCommunityGift", { user: gifter, name }); | ||
module.exports = function onPrimeCommunityGift(channel, user, subInfo, data) { | ||
const userVars = api.getChatUserInfoVars(data); | ||
const { gifter, name } = subInfo; | ||
pushActions("onPrimeCommunityGift", { user: gifter, name, ...userVars }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
const pushActions = require("../../pushActions"); | ||
const api = require("../../api/getUserInfoVars"); | ||
|
||
module.exports = function onPrimePaidUpgrade(channel, user, subInfo) { | ||
module.exports = function onPrimePaidUpgrade(channel, user, subInfo, data) { | ||
const userVars = api.getChatUserInfoVars(data); | ||
const { displayName, plan } = subInfo; | ||
pushActions("onPrimePaidUpgrade", { user: displayName, tiers: plan }); | ||
pushActions("onPrimePaidUpgrade", { | ||
user: displayName, | ||
tiers: plan, | ||
...userVars, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
const pushActions = require("../../pushActions"); | ||
const api = require("../../api/getUserInfoVars"); | ||
|
||
module.exports = function onRaid(channel, user, raidInfo) { | ||
module.exports = function onRaid(channel, user, raidInfo, data) { | ||
const userVars = api.getChatUserInfoVars(data); | ||
const { displayName, viewerCount } = raidInfo; | ||
pushActions("onRaid", { channel: displayName, viewerCount }); | ||
pushActions("onRaid", { channel: displayName, viewerCount, ...userVars }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
const pushActions = require("../../pushActions"); | ||
const api = require("../../api/getUserInfoVars"); | ||
|
||
module.exports = function onRitual(channel, user, ritualInfo) { | ||
module.exports = function onRitual(channel, user, ritualInfo, data) { | ||
const userVars = api.getChatUserInfoVars(data); | ||
const { ritualName, message } = ritualInfo; | ||
pushActions("onRitual", { ritualName, message }); | ||
pushActions("onRitual", { ritualName, message, ...userVars }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
const pushActions = require("../../pushActions"); | ||
const api = require("../../api/getUserInfoVars"); | ||
|
||
module.exports = function onSubExtend(channel, user, subInfo) { | ||
module.exports = function onSubExtend(channel, user, subInfo, data) { | ||
const userVars = api.getChatUserInfoVars(data); | ||
const { displayName, endMonth, months, plan } = subInfo; | ||
pushActions("onSubExtend", { | ||
user: displayName, | ||
months, | ||
endMonth, | ||
tiers: plan, | ||
...userVars, | ||
}); | ||
}; |
Oops, something went wrong.