1
0

♻️ Extract hidrate logic to server

This commit is contained in:
2022-01-05 19:50:42 +01:00
parent 190d7f7d26
commit e3dfe80cc4
3 changed files with 25 additions and 13 deletions

View File

@@ -64,19 +64,6 @@ async function checkEvent(e) {
case "ac750bd6-fb4c-4259-b06d-56953601243b": case "ac750bd6-fb4c-4259-b06d-56953601243b":
await createCard(data.rewardName, data.message, data.backgroundColor, data.rewardImage); await createCard(data.rewardName, data.message, data.backgroundColor, data.rewardImage);
break; break;
// hidratate
case "232e951f-93d1-4138-a0e3-9e822b4852e0":
data.message = `@${data.userDisplayName} ha invitado a una ronda.`;
sendWsActions({
type: "say",
channelId: data.channelId,
userId: data.userId,
data: {
message: "waterGang waterGang waterGang"
}
});
await createCard(data.rewardName, data.message, data.backgroundColor, data.rewardImage);
break;
default: default:
await createCard(data.rewardName, data.message ? data.message : "", data.backgroundColor, data.rewardImage); await createCard(data.rewardName, data.message ? data.message : "", data.backgroundColor, data.rewardImage);
} }

View File

@@ -0,0 +1,23 @@
import { LOG_PREFIX } from "..";
import { RedemptionMessage } from "../../../interfaces/RedemptionMessage";
import { broadcast } from "../../helpers/webServer";
import { getUsernameFromId } from "../../helpers/twitch";
import { say } from "../../chatClient";
async function hidrate(msg: RedemptionMessage): Promise<void> {
const channel = await getUsernameFromId(parseInt(msg.channelId));
if (!channel) {
console.log(`${LOG_PREFIX}No channel found`);
return;
}
msg.message = `@${msg.userDisplayName} ha invitado a una ronda`;
broadcast(JSON.stringify(msg));
await say(channel, "waterGang waterGang waterGang");
}
export { hidrate };

View File

@@ -6,6 +6,7 @@ import { UserIdResolvable } from "twitch";
import { broadcast } from "../helpers/webServer"; import { broadcast } from "../helpers/webServer";
import { getApiClient } from "../helpers/twitch"; import { getApiClient } from "../helpers/twitch";
import { getVip } from "./actions/getVip"; import { getVip } from "./actions/getVip";
import { hidrate } from "./actions/hidrate";
import { russianRoulette } from "./actions/russianRoulette"; import { russianRoulette } from "./actions/russianRoulette";
import { stealVip } from "./actions/stealVip"; import { stealVip } from "./actions/stealVip";
import { timeoutFriend } from "./actions/timeoutFriend"; import { timeoutFriend } from "./actions/timeoutFriend";
@@ -66,6 +67,7 @@ async function onRedemption(message: PubSubRedemptionMessage) {
} }
break; break;
case RedemptionIds.Hidrate: case RedemptionIds.Hidrate:
await hidrate(msg);
break; break;
default: default:
console.log(LOG_PREFIX, msg); console.log(LOG_PREFIX, msg);