-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
aetheryx
committed
Dec 7, 2018
1 parent
b16e9ea
commit 9c64db3
Showing
58 changed files
with
223 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"globals": { | ||
"aethcord": true, | ||
"powercord": true, | ||
"webpackJsonp": true | ||
}, | ||
"parserOptions": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
.idea | ||
node_modules | ||
|
||
src/Aethcord/plugins/stylemanager/styles/* | ||
!src/Aethcord/plugins/stylemanager/styles/ac-*.css | ||
!src/Aethcord/plugins/stylemanager/styles/ac-*.scss | ||
src/Powercord/plugins/stylemanager/styles/* | ||
!src/Powercord/plugins/stylemanager/styles/ac-*.css | ||
!src/Powercord/plugins/stylemanager/styles/ac-*.scss | ||
|
||
config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/Aethcord/plugins/StateWatcher.js → src/Powercord/plugins/StateWatcher.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
const { waitFor, getOwnerInstance } = require('powercord/util'); | ||
const { sleep } = require('powercord/util'); | ||
|
||
module.exports = async function injectAutocomplete () { | ||
const _this = this; | ||
|
||
const plugins = [ ...powercord.plugins.keys() ]; | ||
while (!plugins.every(plugin => | ||
powercord.plugins.get(plugin).ready | ||
)) { | ||
await sleep(1); | ||
} | ||
|
||
const customCommands = [ ...this.commands.values() ] | ||
.map(command => ({ | ||
command: command.name, | ||
description: command.description | ||
})); | ||
|
||
const inject = (inst) => | ||
inst.props.autocompleteOptions.POWERCORD_CUSTOM_COMMANDS = { | ||
getText: (index, { commands }) => this.prefix + commands[index].command, | ||
matches: (_, content) => content && content[0] === this.prefix, | ||
queryResults: (content) => ({ | ||
commands: customCommands.filter(c => c.command.startsWith(content)) | ||
}), | ||
renderResults: (...args) => { | ||
const renderedResults = inst.props.autocompleteOptions.COMMAND.renderResults(...args); | ||
if (!renderedResults) { | ||
return; | ||
} | ||
|
||
let [ header, commands ] = renderedResults; | ||
|
||
header.type = class PatchedHeaderType extends header.type { | ||
renderContent (...args) { | ||
const rendered = super.renderContent(...args); | ||
|
||
if ( | ||
Array.isArray(rendered.props.children) && | ||
rendered.props.children[1] | ||
) { | ||
const commandPreviewChildren = rendered.props.children[1].props.children; | ||
if (commandPreviewChildren[0].startsWith('/')) { | ||
commandPreviewChildren[0] = commandPreviewChildren[0].replace('/', _this.prefix); | ||
} | ||
} | ||
|
||
return rendered; | ||
} | ||
}; | ||
|
||
for (const command of commands) { | ||
command.type = class PatchedCommandType extends command.type { | ||
renderContent (...args) { | ||
const rendered = super.renderContent(...args); | ||
|
||
const children = rendered.props.children; | ||
if (children[0].props.name === 'Slash') { | ||
rendered.props.children.shift(); | ||
} | ||
|
||
const commandName = children[0].props; | ||
if (!commandName.children.startsWith(_this.prefix)) { | ||
commandName.children = _this.prefix + commandName.children; | ||
} | ||
|
||
return rendered; | ||
} | ||
} | ||
} | ||
|
||
return [ header, commands ]; | ||
} | ||
}; | ||
|
||
await waitFor('.channelTextArea-rNsIhG'); | ||
|
||
const getInstance = () => getOwnerInstance(document.querySelector('.channelTextArea-rNsIhG')); | ||
const instance = getInstance(); | ||
const instancePrototype = Object.getPrototypeOf(instance); | ||
|
||
instancePrototype.componentDidMount = (_componentDidMount => function (...args) { | ||
inject(getInstance()); | ||
return _componentDidMount.call(this, ...args);; | ||
})(instancePrototype.componentDidMount); | ||
|
||
inject(instance); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const webpack = require('powercord/webpack'); | ||
const { | ||
messages: { createBotMessage, receiveMessage }, | ||
channels: { getChannelId } | ||
} = webpack; | ||
|
||
const messages = webpack.getModule(webpack.moduleFilters.messages[0]); | ||
|
||
module.exports = async function monkeypatchMessages () { | ||
messages.sendMessage = (sendMessage => async (id, message, ...params) => { | ||
if (!message.content.startsWith(this.prefix)) { | ||
return sendMessage(id, message, ...params); | ||
} | ||
|
||
const [ command, ...args ] = message.content.slice(1).split(' '); | ||
if (!this.commands.has(command)) { | ||
return sendMessage(id, message, ...params); | ||
} | ||
|
||
const result = await this.commands.get(command).func(args, this); | ||
if (!result) { | ||
return; | ||
} | ||
|
||
if (result.send) { | ||
message.content = result.result; | ||
} else { | ||
const receivedMessage = createBotMessage(getChannelId(), ''); | ||
|
||
if (typeof result.result === 'string') { | ||
receivedMessage.content = result.result; | ||
} else { | ||
receivedMessage.embeds.push(result.result); | ||
} | ||
|
||
return receiveMessage(receivedMessage.channel_id, receivedMessage); | ||
} | ||
|
||
return sendMessage(id, message, ...params); | ||
})(this.oldSendMessage = messages.sendMessage); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Aethcord/plugins/libraries/index.js → src/Powercord/plugins/libraries/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.