mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
fixes, alerts/chatwidget websocket error handling, make chatterbot have the new bot badge
This commit is contained in:
@@ -42,9 +42,9 @@ for (const [name, item] of Array.from(items)) {
|
|||||||
export default commands;
|
export default commands;
|
||||||
export { basecommands };
|
export { basecommands };
|
||||||
|
|
||||||
import { singleUserMode, chatterApi, chatterId, streamerId } from "main";
|
import { chatterApi, chatterId, streamerId } from "main";
|
||||||
|
|
||||||
/** Helper function to send a message to the stream */
|
/** Helper function to send a message to the stream */
|
||||||
export const sendMessage = async (message: string, replyParentMessageId?: string) => {
|
export const sendMessage = async (message: string, replyParentMessageId?: string) => {
|
||||||
singleUserMode ? await chatterApi.chat.sendChatMessage(streamerId, message, { replyParentMessageId }) : chatterApi.asUser(chatterId, async newapi => newapi.chat.sendChatMessage(streamerId, message, { replyParentMessageId }));
|
await chatterApi.chat.sendChatMessageAsApp(chatterId, streamerId, message, { replyParentMessageId })
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export type cheerEventRecord = {
|
|||||||
|
|
||||||
export type cheerRecord = {
|
export type cheerRecord = {
|
||||||
id?: string;
|
id?: string;
|
||||||
user?: string;
|
user: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { addInvuln } from "lib/invuln";
|
|||||||
import { redis } from "bun";
|
import { redis } from "bun";
|
||||||
|
|
||||||
const CHATTERINTENTS = ["user:read:chat", "user:write:chat", "user:bot"];
|
const CHATTERINTENTS = ["user:read:chat", "user:write:chat", "user:bot"];
|
||||||
const STREAMERINTENTS = ["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"];
|
||||||
|
|
||||||
export const singleUserMode = process.env.CHATTER_IS_STREAMER === 'true';
|
export const singleUserMode = process.env.CHATTER_IS_STREAMER === 'true';
|
||||||
export const chatterId = process.env.CHATTER_ID ?? "";
|
export const chatterId = process.env.CHATTER_ID ?? "";
|
||||||
|
|||||||
@@ -28,18 +28,23 @@ export default Bun.serve({
|
|||||||
},
|
},
|
||||||
websocket: {
|
websocket: {
|
||||||
message(ws, omessage) {
|
message(ws, omessage) {
|
||||||
const message = JSON.parse(omessage.toString()) as serverInstruction;
|
try {
|
||||||
if (!message.type) return;
|
const message = JSON.parse(omessage.toString()) as serverInstruction;
|
||||||
switch (message.type) {
|
if (!message.type) return;
|
||||||
case 'subscribe':
|
switch (message.type) {
|
||||||
if (!message.target) return;
|
case 'subscribe':
|
||||||
const target = message.target.toLowerCase();
|
if (!message.target) return;
|
||||||
ws.subscribe(message.target);
|
const target = message.target.toLowerCase();
|
||||||
ws.send(JSON.stringify({
|
ws.subscribe(message.target);
|
||||||
function: 'serverNotification',
|
ws.send(JSON.stringify({
|
||||||
message: `Successfully subscribed to ${target} events`
|
function: 'serverNotification',
|
||||||
} as serverNotificationEvent)); // Both alerts and chatwidget eventsub subscriptions have the notification field
|
message: `Successfully subscribed to ${target} events`
|
||||||
break;
|
} as serverNotificationEvent)); // Both alerts and chatwidget eventsub subscriptions have the notification field
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
ws.send('Incorrect instruction. Closing websocket connection');
|
||||||
|
ws.close();
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
close(ws) {
|
close(ws) {
|
||||||
|
|||||||
Reference in New Issue
Block a user