mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
add personalized welcome messages (untested SMILERS)
This commit is contained in:
@@ -122,6 +122,14 @@ The enable and disable redeem commands have a way to enable/disable all sound al
|
||||
|
||||
When running the development database and twitch api application, the redeems will not get created. This is because twitch only allows editing or deleting rewards when the same application created the reward. (fucking stupid)
|
||||
|
||||
### Welcome message
|
||||
|
||||
Welcome message in the context of this project means 2 things:
|
||||
- The message the bot says when it's the first time you're chatting in the channel.
|
||||
- The personalized message the bot says when you chat for the first time during a stream.
|
||||
|
||||
The personalized message can be set by using the channel point redemption. The message cannot be longer than 200 characters.
|
||||
|
||||
### Chatterbot/streamerbot
|
||||
|
||||
This depends on if the `CHATTER_IS_STREAMER` environment variable is set.
|
||||
@@ -224,6 +232,7 @@ NAME|AMOUNT|USAGE|FUNCTION
|
||||
|
||||
NAME|COST|DESCRIPTION|INTERNALNAME
|
||||
-|-|-|-
|
||||
`Set welcome message`|15000|Set the message the bot will say when you first chat during a stream (character limit is 200)|`setwelcomemsg`
|
||||
`FREE MONEY`|1000|Get 100 qbucks|`qbucksredeem`
|
||||
`RIPBOZO`|500|Sound: Coffeezilla calls me a conman [(source)](https://www.youtube.com/watch?v=QRvEGn7i-wM)|`sfxripbozo`
|
||||
`Welcome to the Madhouse`|100|Sound: mrockstar20 says: "Welcome to the Madhouse"|`sfxmrockmadhouse`
|
||||
|
||||
@@ -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