Compare commits
29 Commits
04f882b890
...
f39dab4f40
Author | SHA1 | Date |
---|---|---|
Lexi Sother | f39dab4f40 | |
Keanu Timmermans | 2161ca7851 | |
Ducko | db3fda3dd6 | |
Ducko | d075c67250 | |
Ducko | 36f2c81c89 | |
Ducko | aca4547d96 | |
Ducko | 0ba227267a | |
Ducko | b658064804 | |
Ducko | 5b1f81ae60 | |
Ducko | d94d7bfc42 | |
Ducko | ac3778e574 | |
Ducko | 7e8d5c4533 | |
Ducko | 5f5b84588b | |
Ducko | 9ae7e3260f | |
Ducko | 3f46914b3f | |
Ducko | 958c1129b7 | |
Ducko | 87b84d23e5 | |
Keanu Timmermans | 31dea36c77 | |
Ducko | 2c48e7fd6f | |
Ducko | c58dbac469 | |
Ducko | 86a2e3b7cb | |
Ducko | d95f20db3f | |
Ducko | a597534581 | |
Ducko | c4dcbb69ce | |
Ducko | bec46ebb8f | |
Ducko | fe3e55f022 | |
Ducko | 39ca4f77ec | |
Ducko | 7b2d2def8a | |
Lexi Sother | 8afaa882bd |
|
@ -0,0 +1,64 @@
|
|||
// Also set Powercord global var stuff here since entities import is needed to use Plugin (which every PC plugin uses)
|
||||
|
||||
const sendMessage = goosemodScope.webpackModules.findByProps('sendMessage', 'receiveMessage').sendMessage;
|
||||
const getChannelId = goosemod.webpackModules.findByProps('getChannelId').getChannelId;
|
||||
|
||||
export const powercord = {
|
||||
api: {
|
||||
commands: {
|
||||
registerCommand: ({ command, alias, description, usage, executor }) => {
|
||||
// TODO: implement alias
|
||||
|
||||
goosemodScope.patcher.commands.add(command, description,
|
||||
async ( { args: [ { text } ] } ) => {
|
||||
const out = await executor(text.split(' ')); // Run original executor func (await incase it's an async function)
|
||||
|
||||
console.log(out);
|
||||
|
||||
if (!out.send) {
|
||||
goosemodScope.patcher.internalMessage(out.result); // PC impl. sends internal message when out.send === false, so we also do the same via our previous Patcher API function
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// When send is true, we send it as a message via sendMessage
|
||||
|
||||
sendMessage(getChannelId(), {
|
||||
content: out.result,
|
||||
|
||||
tts: false,
|
||||
invalidEmojis: [],
|
||||
validNonShortcutEmojis: []
|
||||
});
|
||||
}, [
|
||||
{ type: 3, required: false, name: 'args', description: 'Arguments for PC command' } // Argument for any string for compat. with PC's classical commands
|
||||
]);
|
||||
},
|
||||
|
||||
unregisterCommand: (command) => {
|
||||
goosemodScope.patcher.commands.remove(command);
|
||||
}
|
||||
},
|
||||
|
||||
notices: {
|
||||
sendToast: (_id, { header, content, type, buttons }) => {
|
||||
// TODO: implement full toast in future instead of just small current GM toast
|
||||
|
||||
goosemodScope.showToast(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export class Plugin {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
get goosemodHandlers() {
|
||||
return {
|
||||
onImport: this.startPlugin.bind(this),
|
||||
onRemove: this.pluginWillUnload.bind(this)
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
module.exports = goosemodScope.patcher; // GM's Patcher main functions (inject, uninject) have very similar syntax to PC's Injector as it was initially based on PC's design (however was later changed to use patch func)
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
...goosemodScope.reactUtils // Export GooseMod React utils
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
const makeFinalFilter = (filter) => {
|
||||
if (Array.isArray(filter)) {
|
||||
const subs = filter;
|
||||
filter = (mod) => subs.every((s) => mod[s] || (mod.__proto__ && mod.__proto__[s]));
|
||||
}
|
||||
|
||||
return filter;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getModule: (filter, retry, _forever) => { // Ignoring retry and forever arguments for basic implementation
|
||||
filter = makeFinalFilter(filter);
|
||||
|
||||
const result = goosemodScope.webpackModules.find(filter);
|
||||
|
||||
if (!retry) { // retry = false: sync, retry = true: async (returns Promise)
|
||||
return result;
|
||||
}
|
||||
|
||||
return new Promise((res) => res(result));
|
||||
},
|
||||
|
||||
getAllModules: (filter) => {
|
||||
filter = makeFinalFilter(filter);
|
||||
|
||||
return goosemodScope.webpackModules.findAll(filter);
|
||||
},
|
||||
|
||||
getModuleByDisplayName: (displayName) => {
|
||||
return goosemodScope.webpackModules.findByDisplayName(displayName);
|
||||
},
|
||||
|
||||
...goosemodScope.webpackModules.common // Export common modules (eg: React)
|
||||
};
|
16
package.json
16
package.json
|
@ -22,12 +22,16 @@
|
|||
"parcel-bundler": "^1.12.4"
|
||||
},
|
||||
"alias": {
|
||||
"@goosemod/patcher": "./moduleWrappers/patcher.js",
|
||||
"@goosemod/webpack": "./moduleWrappers/webpack.js",
|
||||
"@goosemod/logger": "./moduleWrappers/logger.js",
|
||||
"@goosemod/reactUtils": "./moduleWrappers/reactUtils.js",
|
||||
"@goosemod/toast": "./moduleWrappers/toast.js",
|
||||
"@goosemod/settings": "./moduleWrappers/settings.js"
|
||||
"@goosemod/patcher": "./moduleWrappers/goosemod/patcher.js",
|
||||
"@goosemod/webpack": "./moduleWrappers/goosemod/webpack.js",
|
||||
"@goosemod/logger": "./moduleWrappers/goosemod/logger.js",
|
||||
"@goosemod/reactUtils": "./moduleWrappers/goosemod/reactUtils.js",
|
||||
"@goosemod/toast": "./moduleWrappers/goosemod/toast.js",
|
||||
"@goosemod/settings": "./moduleWrappers/goosemod/settings.js",
|
||||
"powercord/entities": "./moduleWrappers/powercord/entities.js",
|
||||
"powercord/injector": "./moduleWrappers/powercord/injector.js",
|
||||
"powercord/webpack": "./moduleWrappers/powercord/webpack.js",
|
||||
"powercord/util": "./moduleWrappers/powercord/util.js"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import nova from './nova.js';
|
||||
|
||||
import pcPlugins from './ports/plugins/pcPlugins.js';
|
||||
|
||||
export default [
|
||||
{
|
||||
meta: {
|
||||
|
@ -9,4 +11,12 @@ export default [
|
|||
filename: 'nova',
|
||||
modules: nova,
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
name: 'Nova - PC Plugins',
|
||||
description: 'Powercord plugins ported by NovaGM.',
|
||||
},
|
||||
filename: 'pcplugins',
|
||||
modules: pcPlugins,
|
||||
},
|
||||
];
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
export default [
|
||||
['RazerMoon/muteNewGuild', 'a8ea528e67089ea00a457623cebbef6a670127fc', '/manifest.json', 'pcPlugin', {
|
||||
authors: ['162970149857656832'],
|
||||
}],
|
||||
['keanuplayz/PC-Clap', 'master', '/manifest.json', 'pcPlugin', {
|
||||
authors: ['717352467280691331'],
|
||||
}],
|
||||
];
|
|
@ -0,0 +1,26 @@
|
|||
import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs';
|
||||
|
||||
export default (manifestPath, repo) => {
|
||||
const pcManifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
||||
|
||||
let manifest = {
|
||||
main: '../index.js',
|
||||
tags: ['port'],
|
||||
|
||||
name: pcManifest.name,
|
||||
description: pcManifest.description,
|
||||
|
||||
version: pcManifest.version,
|
||||
authors: [ pcManifest.author ]
|
||||
};
|
||||
|
||||
rmSync(manifestPath);
|
||||
mkdirSync(manifestPath);
|
||||
|
||||
const content = readFileSync(pcManifest.main || 'index.js', 'utf8');//.replace(/\\/g, '\\\\').replace(/`/g, '\\`');
|
||||
|
||||
const jsCode = content.replace(`module.exports = class`, `export default new class`).replace(/{ *Plugin *}/, `{ Plugin, powercord }`);
|
||||
|
||||
writeFileSync(`${manifestPath}/goosemodModule.json`, JSON.stringify(manifest));
|
||||
writeFileSync(`${manifestPath}/../index.js`, jsCode);
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"github": {
|
||||
"silent": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue