add onRaided event and now ignoring chatters from shared chats

This commit is contained in:
2025-09-09 23:56:53 +02:00
parent 5c2c3fbb53
commit f243677c5c
4 changed files with 23 additions and 4 deletions

View File

@@ -31,7 +31,7 @@ async function parseChatMessage(msg: EventSubChannelChatMessageEvent) {
if (!await isInvuln(user?.id!)) user?.setVulnerable(); // Make the user vulnerable to explosions if not marked as invuln
if (!await redis.exists(`user:${user?.id}:haschatted`)) {
if (!await redis.exists(`user:${user?.id}:haschatted`) && !msg.sourceMessageId) {
await sendMessage(`Welcome ${user?.displayName}. Please note: This chat has PvP, if you get timed out that's part of the qwerinope experience. You have 10 minutes of invincibility. A full list of commands and items can be found here: https://github.com/qwerinope/qweribot/#qweribot`);
await redis.set(`user:${user?.id}:haschatted`, "1");
if (!streamerUsers.includes(msg.chatterId)) await setTemporaryInvuln(user?.id!); // This would set the invuln expiration lmao

16
src/events/raid.ts Normal file
View File

@@ -0,0 +1,16 @@
import { redis } from "bun";
import { sendMessage } from "commands";
import { getUserRecord } from "db/dbUser";
import { changeItemCount } from "items";
import { eventSub, streamerApi, streamerId } from "main";
import User from "user";
eventSub.onChannelRaidTo(streamerId, async msg => {
await sendMessage(`Ty for raiding ${msg.raidingBroadcasterDisplayName}. You get 10 minutes of invulnerability and 3 pieces of TNT. Enjoy!`);
await streamerApi.chat.shoutoutUser(streamerId, msg.raidingBroadcasterId);
await redis.set(`user:${msg.raidingBroadcasterId}:invuln`, '1');
await redis.expire(`user:${msg.raidingBroadcasterId}:invuln`, 600);
const raider = await User.initUsername(msg.raidingBroadcasterName);
const result = await changeItemCount(raider!, await getUserRecord(raider!), 'tnt', 3);
if (!result) await sendMessage("oopsies, no tnt for you!");
});

View File

@@ -1,10 +1,13 @@
import { redis } from "bun";
import { sendMessage } from "commands";
import { eventSub, streamerId } from "main";
eventSub.onStreamOnline(streamerId, async _msg => {
eventSub.onStreamOnline(streamerId, async msg => {
await redis.set('streamIsLive', '1');
await sendMessage(`${msg.broadcasterDisplayName} IS LIVE! START DIGGING!`);
});
eventSub.onStreamOffline(streamerId, async _msg => {
eventSub.onStreamOffline(streamerId, async msg => {
await redis.del('streamIsLive');
await sendMessage(`${msg.broadcasterDisplayName} IS OFFLINE! NO MORE FREE LOOT!`);
});

View File

@@ -10,7 +10,7 @@ import User from "user";
import { buildTimeString } from "lib/dateManager";
const CHATTERINTENTS = ["user:read:chat", "user:write:chat", "user:bot"];
const STREAMERINTENTS = ["channel:bot", "user:read:chat", "moderation:read", "channel:manage:moderators", "moderator:manage:banned_users", "bits:read", "channel:moderate"];
const STREAMERINTENTS = ["channel:bot", "user:read:chat", "moderation:read", "channel:manage:moderators", "moderator:manage:banned_users", "bits:read", "channel:moderate", "moderator:manage:shoutouts"];
export const singleUserMode = process.env.CHATTER_IS_STREAMER === 'true';
export const chatterId = process.env.CHATTER_ID ?? "";