Skip to content

Commit 89f1ec4

Browse files
committed
Initial commit
0 parents  commit 89f1ec4

File tree

22 files changed

+893
-0
lines changed

22 files changed

+893
-0
lines changed

.github/workflows/build.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build
2+
3+
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency
4+
concurrency:
5+
group: "build"
6+
cancel-in-progress: true
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
paths-ignore:
13+
- '*.md'
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-20.04
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@master
21+
with:
22+
path: "src"
23+
24+
- name: Checkout builds
25+
uses: actions/checkout@master
26+
with:
27+
ref: "builds"
28+
path: "builds"
29+
30+
- name: Checkout Aliucord
31+
uses: actions/checkout@master
32+
with:
33+
repository: "Aliucord/Aliucord"
34+
path: "repo"
35+
36+
- name: Setup JDK 11
37+
uses: actions/setup-java@v1
38+
with:
39+
java-version: 11
40+
41+
- name: Setup Android SDK
42+
uses: android-actions/setup-android@v2
43+
44+
- name: Build Plugins
45+
run: |
46+
cd $GITHUB_WORKSPACE/src
47+
chmod +x gradlew
48+
./gradlew make generateUpdaterJson
49+
cp **/build/*.zip $GITHUB_WORKSPACE/builds
50+
cp build/updater.json $GITHUB_WORKSPACE/builds
51+
52+
- name: Push builds
53+
run: |
54+
cd $GITHUB_WORKSPACE/builds
55+
git config --local user.email "[email protected]"
56+
git config --local user.name "GitHub Actions"
57+
git add .
58+
git commit -m "Build $GITHUB_SHA" || exit 0 # do not error if nothing to commit
59+
git push

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea
5+
.DS_Store
6+
/build
7+
**/build
8+
/captures
9+
.externalNativeBuild
10+
.cxx
11+
local.properties
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version = "1.0.0" // Plugin version. Increment this to trigger the updater
2+
description = "My first commands!" // Plugin description that will be shown to user
3+
4+
aliucord {
5+
// Changelog of your plugin
6+
changelog.set("""
7+
Some changelog
8+
""".trimIndent())
9+
// Image or Gif that will be shown at the top of your changelog page
10+
// changelogMedia.set("https://cool.png")
11+
12+
// Add additional authors to this plugin
13+
// author("Name", 0)
14+
// author("Name", 0)
15+
16+
// Excludes this plugin from the updater, meaning it won't show up for users.
17+
// Set this if the plugin is unfinished
18+
excludeFromUpdaterJson.set(true)
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="youImportedTheWrongR" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.github.yournamehere;
2+
3+
import android.content.Context;
4+
import com.aliucord.Utils;
5+
import com.aliucord.annotations.AliucordPlugin;
6+
import com.aliucord.api.CommandsAPI;
7+
import com.aliucord.entities.Plugin;
8+
import com.discord.api.commands.ApplicationCommandType;
9+
10+
import java.util.Arrays;
11+
12+
// Aliucord Plugin annotation. Must be present on the main class of your plugin
13+
@AliucordPlugin(requiresRestart = false /* Whether your plugin requires a restart after being installed/updated */)
14+
// Plugin class. Must extend Plugin and override start and stop
15+
// Learn more: https://github.com/Aliucord/documentation/blob/main/plugin-dev/1_introduction.md#basic-plugin-structure
16+
public class MyFirstCommand extends Plugin {
17+
@Override
18+
public void start(Context context) {
19+
// Register a command with the name hello and description "My first command!" and no arguments.
20+
// Learn more: https://github.com/Aliucord/documentation/blob/main/plugin-dev/2_commands.md
21+
commands.registerCommand("hello", "My first command!", ctx -> {
22+
// Just return a command result with hello world as the content
23+
return new CommandsAPI.CommandResult(
24+
"Hello World!",
25+
null, // List of embeds
26+
false // Whether to send visible for everyone
27+
);
28+
});
29+
30+
// A bit more advanced command with arguments
31+
commands.registerCommand(
32+
"hellowitharguments",
33+
"Hello World but with arguments!",
34+
Arrays.asList(
35+
Utils.createCommandOption(ApplicationCommandType.STRING, "name", "Person to say hello to"),
36+
Utils.createCommandOption(ApplicationCommandType.USER, "user", "User to say hello to")
37+
),
38+
ctx -> {
39+
// Check if a user argument was passed
40+
if (ctx.containsArg("user")) {
41+
var user = ctx.getRequiredUser("user");
42+
return new CommandsAPI.CommandResult("Hello " + user.getUsername() + "!");
43+
} else {
44+
// Returns either the argument value if present, or the defaultValue ("World" in this case)
45+
var name = ctx.getStringOrDefault("name", "World");
46+
return new CommandsAPI.CommandResult("Hello " + name + "!");
47+
}
48+
}
49+
);
50+
}
51+
52+
@Override
53+
public void stop(Context context) {
54+
// Unregister all commands
55+
commands.unregisterAll();
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version = "1.0.0" // Plugin version. Increment this to trigger the updater
2+
description = "My first patch!" // Plugin description that will be shown to user
3+
4+
aliucord {
5+
// Changelog of your plugin
6+
changelog.set("""
7+
Some changelog
8+
""".trimIndent())
9+
// Image or Gif that will be shown at the top of your changelog page
10+
// changelogMedia.set("https://cool.png")
11+
12+
// Add additional authors to this plugin
13+
// author("Name", 0)
14+
// author("Name", 0)
15+
16+
// Excludes this plugin from the updater, meaning it won't show up for users.
17+
// Set this if the plugin is unfinished
18+
excludeFromUpdaterJson.set(true)
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="youImportedTheWrongR" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.github.yournamehere;
2+
3+
import android.content.Context;
4+
import com.aliucord.CollectionUtils;
5+
import com.aliucord.annotations.AliucordPlugin;
6+
import com.aliucord.entities.MessageEmbedBuilder;
7+
import com.aliucord.entities.Plugin;
8+
import com.aliucord.patcher.*;
9+
import com.aliucord.wrappers.embeds.MessageEmbedWrapper;
10+
import com.discord.models.user.CoreUser;
11+
import com.discord.stores.StoreUserTyping;
12+
import com.discord.widgets.chat.list.adapter.WidgetChatListAdapterItemMessage;
13+
import com.discord.widgets.chat.list.entries.ChatListEntry;
14+
import com.discord.widgets.chat.list.entries.MessageEntry;
15+
16+
// Aliucord Plugin annotation. Must be present on the main class of your plugin
17+
@AliucordPlugin(requiresRestart = false /* Whether your plugin requires a restart after being installed/updated */)
18+
// Plugin class. Must extend Plugin and override start and stop
19+
// Learn more: https://github.com/Aliucord/documentation/blob/main/plugin-dev/1_introduction.md#basic-plugin-structure
20+
public class MyFirstPatch extends Plugin {
21+
@Override
22+
public void start(Context context) throws Throwable {
23+
// Patch that adds an embed with message statistics to each message
24+
// Patched method is WidgetChatListAdapterItemMessage.onConfigure(int type, ChatListEntry entry)
25+
patcher.patch(
26+
// see https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
27+
WidgetChatListAdapterItemMessage.class.getDeclaredMethod("onConfigure", int.class, ChatListEntry.class),
28+
new Hook(param -> { // see https://api.xposed.info/reference/de/robv/android/xposed/XC_MethodHook.MethodHookParam.html
29+
// Obtain the second argument passed to the method, so the ChatListEntry
30+
// Because this is a Message item, it will always be a MessageEntry, so cast it to that
31+
var entry = (MessageEntry) param.args[1];
32+
33+
// You need to be careful when messing with messages, because they may be loading
34+
// (user sent a message, and it is currently sending)
35+
if (entry.getMessage().isLoading()) return;
36+
37+
// Now add an embed with the statistics
38+
39+
// This method may be called multiple times per message, e.g. if it is edited,
40+
// so first remove existing embeds
41+
CollectionUtils.removeIf(entry.getMessage().getEmbeds(), e -> {
42+
// MessageEmbed is an obfuscated class. However, Aliucord provides wrappers for commonly used
43+
// obfuscated classes, the MessageEmbedWrapper in this case.
44+
return "Message Statistics".equals(MessageEmbedWrapper.getTitle(e));
45+
});
46+
47+
// Creating embeds is a pain, so Aliucord provides a convenient builder
48+
var embed = new MessageEmbedBuilder().
49+
setTitle("Message Statistics")
50+
.addField("Length", entry.getMessage().getContent() != null ? Integer.toString(entry.getMessage().getContent().length()) : "0", false)
51+
.addField("ID", Long.toString(entry.getMessage().getId()), false).build();
52+
53+
entry.getMessage().getEmbeds().add(embed);
54+
})
55+
);
56+
57+
// Patch that renames Juby to JoobJoob
58+
patcher.patch(
59+
CoreUser.class.getDeclaredMethod("getUsername"),
60+
new PreHook(param -> { // see https://api.xposed.info/reference/de/robv/android/xposed/XC_MethodHook.MethodHookParam.html
61+
if (((CoreUser) param.thisObject).getId() == 925141667688878090L) {
62+
// setResult() in before patches skips original method invocation
63+
param.setResult("JoobJoob");
64+
}
65+
})
66+
);
67+
68+
// Patch that hides your typing status by replacing the method and simply doing nothing
69+
patcher.patch(
70+
StoreUserTyping.class.getDeclaredMethod("setUserTyping", long.class),
71+
InsteadHook.DO_NOTHING
72+
);
73+
}
74+
75+
@Override
76+
public void stop(Context context) {
77+
// Remove all patches
78+
patcher.unpatchAll();
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version = "1.0.0" // Plugin version. Increment this to trigger the updater
2+
description = "My first commands!" // Plugin description that will be shown to user
3+
4+
aliucord {
5+
// Changelog of your plugin
6+
changelog.set("""
7+
Some changelog
8+
""".trimIndent())
9+
// Image or Gif that will be shown at the top of your changelog page
10+
// changelogMedia.set("https://cool.png")
11+
12+
// Add additional authors to this plugin
13+
// author("Name", 0)
14+
// author("Name", 0)
15+
16+
// Excludes this plugin from the updater, meaning it won't show up for users.
17+
// Set this if the plugin is unfinished
18+
excludeFromUpdaterJson.set(true)
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="youImportedTheWrongR" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.github.yournamehere
2+
3+
import android.content.Context
4+
import com.aliucord.Utils
5+
import com.aliucord.annotations.AliucordPlugin
6+
import com.aliucord.api.CommandsAPI
7+
import com.aliucord.entities.Plugin
8+
import com.discord.api.commands.ApplicationCommandType
9+
10+
// Aliucord Plugin annotation. Must be present on the main class of your plugin
11+
@AliucordPlugin(requiresRestart = false /* Whether your plugin requires a restart after being installed/updated */)
12+
// Plugin class. Must extend Plugin and override start and stop
13+
// Learn more: https://github.com/Aliucord/documentation/blob/main/plugin-dev/1_introduction.md#basic-plugin-structure
14+
class MyFirstCommand : Plugin() {
15+
override fun start(context: Context) {
16+
// Register a command with the name hello and description "My first command!" and no arguments.
17+
// Learn more: https://github.com/Aliucord/documentation/blob/main/plugin-dev/2_commands.md
18+
commands.registerCommand("hello", "My first command!") {
19+
// Just return a command result with hello world as the content
20+
CommandsAPI.CommandResult(
21+
"Hello World!",
22+
null, // List of embeds
23+
false // Whether to send visible for everyone
24+
)
25+
}
26+
27+
// A bit more advanced command with arguments
28+
commands.registerCommand("hellowitharguments", "Hello World but with arguments!", listOf(
29+
Utils.createCommandOption(ApplicationCommandType.STRING, "name", "Person to say hello to"),
30+
Utils.createCommandOption(ApplicationCommandType.USER, "user", "User to say hello to")
31+
)) { ctx ->
32+
// Check if a user argument was passed
33+
if (ctx.containsArg("user")) {
34+
val user = ctx.getRequiredUser("user")
35+
CommandsAPI.CommandResult("Hello ${user.username}!")
36+
} else {
37+
// Returns either the argument value if present, or the defaultValue ("World" in this case)
38+
val name = ctx.getStringOrDefault("name", "World")
39+
CommandsAPI.CommandResult("Hello $name!")
40+
}
41+
}
42+
}
43+
44+
override fun stop(context: Context) {
45+
// Unregister our commands
46+
commands.unregisterAll()
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version = "1.0.0" // Plugin version. Increment this to trigger the updater
2+
description = "My first patch!" // Plugin description that will be shown to user
3+
4+
aliucord {
5+
// Changelog of your plugin
6+
changelog.set("""
7+
Some changelog
8+
""".trimIndent())
9+
// Image or Gif that will be shown at the top of your changelog page
10+
// changelogMedia.set("https://cool.png")
11+
12+
// Add additional authors to this plugin
13+
// author("Name", 0)
14+
// author("Name", 0)
15+
16+
// Excludes this plugin from the updater, meaning it won't show up for users.
17+
// Set this if the plugin is unfinished
18+
excludeFromUpdaterJson.set(true)
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="youImportedTheWrongR" />

0 commit comments

Comments
 (0)