From 7489c4f52d6474d497b47d77eebe5de8e3478cc3 Mon Sep 17 00:00:00 2001 From: qwerinope Date: Wed, 23 Jul 2025 02:53:45 +0100 Subject: [PATCH] remove ping command, add backshot command, add nice font to chatwidget, add first time chatting warning --- README.md | 2 +- bun.lock | 3 +++ package.json | 1 + src/commands/backshot.ts | 10 ++++++++++ src/commands/ping.ts | 6 ------ src/events/message.ts | 8 +++++++- src/lib/invuln.ts | 4 ++++ src/web/chatWidget/www/src/main.ts | 1 + src/web/chatWidget/www/src/style.css | 9 ++++----- 9 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 src/commands/backshot.ts delete mode 100644 src/commands/ping.ts diff --git a/README.md b/README.md index 01fa9ff..e33a4d4 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,9 @@ The streamerbot (not that streamerbot) is the broadcaster. This bot needs them t COMMAND|FUNCTION|USER|ALIASES|DISABLEABLE -|-|-|-|- -`ping`|Testing command|anyone|`ping`|:white_check_mark: `yabai`|Random number|anyone|`yabai` `goon`|:white_check_mark: `seiso`|Random number|anyone|`seiso`|:white_check_mark: +`backshot`|'Backshot' a random previous chatter|anyone|`backshot`|:white_check_mark: `roulette`|Play russian roulette for a 5 minute timeout|anyone|`roulette`|:white_check_mark: `timeout {target}`|Times targeted user out for 60 seconds (costs 100 qweribucks)|anyone|`timeout`|:white_check_mark: diff --git a/bun.lock b/bun.lock index 8035f59..8a404d6 100644 --- a/bun.lock +++ b/bun.lock @@ -4,6 +4,7 @@ "": { "name": "qweribot", "dependencies": { + "@fontsource/jersey-15": "^5.2.6", "@twurple/auth": "^7.3.0", "@twurple/eventsub-ws": "^7.3.0", "kleur": "^4.1.5", @@ -38,6 +39,8 @@ "@d-fischer/typed-event-emitter": ["@d-fischer/typed-event-emitter@3.3.3", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-OvSEOa8icfdWDqcRtjSEZtgJTFOFNgTjje7zaL0+nAtu2/kZtRCSK5wUMrI/aXtCH8o0Qz2vA8UqkhWUTARFQQ=="], + "@fontsource/jersey-15": ["@fontsource/jersey-15@5.2.6", "", {}, "sha512-3zkkEnu91esusWLqAK/AN1uc6jNtWT8idfO0UfYLqNlbMBKkbbiIVXtq6UbQsyegxnmRMppVV1J2t1zrJ36VgA=="], + "@twurple/api": ["@twurple/api@7.3.0", "", { "dependencies": { "@d-fischer/cache-decorators": "^4.0.0", "@d-fischer/cross-fetch": "^5.0.1", "@d-fischer/detect-node": "^3.0.1", "@d-fischer/logger": "^4.2.1", "@d-fischer/rate-limiter": "^1.1.0", "@d-fischer/shared-utils": "^3.6.1", "@d-fischer/typed-event-emitter": "^3.3.1", "@twurple/api-call": "7.3.0", "@twurple/common": "7.3.0", "retry": "^0.13.1", "tslib": "^2.0.3" }, "peerDependencies": { "@twurple/auth": "7.3.0" } }, "sha512-QtaVgYi50E3AB/Nxivjou/u6w1cuQ6g4R8lzQawYDaQNtlP2Ue8vvYuSp2PfxSpe8vNiKhgV8hZAs+j4V29sxQ=="], "@twurple/api-call": ["@twurple/api-call@7.3.0", "", { "dependencies": { "@d-fischer/cross-fetch": "^5.0.1", "@d-fischer/qs": "^7.0.2", "@d-fischer/shared-utils": "^3.6.1", "@twurple/common": "7.3.0", "tslib": "^2.0.3" } }, "sha512-nx389kXjVphAeR3RfnzkRRf7Qa45wqHla067/mr3YxnUICCg4YOFv0Jb5UohQGHkj5h18mDZ3iUu/x2J49c1lA=="], diff --git a/package.json b/package.json index 222da61..2feb889 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "private": true, "type": "module", "dependencies": { + "@fontsource/jersey-15": "^5.2.6", "@twurple/auth": "^7.3.0", "@twurple/eventsub-ws": "^7.3.0", "kleur": "^4.1.5", diff --git a/src/commands/backshot.ts b/src/commands/backshot.ts new file mode 100644 index 0000000..0ef37ff --- /dev/null +++ b/src/commands/backshot.ts @@ -0,0 +1,10 @@ +import { Command, sendMessage } from "."; +import { User } from "../user"; +import { redis } from "bun"; + +export default new Command('backshot', ['backshot'], 'chatter', async (msg, user) => { + const targets = await redis.keys(`user:*:haschatted`); + const selection = targets[Math.floor(Math.random() * targets.length)]!; + const target = await User.initUserId(selection.slice(5, -11)); + await sendMessage(`${user.displayName} backshotted ${target?.displayName}`, msg.messageId); +}); diff --git a/src/commands/ping.ts b/src/commands/ping.ts deleted file mode 100644 index ded8838..0000000 --- a/src/commands/ping.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Command, sendMessage } from "."; - -// This command is purely for testing -export default new Command('ping', ['ping'], 'chatter', async msg => { - await sendMessage('pong!', msg.messageId); -}); diff --git a/src/events/message.ts b/src/events/message.ts index 94e826b..819b53a 100644 --- a/src/events/message.ts +++ b/src/events/message.ts @@ -7,7 +7,7 @@ import { isAdmin } from "../lib/admins"; import cheers from "../cheers"; import logger from "../lib/logger"; import { addMessageToChatWidget } from "../web/chatWidget/message"; -import { isInvuln } from "../lib/invuln"; +import { isInvuln, setTemporaryInvuln } from "../lib/invuln"; logger.info(`Loaded the following commands: ${commands.keys().toArray().join(', ')}`); @@ -28,6 +28,12 @@ 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`)) { + 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, cheer events 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 + }; + if (!msg.isCheer && !msg.isRedemption) await handleChatMessage(msg, user!) else if (msg.isCheer && !msg.isRedemption) await handleCheer(msg, msg.bits, user!); }; diff --git a/src/lib/invuln.ts b/src/lib/invuln.ts index 8fc4f4e..439c73e 100644 --- a/src/lib/invuln.ts +++ b/src/lib/invuln.ts @@ -14,3 +14,7 @@ export async function addInvuln(userid: string) { export async function removeInvuln(userid: string) { return await redis.del(`user:${userid}:invulnerable`); }; +export async function setTemporaryInvuln(userid: string) { + await redis.set(`user:${userid}:invulnerable`, '1'); + await redis.expire(`user:${userid}:invulnerable`, 600); +}; diff --git a/src/web/chatWidget/www/src/main.ts b/src/web/chatWidget/www/src/main.ts index 10b2ec8..48f8569 100644 --- a/src/web/chatWidget/www/src/main.ts +++ b/src/web/chatWidget/www/src/main.ts @@ -1,4 +1,5 @@ import './style.css'; +import '@fontsource/jersey-15'; import { type twitchEventData } from "../../websockettypes"; import { parseMessage } from './createMessage'; diff --git a/src/web/chatWidget/www/src/style.css b/src/web/chatWidget/www/src/style.css index 161b8b9..6b187a5 100644 --- a/src/web/chatWidget/www/src/style.css +++ b/src/web/chatWidget/www/src/style.css @@ -1,7 +1,8 @@ :root { - font-family: system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; + font-family: 'Jersey 15', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + line-height: 1; font-weight: 400; + font-size: 5vmin; color-scheme: light dark; color: rgba(255, 255, 255, 0.87); @@ -22,8 +23,6 @@ body { #app { max-width: 1280px; - margin: 0 auto; - padding: 2rem; } .message { @@ -43,7 +42,7 @@ body { img { vertical-align: middle; - height: 18px; + height: 5vmin; padding: 1px; }