Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/CopyUrlInsteadOfShare/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Replaces the share message function with a copy url one

2 changes: 2 additions & 0 deletions plugins/CopyUrlInsteadOfShare/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "1.1.1"
description = "Replaces share message function with a copy url one"
2 changes: 2 additions & 0 deletions plugins/CopyUrlInsteadOfShare/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.1" encoding="utf-8"?>
<manifest package="com.nope.plugins.copyurlinsteadofshare" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package dev.nope.plugins.copyurlinsteadofshare

import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.core.widget.NestedScrollView
import com.aliucord.Constants
import com.aliucord.Utils
import com.aliucord.Utils.showToast
import com.aliucord.annotations.AliucordPlugin
import com.aliucord.entities.Plugin
import com.aliucord.patcher.Hook
import com.discord.app.AppBottomSheet
import com.discord.databinding.WidgetChatListActionsBinding
import com.discord.utilities.color.ColorCompat
import com.discord.widgets.chat.list.actions.WidgetChatListActions
import com.lytefast.flexinput.R
import java.lang.reflect.InvocationTargetException


@AliucordPlugin(requiresRestart = false)
class MessageLinkContext : Plugin() {

/* No settings tab for you because Cannot access 'com.discord.app.AppLogger$a' which is a supertype of 'dev.nope.plugins.copyurlinsteadofshare.HelpMeeee'. Check your module classpath for missing or conflicting dependencies
init {
settingsTab = SettingsTab(
Halp::class.java,
SettingsTab.Type.BOTTOM_SHEET
).withArgs(settings)
}
*/

@SuppressLint("SetTextI18n")
override fun start(context: Context) {

val icon = ContextCompat.getDrawable(context, R.e.ic_diag_link_24dp)!!
.mutate()

val copyMessageUrlViewId = View.generateViewId()

with(WidgetChatListActions::class.java) {
val getBinding = getDeclaredMethod("getBinding").apply { isAccessible = true }

val replaceShare = settings.getBool("replaceShare", true)

patcher.patch( //creating the option
getDeclaredMethod("onViewCreated", View::class.java, Bundle::class.java),
Hook { callFrame ->
val shareMessagesViewId = Utils.getResId("dialog_chat_actions_share", "id")
val binding =
getBinding.invoke(callFrame.thisObject) as WidgetChatListActionsBinding
val shareMessageView =
binding.a.findViewById<TextView>(shareMessagesViewId).apply {
visibility = View.VISIBLE
}
val linearLayout =
(callFrame.args[0] as NestedScrollView).getChildAt(0) as LinearLayout
val ctx = linearLayout.context
icon.setTint(ColorCompat.getThemedColor(ctx, R.b.colorInteractiveNormal))
val copyMessageUrl =
TextView(ctx, null, 0, R.i.UiKit_Settings_Item_Icon).apply {

text = ctx.getString(R.h.copy_link)
id = copyMessageUrlViewId
typeface = ResourcesCompat.getFont(ctx, Constants.Fonts.whitney_medium)
setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null)
}
var replacementId = linearLayout.indexOfChild(shareMessageView)
linearLayout.removeView(shareMessageView) // poof

linearLayout.addView(
copyMessageUrl,
replacementId
)
})

patcher.patch( //setting onClickListener
getDeclaredMethod("configureUI", WidgetChatListActions.Model::class.java),
Hook { callFrame ->
try {
val binding =
getBinding.invoke(callFrame.thisObject) as WidgetChatListActionsBinding
val shareMessageView =
binding.a.findViewById<TextView>(copyMessageUrlViewId).apply {
visibility = View.VISIBLE
}

shareMessageView.setOnClickListener {
try {
val msg = (callFrame.args[0] as WidgetChatListActions.Model).message
val guild =
(callFrame.args[0] as WidgetChatListActions.Model).guild // because msg.guildId is null
val messageUri = String.format(
"https://discord.com/channels/%s/%s/%s",
try {
guild.id
} catch (e: Throwable) { // for DMs
"@me"
},
msg.channelId,
msg.id
)
Utils.setClipboard(
"message link",
messageUri
)
showToast("Copied url", showLonger = false)

val bottomSheetDismisser =
AppBottomSheet::class.java.getDeclaredMethod("dismiss") // because cannot access shit again
bottomSheetDismisser.invoke((callFrame.thisObject as WidgetChatListActions))
} catch (e: IllegalAccessException) {
e.printStackTrace()
} catch (e: InvocationTargetException) {
e.printStackTrace()
}
}
} catch (e: Exception) { //yes generic maybe works idk
e.printStackTrace()
}
})
}
}

override fun stop(context: Context) = patcher.unpatchAll()
}
5 changes: 5 additions & 0 deletions plugins/Find/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Find

A slashcommand to find what the ids you give are related to
Usage: /find id1,id2,id3...
Will not find messages or uncached servers/channels/users
2 changes: 2 additions & 0 deletions plugins/Find/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "1.0.4"
description = "/find command"
2 changes: 2 additions & 0 deletions plugins/Find/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.nope.plugins.find" />
147 changes: 147 additions & 0 deletions plugins/Find/src/main/java/dev/nope/plugins/find/Find.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package dev.nope.plugins.find

import android.content.Context
import com.aliucord.Http
import com.aliucord.Utils
import com.aliucord.annotations.AliucordPlugin
import com.aliucord.api.CommandsAPI.CommandResult
import com.aliucord.entities.Plugin
import com.aliucord.utils.RxUtils.await
import com.aliucord.wrappers.ChannelWrapper.Companion.guildId
import com.aliucord.wrappers.ChannelWrapper.Companion.parentId
import com.discord.api.commands.ApplicationCommandType
import com.discord.models.user.User
import com.discord.stores.StoreStream
import com.discord.utilities.rest.RestAPI
import com.discord.api.user.UserProfile
import com.discord.models.user.CoreUser


@AliucordPlugin(requiresRestart = false)
class Find : Plugin() {

private fun timestampToUnixTime(x: Long): Long {
val discordEpoch = 1420070400000
val dateBits = x shr 22
val unixTimes1000 = (dateBits + discordEpoch)
return unixTimes1000 / 1000
}

override fun start(context: Context) {

commands.registerCommand(
"find", "Tries fo find what a timestamp or a list of timestamps refers to", listOf(
Utils.createCommandOption(
ApplicationCommandType.STRING,
"timestampList",
"Timestamps you want answers on. Separate with simple spaces.",
null,
required = true,
default = true
)
)
) { ctx ->
val ids = ctx.getRequiredString("timestampList")
val input = findStringtoList(ids)
val results: MutableMap<Long, String> = mutableMapOf()

input.forEach {
StoreStream.getUsers()
Utils
val colit: Collection<Long> = listOf(it)
val tempUser: User? = StoreStream.getUsers().getUsers(colit, false)[it]
val tempChannel = StoreStream.getChannels().getChannel(it)
val tempServer = StoreStream.getGuilds().getGuild(it)
// val tempMessage = StoreStream.getMessages().getMe i need to test every channel lolilol
try {
if (tempUser?.username == null) {
if (tempChannel?.guildId == null) {
if (tempServer?.id == null) {
results.put(it, "is neither a user, a channel nor guild ID, or is not cached.")
} else {
results.put(it, "is a server.\nName: ${tempServer.name}.")
}
} else {
results.put(
it,
"is the channel: <#${it}> in category ${tempChannel.parentId} in server ${
StoreStream.getGuilds().getGuild(tempChannel.guildId).name
}."
)
}
} else {
results.put(it, "is the user <@$it>.")
}
} catch (throwable: Throwable) {
return@registerCommand CommandResult(
"oopsie doopsie, an error happened. Sorry ! Please check the logs !",
null,
false
)
}


// welp i want to avoid making requests like that so i have to see what to do with the uncached things
if (false && results[it] == "is neither a user, a channel nor guild ID.") { //Checks if the user exists.
try {

val directuser = RestAPI.api.userGet(it).await().first ?: return@forEach
val userinfo =
UserProfile(null, null, directuser, null, null, null, null)
val user = CoreUser(userinfo.g())
results[it] =
"is a user that is not cached. Name: ${user.username}#${user.discriminator}, created on <t:${
timestampToUnixTime(it)
}:F>. Avatar id: ${user.avatar}"


} catch (throwable: Throwable) {
return@forEach
}

}
}

var finalList = ""
results.forEach { (t, u) -> finalList += "\n**$t** $u" }

CommandResult(
finalList,
null,
false
)
}
}


private fun findStringtoList(ids: String): MutableList<Long> {
val result = ids.split(" ").map { it.trim() }
val result2: MutableList<String> = result as MutableList<String>
val result3: MutableList<Long> = mutableListOf()
val counter = 0
result.forEach {
try {
it.toLong().takeIf { that -> that.toString().length in 17..19 } ?: (result2.set(
result.indexOf(it),
"0"
))
} catch (throwable: Throwable) {
result2[result.indexOf(it)] = "0"
}
}
result2.forEach {
if (it.toLong() != 0L) {
result3.add(it.toLong())
} else {
counter + 1
}

}
return result3
}

override fun stop(context: Context) {
// Unregister our commands
commands.unregisterAll()
}
}
3 changes: 3 additions & 0 deletions plugins/MoreMoreSlashCommands/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# MoreMoreSlashCommands

Adds more useless slash commands for text editing : full width, bold, small, smaller, plus a morse encoder and decoder
14 changes: 14 additions & 0 deletions plugins/MoreMoreSlashCommands/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version = "1.0.2"
description = "Adds a few charcter modification slash commands"

aliucord.changelog.set("""
#1.0.2
fixed morse translation issues
# 1.0.1
* Now with morse, bold, and small yay
# 1.0.0
* Initial release
""".trimIndent()

)

2 changes: 2 additions & 0 deletions plugins/MoreMoreSlashCommands/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.nope.plugins.test" />
Loading
Loading