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-bot": "bun src/mpp/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": {
"@types/bun": "^1.1.11",

View File

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

View File

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