fixed that @ sign breaks data from redis, minor rephrasing, tnt cheer now plays alert

This commit is contained in:
2025-09-08 20:30:15 +02:00
parent 8b9239bedf
commit ba2a520369
5 changed files with 14 additions and 9 deletions

2
.gitignore vendored
View File

@@ -17,6 +17,8 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# dotenv environment variable files
.env
.env.production
.env.development
.env.development.local
.env.test.local
.env.production.local

View File

@@ -2,6 +2,8 @@
## Concepts
#### Note: Cheering functionality is working but as I don't have affiliate you can't cheer. You can safely ignore all mentions of cheering.
### Admins
Admins are defined by the streamer and can use special administrative commands on the bot.

View File

@@ -25,13 +25,13 @@ export default new Cheer('tnt', 1000, async (msg, user) => {
sendMessage(`wybuh ${target?.displayName} got hit by ${user.displayName}'s TNT wybuh`),
createTimeoutRecord(user, target!, ITEMNAME),
createCheerEventRecord(user, ITEMNAME),
playAlert({
name: 'tntExplosion',
user: user.displayName,
targets
})
]);
}));
await playAlert({
name: 'tntExplosion',
user: user.displayName,
targets
})
await sendMessage(`RIPBOZO ${user.displayName} exploded ${targets.length} chatter${targets.length === 1 ? '' : 's'} with their TNT RIPBOZO`);
});

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`)) {
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 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
};

View File

@@ -20,10 +20,11 @@ export default class User {
public id!: string;
public displayName!: string;
static async initUsername(username: string): Promise<User | null> {
static async initUsername(dirtyUsername: string): Promise<User | null> {
try {
const userObj = new User();
userObj.username = username.replaceAll(/[@]/g, '');
const username = dirtyUsername.replaceAll(/@/gi, '');
userObj.username = username;
const userid = await redis.get(`userlookup:${username}`);
if (!userid) {
const userdata = await chatterApi.users.getUserByName(username);
@@ -39,7 +40,7 @@ export default class User {
};
return userObj;
} catch {
logger.err(`Failed to initialize user with name: ${username}`);
logger.err(`Failed to initialize user with name: ${dirtyUsername}`);
return null;
};
};