From 9092dfcae95dbfe4a4a40ab58ec3df96cca22348 Mon Sep 17 00:00:00 2001 From: Matthew Ray Date: Fri, 22 May 2020 22:19:38 -0400 Subject: [PATCH] send msgs to terminals on certain actions --- src/commands/lock.ts | 1 + src/commands/notify.ts | 1 + src/commands/tier.ts | 1 + src/commands/warn.ts | 1 + src/intervals/memory.ts | 2 ++ 5 files changed, 6 insertions(+) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index 17e3740..d3df486 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -20,6 +20,7 @@ export default class Lock extends Command { if (account.locked) return message.channel.createMessage(`***${this.client.stores.emojis.error} This account is already locked.***`); const edit = await message.channel.createMessage(`***${this.client.stores.emojis.loading} Locking account...***`); if (account.username === 'matthew' || account.root) return edit.edit(`***${this.client.stores.emojis.error} Permission denied.***`); + await this.client.util.sendMessageToUserTerminal(account.username, 'ACCOUNT LOCKED BY TECHNICIAN | PREPARING TO LOGOUT').catch(() => { }); await this.client.util.exec(`lock ${account.username}`); await account.updateOne({ locked: true }); diff --git a/src/commands/notify.ts b/src/commands/notify.ts index fcb57df..2a365e3 100644 --- a/src/commands/notify.ts +++ b/src/commands/notify.ts @@ -42,6 +42,7 @@ export default class Notify extends Command { `, }); message.delete(); + await this.client.util.sendMessageToUserTerminal(account.username, `NOTIFICATION FROM TECHNICIAN: ${args.slice(1).join(' ')}`).catch(() => { }); return edit.edit(`***${this.client.stores.emojis.success} Send notification to ${account.username}.***`); } catch (error) { return this.client.util.handleError(error, message, this); diff --git a/src/commands/tier.ts b/src/commands/tier.ts index ec625cf..41376ae 100644 --- a/src/commands/tier.ts +++ b/src/commands/tier.ts @@ -37,6 +37,7 @@ export default class Tier extends Command { embed.addField('Old Tier -> New Tier', `${account.tier} -> ${args[1]}`, true); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); + await this.client.util.sendMessageToUserTerminal(account.username, `A technician has upgraded your tier to ${args[1]}`).catch(() => { }); this.client.createMessage('580950455581147146', { embed }); return this.client.getDMChannel(account.userID).then((channel) => channel.createMessage({ embed })).catch(); } catch (error) { return this.client.util.handleError(error, message, this); diff --git a/src/commands/warn.ts b/src/commands/warn.ts index 1c42332..3e2c9b4 100644 --- a/src/commands/warn.ts +++ b/src/commands/warn.ts @@ -22,6 +22,7 @@ export default class Warn extends Command { await this.client.util.createModerationLog(account.userID, message.member, 1, args.slice(1).join(' ')); message.delete(); edit.edit(`***${this.client.stores.emojis.success} Account ${account.username} has been warned by Technician ${message.author.username}#${message.author.discriminator}.***`); + await this.client.util.sendMessageToUserTerminal(account.username, `WARNING FROM TECHNICIAN: ${args.slice(1).join(' ')}`).catch(() => { }); return this.client.util.transport.sendMail({ to: account.emailAddress, from: 'Library of Code sp-us | Cloud Services ', diff --git a/src/intervals/memory.ts b/src/intervals/memory.ts index 307d0fe..eea94ed 100644 --- a/src/intervals/memory.ts +++ b/src/intervals/memory.ts @@ -31,6 +31,7 @@ export default function memory(client: Client) { */ if ((memoryConversion >= userLimits.hard) && set.has(acc.username)) { client.signale.info(`RAM Hard Limit Reached | ${acc.username} | ${memoryConversion}/${userLimits.hard} MB`); + await client.util.sendMessageToUserTerminal(acc.username, 'REACHED RAM LIMIT; SENDING KILL SIGNAL'); client.util.exec(`killall -9 -u ${acc.username}`); const embed = new RichEmbed(); embed.setTitle('Resource Enforcement Notification'); @@ -83,6 +84,7 @@ export default function memory(client: Client) { client.getDMChannel(acc.userID).then((channel) => { channel.createMessage({ embed: notifyEmbed }); }); + await client.util.sendMessageToUserTerminal(acc.username, `You are about to reach your RAM resource limits, you are currently using '${String(Math.round(memoryConversion))} MB' and your limit is '${String(userLimits.hard)} MB'. Please correct your usage to avoid further action.`).catch(() => { }); client.util.transport.sendMail({ to: acc.emailAddress, from: 'Library of Code sp-us | Cloud Services ',