kick button for admins in chats
This commit is contained in:
@@ -11,5 +11,6 @@ public enum MsgAction {
|
||||
PIN,
|
||||
UNPIN,
|
||||
TRANSLATE,
|
||||
READTO
|
||||
READTO,
|
||||
KICK
|
||||
}
|
||||
@@ -35,6 +35,14 @@ public final class MsgActionHelper {
|
||||
CollectionExt.a(arrayList, MsgAction.TRANSLATE, true);
|
||||
CollectionExt.a(arrayList, MsgAction.READTO, true);
|
||||
|
||||
boolean isAdmin;
|
||||
try {
|
||||
isAdmin = aVar.a().z1().t1().contains(aVar.b().j().b()); // get admin list and check if it has you
|
||||
} catch (Exception ignored) {
|
||||
isAdmin = false;
|
||||
}
|
||||
CollectionExt.a(arrayList, MsgAction.KICK, isAdmin);
|
||||
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
|
||||
@@ -298,19 +298,25 @@ public class DNRInjector {
|
||||
}
|
||||
|
||||
public static LinkedHashMap<MsgAction, DelegateMsg.a.a> injectToHashMapMsg(LinkedHashMap<MsgAction, DelegateMsg.a.a> hashMap) {
|
||||
hashMap.put(MsgAction.valueOf("TRANSLATE"), new DelegateMsg.a.a(R.string.translator));
|
||||
hashMap.put(MsgAction.valueOf("READTO"), new DelegateMsg.a.a(R.string.readto));
|
||||
hashMap.put(MsgAction.KICK, new DelegateMsg.a.a(R.string.vkim_accessibility_kick_from_chat));
|
||||
hashMap.put(MsgAction.TRANSLATE, new DelegateMsg.a.a(R.string.translator));
|
||||
hashMap.put(MsgAction.READTO, new DelegateMsg.a.a(R.string.readto));
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
public static boolean onClickMsg(Context context, MsgAction action, Msg msg) {
|
||||
var peerId = msg.v1();
|
||||
|
||||
if (action == MsgAction.valueOf("READTO")) {
|
||||
if (action == MsgAction.READTO) {
|
||||
DNRModule.hookReadStartMsgTo(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == MsgAction.KICK) {
|
||||
DNRModule.hookKick(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg instanceof MsgFromUser) {
|
||||
var text = ((MsgFromUser) msg).f();
|
||||
var isTextExist = !text.isEmpty() && !text.equals(" ");
|
||||
@@ -319,7 +325,7 @@ public class DNRInjector {
|
||||
text = EncryptProvider.decryptMessage(text, peerId);
|
||||
}
|
||||
|
||||
if (action == MsgAction.valueOf("TRANSLATE")) {
|
||||
if (action == MsgAction.TRANSLATE) {
|
||||
if (isTextExist) {
|
||||
Translate.showTranslatedText(context, text);
|
||||
} else {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package ru.vtosters.lite.dnr;
|
||||
|
||||
import android.util.Log;
|
||||
import com.vk.core.util.LangUtils;
|
||||
import com.vk.im.engine.commands.messages.SetUserActivityCmd;
|
||||
import com.vk.im.engine.models.dialogs.Dialog;
|
||||
import com.vk.im.engine.models.messages.Msg;
|
||||
import com.vk.im.engine.utils.ImDialogsUtils;
|
||||
import ru.vtosters.lite.dnr.helpers.DoNotReadDBHelper;
|
||||
import ru.vtosters.lite.dnr.helpers.DoNotTypeDBHelper;
|
||||
import ru.vtosters.lite.net.Request;
|
||||
@@ -19,11 +19,9 @@ import java.util.List;
|
||||
public class DNRModule {
|
||||
public static DoNotReadDBHelper mDoNotReadDBHelper = new DoNotReadDBHelper();
|
||||
public static DoNotTypeDBHelper mDoNotTypeDBHelper = new DoNotTypeDBHelper();
|
||||
public static Dialog mDialog;
|
||||
|
||||
public static boolean isDnrEnabledFor(int id) {
|
||||
var isEnabled = mDoNotReadDBHelper.isEnabledForPeerId(id);
|
||||
return isEnabled;
|
||||
return mDoNotReadDBHelper.isEnabledForPeerId(id);
|
||||
}
|
||||
|
||||
public static List<Integer> getDnrEnabled() {
|
||||
@@ -35,8 +33,7 @@ public class DNRModule {
|
||||
}
|
||||
|
||||
public static boolean isDntEnabledFor(int id) {
|
||||
var isEnabled = mDoNotTypeDBHelper.isEnabledForPeerId(id);
|
||||
return isEnabled;
|
||||
return mDoNotTypeDBHelper.isEnabledForPeerId(id);
|
||||
}
|
||||
|
||||
public static boolean isDntEnabledFor(SetUserActivityCmd cmd) {
|
||||
@@ -59,11 +56,15 @@ public class DNRModule {
|
||||
}
|
||||
|
||||
public static void hookReadStartMsgTo(Msg dialog) {
|
||||
Log.d("DNR", "hookReadStartMsgTo: " + dialog.C1() + " " + dialog.v1());
|
||||
Request.makeRequest("https://" + ProxyUtils.getApi() + "/method/messages.markAsRead?start_message_id=" + dialog.C1() + "&peer_id=" + dialog.v1() + "&v=5.119&access_token=" + AccountManagerUtils.getUserToken(), response -> {
|
||||
});
|
||||
}
|
||||
|
||||
public static void hookKick(Msg dialog) {
|
||||
Request.makeRequest("https://" + ProxyUtils.getApi() + "/method/messages.removeChatUser?member_id=" + dialog.getFrom().t1() + "&chat_id=" + ImDialogsUtils.c(dialog.v1()) + "&v=5.119&access_token=" + AccountManagerUtils.getUserToken(), response -> {
|
||||
});
|
||||
}
|
||||
|
||||
public static void hookDialogInfo(Dialog dialog) {
|
||||
AndroidUtils.openWebView("https://vkscripts.ru/run/i/" +
|
||||
AccountManagerUtils.getUserToken() +
|
||||
|
||||
Reference in New Issue
Block a user