This commit is contained in:
kmmiio99o 2025-09-28 23:45:17 +02:00
parent a690f7446c
commit 0f9c60858b
3 changed files with 178 additions and 179 deletions

View file

@ -2,32 +2,33 @@ name: Build and deploy
on:
push:
branches: [main]
branches: [main, master]
permissions:
contents: read
pages: write
id-token: write
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Prepare environment
uses: actions/setup-node@v3
uses: actions/setup-node@v2
with:
node-version: "22"
node-version: 22
- run: npm install --global pnpm
- name: Install deps
run: npm install
run: pnpm m i
- name: Build plugin(s)
run: npm run build
run: node ./build.mjs
# Foolproof feature:
# - Copies over README so that the root of the deployed website shows it
# - Changes 404 page to README so that you don't get lost while clicking links
# If you remove this step then you should probably remove the enable_jekyll option in the next one
- name: Copy additional files
run: |
cp README.md dist/README.md
@ -35,13 +36,9 @@ jobs:
printf -- "> **Note:** You accessed a link that returned a 404, probably by clicking one of the plugin links. You're supposed to copy the link address and add it into Vendetta.\n\n" >> dist/404.md
cat README.md >> dist/404.md
# Documentation: https://github.com/peaceiris/actions-gh-pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
# Makes it so the md files in the previous step get processed by GitHub Pages
enable_jekyll: true
# This creates the CNAME file required to host GitHub Pages on a custom domain
# cname: example.com

View file

@ -40,6 +40,7 @@ if (!storage.enabledCommands) {
konoself: true,
konosend: true,
firstmessage: true,
sysinfo: true,
};
}
@ -190,6 +191,16 @@ export default function Settings() {
/>
</TableRowGroup>
{/* System Commands */}
<TableRowGroup title="System Commands">
<TableSwitchRow
label="/sysinfo"
subLabel="Display system information"
value={storage.enabledCommands?.sysinfo ?? true}
onValueChange={(v) => handleCommandToggle("sysinfo", v)}
/>
</TableRowGroup>
{/* Credits */}
<TableRowGroup title="Credits">
<TableRow label="Facts Commands" subLabel="by jdev082" />
@ -200,6 +211,7 @@ export default function Settings() {
subLabel="by btmc727 & Rico040"
/>
<TableRow label="FirstMessage Command" subLabel="by sapphire" />
<TableRow label="Sysinfo Command" subLabel="by kmmiio99o" />
</TableRowGroup>
{/* About */}

View file

@ -1,120 +1,191 @@
import { findByProps } from "@vendetta/metro";
import { getDebugInfo } from "@vendetta/debug";
import { ReactNative } from "@vendetta/metro/common";
import { NativeModules } from "@vendetta/metro/common/ReactNative";
import { storage } from "@vendetta/plugin";
const MessageActions = findByProps("sendMessage");
const messageUtil = findByProps("sendBotMessage", "sendMessage", "receiveMessage");
// Hardware info function
const hwinfo = () => {
const { cpuCoreCount, cpuPercentage, memory } = findByProps("memory");
const cpuPerc = cpuPercentage.toFixed(2) + "%";
const memUsage = parseFloat((memory / 1000).toPrecision(3)) + " MB";
const { type, details } = Object.values(
findByProps("useNetInfo").fetch(),
).filter((i) => i?.type)[0];
let netInfo = "";
const networkMap = {
wifi: "WiFi",
ethernet: "Ethernet",
other: "Unknown",
bluetooth: "Bluetooth",
wimax: "WiMAX",
vpn: "VPN",
cellular: details.cellularGeneration?.toUpperCase() || "Cellular",
};
netInfo = networkMap[type] ?? type;
return { cpuCoreCount, cpuPerc, memUsage, netInfo };
};
// Device info function
const deviceInfo = () => {
// Device info helper
function getDeviceInfo() {
let { height, width, scale } = ReactNative.Dimensions.get("screen");
height *= scale;
width *= scale;
return {
width,
height,
};
};
return { width, height };
}
// Discord info function
const discordinfo = () => {
return (
NativeModules.InfoDictionaryManager ?? NativeModules.RTNClientInfoManager
);
};
// Generate debug info
const genDebug = () => {
// Hardware info helper
function getHardwareInfo() {
try {
const { cpuCoreCount, cpuPerc, memUsage, netInfo } = hwinfo();
const hwProps = findByProps("memory");
if (!hwProps) return { cpuCoreCount: "N/A", cpuPerc: "N/A", memUsage: "N/A", netInfo: "N/A" };
const { cpuCoreCount, cpuPercentage, memory } = hwProps;
const cpuPerc = cpuPercentage ? cpuPercentage.toFixed(2) + "%" : "N/A";
const memUsage = memory ? parseFloat((memory / 1000).toPrecision(3)) + " MB" : "N/A";
let netInfo = "N/A";
try {
const netInfoModule = findByProps("useNetInfo");
if (netInfoModule) {
const networkData = Object.values(netInfoModule.fetch()).filter((i: any) => i?.type)[0] as any;
if (networkData) {
const { type, details } = networkData;
const networkMap: Record<string, string> = {
wifi: "WiFi",
ethernet: "Ethernet",
other: "Unknown",
bluetooth: "Bluetooth",
wimax: "WiMAX",
vpn: "VPN",
cellular: details?.cellularGeneration?.toUpperCase() || "Cellular",
};
netInfo = networkMap[type] ?? type;
}
}
} catch (e) {
console.warn("Network info unavailable:", e);
}
return { cpuCoreCount, cpuPerc, memUsage, netInfo };
} catch (e) {
console.warn("Hardware info unavailable:", e);
return { cpuCoreCount: "N/A", cpuPerc: "N/A", memUsage: "N/A", netInfo: "N/A" };
}
}
const { ReleaseChannel: discordBranch } = discordinfo();
// Discord info helper
function getDiscordInfo() {
try {
const { NativeModules } = ReactNative;
const discordInfo = NativeModules.InfoDictionaryManager ?? NativeModules.RTNClientInfoManager;
return discordInfo || {};
} catch (e) {
console.warn("Discord info unavailable:", e);
return {};
}
}
// Generate system info
function generateSystemInfo() {
try {
const { cpuCoreCount, cpuPerc, memUsage, netInfo } = getHardwareInfo();
const discordInfo = getDiscordInfo();
const { vendetta, discord, react, hermes, os, device } = getDebugInfo();
const { version: HermesRelease, bytecodeVersion: HermesBytecode } = hermes;
const { version: ReactVersion, nativeVersion: RNVersion } = react;
const { name: osName, version: osVersion, sdk: osSdk } = os;
const { version: HermesRelease, bytecodeVersion: HermesBytecode } = hermes || {};
const { version: ReactVersion, nativeVersion: RNVersion } = react || {};
const { name: osName, version: osVersion, sdk: osSdk } = os || {};
const {
manufacturer: deviceManufacturer,
brand: deviceBrand,
model: deviceModel,
codename: deviceCodename,
} = device;
const { version: vendettaVersion } = vendetta;
const { version: discordVersion, build: discordBuild } = discord;
} = device || {};
const { version: vendettaVersion } = vendetta || {};
const { version: discordVersion, build: discordBuild } = discord || {};
const { ReleaseChannel: discordBranch } = discordInfo;
const deviceName =
osName == "iOS" ? deviceCodename : `${deviceBrand} ${deviceModel}`;
const { width, height } = deviceInfo();
const deviceName = osName == "iOS" ? deviceCodename : `${deviceBrand} ${deviceModel}`;
const { width, height } = getDeviceInfo();
let output = {
Device: {
Device: deviceName,
Model: deviceModel,
Manufacturer: deviceManufacturer,
Brand: deviceBrand,
Display: width + "x" + height,
Device: deviceName || "Unknown",
Model: deviceModel || "Unknown",
Manufacturer: deviceManufacturer || "Unknown",
Brand: deviceBrand || "Unknown",
Display: `${width}x${height}`,
},
Hardware: {
"CPU Cores": cpuCoreCount,
"CPU Cores": cpuCoreCount || "N/A",
Network: netInfo,
},
Software: {
OS: osName,
Version: osVersion,
OS: osName || "Unknown",
Version: osVersion || "Unknown",
},
Discord: {
Branch: discordBranch,
Version: discordVersion,
Build: discordBuild,
Vendetta: vendettaVersion,
Branch: discordBranch || "Unknown",
Version: discordVersion || "Unknown",
Build: discordBuild || "Unknown",
Vendetta: vendettaVersion || "Unknown",
"CPU Usage": cpuPerc,
"Memory Usage": memUsage,
},
React: {
Version: ReactVersion,
"Hermes Bytecode": HermesBytecode,
Hermes: HermesRelease,
Native: RNVersion,
Version: ReactVersion || "Unknown",
"Hermes Bytecode": HermesBytecode || "Unknown",
Hermes: HermesRelease || "Unknown",
Native: RNVersion || "Unknown",
},
};
if (window.enmity) {
output.Discord.Enmity = window.enmity.version;
// Add additional mod versions if available
if ((window as any).enmity) {
output.Discord.Enmity = (window as any).enmity.version;
}
if (window.aliucord) {
output.Discord.Aliucord = window.aliucord.version;
if ((window as any).aliucord) {
output.Discord.Aliucord = (window as any).aliucord.version;
}
if (osSdk) {
output.Software["SDK Version"] = osSdk;
}
return output;
} catch (e) {
console.error(e);
console.error("Error generating system info:", e);
throw e;
}
};
}
// Initialize storage defaults
const categories = ["device", "hardware", "software", "discord", "react", "ephemeral"];
for (const cat of categories) {
if (storage[cat] === undefined) storage[cat] = true;
}
// Command execution function
function sysinfoCommand(args: any[], ctx: any) {
try {
let output = ["__System Information__\n"];
const data = generateSystemInfo();
Object.keys(data).forEach((option) => {
const permit = storage[option.toLowerCase()];
const slasharg = args.find((i) => i.name == option.toLowerCase());
const slashval = slasharg?.value ?? permit;
if ((slashval || permit) && !(permit && !slashval)) {
output.push(`[**${option}**]`);
Object.keys(data[option as keyof typeof data]).forEach((subOption) => {
output.push(`> ${subOption}: ${(data[option as keyof typeof data] as any)[subOption]}`);
});
}
});
const epermit = storage["ephemeral"];
const ephemeral = args.find((i) => i.name == "ephemeral")?.value ?? epermit;
if ((ephemeral || epermit) && !(epermit && !ephemeral)) {
messageUtil.sendBotMessage(ctx.channel.id, output.join("\n"));
return { type: 4 };
} else {
const fixNonce = Date.now().toString();
MessageActions.sendMessage(
ctx.channel.id,
{ content: output.join("\n") },
void 0,
{ nonce: fixNonce }
);
return { type: 4 };
}
} catch (e) {
console.error("[Sysinfo] Error:", e);
messageUtil.sendBotMessage(ctx.channel.id, "Failed to generate system information. Please try again.");
return { type: 4 };
}
}
export const sysinfoCommand = {
name: "sysinfo",
@ -127,100 +198,19 @@ export const sysinfoCommand = {
displayName: "ephemeral",
description: "Keep sysinfo ephemeral (default: true)",
displayDescription: "Keep sysinfo ephemeral (default: true)",
type: 5, // BOOLEAN type
type: 5,
required: false,
},
{
name: "device",
displayName: "device",
description: "Display the device section",
displayDescription: "Display the device section",
type: 5, // BOOLEAN type
...categories.slice(0, -1).map((cat) => ({
name: cat,
displayName: cat,
description: `Display the ${cat} section. Set default in settings.`,
displayDescription: `Display the ${cat} section. Set default in settings.`,
type: 5,
required: false,
},
{
name: "hardware",
displayName: "hardware",
description: "Display the hardware section",
displayDescription: "Display the hardware section",
type: 5, // BOOLEAN type
required: false,
},
{
name: "software",
displayName: "software",
description: "Display the software section",
displayDescription: "Display the software section",
type: 5, // BOOLEAN type
required: false,
},
{
name: "discord",
displayName: "discord",
description: "Display the discord section",
displayDescription: "Display the discord section",
type: 5, // BOOLEAN type
required: false,
},
{
name: "react",
displayName: "react",
description: "Display the react section",
displayDescription: "Display the react section",
type: 5, // BOOLEAN type
required: false,
},
})),
],
execute: async (args: any, ctx: any) => {
try {
const options = new Map(args.map((option: any) => [option.name, option]));
// Default settings - show all sections by default
const defaultSettings = {
device: true,
hardware: true,
software: true,
discord: true,
react: true,
ephemeral: true,
};
let output = ["__System Information__\n"];
const data = genDebug();
Object.keys(data).forEach((section) => {
const sectionKey = section.toLowerCase();
const argValue = options.get(sectionKey)?.value;
const shouldShow = argValue !== undefined ? argValue : defaultSettings[sectionKey];
if (shouldShow) {
output.push(`[**${section}**]`);
Object.keys(data[section]).forEach((subOption) => {
output.push(`> ${subOption}: ${data[section][subOption]}`);
});
}
});
const ephemeralArg = options.get("ephemeral")?.value;
const isEphemeral = ephemeralArg !== undefined ? ephemeralArg : defaultSettings.ephemeral;
if (isEphemeral) {
messageUtil.sendBotMessage(ctx.channel.id, output.join("\n"));
return { type: 4 };
} else {
return {
type: 4,
data: {
content: output.join("\n")
}
};
}
} catch (error) {
console.error("[Sysinfo] Error:", error);
messageUtil.sendBotMessage(ctx.channel.id, "Failed to generate system information. Please try again.");
return { type: 4 };
}
},
execute: sysinfoCommand,
applicationId: "-1",
inputType: 1,
type: 1,