mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 20:30:58 -05:00
Remove clock speed if virtualized
Add dataSweeper cronjob Add Better Breakfast Day array Update @types/node
This commit is contained in:
parent
84c803671b
commit
d0d65c2986
18
.pnp.cjs
generated
18
.pnp.cjs
generated
@ -30,7 +30,7 @@ const RAW_RUNTIME_STATE =
|
|||||||
["@octokit/rest", "npm:20.0.2"],\
|
["@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"],\
|
["@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/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/node-cron", "npm:3.0.11"],\
|
||||||
["@types/pg", "npm:8.10.9"],\
|
["@types/pg", "npm:8.10.9"],\
|
||||||
["@types/sequelize", "npm:4.28.20"],\
|
["@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/",\
|
"packageLocation": "./.yarn/cache/@types-continuation-local-storage-npm-3.2.7-763e4dc12b-1f272b53bc.zip/node_modules/@types/continuation-local-storage/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@types/continuation-local-storage", "npm:3.2.7"],\
|
["@types/continuation-local-storage", "npm:3.2.7"],\
|
||||||
["@types/node", "npm:20.11.0"]\
|
["@types/node", "npm:20.11.3"]\
|
||||||
],\
|
],\
|
||||||
"linkType": "HARD"\
|
"linkType": "HARD"\
|
||||||
}]\
|
}]\
|
||||||
@ -637,10 +637,10 @@ const RAW_RUNTIME_STATE =
|
|||||||
}]\
|
}]\
|
||||||
]],\
|
]],\
|
||||||
["@types/node", [\
|
["@types/node", [\
|
||||||
["npm:20.11.0", {\
|
["npm:20.11.3", {\
|
||||||
"packageLocation": "./.yarn/cache/@types-node-npm-20.11.0-cb757f0c2a-8da60a8ccb.zip/node_modules/@types/node/",\
|
"packageLocation": "./.yarn/cache/@types-node-npm-20.11.3-78cf05078e-dff6433343.zip/node_modules/@types/node/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@types/node", "npm:20.11.0"],\
|
["@types/node", "npm:20.11.3"],\
|
||||||
["undici-types", "npm:5.26.5"]\
|
["undici-types", "npm:5.26.5"]\
|
||||||
],\
|
],\
|
||||||
"linkType": "HARD"\
|
"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/",\
|
"packageLocation": "./.yarn/cache/@types-pg-npm-8.10.9-ee8620c8e7-787be5431a.zip/node_modules/@types/pg/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@types/pg", "npm:8.10.9"],\
|
["@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-protocol", "npm:1.6.0"],\
|
||||||
["pg-types", "npm:4.0.1"]\
|
["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/",\
|
"packageLocation": "./.yarn/cache/@types-ws-npm-8.5.9-91d1b2ab07-7cf66383b8.zip/node_modules/@types/ws/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@types/ws", "npm:8.5.9"],\
|
["@types/ws", "npm:8.5.9"],\
|
||||||
["@types/node", "npm:20.11.0"]\
|
["@types/node", "npm:20.11.3"]\
|
||||||
],\
|
],\
|
||||||
"linkType": "HARD"\
|
"linkType": "HARD"\
|
||||||
}]\
|
}]\
|
||||||
@ -995,7 +995,7 @@ const RAW_RUNTIME_STATE =
|
|||||||
["@octokit/rest", "npm:20.0.2"],\
|
["@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"],\
|
["@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/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/node-cron", "npm:3.0.11"],\
|
||||||
["@types/pg", "npm:8.10.9"],\
|
["@types/pg", "npm:8.10.9"],\
|
||||||
["@types/sequelize", "npm:4.28.20"],\
|
["@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/",\
|
"packageLocation": "./.yarn/cache/wkx-npm-0.5.0-fca5152cd8-b8975e33f9.zip/node_modules/wkx/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["wkx", "npm:0.5.0"],\
|
["wkx", "npm:0.5.0"],\
|
||||||
["@types/node", "npm:20.11.0"]\
|
["@types/node", "npm:20.11.3"]\
|
||||||
],\
|
],\
|
||||||
"linkType": "HARD"\
|
"linkType": "HARD"\
|
||||||
}]\
|
}]\
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/ms": "0.7.34",
|
"@types/ms": "0.7.34",
|
||||||
"@types/node": "20.11.0",
|
"@types/node": "20.11.3",
|
||||||
"@types/node-cron": "3.0.11",
|
"@types/node-cron": "3.0.11",
|
||||||
"@types/pg": "8.10.9",
|
"@types/pg": "8.10.9",
|
||||||
"@types/sequelize": "4.28.20",
|
"@types/sequelize": "4.28.20",
|
||||||
|
@ -6,7 +6,7 @@ import GitHub from '../helpers/GitHub.js';
|
|||||||
import si from 'systeminformation';
|
import si from 'systeminformation';
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import ts from 'typescript';
|
import ts from 'typescript';
|
||||||
import {readFileSync} from 'node:fs';
|
import {readFileSync, existsSync} from 'node:fs';
|
||||||
export default class Statistics {
|
export default class Statistics {
|
||||||
static async run(client:TClient, interaction:Discord.ChatInputCommandInteraction<'cached'>) {
|
static async run(client:TClient, interaction:Discord.ChatInputCommandInteraction<'cached'>) {
|
||||||
const initialMsg = await interaction.reply({content: '<a:sakjdfsajkfhsdjhjfsa:1065342869428252743>', fetchReply:true});
|
const initialMsg = await interaction.reply({content: '<a:sakjdfsajkfhsdjhjfsa:1065342869428252743>', fetchReply:true});
|
||||||
@ -58,7 +58,7 @@ export default class Statistics {
|
|||||||
)},
|
)},
|
||||||
{name: '🔹 *Host*', value: MessageTool.concatMessage(
|
{name: '🔹 *Host*', value: MessageTool.concatMessage(
|
||||||
`>>> **OS:** ${systemInfo.osInfo.distro} ${systemInfo.osInfo.release}`,
|
`>>> **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**',
|
'**RAM**',
|
||||||
`╰ **Host:** ${this.progressBar(systemInfo.mem.used, systemInfo.mem.total)} (${Formatters.byteFormat(systemInfo.mem.used)}/${Formatters.byteFormat(systemInfo.mem.total)})`,
|
`╰ **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)})`,
|
`╰ **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));
|
const bar = '▓'.repeat(Math.round(percent*length)) + '░'.repeat(length-Math.round(percent*length));
|
||||||
return `${bar} ${Math.round(percent*100)}%`;
|
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()
|
static data = new Discord.SlashCommandBuilder()
|
||||||
.setName('statistics')
|
.setName('statistics')
|
||||||
.setDescription('List of commands used in current session and host statistics')
|
.setDescription('List of commands used in current session and host statistics')
|
||||||
|
@ -57,6 +57,8 @@ setInterval(async()=>{
|
|||||||
}
|
}
|
||||||
}, 5000)
|
}, 5000)
|
||||||
|
|
||||||
if (client.config.botSwitches.dailyMsgsBackup) client.userLevels.initSelfdestruct()
|
if (client.config.botSwitches.dailyMsgsBackup) {
|
||||||
// Initiate the nuke on userLevels and dailyMsgs tables
|
client.userLevels.initSelfdestruct();
|
||||||
// Also don't ask why it's outside the interval
|
client.userLevels.dataSweeper();
|
||||||
|
}
|
||||||
|
// Cronjob tasks
|
||||||
|
@ -81,6 +81,21 @@ export class UserLevelsSvc {
|
|||||||
}
|
}
|
||||||
} else await this.model.create({id: userId, messages: 1, level: 0, pingToggle: true});
|
} 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() {
|
async initSelfdestruct() {
|
||||||
// Every 1st of January at 11:00 (Midnight in London, Middayish in Sydney)
|
// Every 1st of January at 11:00 (Midnight in London, Middayish in Sydney)
|
||||||
cron.schedule('0 11 1 1 *', async()=>{
|
cron.schedule('0 11 1 1 *', async()=>{
|
||||||
|
@ -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)
|
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) {
|
protected static outgoingArrays(message:Discord.Message) {
|
||||||
|
const currDate = new Date();
|
||||||
const PersonnyMcPerson = `**${message.member.displayName}**`;
|
const PersonnyMcPerson = `**${message.member.displayName}**`;
|
||||||
// const responseCreator =(id:Discord.Snowflake)=>`\n╰*Response made by <@${id}>*`;
|
// const responseCreator =(id:Discord.Snowflake)=>`\n╰*Response made by <@${id}>*`;
|
||||||
return {
|
|
||||||
|
const respArrays = {
|
||||||
morning: [
|
morning: [
|
||||||
`Morning ${PersonnyMcPerson}, did you sleep great?`, `Good morning ${PersonnyMcPerson}!`, `Hope you enjoyed your breakfast, ${PersonnyMcPerson}!`,
|
`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}.`,
|
`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!`,
|
`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}.`
|
`# 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
yarn.lock
10
yarn.lock
@ -441,12 +441,12 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@types/node@npm:*, @types/node@npm:20.11.0":
|
"@types/node@npm:*, @types/node@npm:20.11.3":
|
||||||
version: 20.11.0
|
version: 20.11.3
|
||||||
resolution: "@types/node@npm:20.11.0"
|
resolution: "@types/node@npm:20.11.3"
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: "npm:~5.26.4"
|
undici-types: "npm:~5.26.4"
|
||||||
checksum: 8da60a8ccb65181c3d6f7686ddc5f1b1616cafa14d9e520a866adff82c17cc99336a78dd7ce7bee8f54e2332946f678b0e3aa377fbaaf751d3c05b64600872c6
|
checksum: dff64333435bbda87e200e24e2103f40692d0a01849db685ecb31db7c589f2556843a03dd351ddaee9981020263939c026557b36df49154efd910c610deefe78
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@ -748,7 +748,7 @@ __metadata:
|
|||||||
"@octokit/rest": "npm:20.0.2"
|
"@octokit/rest": "npm:20.0.2"
|
||||||
"@toast/tokenservice-client": "npm:1.0.6"
|
"@toast/tokenservice-client": "npm:1.0.6"
|
||||||
"@types/ms": "npm:0.7.34"
|
"@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/node-cron": "npm:3.0.11"
|
||||||
"@types/pg": "npm:8.10.9"
|
"@types/pg": "npm:8.10.9"
|
||||||
"@types/sequelize": "npm:4.28.20"
|
"@types/sequelize": "npm:4.28.20"
|
||||||
|
Loading…
Reference in New Issue
Block a user