1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-29 08:20:59 -04:00

Remove clock speed if virtualized

Add dataSweeper cronjob

Add Better Breakfast Day array

Update @types/node
This commit is contained in:
toast-ts 2024-01-16 17:26:26 +11:00
parent 127dd8ad05
commit f6fec518cf
7 changed files with 74 additions and 21 deletions

18
.pnp.cjs generated
View File

@ -30,7 +30,7 @@ const RAW_RUNTIME_STATE =
["@octokit/rest", "npm:20.0.2"],\
["@toast/tokenservice-client", "npm:1.0.6::__archiveUrl=https%3A%2F%2Fgit.toast-server.net%2Fapi%2Fpackages%2Ftoast%2Fnpm%2F%2540toast%252Ftokenservice-client%2F-%2F1.0.6%2Ftokenservice-client-1.0.6.tgz"],\
["@types/ms", "npm:0.7.34"],\
["@types/node", "npm:20.11.0"],\
["@types/node", "npm:20.11.3"],\
["@types/node-cron", "npm:3.0.11"],\
["@types/pg", "npm:8.10.9"],\
["@types/sequelize", "npm:4.28.20"],\
@ -603,7 +603,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/@types-continuation-local-storage-npm-3.2.7-763e4dc12b-1f272b53bc.zip/node_modules/@types/continuation-local-storage/",\
"packageDependencies": [\
["@types/continuation-local-storage", "npm:3.2.7"],\
["@types/node", "npm:20.11.0"]\
["@types/node", "npm:20.11.3"]\
],\
"linkType": "HARD"\
}]\
@ -637,10 +637,10 @@ const RAW_RUNTIME_STATE =
}]\
]],\
["@types/node", [\
["npm:20.11.0", {\
"packageLocation": "./.yarn/cache/@types-node-npm-20.11.0-cb757f0c2a-8da60a8ccb.zip/node_modules/@types/node/",\
["npm:20.11.3", {\
"packageLocation": "./.yarn/cache/@types-node-npm-20.11.3-78cf05078e-dff6433343.zip/node_modules/@types/node/",\
"packageDependencies": [\
["@types/node", "npm:20.11.0"],\
["@types/node", "npm:20.11.3"],\
["undici-types", "npm:5.26.5"]\
],\
"linkType": "HARD"\
@ -660,7 +660,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/@types-pg-npm-8.10.9-ee8620c8e7-787be5431a.zip/node_modules/@types/pg/",\
"packageDependencies": [\
["@types/pg", "npm:8.10.9"],\
["@types/node", "npm:20.11.0"],\
["@types/node", "npm:20.11.3"],\
["pg-protocol", "npm:1.6.0"],\
["pg-types", "npm:4.0.1"]\
],\
@ -694,7 +694,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/@types-ws-npm-8.5.9-91d1b2ab07-7cf66383b8.zip/node_modules/@types/ws/",\
"packageDependencies": [\
["@types/ws", "npm:8.5.9"],\
["@types/node", "npm:20.11.0"]\
["@types/node", "npm:20.11.3"]\
],\
"linkType": "HARD"\
}]\
@ -995,7 +995,7 @@ const RAW_RUNTIME_STATE =
["@octokit/rest", "npm:20.0.2"],\
["@toast/tokenservice-client", "npm:1.0.6::__archiveUrl=https%3A%2F%2Fgit.toast-server.net%2Fapi%2Fpackages%2Ftoast%2Fnpm%2F%2540toast%252Ftokenservice-client%2F-%2F1.0.6%2Ftokenservice-client-1.0.6.tgz"],\
["@types/ms", "npm:0.7.34"],\
["@types/node", "npm:20.11.0"],\
["@types/node", "npm:20.11.3"],\
["@types/node-cron", "npm:3.0.11"],\
["@types/pg", "npm:8.10.9"],\
["@types/sequelize", "npm:4.28.20"],\
@ -2733,7 +2733,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/wkx-npm-0.5.0-fca5152cd8-b8975e33f9.zip/node_modules/wkx/",\
"packageDependencies": [\
["wkx", "npm:0.5.0"],\
["@types/node", "npm:20.11.0"]\
["@types/node", "npm:20.11.3"]\
],\
"linkType": "HARD"\
}]\

View File

@ -52,7 +52,7 @@
},
"devDependencies": {
"@types/ms": "0.7.34",
"@types/node": "20.11.0",
"@types/node": "20.11.3",
"@types/node-cron": "3.0.11",
"@types/pg": "8.10.9",
"@types/sequelize": "4.28.20",

View File

@ -6,7 +6,7 @@ import GitHub from '../helpers/GitHub.js';
import si from 'systeminformation';
import os from 'node:os';
import ts from 'typescript';
import {readFileSync} from 'node:fs';
import {readFileSync, existsSync} from 'node:fs';
export default class Statistics {
static async run(client:TClient, interaction:Discord.ChatInputCommandInteraction<'cached'>) {
const initialMsg = await interaction.reply({content: '<a:sakjdfsajkfhsdjhjfsa:1065342869428252743>', fetchReply:true});
@ -58,7 +58,7 @@ export default class Statistics {
)},
{name: '🔹 *Host*', value: MessageTool.concatMessage(
`>>> **OS:** ${systemInfo.osInfo.distro} ${systemInfo.osInfo.release}`,
`**CPU:** ${systemInfo.cpu.manufacturer} ${systemInfo.cpu.brand} ${systemInfo.cpu.speed} GHz`,
`**CPU:** ${systemInfo.cpu.manufacturer} ${systemInfo.cpu.brand} ${this.isHostVirtualized() ? '' : `${systemInfo.cpu.speed} GHz`}`,
'**RAM**',
`╰ **Host:** ${this.progressBar(systemInfo.mem.used, systemInfo.mem.total)} (${Formatters.byteFormat(systemInfo.mem.used)}/${Formatters.byteFormat(systemInfo.mem.total)})`,
`╰ **Bot:** ${this.progressBar(process.memoryUsage().heapUsed, process.memoryUsage().heapTotal)} (${Formatters.byteFormat(process.memoryUsage().heapUsed)}/${Formatters.byteFormat(process.memoryUsage().heapTotal)})`,
@ -78,6 +78,10 @@ export default class Statistics {
const bar = '▓'.repeat(Math.round(percent*length)) + '░'.repeat(length-Math.round(percent*length));
return `${bar} ${Math.round(percent*100)}%`;
}
private static isHostVirtualized():boolean {
if (existsSync('/sys/firmware/qemu_fw_cfg') ?? existsSync('/sys/module/qemu_fw_cfg')) return true
return false;
}
static data = new Discord.SlashCommandBuilder()
.setName('statistics')
.setDescription('List of commands used in current session and host statistics')

View File

@ -57,6 +57,8 @@ setInterval(async()=>{
}
}, 5000)
if (client.config.botSwitches.dailyMsgsBackup) client.userLevels.initSelfdestruct()
// Initiate the nuke on userLevels and dailyMsgs tables
// Also don't ask why it's outside the interval
if (client.config.botSwitches.dailyMsgsBackup) {
client.userLevels.initSelfdestruct();
client.userLevels.dataSweeper();
}
// Cronjob tasks

View File

@ -81,6 +81,21 @@ export class UserLevelsSvc {
}
} else await this.model.create({id: userId, messages: 1, level: 0, pingToggle: true});
}
async dataSweeper() {
// Every Monday at 12:00 (Sydney Time)
cron.schedule('0 12 * * 1', async()=>{
Logger.console('log', 'Cron', 'Running job "dataSweeper", this is activated every Monday at 12:00');
const fetchDiscordMembers = await this.client.guilds.cache.get(this.client.config.dcServer.id).members.fetch();
const fetchUsers = await this.model.findAll();
for (const user of fetchUsers) {
if (!fetchDiscordMembers.has(user.dataValues.id)) {
await this.deleteUser(user.dataValues.id);
Logger.console('log', 'Cron:dataSweeper', `Removing ${user.dataValues.id}`);
}
}
Logger.console('log', 'Cron:dataSweeper', 'Job completed');
})
}
async initSelfdestruct() {
// Every 1st of January at 11:00 (Midnight in London, Middayish in Sydney)
cron.schedule('0 11 1 1 *', async()=>{

View File

@ -32,9 +32,11 @@ export default class Response {
if (new RegExp(`^(${this.incomingArrays[responseKeyword].prefix.join('|')})?\\s?${responseKeyword} (${this.incomingArrays[responseKeyword].suffix.join('|')})\\b`, 'i').test(message.content)) return message.reply(`${this.outgoingArrays(message)[responseKeyword][Math.floor(Math.random()*this.outgoingArrays(message)[responseKeyword].length)]}`).catch(()=>null)
}
protected static outgoingArrays(message:Discord.Message) {
const currDate = new Date();
const PersonnyMcPerson = `**${message.member.displayName}**`;
// const responseCreator =(id:Discord.Snowflake)=>`\n╰*Response made by <@${id}>*`;
return {
const respArrays = {
morning: [
`Morning ${PersonnyMcPerson}, did you sleep great?`, `Good morning ${PersonnyMcPerson}!`, `Hope you enjoyed your breakfast, ${PersonnyMcPerson}!`,
`Gm ${PersonnyMcPerson}.`, `Uh.. What time is it? Oh yea, morning ${PersonnyMcPerson}.`, `Morning and hope you had a good dream last night, ${PersonnyMcPerson}.`,
@ -65,6 +67,36 @@ export default class Response {
`Sleep well ${PersonnyMcPerson}.`, `Gn ${PersonnyMcPerson}.`, `Close your eyelids and sleep, ${PersonnyMcPerson}.`, `Good night ${PersonnyMcPerson} and hope your pillow is nice and cold!`,
`# Night ${PersonnyMcPerson}!`, `You should try maintaining your sleep schedule if you're really that tired, ${PersonnyMcPerson}.`
]
};
// Better Breakfast Day (Sept. 26)
if (currDate.getUTCMonth() === 8 && currDate.getUTCDate() === 26) {
return {
morning: [
`Hello ${PersonnyMcPerson}, have you tried avocado toast for breakfast?`,
`Hey and good morning ${PersonnyMcPerson}!\nDid you know that breakfast is the most important meal of the day?`,
`Morning ${PersonnyMcPerson}, having a balanced breakfast can help you feel more energized throughout the day.`,
`Good morning ${PersonnyMcPerson}, how about some eggs benedict for breakfast today?`,
`Morning ${PersonnyMcPerson}!\nDid you know that a high protein breakfast can help control your hunger throughout the day?`,
'Have you tried a breakfast burrito? They\'re delicious and filling.',
`Morning ${PersonnyMcPerson}, remember that fruits are a great addition to your breakfast.`,
`Hello ${PersonnyMcPerson}!\nStart your morning with some French toast for a treat. They're easy to make and tastes delicious!`,
'A breakfast sandwich or toast is a quick and easy option for busy mornings.',
`Good morning ${PersonnyMcPerson}, don't forget to add some veggies to your breakfast for extra nutrients.`,
`Morning ${PersonnyMcPerson}, have you tried a breakfast casserole? They're a great make-ahead option.`,
'Cereal is the quickest option to start your busy day with!',
`Gooood morning ${PersonnyMcPerson}! How about some pancakes for breakfast today?`,
`Morning ${PersonnyMcPerson}, don't forget to have some milk with your breakfast.`
],
afternoon: respArrays.afternoon,
evening: respArrays.evening,
night: respArrays.night
}
} else return {
morning: respArrays.morning,
afternoon: respArrays.afternoon,
evening: respArrays.evening,
night: respArrays.night
}
}
}

View File

@ -441,12 +441,12 @@ __metadata:
languageName: node
linkType: hard
"@types/node@npm:*, @types/node@npm:20.11.0":
version: 20.11.0
resolution: "@types/node@npm:20.11.0"
"@types/node@npm:*, @types/node@npm:20.11.3":
version: 20.11.3
resolution: "@types/node@npm:20.11.3"
dependencies:
undici-types: "npm:~5.26.4"
checksum: 8da60a8ccb65181c3d6f7686ddc5f1b1616cafa14d9e520a866adff82c17cc99336a78dd7ce7bee8f54e2332946f678b0e3aa377fbaaf751d3c05b64600872c6
checksum: dff64333435bbda87e200e24e2103f40692d0a01849db685ecb31db7c589f2556843a03dd351ddaee9981020263939c026557b36df49154efd910c610deefe78
languageName: node
linkType: hard
@ -748,7 +748,7 @@ __metadata:
"@octokit/rest": "npm:20.0.2"
"@toast/tokenservice-client": "npm:1.0.6"
"@types/ms": "npm:0.7.34"
"@types/node": "npm:20.11.0"
"@types/node": "npm:20.11.3"
"@types/node-cron": "npm:3.0.11"
"@types/pg": "npm:8.10.9"
"@types/sequelize": "npm:4.28.20"