Merge branch 'dev'

This commit is contained in:
Hri7566 2024-10-25 21:28:28 -04:00
commit b05f7ec8b8
4 changed files with 406 additions and 322 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,8 @@
"start": "bun .", "start": "bun .",
"start-bot": "bun src/mpp/index.ts", "start-bot": "bun src/mpp/index.ts",
"start-discord": "bun src/discord/index.ts", "start-discord": "bun src/discord/index.ts",
"build-talko": "bunx tsc --build tsconfig.talko.json" "build-talko": "bun scripts/build-talko.ts",
"dev-talko": "bun run build-talko && node build/index.js"
}, },
"devDependencies": { "devDependencies": {
"@types/bun": "^1.1.11", "@types/bun": "^1.1.11",

View File

@ -128,10 +128,13 @@ export const appRouter = router({
}) })
) )
.query(async opts => { .query(async opts => {
if (typeof opts.input.color !== "string") return { success: false };
const { id, json } = await kvSet(`usercolor~${opts.input.userId}`, { const { id, json } = await kvSet(`usercolor~${opts.input.userId}`, {
color: opts.input.color color: opts.input.color
}); });
logger.debug(json);
return { return {
success: true, success: true,
id, id,
@ -148,6 +151,7 @@ export const appRouter = router({
.query(async opts => { .query(async opts => {
const color = await kvGet(`usercolor~${opts.input.userId}`); const color = await kvGet(`usercolor~${opts.input.userId}`);
if (typeof color === "object") return { color: color.color };
return { return {
color color
}; };

View File

@ -38,10 +38,13 @@ export class TalkomaticBot extends EventEmitter {
this.logger = new Logger("Talkomatic - " + config.channel.name); this.logger = new Logger("Talkomatic - " + config.channel.name);
this.client = io("https://talkomatic.co/", { this.client = io("https://talkomatic.co/", {
extraHeaders: { // extraHeaders: {
Cookie: "connect.sid=" + process.env.TALKOMATIC_SID // Cookie: "connect.sid=" + process.env.TALKOMATIC_SID
}, // },
autoConnect: false autoConnect: false,
auth: {
apiKey: process.env.TALKOMATIC_API_KEY
}
}); });
this.bindEventListeners(); this.bindEventListeners();
@ -87,11 +90,15 @@ export class TalkomaticBot extends EventEmitter {
this.client.on( this.client.on(
"userTyping", "userTyping",
(msg: { userId: string; text: string; color: string }) => { (msg: {
userId: string;
text: string;
color: { color: string };
}) => {
const p = ppl[msg.userId] || { const p = ppl[msg.userId] || {
name: "<unknown user>", name: "<unknown user>",
id: msg.userId, id: msg.userId,
color: msg.color, color: msg.color.color,
typingFlag: false typingFlag: false
}; };
@ -112,7 +119,7 @@ export class TalkomaticBot extends EventEmitter {
); );
this.client.on( this.client.on(
"udpateRoom", "updateRoom",
async (msg: { async (msg: {
users: { users: {
id: string; id: string;
@ -143,6 +150,8 @@ export class TalkomaticBot extends EventEmitter {
typingFlag: false typingFlag: false
}; };
if (color) p.color = color;
ppl[user.id] = p; ppl[user.id] = p;
} }
} catch (err) { } catch (err) {
@ -194,7 +203,11 @@ export class TalkomaticBot extends EventEmitter {
this.on( this.on(
"command", "command",
async (msg: { userId: string; text: string; color: string }) => { async (msg: {
userId: string;
text: string;
color: { color: string };
}) => {
let prefixes: string[]; let prefixes: string[];
try { try {
@ -209,7 +222,7 @@ export class TalkomaticBot extends EventEmitter {
msg.text.startsWith(pr) msg.text.startsWith(pr)
); );
let color = ( let color: string = (
await this.trpc.getUserColor.query({ await this.trpc.getUserColor.query({
userId: msg.userId userId: msg.userId
}) })
@ -323,7 +336,8 @@ export class TalkomaticBot extends EventEmitter {
const msg = { const msg = {
roomId: this.channelId, roomId: this.channelId,
// text: text.split("sack").join("ʂасκ"), // text: text.split("sack").join("ʂасκ"),
text: text.split("sack").join("caught"), // text: text.split("sack").join("caught"),
text,
color: id ? ppl[id].color : this.defaultColor color: id ? ppl[id].color : this.defaultColor
}; };
@ -344,6 +358,7 @@ export class TalkomaticBot extends EventEmitter {
this.logger.warn("Unable to parse markdown:", err); this.logger.warn("Unable to parse markdown:", err);
} }
this.logger.debug("Sending typing:", msg);
this.client.emit("typing", msg); this.client.emit("typing", msg);
this.oldText = text; this.oldText = text;