mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 01:01:39 +01:00
add personalized welcome messages (untested SMILERS)
This commit is contained in:
@@ -48,6 +48,18 @@ async function parseChatMessage(msg: EventSubChannelChatMessageEvent) {
|
||||
|
||||
if (!(await isInvuln(user?.id!))) user?.setVulnerable(); // Make the user vulnerable to explosions if not marked as invuln
|
||||
|
||||
// Custom welcome messages
|
||||
const wcmessage = await redis.get(`user:${user?.id}:welcomemessagetext`);
|
||||
if (
|
||||
process.env.NODE_ENV === "production" && // when running prod DB
|
||||
wcmessage && // when chatter has a welcome message set
|
||||
(await redis.exists(`streamIsLive`)) && // when the stream is active
|
||||
!(await redis.exists(`user:${user?.id}:haschattedthisstream`)) // when the user hasn't chatted this stream
|
||||
)
|
||||
await sendMessage(wcmessage);
|
||||
|
||||
await redis.set(`user:${user?.id}:haschattedthisstream`, "1");
|
||||
|
||||
if (!msg.isCheer && !msg.isRedemption) await handleChatMessage(msg, user!);
|
||||
else if (msg.isCheer && !msg.isRedemption)
|
||||
await handleCheer(msg, msg.bits, user!);
|
||||
|
||||
@@ -5,16 +5,23 @@ import { streamerId } from "main";
|
||||
import { sendDiscordMessage } from "web/discordConnection";
|
||||
|
||||
eventSub.onStreamOnline(streamerId, async (msg) => {
|
||||
await redis.set("streamIsLive", "1");
|
||||
await sendMessage(
|
||||
`${msg.broadcasterDisplayName.toUpperCase()} IS LIVE! START DIGGING!`,
|
||||
);
|
||||
await sendDiscordMessage({ message: "live" });
|
||||
await Promise.all([
|
||||
redis.set("streamIsLive", "1"),
|
||||
sendMessage(
|
||||
`${msg.broadcasterDisplayName.toUpperCase()} IS LIVE! START DIGGING!`,
|
||||
),
|
||||
sendDiscordMessage({ message: "live" }),
|
||||
redis
|
||||
.keys("user:*:haschattedthisstream")
|
||||
.then((a) => a.map(async (b) => await redis.del(b))),
|
||||
]);
|
||||
});
|
||||
|
||||
eventSub.onStreamOffline(streamerId, async (msg) => {
|
||||
await redis.del("streamIsLive");
|
||||
await sendMessage(
|
||||
`${msg.broadcasterDisplayName.toUpperCase()} IS OFFLINE! NO MORE FREE LOOT!`,
|
||||
);
|
||||
await Promise.all([
|
||||
redis.del("streamIsLive"),
|
||||
sendMessage(
|
||||
`${msg.broadcasterDisplayName.toUpperCase()} IS OFFLINE! NO MORE FREE LOOT!`,
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
26
src/pointRedeems/welcomemessageset.ts
Normal file
26
src/pointRedeems/welcomemessageset.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import PointRedeem from "pointRedeems";
|
||||
import { sendMessage } from "lib/commandUtils";
|
||||
import { redis } from "lib/redis";
|
||||
|
||||
export default new PointRedeem({
|
||||
name: "setwelcomemsg",
|
||||
cost: 15000,
|
||||
title: "Set welcome message",
|
||||
input: true,
|
||||
color: "#0099FF",
|
||||
prompt:
|
||||
"Set your welcome message (echoed once per stream). Character limit is 200",
|
||||
async execution(msg) {
|
||||
if (msg.input.length > 200) {
|
||||
await sendMessage(`Your desired welcome message is too long`);
|
||||
if (process.env.NODE_ENV === "production")
|
||||
await msg.updateStatus("CANCELED");
|
||||
}
|
||||
await Promise.all([
|
||||
sendMessage(
|
||||
`${msg.userDisplayName} successfully set their new welcome message`,
|
||||
),
|
||||
redis.set(`user:${msg.userId}:welcomemessagetext`, "1"),
|
||||
]);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user