mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 05:12:17 +00:00
Compare commits
77 Commits
5637db43be
...
master
Author | SHA1 | Date | |
---|---|---|---|
40ffa2b71b | |||
cca2cbbbd7 | |||
40d2911135 | |||
823d9911a0 | |||
4adbc12a0b | |||
114fbfdd23 | |||
0a563d60a1 | |||
5fb1d0aeb9 | |||
012ecaa85d | |||
7ea127a279 | |||
02f83a3c48 | |||
4016c05882 | |||
59d762eecf | |||
e891bc8512 | |||
494c70f2f8 | |||
7baf459b2a | |||
36a09ca088 | |||
926c4659f6 | |||
cb7c68f36c | |||
72af39208c | |||
042f4bd330 | |||
9aef71b09f | |||
9cbe755520 | |||
df02f9f872 | |||
5cbb695a66 | |||
c014e85faa | |||
4a396b0935 | |||
d59fcf9f6a | |||
cdc664f44a | |||
ad313f384c | |||
b6a510ce05 | |||
bed5947909 | |||
fb6578d243 | |||
d33cace7aa | |||
659d4e5da4 | |||
ac2aee8c0e | |||
0faada7b5a | |||
680317da13 | |||
7782feb6ac | |||
d66358a1f3 | |||
824f280b3a | |||
6936262d62 | |||
0955267ee5 | |||
f3da62fa74 | |||
abbac6315c | |||
0cf10eabd6 | |||
8c33267887 | |||
f030104ff2 | |||
ee5fcc3403 | |||
5e819179b4 | |||
ea206faf4f | |||
5adfc544a2 | |||
bdb75841cf | |||
a3dc0d06b2 | |||
3664352f23 | |||
2770979fee | |||
6c9b282c6a | |||
3a07116093 | |||
be58c368e9 | |||
a95d8d85e8 | |||
1d035fa378 | |||
7d0b60271e | |||
d38777d06a | |||
7bacea3288 | |||
ca47f9dbdf | |||
cb4268edef | |||
c16f9d543c | |||
93c49953cf | |||
883e949cc1 | |||
a528030cbb | |||
bbdfb7c04e | |||
1afc0ac6a6 | |||
638bf72392 | |||
07364c8298 | |||
ee6e13a5bb | |||
c3934778c7 | |||
13a49dd70b |
1
.github/ISSUE_TEMPLATE/bug.md
vendored
1
.github/ISSUE_TEMPLATE/bug.md
vendored
@ -21,6 +21,7 @@ labels: bug
|
|||||||
## 系统信息
|
## 系统信息
|
||||||
|
|
||||||
- Shamrock 版本:
|
- Shamrock 版本:
|
||||||
|
- QQ 版本:
|
||||||
- Android 版本:
|
- Android 版本:
|
||||||
- LSPosed 框架版本:
|
- LSPosed 框架版本:
|
||||||
- 设备的制造商和型号:
|
- 设备的制造商和型号:
|
||||||
|
2
.github/workflows/build-apk.yml
vendored
2
.github/workflows/build-apk.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
submodules: recursive
|
||||||
|
|
||||||
- name: Setup JDK 17
|
- name: Setup JDK 17
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "kritor"]
|
||||||
|
path = kritor/kritor
|
||||||
|
url = https://github.com/KarinJS/kritor
|
27
README.md
27
README.md
@ -16,20 +16,39 @@
|
|||||||
|
|
||||||
## 简介
|
## 简介
|
||||||
|
|
||||||
☘ 基于 Lsposed(**Non**-Riru) 实现 OneBot 标准的 QQ 机器人框架,原作者[**fuqiuluo**](https://github.com/fuqiuluo)已脱离开发,接下来由白池接手哦!本项目为OpenShamrock,不会有任何收费行为,欢迎大家的加入!
|
☘ 基于 Lsposed(**Non**-Riru) 实现 Kritor 标准的 QQ 机器人框架!
|
||||||
|
|
||||||
> 本项目仅提供学习与交流用途,请在24小时内删除。
|
> 本项目仅提供学习与交流用途,请在24小时内删除。
|
||||||
> 本项目目的是研究 Xposed 和 LSPosed 框架的使用。 Epic 框架开发相关知识。
|
> 本项目目的是研究 Xposed 和 LSPosed 框架的使用。 Epic 框架开发相关知识。
|
||||||
> Riru可能导致封禁,请减少使用。
|
> Riru可能导致封禁,请减少使用。
|
||||||
> 如有违反法律,请联系删除。
|
> 如有违反法律,请联系删除。
|
||||||
> 请勿在任何平台宣传,宣扬,转发本项目,请勿恶意修改企业安装包造成相关企业产生损失,如有违背,必将追责到底。
|
> 请勿在任何平台宣传,宣扬,转发本项目,请勿恶意修改企业安装包造成相关企业产生损失,如有违背,必将追责到底。
|
||||||
> 官方论坛,[点我直达](https://forum.libfekit.so/)!
|
>
|
||||||
|
> 社区地址:[discord](https://discord.gg/MKR2wz863h)
|
||||||
|
|
||||||
## 兼容|迁移|替代 说明
|
## 兼容|迁移|替代 说明
|
||||||
|
|
||||||
|
仅支持QQ9.0.70以上的版本,低版本问题将不再修复与处理。
|
||||||
|
|
||||||
- 一键移植:本项目基于 go-cqhttp 的文档进行开发实现。
|
- 一键移植:本项目基于 go-cqhttp 的文档进行开发实现。
|
||||||
- 平行部署:可多平台部署,未来将会支持 Docker 部署的教程。
|
- 平行部署:可多平台部署。
|
||||||
- 替代方案:[Lagrange.Core](https://github.com/LagrangeDev/Lagrange.Core)
|
|
||||||
|
## 相关项目
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><a href="https://github.com/LagrangeDev/Lagrange.Core">Lagrange.Core</a></td>
|
||||||
|
<td>NTQQ 的协议实现</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="https://github.com/whitechi73/OpenShamrock">OpenShamrock</a></td>
|
||||||
|
<td>基于 Xposed 实现 OneBot 标准的机器人框架(👈你在这里</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="https://github.com/chrononeko/chronocat">Chronocat</a></td>
|
||||||
|
<td>基于 Electron 的、模块化的 Satori 框架</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
## 权限声明
|
## 权限声明
|
||||||
|
|
||||||
|
@ -9,6 +9,6 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(DEPENDENCY_PROTOBUF)
|
//implementation(DEPENDENCY_PROTOBUF)
|
||||||
implementation(kotlinx("serialization-protobuf", "1.6.2"))
|
implementation(kotlinx("serialization-protobuf", "1.6.2"))
|
||||||
}
|
}
|
9
annotations/src/main/java/kritor/service/Grpc.kt
Normal file
9
annotations/src/main/java/kritor/service/Grpc.kt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
@Retention(AnnotationRetention.SOURCE)
|
||||||
|
@Target(AnnotationTarget.FUNCTION)
|
||||||
|
annotation class Grpc(
|
||||||
|
val serviceName: String,
|
||||||
|
val funcName: String,
|
||||||
|
|
||||||
|
)
|
@ -1,8 +0,0 @@
|
|||||||
package moe.fuqiuluo.symbols
|
|
||||||
|
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
|
||||||
@Target(AnnotationTarget.CLASS)
|
|
||||||
annotation class OneBotHandler(
|
|
||||||
val actionName: String,
|
|
||||||
val alias: Array<String> = []
|
|
||||||
)
|
|
@ -5,6 +5,8 @@ import kotlinx.serialization.protobuf.ProtoBuf
|
|||||||
|
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
val EMPTY_BYTE_ARRAY = ByteArray(0)
|
||||||
|
|
||||||
interface Protobuf<T: Protobuf<T>>
|
interface Protobuf<T: Protobuf<T>>
|
||||||
|
|
||||||
inline fun <reified T: Protobuf<T>> ByteArray.decodeProtobuf(to: KClass<T>? = null): T {
|
inline fun <reified T: Protobuf<T>> ByteArray.decodeProtobuf(to: KClass<T>? = null): T {
|
||||||
|
@ -17,7 +17,7 @@ android {
|
|||||||
minSdk = 27
|
minSdk = 27
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = getVersionCode()
|
versionCode = getVersionCode()
|
||||||
versionName = "1.1.0" + ".r${getGitCommitCount()}." + getVersionName()
|
versionName = "1.1.1" + ".r${getGitCommitCount()}." + getVersionName()
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
|
@ -37,7 +37,6 @@ add_library(${CMAKE_PROJECT_NAME} SHARED
|
|||||||
# List C/C++ source files with relative paths to this CMakeLists.txt.
|
# List C/C++ source files with relative paths to this CMakeLists.txt.
|
||||||
${SRC_DIR}
|
${SRC_DIR}
|
||||||
md5.cpp
|
md5.cpp
|
||||||
cqcode.cpp
|
|
||||||
silk.cpp
|
silk.cpp
|
||||||
message.cpp
|
message.cpp
|
||||||
shamrock.cpp)
|
shamrock.cpp)
|
||||||
|
@ -1,138 +0,0 @@
|
|||||||
#include <stdexcept>
|
|
||||||
#include "cqcode.h"
|
|
||||||
|
|
||||||
inline void replace_string(std::string& str, const std::string& from, const std::string& to) {
|
|
||||||
size_t startPos = 0;
|
|
||||||
while ((startPos = str.find(from, startPos)) != std::string::npos) {
|
|
||||||
str.replace(startPos, from.length(), to);
|
|
||||||
startPos += to.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int utf8_next_len(const std::string& str, size_t offset)
|
|
||||||
{
|
|
||||||
uint8_t c = (uint8_t)str[offset];
|
|
||||||
if (c >= 0xFC)
|
|
||||||
return 6;
|
|
||||||
else if (c >= 0xF8)
|
|
||||||
return 5;
|
|
||||||
else if (c >= 0xF0)
|
|
||||||
return 4;
|
|
||||||
else if (c >= 0xE0)
|
|
||||||
return 3;
|
|
||||||
else if (c >= 0xC0)
|
|
||||||
return 2;
|
|
||||||
else if (c > 0x00)
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void decode_cqcode(const std::string& code, std::vector<std::unordered_map<std::string, std::string>>& dest) {
|
|
||||||
std::string cache;
|
|
||||||
bool is_start = false;
|
|
||||||
std::string key_tmp;
|
|
||||||
std::unordered_map<std::string, std::string> kv;
|
|
||||||
for(size_t i = 0; i < code.size(); i++) {
|
|
||||||
int utf8_char_len = utf8_next_len(code, i);
|
|
||||||
if(utf8_char_len == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::string_view c(&code[i],utf8_char_len);
|
|
||||||
if (c == "[") {
|
|
||||||
if (is_start) {
|
|
||||||
throw illegal_code();
|
|
||||||
} else {
|
|
||||||
if (!cache.empty()) {
|
|
||||||
std::unordered_map<std::string, std::string> kv;
|
|
||||||
replace_string(cache, "[", "[");
|
|
||||||
replace_string(cache, "]", "]");
|
|
||||||
replace_string(cache, "&", "&");
|
|
||||||
kv.emplace("_type", "text");
|
|
||||||
kv.emplace("text", cache);
|
|
||||||
dest.push_back(kv);
|
|
||||||
cache.clear();
|
|
||||||
}
|
|
||||||
std::string_view cq_flag(&code[i],4);
|
|
||||||
if(cq_flag == "[CQ:"){
|
|
||||||
is_start = true;
|
|
||||||
i += 3;
|
|
||||||
}else{
|
|
||||||
cache += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (c == "=") {
|
|
||||||
if (is_start) {
|
|
||||||
if (cache.empty()) {
|
|
||||||
throw illegal_code();
|
|
||||||
} else {
|
|
||||||
if (key_tmp.empty()) {
|
|
||||||
key_tmp.append(cache);
|
|
||||||
cache.clear();
|
|
||||||
} else {
|
|
||||||
cache += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cache += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (c == ",") {
|
|
||||||
if (is_start) {
|
|
||||||
if (kv.count("_type") == 0 && !cache.empty()) {
|
|
||||||
kv.emplace("_type", cache);
|
|
||||||
cache.clear();
|
|
||||||
} else {
|
|
||||||
if (!key_tmp.empty()) {
|
|
||||||
replace_string(cache, "[", "[");
|
|
||||||
replace_string(cache, "]", "]");
|
|
||||||
replace_string(cache, ",", ",");
|
|
||||||
replace_string(cache, "&", "&");
|
|
||||||
kv.emplace(key_tmp, cache);
|
|
||||||
cache.clear();
|
|
||||||
key_tmp.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cache += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (c == "]") {
|
|
||||||
if (is_start) {
|
|
||||||
if (!cache.empty()) {
|
|
||||||
if (!key_tmp.empty()) {
|
|
||||||
replace_string(cache, "[", "[");
|
|
||||||
replace_string(cache, "]", "]");
|
|
||||||
replace_string(cache, ",", ",");
|
|
||||||
replace_string(cache, "&", "&");
|
|
||||||
kv.emplace(key_tmp, cache);
|
|
||||||
} else {
|
|
||||||
kv.emplace("_type", cache);
|
|
||||||
}
|
|
||||||
dest.push_back(kv);
|
|
||||||
kv.clear();
|
|
||||||
key_tmp.clear();
|
|
||||||
cache.clear();
|
|
||||||
is_start = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cache += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cache += c;
|
|
||||||
i += (utf8_char_len - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!cache.empty()) {
|
|
||||||
std::unordered_map<std::string, std::string> kv;
|
|
||||||
replace_string(cache, "[", "[");
|
|
||||||
replace_string(cache, "]", "]");
|
|
||||||
replace_string(cache, "&", "&");
|
|
||||||
kv.emplace("_type", "text");
|
|
||||||
kv.emplace("text", cache);
|
|
||||||
dest.push_back(kv);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
#include "jni.h"
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
struct Honor {
|
|
||||||
int id;
|
|
||||||
std::string name;
|
|
||||||
std::string icon_url;
|
|
||||||
int priority;
|
|
||||||
};
|
|
||||||
|
|
||||||
int calc_honor_flag(int honor_id, char honor_flag);
|
|
||||||
|
|
||||||
jobject make_honor_object(JNIEnv *env, jobject user_id, const Honor& honor);
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
JNIEXPORT jobject JNICALL
|
|
||||||
Java_moe_fuqiuluo_shamrock_remote_action_handlers_GetTroopHonor_nativeDecodeHonor(JNIEnv *env, jobject thiz,
|
|
||||||
jstring user_id,
|
|
||||||
jint honor_id,
|
|
||||||
jbyte honor_flag) {
|
|
||||||
static std::vector<Honor> honor_list = {
|
|
||||||
Honor{1, "龙王", "https://qzonestyle.gtimg.cn/aoi/sola/20200213150116_n4PxCiurbm.png", 1},
|
|
||||||
Honor{2, "群聊之火", "https://qzonestyle.gtimg.cn/aoi/sola/20200217190136_92JEGFKC5k.png", 3},
|
|
||||||
Honor{3, "群聊炽焰", "https://qzonestyle.gtimg.cn/aoi/sola/20200217190204_zgCTeSrMq1.png", 4},
|
|
||||||
Honor{5, "冒尖小春笋", "https://qzonestyle.gtimg.cn/aoi/sola/20200213150335_tUJCAtoKVP.png", 5},
|
|
||||||
Honor{6, "快乐源泉", "https://qzonestyle.gtimg.cn/aoi/sola/20200213150434_3tDmsJExCP.png", 7},
|
|
||||||
Honor{7, "学术新星", "https://sola.gtimg.cn/aoi/sola/20200515140645_j0X6gbuHNP.png", 8},
|
|
||||||
Honor{8, "顶尖学霸", "https://sola.gtimg.cn/aoi/sola/20200515140639_0CtWOpfVzK.png", 9},
|
|
||||||
Honor{9, "至尊学神", "https://sola.gtimg.cn/aoi/sola/20200515140628_P8UEYBjMBT.png", 10},
|
|
||||||
Honor{10, "一笔当先", "https://sola.gtimg.cn/aoi/sola/20200515140654_4r94tSCdaB.png", 11},
|
|
||||||
Honor{11, "奋进小翠竹", "https://sola.gtimg.cn/aoi/sola/20200812151819_wbj6z2NGoB.png", 6},
|
|
||||||
Honor{12, "氛围魔杖", "https://sola.gtimg.cn/aoi/sola/20200812151831_4ZJgQCaD1H.png", 2},
|
|
||||||
Honor{13, "壕礼皇冠", "https://sola.gtimg.cn/aoi/sola/20200930154050_juZOAMg7pt.png", 12},
|
|
||||||
};
|
|
||||||
int flag = calc_honor_flag(honor_id, honor_flag);
|
|
||||||
if ((honor_id != 1 && honor_id != 2 && honor_id != 3) || flag != 1) {
|
|
||||||
auto honor = *std::find_if(honor_list.begin(), honor_list.end(), [&honor_id](auto &honor) {
|
|
||||||
return honor.id == honor_id;
|
|
||||||
});
|
|
||||||
return make_honor_object(env, user_id, honor);
|
|
||||||
} else {
|
|
||||||
auto honor = *std::find_if(honor_list.begin(), honor_list.end(), [&honor_id](auto &honor) {
|
|
||||||
return honor.id == honor_id;
|
|
||||||
});
|
|
||||||
std::string url = "https://static-res.qq.com/static-res/groupInteract/vas/a/" + std::to_string(honor_id) + "_1.png";
|
|
||||||
honor = Honor{honor_id, honor.name, url, honor.priority};
|
|
||||||
return make_honor_object(env, user_id, honor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int calc_honor_flag(int honor_id, char honor_flag) {
|
|
||||||
int flag;
|
|
||||||
if (honor_flag == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (honor_id == 1) {
|
|
||||||
flag = honor_flag;
|
|
||||||
} else if (honor_id == 2 || honor_id == 3) {
|
|
||||||
flag = honor_flag >> 2;
|
|
||||||
} else if (honor_id != 4) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
flag = honor_flag >> 4;
|
|
||||||
}
|
|
||||||
return flag & 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
jobject make_honor_object(JNIEnv *env, jobject user_id, const Honor& honor) {
|
|
||||||
jclass GroupMemberHonor = env->FindClass("moe/fuqiuluo/shamrock/remote/service/data/GroupMemberHonor");
|
|
||||||
jmethodID GroupMemberHonor_init = env->GetMethodID(GroupMemberHonor, "<init>",
|
|
||||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;)V");
|
|
||||||
auto user_id_str = (jstring) user_id;
|
|
||||||
jstring honor_desc = env->NewStringUTF(honor.name.c_str());
|
|
||||||
jstring uin_name = env->NewStringUTF("");
|
|
||||||
jstring honor_icon_url = env->NewStringUTF(honor.icon_url.c_str());
|
|
||||||
jobject ret = env->NewObject(GroupMemberHonor, GroupMemberHonor_init, user_id_str, uin_name, honor_icon_url, 0, honor.id, honor_desc);
|
|
||||||
|
|
||||||
env->DeleteLocalRef(GroupMemberHonor);
|
|
||||||
env->DeleteLocalRef(user_id_str);
|
|
||||||
env->DeleteLocalRef(honor_desc);
|
|
||||||
env->DeleteLocalRef(honor_icon_url);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
#ifndef UNTITLED_CQCODE_H
|
|
||||||
#define UNTITLED_CQCODE_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
class illegal_code: std::exception {
|
|
||||||
public:
|
|
||||||
[[nodiscard]] const char * what() const noexcept override {
|
|
||||||
return "Error cq code.";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void decode_cqcode(const std::string& code, std::vector<std::unordered_map<std::string, std::string>>& dest);
|
|
||||||
|
|
||||||
void encode_cqcode(const std::vector<std::unordered_map<std::string, std::string>>& segment, std::string& dest);
|
|
||||||
|
|
||||||
#endif //UNTITLED_CQCODE_H
|
|
@ -1,5 +1,4 @@
|
|||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "cqcode.h"
|
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
inline void replace_string(std::string& str, const std::string& from, const std::string& to) {
|
inline void replace_string(std::string& str, const std::string& from, const std::string& to) {
|
||||||
@ -12,7 +11,7 @@ inline void replace_string(std::string& str, const std::string& from, const std:
|
|||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_moe_fuqiuluo_shamrock_helper_MessageHelper_createMessageUniseq(JNIEnv *env, jobject thiz,
|
Java_qq_service_msg_MessageHelper_createMessageUniseq(JNIEnv *env, jobject thiz,
|
||||||
jint chat_type,
|
jint chat_type,
|
||||||
jlong time) {
|
jlong time) {
|
||||||
static std::random_device rd;
|
static std::random_device rd;
|
||||||
@ -32,123 +31,6 @@ Java_moe_fuqiuluo_shamrock_helper_MessageHelper_getChatType(JNIEnv *env, jobject
|
|||||||
return (int32_t) ((int64_t) msg_id & 0xffL);
|
return (int32_t) ((int64_t) msg_id & 0xffL);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
|
||||||
JNIEXPORT jobject JNICALL
|
|
||||||
Java_moe_fuqiuluo_shamrock_helper_MessageHelper_nativeDecodeCQCode(JNIEnv *env, jobject thiz,
|
|
||||||
jstring code) {
|
|
||||||
jclass ArrayList = env->FindClass("java/util/ArrayList");
|
|
||||||
jmethodID NewArrayList = env->GetMethodID(ArrayList, "<init>", "()V");
|
|
||||||
jmethodID ArrayListAdd = env->GetMethodID(ArrayList, "add", "(Ljava/lang/Object;)Z");
|
|
||||||
jobject arrayList = env->NewObject(ArrayList, NewArrayList);
|
|
||||||
|
|
||||||
const char* cCode = env->GetStringUTFChars(code, nullptr);
|
|
||||||
std::string cppCode = cCode;
|
|
||||||
std::vector<std::unordered_map<std::string, std::string>> dest;
|
|
||||||
try {
|
|
||||||
decode_cqcode(cppCode, dest);
|
|
||||||
} catch (illegal_code& code) {
|
|
||||||
return arrayList;
|
|
||||||
}
|
|
||||||
|
|
||||||
jclass HashMap = env->FindClass("java/util/HashMap");
|
|
||||||
jmethodID NewHashMap = env->GetMethodID(HashMap, "<init>", "()V");
|
|
||||||
jclass String = env->FindClass("java/lang/String");
|
|
||||||
jmethodID NewString = env->GetMethodID(String, "<init>", "([BLjava/lang/String;)V");
|
|
||||||
jstring charset = env->NewStringUTF("UTF-8");
|
|
||||||
jmethodID put = env->GetMethodID(HashMap, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
|
||||||
for (auto& map : dest) {
|
|
||||||
jobject hashMap = env->NewObject(HashMap, NewHashMap);
|
|
||||||
for (const auto& pair : map) {
|
|
||||||
jbyteArray keyArray = env->NewByteArray((int) pair.first.size());
|
|
||||||
jbyteArray valueArray = env->NewByteArray((int) pair.second.size());
|
|
||||||
env->SetByteArrayRegion(keyArray, 0, (int) pair.first.size(), (jbyte*)pair.first.c_str());
|
|
||||||
env->SetByteArrayRegion(valueArray, 0, (int) pair.second.size(), (jbyte*)pair.second.c_str());
|
|
||||||
auto key = (jstring) env->NewObject(String, NewString, keyArray, charset);
|
|
||||||
auto value = (jstring) env->NewObject(String, NewString, valueArray, charset);
|
|
||||||
env->CallObjectMethod(hashMap, put, key, value);
|
|
||||||
}
|
|
||||||
env->CallBooleanMethod(arrayList, ArrayListAdd, hashMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
env->DeleteLocalRef(ArrayList);
|
|
||||||
env->DeleteLocalRef(HashMap);
|
|
||||||
env->DeleteLocalRef(String);
|
|
||||||
env->DeleteLocalRef(charset);
|
|
||||||
env->ReleaseStringUTFChars(code, cCode);
|
|
||||||
|
|
||||||
return arrayList;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
JNIEXPORT jstring JNICALL
|
|
||||||
Java_moe_fuqiuluo_shamrock_helper_MessageHelper_nativeEncodeCQCode(JNIEnv *env, jobject thiz,
|
|
||||||
jobject segment_list) {
|
|
||||||
jclass List = env->FindClass("java/util/List");
|
|
||||||
jmethodID ListSize = env->GetMethodID(List, "size", "()I");
|
|
||||||
jmethodID ListGet = env->GetMethodID(List, "get", "(I)Ljava/lang/Object;");
|
|
||||||
jclass Map = env->FindClass("java/util/Map");
|
|
||||||
jmethodID MapGet = env->GetMethodID(Map, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
|
|
||||||
jmethodID entrySetMethod = env->GetMethodID(Map, "entrySet", "()Ljava/util/Set;");
|
|
||||||
jclass setClass = env->FindClass("java/util/Set");
|
|
||||||
jmethodID iteratorMethod = env->GetMethodID(setClass, "iterator", "()Ljava/util/Iterator;");
|
|
||||||
jclass entryClass = env->FindClass("java/util/Map$Entry");
|
|
||||||
jmethodID getKeyMethod = env->GetMethodID(entryClass, "getKey", "()Ljava/lang/Object;");
|
|
||||||
jmethodID getValueMethod = env->GetMethodID(entryClass, "getValue", "()Ljava/lang/Object;");
|
|
||||||
|
|
||||||
std::string result;
|
|
||||||
jint size = env->CallIntMethod(segment_list, ListSize);
|
|
||||||
for (int i = 0; i < size; i++ ) {
|
|
||||||
jobject segment = env->CallObjectMethod(segment_list, ListGet, i);
|
|
||||||
jobject entrySet = env->CallObjectMethod(segment, entrySetMethod);
|
|
||||||
jobject iterator = env->CallObjectMethod(entrySet, iteratorMethod);
|
|
||||||
auto type = (jstring) env->CallObjectMethod(segment, MapGet, env->NewStringUTF("_type"));
|
|
||||||
auto typeString = env->GetStringUTFChars(type, nullptr);
|
|
||||||
if (strcmp(typeString, "text") == 0) {
|
|
||||||
auto text = (jstring) env->CallObjectMethod(segment, MapGet, env->NewStringUTF("text"));
|
|
||||||
auto textString = env->GetStringUTFChars(text, nullptr);
|
|
||||||
std::string tmpValue = textString;
|
|
||||||
replace_string(tmpValue, "&", "&");
|
|
||||||
replace_string(tmpValue, "[", "[");
|
|
||||||
replace_string(tmpValue, "]", "]");
|
|
||||||
replace_string(tmpValue, ",", ",");
|
|
||||||
result.append(tmpValue);
|
|
||||||
env->ReleaseStringUTFChars(text, textString);
|
|
||||||
} else {
|
|
||||||
result.append("[CQ:");
|
|
||||||
result.append(typeString);
|
|
||||||
while (env->CallBooleanMethod(iterator, env->GetMethodID(env->GetObjectClass(iterator), "hasNext", "()Z"))) {
|
|
||||||
jobject entry = env->CallObjectMethod(iterator, env->GetMethodID(env->GetObjectClass(iterator), "next", "()Ljava/lang/Object;"));
|
|
||||||
auto key = (jstring) env->CallObjectMethod(entry, getKeyMethod);
|
|
||||||
auto value = (jstring) env->CallObjectMethod(entry, getValueMethod);
|
|
||||||
auto keyString = env->GetStringUTFChars(key, nullptr);
|
|
||||||
auto valueString = env->GetStringUTFChars(value, nullptr);
|
|
||||||
if (strcmp(keyString, "_type") != 0) {
|
|
||||||
std::string tmpValue = valueString;
|
|
||||||
replace_string(tmpValue, "&", "&");
|
|
||||||
replace_string(tmpValue, "[", "[");
|
|
||||||
replace_string(tmpValue, "]", "]");
|
|
||||||
replace_string(tmpValue, ",", ",");
|
|
||||||
result.append(",").append(keyString).append("=").append(tmpValue);
|
|
||||||
}
|
|
||||||
env->ReleaseStringUTFChars(key, keyString);
|
|
||||||
env->ReleaseStringUTFChars(value, valueString);
|
|
||||||
env->DeleteLocalRef(entry);
|
|
||||||
env->DeleteLocalRef(key);
|
|
||||||
env->DeleteLocalRef(value);
|
|
||||||
}
|
|
||||||
result.append("]");
|
|
||||||
}
|
|
||||||
env->ReleaseStringUTFChars(type, typeString);
|
|
||||||
}
|
|
||||||
|
|
||||||
env->DeleteLocalRef(List);
|
|
||||||
env->DeleteLocalRef(Map);
|
|
||||||
env->DeleteLocalRef(setClass);
|
|
||||||
env->DeleteLocalRef(entryClass);
|
|
||||||
return env->NewStringUTF(result.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_moe_fuqiuluo_shamrock_helper_MessageHelper_insertChatTypeToMsgId(JNIEnv *env, jobject thiz,
|
Java_moe_fuqiuluo_shamrock_helper_MessageHelper_insertChatTypeToMsgId(JNIEnv *env, jobject thiz,
|
||||||
|
@ -118,9 +118,7 @@ private fun APIInfoCard(
|
|||||||
text = rpcAddress,
|
text = rpcAddress,
|
||||||
hint = "请输入回调地址",
|
hint = "请输入回调地址",
|
||||||
error = "输入的地址不合法",
|
error = "输入的地址不合法",
|
||||||
checker = {
|
checker = { true },
|
||||||
it.isEmpty() || it.contains(":")
|
|
||||||
},
|
|
||||||
confirm = {
|
confirm = {
|
||||||
ShamrockConfig[ctx, RPCAddress] = rpcAddress.value
|
ShamrockConfig[ctx, RPCAddress] = rpcAddress.value
|
||||||
AppRuntime.log("设置回调RPC地址为[${rpcAddress.value}]。")
|
AppRuntime.log("设置回调RPC地址为[${rpcAddress.value}]。")
|
||||||
@ -164,7 +162,7 @@ private fun FunctionCard(
|
|||||||
|
|
||||||
Function(
|
Function(
|
||||||
title = "主动RPC",
|
title = "主动RPC",
|
||||||
desc = "Kritor协议实现RPC",
|
desc = "Kritor协议实现RPC,由Shamrock放出rpc服务",
|
||||||
isSwitch = ShamrockConfig[ctx, ActiveRPC]
|
isSwitch = ShamrockConfig[ctx, ActiveRPC]
|
||||||
) {
|
) {
|
||||||
ShamrockConfig[ctx, ActiveRPC] = it
|
ShamrockConfig[ctx, ActiveRPC] = it
|
||||||
@ -173,7 +171,7 @@ private fun FunctionCard(
|
|||||||
|
|
||||||
Function(
|
Function(
|
||||||
title = "被动RPC",
|
title = "被动RPC",
|
||||||
desc = "Kritor协议实现RPC",
|
desc = "Kritor协议实现RPC,由客户端提供反向的rpc服务",
|
||||||
isSwitch = ShamrockConfig[ctx, PassiveRPC]
|
isSwitch = ShamrockConfig[ctx, PassiveRPC]
|
||||||
) {
|
) {
|
||||||
ShamrockConfig[ctx, PassiveRPC] = it
|
ShamrockConfig[ctx, PassiveRPC] = it
|
||||||
|
@ -18,12 +18,17 @@ internal object InitHandler: ModuleHandler() {
|
|||||||
|
|
||||||
val maps = hashMapOf<String, Any?>()
|
val maps = hashMapOf<String, Any?>()
|
||||||
|
|
||||||
RPCPort.update(context, maps)
|
|
||||||
RPCAddress.update(context, maps)
|
|
||||||
ForceTablet.update(context, maps)
|
|
||||||
ActiveRPC.update(context, maps)
|
ActiveRPC.update(context, maps)
|
||||||
|
AliveReply.update(context, maps)
|
||||||
|
AntiJvmTrace.update(context, maps)
|
||||||
|
DebugMode.update(context, maps)
|
||||||
|
EnableOldBDH.update(context, maps)
|
||||||
|
EnableSelfMessage.update(context, maps)
|
||||||
|
ForceTablet.update(context, maps)
|
||||||
PassiveRPC.update(context, maps)
|
PassiveRPC.update(context, maps)
|
||||||
ResourceGroup.update(context, maps)
|
ResourceGroup.update(context, maps)
|
||||||
|
RPCAddress.update(context, maps)
|
||||||
|
RPCPort.update(context, maps)
|
||||||
|
|
||||||
callback(context, 1, maps)
|
callback(context, 1, maps)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.9.21"
|
kotlin("jvm") version "1.9.22"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -7,9 +7,6 @@ val DEPENDENCY_ANDROIDX = arrayOf(
|
|||||||
"androidx.activity:activity-compose:1.7.2",
|
"androidx.activity:activity-compose:1.7.2",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
const val DEPENDENCY_PROTOBUF = "com.google.protobuf:protobuf-java:3.24.0"
|
|
||||||
|
|
||||||
fun room(name: String) = "androidx.room:room-$name:${Versions.roomVersion}"
|
fun room(name: String) = "androidx.room:room-$name:${Versions.roomVersion}"
|
||||||
|
|
||||||
fun kotlinx(name: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$name:$version"
|
fun kotlinx(name: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$name:$version"
|
||||||
@ -18,8 +15,9 @@ fun ktor(target: String, name: String): String {
|
|||||||
return "io.ktor:ktor-$target-$name:${Versions.ktorVersion}"
|
return "io.ktor:ktor-$target-$name:${Versions.ktorVersion}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun grpc(name: String, version: String) = "io.grpc:grpc-$name:$version"
|
||||||
|
|
||||||
object Versions {
|
object Versions {
|
||||||
const val roomVersion = "2.5.0"
|
const val roomVersion = "2.5.0"
|
||||||
|
|
||||||
const val ktorVersion = "2.3.3"
|
const val ktorVersion = "2.3.3"
|
||||||
}
|
}
|
42
kritor/.gitignore
vendored
Normal file
42
kritor/.gitignore
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
.gradle
|
||||||
|
build/
|
||||||
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
76
kritor/build.gradle.kts
Normal file
76
kritor/build.gradle.kts
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("com.android.library")
|
||||||
|
id("org.jetbrains.kotlin.android")
|
||||||
|
id("com.google.protobuf") version "0.9.4"
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "moe.whitechi73.kritor"
|
||||||
|
compileSdk = 34
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdk = 24
|
||||||
|
|
||||||
|
consumerProguardFiles("consumer-rules.pro")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = false
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
protobuf(files("kritor/protos"))
|
||||||
|
|
||||||
|
implementation("com.google.protobuf:protobuf-java:4.26.0")
|
||||||
|
|
||||||
|
implementation(kotlinx("coroutines-core", "1.8.0"))
|
||||||
|
|
||||||
|
implementation(grpc("stub", "1.62.2"))
|
||||||
|
implementation(grpc("protobuf", "1.62.2"))
|
||||||
|
implementation(grpc("kotlin-stub", "1.4.1"))
|
||||||
|
}
|
||||||
|
|
||||||
|
protobuf {
|
||||||
|
protoc {
|
||||||
|
artifact = "com.google.protobuf:protoc:4.26.0"
|
||||||
|
}
|
||||||
|
plugins {
|
||||||
|
create("grpc") {
|
||||||
|
artifact = "io.grpc:protoc-gen-grpc-java:1.62.2"
|
||||||
|
}
|
||||||
|
create("grpckt") {
|
||||||
|
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.4.1:jdk8@jar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
generateProtoTasks {
|
||||||
|
all().forEach {
|
||||||
|
it.plugins {
|
||||||
|
create("grpc")
|
||||||
|
create("grpckt")
|
||||||
|
}
|
||||||
|
it.builtins {
|
||||||
|
create("java")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile>().configureEach {
|
||||||
|
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
|
||||||
|
}
|
0
kritor/consumer-rules.pro
Normal file
0
kritor/consumer-rules.pro
Normal file
1
kritor/kritor
Submodule
1
kritor/kritor
Submodule
Submodule kritor/kritor added at 3dec747a8e
21
kritor/proguard-rules.pro
vendored
Normal file
21
kritor/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
@ -15,7 +15,7 @@ dependencies {
|
|||||||
implementation("com.google.devtools.ksp:symbol-processing-api:1.9.21-1.0.15")
|
implementation("com.google.devtools.ksp:symbol-processing-api:1.9.21-1.0.15")
|
||||||
implementation("com.squareup:kotlinpoet:1.14.2")
|
implementation("com.squareup:kotlinpoet:1.14.2")
|
||||||
|
|
||||||
implementation(DEPENDENCY_PROTOBUF)
|
//implementation(DEPENDENCY_PROTOBUF)
|
||||||
implementation(kotlinx("serialization-protobuf", "1.6.2"))
|
implementation(kotlinx("serialization-protobuf", "1.6.2"))
|
||||||
|
|
||||||
ksp("dev.zacsweers.autoservice:auto-service-ksp:1.1.0")
|
ksp("dev.zacsweers.autoservice:auto-service-ksp:1.1.0")
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
@file:Suppress("UNCHECKED_CAST")
|
||||||
|
@file:OptIn(KspExperimental::class)
|
||||||
|
|
||||||
|
package moe.fuqiuluo.ksp.impl
|
||||||
|
|
||||||
|
import com.google.devtools.ksp.KspExperimental
|
||||||
|
import com.google.devtools.ksp.getAnnotationsByType
|
||||||
|
import com.google.devtools.ksp.processing.*
|
||||||
|
import com.google.devtools.ksp.symbol.KSAnnotated
|
||||||
|
import com.google.devtools.ksp.symbol.KSFunctionDeclaration
|
||||||
|
import com.squareup.kotlinpoet.FileSpec
|
||||||
|
import com.squareup.kotlinpoet.FunSpec
|
||||||
|
import com.squareup.kotlinpoet.KModifier
|
||||||
|
import kritor.service.Grpc
|
||||||
|
|
||||||
|
class GrpcProcessor(
|
||||||
|
private val codeGenerator: CodeGenerator,
|
||||||
|
private val logger: KSPLogger
|
||||||
|
): SymbolProcessor {
|
||||||
|
override fun process(resolver: Resolver): List<KSAnnotated> {
|
||||||
|
val symbols = resolver.getSymbolsWithAnnotation(Grpc::class.qualifiedName!!)
|
||||||
|
val actions = (symbols as Sequence<KSFunctionDeclaration>).toList()
|
||||||
|
|
||||||
|
if (actions.isEmpty()) return emptyList()
|
||||||
|
|
||||||
|
// 怎么返回nullable的结果
|
||||||
|
val packageName = "kritor.handlers"
|
||||||
|
val funcBuilder = FunSpec.builder("handleGrpc")
|
||||||
|
.addModifiers(KModifier.SUSPEND)
|
||||||
|
.addParameter("cmd", String::class)
|
||||||
|
.addParameter("data", ByteArray::class)
|
||||||
|
.returns(ByteArray::class)
|
||||||
|
val fileSpec = FileSpec.scriptBuilder("AutoGrpcHandlers", packageName)
|
||||||
|
|
||||||
|
logger.warn("Found ${actions.size} grpc-actions")
|
||||||
|
|
||||||
|
//logger.error(resolver.getClassDeclarationByName("io.kritor.AuthReq").toString())
|
||||||
|
//logger.error(resolver.getJavaClassByName("io.kritor.AuthReq").toString())
|
||||||
|
//logger.error(resolver.getKotlinClassByName("io.kritor.AuthReq").toString())
|
||||||
|
|
||||||
|
actions.forEach { action ->
|
||||||
|
val methodName = action.qualifiedName?.asString()!!
|
||||||
|
val grpcMethod = action.getAnnotationsByType(Grpc::class).first()
|
||||||
|
val service = grpcMethod.serviceName
|
||||||
|
val funcName = grpcMethod.funcName
|
||||||
|
funcBuilder.addStatement("if (cmd == \"${service}.${funcName}\") {\t")
|
||||||
|
|
||||||
|
val reqType = action.parameters[0].type.toString()
|
||||||
|
val rspType = action.returnType.toString()
|
||||||
|
funcBuilder.addStatement("val resp: $rspType = $methodName($reqType.parseFrom(data))")
|
||||||
|
funcBuilder.addStatement("return resp.toByteArray()")
|
||||||
|
|
||||||
|
funcBuilder.addStatement("}")
|
||||||
|
}
|
||||||
|
funcBuilder.addStatement("return EMPTY_BYTE_ARRAY")
|
||||||
|
fileSpec
|
||||||
|
.addStatement("import io.kritor.authentication.*")
|
||||||
|
.addStatement("import io.kritor.core.*")
|
||||||
|
.addStatement("import io.kritor.customization.*")
|
||||||
|
.addStatement("import io.kritor.developer.*")
|
||||||
|
.addStatement("import io.kritor.file.*")
|
||||||
|
.addStatement("import io.kritor.friend.*")
|
||||||
|
.addStatement("import io.kritor.group.*")
|
||||||
|
.addStatement("import io.kritor.guild.*")
|
||||||
|
.addStatement("import io.kritor.message.*")
|
||||||
|
.addStatement("import io.kritor.web.*")
|
||||||
|
.addFunction(funcBuilder.build())
|
||||||
|
.addImport("moe.fuqiuluo.symbols", "EMPTY_BYTE_ARRAY")
|
||||||
|
runCatching {
|
||||||
|
codeGenerator.createNewFile(
|
||||||
|
dependencies = Dependencies(aggregating = false),
|
||||||
|
packageName = packageName,
|
||||||
|
fileName = fileSpec.name
|
||||||
|
).use { outputStream ->
|
||||||
|
outputStream.writer().use {
|
||||||
|
fileSpec.build().writeTo(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package moe.fuqiuluo.ksp.providers
|
||||||
|
|
||||||
|
import com.google.auto.service.AutoService
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessor
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
|
||||||
|
import com.google.devtools.ksp.processing.SymbolProcessorProvider
|
||||||
|
import moe.fuqiuluo.ksp.impl.GrpcProcessor
|
||||||
|
|
||||||
|
@AutoService(SymbolProcessorProvider::class)
|
||||||
|
class GrpcProvider: SymbolProcessorProvider {
|
||||||
|
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
|
||||||
|
return GrpcProcessor(
|
||||||
|
environment.codeGenerator,
|
||||||
|
environment.logger
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -37,7 +37,6 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(DEPENDENCY_PROTOBUF)
|
|
||||||
implementation(kotlinx("serialization-protobuf", "1.6.2"))
|
implementation(kotlinx("serialization-protobuf", "1.6.2"))
|
||||||
implementation(kotlinx("serialization-json", "1.6.2"))
|
implementation(kotlinx("serialization-json", "1.6.2"))
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ data class ButtonExtra(
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class Object1(
|
data class Object1(
|
||||||
@ProtoNumber(1) val rows: List<Row>? = null,
|
@ProtoNumber(1) val rows: List<Row>? = null,
|
||||||
@ProtoNumber(2) val appid: Int? = null,
|
@ProtoNumber(2) val appid: ULong? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -8,7 +8,9 @@ import moe.fuqiuluo.symbols.Protobuf
|
|||||||
data class TrpcOidb(
|
data class TrpcOidb(
|
||||||
@ProtoNumber(1) val cmd: Int = Int.MIN_VALUE,
|
@ProtoNumber(1) val cmd: Int = Int.MIN_VALUE,
|
||||||
@ProtoNumber(2) val service: Int = Int.MIN_VALUE,
|
@ProtoNumber(2) val service: Int = Int.MIN_VALUE,
|
||||||
@ProtoNumber(4) val buffer: ByteArray,
|
@ProtoNumber(3) val result: UInt? = null,
|
||||||
|
@ProtoNumber(4) val buffer: ByteArray? = null,
|
||||||
|
@ProtoNumber(5) val msg: String? = null,
|
||||||
//@ProtoNumber(11) val traceParams: Map<String, String> = mapOf(),
|
//@ProtoNumber(11) val traceParams: Map<String, String> = mapOf(),
|
||||||
@ProtoNumber(12) val flag: Int = Int.MIN_VALUE,
|
@ProtoNumber(12) val flag: Int = Int.MIN_VALUE,
|
||||||
): Protobuf<TrpcOidb>
|
): Protobuf<TrpcOidb>
|
@ -94,7 +94,8 @@ data class DeleteReq(
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class DownloadRkeyReq(
|
data class DownloadRkeyReq(
|
||||||
@ProtoNumber(1) val types: List<Int>
|
@ProtoNumber(1) val types: List<Int>,
|
||||||
|
@ProtoNumber(2) val downloadType: Int
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@file:OptIn(ExperimentalSerializationApi::class)
|
@file:OptIn(ExperimentalSerializationApi::class)
|
||||||
package protobuf.oidb.cmd0x11c5
|
package protobuf.oidb.cmd0x11c5
|
||||||
|
|
||||||
import com.google.protobuf.Internal.EMPTY_BYTE_ARRAY
|
import moe.fuqiuluo.symbols.EMPTY_BYTE_ARRAY
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.protobuf.ProtoNumber
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
@ -9,7 +9,7 @@ import moe.fuqiuluo.symbols.Protobuf
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class NtV2RichMediaRsp(
|
data class NtV2RichMediaRsp(
|
||||||
@ProtoNumber(1) val head: RspHead,
|
@ProtoNumber(1) val head: RspHead?,
|
||||||
@ProtoNumber(2) val upload: UploadRsp?,
|
@ProtoNumber(2) val upload: UploadRsp?,
|
||||||
@ProtoNumber(3) val download: DownloadRsp?,
|
@ProtoNumber(3) val download: DownloadRsp?,
|
||||||
@ProtoNumber(4) val downloadRkeyRsp: DownloadRkeyRsp?,
|
@ProtoNumber(4) val downloadRkeyRsp: DownloadRkeyRsp?,
|
||||||
@ -52,11 +52,11 @@ data class DownloadRkeyRsp(
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RKeyInfo(
|
data class RKeyInfo(
|
||||||
@ProtoNumber(1) val rkey: String?,
|
@ProtoNumber(1) val rkey: String,
|
||||||
@ProtoNumber(2) val rkeyTtlSec: ULong?,
|
@ProtoNumber(2) val rkeyTtlSec: ULong?,
|
||||||
@ProtoNumber(3) val storeId: UInt = 0u,
|
@ProtoNumber(3) val storeId: UInt = 0u,
|
||||||
@ProtoNumber(4) val rkeyCreateTime: UInt?,
|
@ProtoNumber(4) val rkeyCreateTime: UInt?,
|
||||||
@ProtoNumber(4) val type: UInt?,
|
@ProtoNumber(4) val type: UInt,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package protobuf.oidb.cmd0x388
|
package protobuf.oidb.cmd0x388
|
||||||
|
|
||||||
import com.google.protobuf.Internal.EMPTY_BYTE_ARRAY
|
import moe.fuqiuluo.symbols.EMPTY_BYTE_ARRAY
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.protobuf.ProtoNumber
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
import moe.fuqiuluo.symbols.Protobuf
|
import moe.fuqiuluo.symbols.Protobuf
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
package protobuf.oidb.cmd0x388
|
package protobuf.oidb.cmd0x388
|
||||||
|
|
||||||
import com.google.protobuf.Internal.EMPTY_BYTE_ARRAY
|
import moe.fuqiuluo.symbols.EMPTY_BYTE_ARRAY
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.protobuf.ProtoNumber
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.tencent.qphone.base.util;
|
package com.tencent.qphone.base.util;
|
||||||
|
|
||||||
public abstract class CodecWarpper {
|
public abstract class CodecWarpper {
|
||||||
public abstract void onResponse(int i2, Object obj, int i3);
|
// public abstract void onResponse(int i2, Object obj, int i3);
|
||||||
|
|
||||||
|
public abstract void onInvalidData(int i2, int i3, String str);
|
||||||
|
|
||||||
public abstract void onResponse(int i2, Object obj, int i3, byte[] bArr);
|
public abstract void onResponse(int i2, Object obj, int i3, byte[] bArr);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.tencent.qqnt.aio.api;
|
package com.tencent.qqnt.aio.api;
|
||||||
|
|
||||||
import com.tencent.mobileqq.qroute.QRouteApi;
|
import com.tencent.mobileqq.qroute.QRouteApi;
|
||||||
import com.tencent.qqnt.kernel.nativeinterface.Contact;
|
import com.tencent.qqnt.kernelpublic.nativeinterface.Contact;
|
||||||
import com.tencent.qqnt.kernel.nativeinterface.IOperateCallback;
|
import com.tencent.qqnt.kernel.nativeinterface.IOperateCallback;
|
||||||
|
|
||||||
public interface IAIOFileTransfer extends QRouteApi {
|
public interface IAIOFileTransfer extends QRouteApi {
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
package com.tencent.qqnt.kernel.api.impl;
|
||||||
|
|
||||||
|
public class GroupService {
|
||||||
|
}
|
@ -18,6 +18,11 @@ public class MsgService {
|
|||||||
public void addMsgListener(IKernelMsgListener listener) {
|
public void addMsgListener(IKernelMsgListener listener) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeMsgListener(@NotNull IKernelMsgListener iKernelMsgListener) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getRichMediaFilePathForGuild(@NotNull RichMediaFilePathInfo richMediaFilePathInfo) {
|
public String getRichMediaFilePathForGuild(@NotNull RichMediaFilePathInfo richMediaFilePathInfo) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.tencent.qqnt.kernel.nativeinterface;
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import com.tencent.qqnt.kernelpublic.nativeinterface.Contact;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public class GProGuildTopFeedMsg {
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.tencent.qqnt.kernel.nativeinterface;
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import com.tencent.qqnt.kernelpublic.nativeinterface.Contact;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class GroupMemberCommonListResult {
|
||||||
|
public long groupCode;
|
||||||
|
public int identifyFlag;
|
||||||
|
public long startUin;
|
||||||
|
public ArrayList<MemberCommonInfo> memberList = new ArrayList<>();
|
||||||
|
public String strErrorInfo = "";
|
||||||
|
|
||||||
|
public long getGroupCode() {
|
||||||
|
return this.groupCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIdentifyFlag() {
|
||||||
|
return this.identifyFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<MemberCommonInfo> getMemberList() {
|
||||||
|
return this.memberList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getStartUin() {
|
||||||
|
return this.startUin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStrErrorInfo() {
|
||||||
|
return this.strErrorInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "GroupMemberCommonListResult{groupCode=" + this.groupCode + ",startUin=" + this.startUin + ",identifyFlag=" + this.identifyFlag + ",memberList=" + this.memberList + ",strErrorInfo=" + this.strErrorInfo + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class GroupMemberCommonReq {
|
||||||
|
public long groupCode;
|
||||||
|
public int sourceType;
|
||||||
|
public String startUin = "";
|
||||||
|
public String identifyFlag = "";
|
||||||
|
public ArrayList<Long> uinList = new ArrayList<>();
|
||||||
|
public MemberCommonInfoFilter memberCommonFilter = new MemberCommonInfoFilter();
|
||||||
|
public String memberNum = "";
|
||||||
|
public String filterMethod = "";
|
||||||
|
public String onlineFlag = "";
|
||||||
|
public String realSpecialTitleFlag = "";
|
||||||
|
|
||||||
|
public String getFilterMethod() {
|
||||||
|
return this.filterMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getGroupCode() {
|
||||||
|
return this.groupCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIdentifyFlag() {
|
||||||
|
return this.identifyFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MemberCommonInfoFilter getMemberCommonFilter() {
|
||||||
|
return this.memberCommonFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMemberNum() {
|
||||||
|
return this.memberNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOnlineFlag() {
|
||||||
|
return this.onlineFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRealSpecialTitleFlag() {
|
||||||
|
return this.realSpecialTitleFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSourceType() {
|
||||||
|
return this.sourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStartUin() {
|
||||||
|
return this.startUin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Long> getUinList() {
|
||||||
|
return this.uinList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilterMethod(String str) {
|
||||||
|
this.filterMethod = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupCode(long j2) {
|
||||||
|
this.groupCode = j2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdentifyFlag(String str) {
|
||||||
|
this.identifyFlag = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberCommonFilter(MemberCommonInfoFilter memberCommonInfoFilter) {
|
||||||
|
this.memberCommonFilter = memberCommonInfoFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberNum(String str) {
|
||||||
|
this.memberNum = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnlineFlag(String str) {
|
||||||
|
this.onlineFlag = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRealSpecialTitleFlag(String str) {
|
||||||
|
this.realSpecialTitleFlag = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceType(int i2) {
|
||||||
|
this.sourceType = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartUin(String str) {
|
||||||
|
this.startUin = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUinList(ArrayList<Long> arrayList) {
|
||||||
|
this.uinList = arrayList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "GroupMemberCommonReq{groupCode=" + this.groupCode + ",startUin=" + this.startUin + ",identifyFlag=" + this.identifyFlag + ",uinList=" + this.uinList + ",memberCommonFilter=" + this.memberCommonFilter + ",memberNum=" + this.memberNum + ",filterMethod=" + this.filterMethod + ",onlineFlag=" + this.onlineFlag + ",realSpecialTitleFlag=" + this.realSpecialTitleFlag + ",sourceType=" + this.sourceType + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class GroupMemberExtListResult {
|
||||||
|
public long dataTime;
|
||||||
|
public long endUin;
|
||||||
|
public long groupCode;
|
||||||
|
public int levelNameSeq;
|
||||||
|
public int memberInfoSeq;
|
||||||
|
public int sysShowFlag;
|
||||||
|
public int timeToUpdate;
|
||||||
|
public int userShowFlag;
|
||||||
|
public int userShowFlagNew;
|
||||||
|
public ArrayList<MemberExtInfo> memberLevelInfo = new ArrayList<>();
|
||||||
|
public ArrayList<MemberLevelName> msgLevelName = new ArrayList<>();
|
||||||
|
public String strOwnerName = "";
|
||||||
|
public String strAdminName = "";
|
||||||
|
public ArrayList<MemberLevelName> msgLevelNameNew = new ArrayList<>();
|
||||||
|
|
||||||
|
public long getDataTime() {
|
||||||
|
return this.dataTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getEndUin() {
|
||||||
|
return this.endUin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getGroupCode() {
|
||||||
|
return this.groupCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevelNameSeq() {
|
||||||
|
return this.levelNameSeq;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberInfoSeq() {
|
||||||
|
return this.memberInfoSeq;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<MemberExtInfo> getMemberLevelInfo() {
|
||||||
|
return this.memberLevelInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<MemberLevelName> getMsgLevelName() {
|
||||||
|
return this.msgLevelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<MemberLevelName> getMsgLevelNameNew() {
|
||||||
|
return this.msgLevelNameNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStrAdminName() {
|
||||||
|
return this.strAdminName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStrOwnerName() {
|
||||||
|
return this.strOwnerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSysShowFlag() {
|
||||||
|
return this.sysShowFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimeToUpdate() {
|
||||||
|
return this.timeToUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserShowFlag() {
|
||||||
|
return this.userShowFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserShowFlagNew() {
|
||||||
|
return this.userShowFlagNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "GroupMemberExtListResult{groupCode=" + this.groupCode + ",memberLevelInfo=" + this.memberLevelInfo + ",msgLevelName=" + this.msgLevelName + ",endUin=" + this.endUin + ",dataTime=" + this.dataTime + ",userShowFlag=" + this.userShowFlag + ",sysShowFlag=" + this.sysShowFlag + ",timeToUpdate=" + this.timeToUpdate + ",strOwnerName=" + this.strOwnerName + ",strAdminName=" + this.strAdminName + ",levelNameSeq=" + this.levelNameSeq + ",userShowFlagNew=" + this.userShowFlagNew + ",msgLevelNameNew=" + this.msgLevelNameNew + ",memberInfoSeq=" + this.memberInfoSeq + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class GroupMemberExtReq {
|
||||||
|
public long groupCode;
|
||||||
|
public int sourceType;
|
||||||
|
public String beginUin = "";
|
||||||
|
public String dataTime = "";
|
||||||
|
public ArrayList<Long> uinList = new ArrayList<>();
|
||||||
|
public MemberExtInfoFilter memberExtFilter = new MemberExtInfoFilter();
|
||||||
|
public String seq = "";
|
||||||
|
public String uinNum = "";
|
||||||
|
public String groupType = "";
|
||||||
|
public String richCardNameVer = "";
|
||||||
|
|
||||||
|
public String getBeginUin() {
|
||||||
|
return this.beginUin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDataTime() {
|
||||||
|
return this.dataTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getGroupCode() {
|
||||||
|
return this.groupCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupType() {
|
||||||
|
return this.groupType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MemberExtInfoFilter getMemberExtFilter() {
|
||||||
|
return this.memberExtFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRichCardNameVer() {
|
||||||
|
return this.richCardNameVer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSeq() {
|
||||||
|
return this.seq;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSourceType() {
|
||||||
|
return this.sourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Long> getUinList() {
|
||||||
|
return this.uinList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUinNum() {
|
||||||
|
return this.uinNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeginUin(String str) {
|
||||||
|
this.beginUin = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataTime(String str) {
|
||||||
|
this.dataTime = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupCode(long j2) {
|
||||||
|
this.groupCode = j2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupType(String str) {
|
||||||
|
this.groupType = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberExtFilter(MemberExtInfoFilter memberExtInfoFilter) {
|
||||||
|
this.memberExtFilter = memberExtInfoFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRichCardNameVer(String str) {
|
||||||
|
this.richCardNameVer = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeq(String str) {
|
||||||
|
this.seq = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceType(int i2) {
|
||||||
|
this.sourceType = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUinList(ArrayList<Long> arrayList) {
|
||||||
|
this.uinList = arrayList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUinNum(String str) {
|
||||||
|
this.uinNum = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "GroupMemberExtReq{groupCode=" + this.groupCode + ",beginUin=" + this.beginUin + ",dataTime=" + this.dataTime + ",uinList=" + this.uinList + ",memberExtFilter=" + this.memberExtFilter + ",seq=" + this.seq + ",uinNum=" + this.uinNum + ",groupType=" + this.groupType + ",richCardNameVer=" + this.richCardNameVer + ",sourceType=" + this.sourceType + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class GroupMemberListResult {
|
||||||
|
public boolean finish;
|
||||||
|
public boolean hasRobot;
|
||||||
|
public ArrayList<GroupMemberInfoListId> ids = new ArrayList<>();
|
||||||
|
public HashMap<String, MemberInfo> infos = new HashMap<>();
|
||||||
|
|
||||||
|
public boolean getFinish() {
|
||||||
|
return this.finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHasRobot() {
|
||||||
|
return this.hasRobot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<GroupMemberInfoListId> getIds() {
|
||||||
|
return this.ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, MemberInfo> getInfos() {
|
||||||
|
return this.infos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "GroupMemberListResult{ids=" + this.ids + ",infos=" + this.infos + ",finish=" + this.finish + ",hasRobot=" + this.hasRobot + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public interface IGroupMemberCommonCallback {
|
||||||
|
void onResult(int i2, String str, GroupMemberCommonListResult groupMemberCommonListResult);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public interface IGroupMemberExtCallback {
|
||||||
|
void onResult(int i2, String str, GroupMemberExtListResult groupMemberExtListResult);
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public interface IGroupMemberListCallback {
|
||||||
|
void onResult(int result, String str, GroupMemberListResult groupMemberListResult);
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,25 @@
|
|||||||
package com.tencent.qqnt.kernel.nativeinterface;
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public interface IKernelGroupService {
|
public interface IKernelGroupService {
|
||||||
void getTransferableMemberInfo(long uin, IGetTransferableMemberCallback cb);
|
void getTransferableMemberInfo(long uin, IGetTransferableMemberCallback cb);
|
||||||
|
|
||||||
long addKernelGroupListener(IKernelGroupListener ln);
|
long addKernelGroupListener(IKernelGroupListener ln);
|
||||||
|
|
||||||
|
void getAllMemberList(long groupCode, boolean refresh, IGroupMemberListCallback iGroupMemberListCallback);
|
||||||
|
|
||||||
|
void getMemberCommonInfo(GroupMemberCommonReq groupMemberCommonReq, IGroupMemberCommonCallback iGroupMemberCommonCallback);
|
||||||
|
|
||||||
|
void getMemberExtInfo(GroupMemberExtReq groupMemberExtReq, IGroupMemberExtCallback iGroupMemberExtCallback);
|
||||||
|
|
||||||
|
void getMemberInfo(long j2, ArrayList<String> arrayList, boolean z, IOperateCallback iOperateCallback);
|
||||||
|
|
||||||
|
void getMemberInfoForMqq(long groupCode, ArrayList<String> uids, boolean z, IGroupMemberListCallback iGroupMemberListCallback);
|
||||||
|
|
||||||
|
void getNextMemberList(String sceneId, GroupMemberInfoListId groupMemberInfoListId, int i2, IGroupMemberListCallback iGroupMemberListCallback);
|
||||||
|
|
||||||
|
void getPrevMemberList(String sceneId, GroupMemberInfoListId groupMemberInfoListId, int i2, IGroupMemberListCallback iGroupMemberListCallback);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.tencent.qqnt.kernel.nativeinterface;
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import com.tencent.qqnt.kernelpublic.nativeinterface.Contact;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -16,7 +18,7 @@ public interface IKernelMsgListener {
|
|||||||
|
|
||||||
void onCustomWithdrawConfigUpdate(CustomWithdrawConfig customWithdrawConfig);
|
void onCustomWithdrawConfigUpdate(CustomWithdrawConfig customWithdrawConfig);
|
||||||
|
|
||||||
void onDraftUpdate(Contact contact, ArrayList<MsgElement> arrayList, long j2);
|
void onDraftUpdate(Contact contact, ArrayList<MsgElement> arrayList, long j);
|
||||||
|
|
||||||
void onEmojiDownloadComplete(EmojiNotifyInfo emojiNotifyInfo);
|
void onEmojiDownloadComplete(EmojiNotifyInfo emojiNotifyInfo);
|
||||||
|
|
||||||
@ -30,7 +32,7 @@ public interface IKernelMsgListener {
|
|||||||
|
|
||||||
void onFirstViewGroupGuildMapping(ArrayList<FirstViewGroupGuildInfo> arrayList);
|
void onFirstViewGroupGuildMapping(ArrayList<FirstViewGroupGuildInfo> arrayList);
|
||||||
|
|
||||||
void onGrabPasswordRedBag(int i2, String str, int i3, RecvdOrder recvdOrder, MsgRecord msgRecord);
|
void onGrabPasswordRedBag(int i, String str, int i2, RecvdOrder recvdOrder, MsgRecord msgRecord);
|
||||||
|
|
||||||
void onGroupFileInfoAdd(GroupItem groupItem);
|
void onGroupFileInfoAdd(GroupItem groupItem);
|
||||||
|
|
||||||
@ -48,6 +50,8 @@ public interface IKernelMsgListener {
|
|||||||
|
|
||||||
void onGuildNotificationAbstractUpdate(GuildNotificationAbstractInfo guildNotificationAbstractInfo);
|
void onGuildNotificationAbstractUpdate(GuildNotificationAbstractInfo guildNotificationAbstractInfo);
|
||||||
|
|
||||||
|
void onGuildTopFeedUpdate(GProGuildTopFeedMsg gProGuildTopFeedMsg);
|
||||||
|
|
||||||
void onHitCsRelatedEmojiResult(DownloadRelateEmojiResultInfo downloadRelateEmojiResultInfo);
|
void onHitCsRelatedEmojiResult(DownloadRelateEmojiResultInfo downloadRelateEmojiResultInfo);
|
||||||
|
|
||||||
void onHitEmojiKeywordResult(HitRelatedEmojiWordsResult hitRelatedEmojiWordsResult);
|
void onHitEmojiKeywordResult(HitRelatedEmojiWordsResult hitRelatedEmojiWordsResult);
|
||||||
@ -62,7 +66,7 @@ public interface IKernelMsgListener {
|
|||||||
|
|
||||||
void onLineDev(ArrayList<DevInfo> arrayList);
|
void onLineDev(ArrayList<DevInfo> arrayList);
|
||||||
|
|
||||||
void onLogLevelChanged(long j2);
|
void onLogLevelChanged(long j);
|
||||||
|
|
||||||
void onMsgAbstractUpdate(ArrayList<MsgAbstract> arrayList);
|
void onMsgAbstractUpdate(ArrayList<MsgAbstract> arrayList);
|
||||||
|
|
||||||
@ -76,14 +80,16 @@ public interface IKernelMsgListener {
|
|||||||
|
|
||||||
void onMsgInfoListUpdate(ArrayList<MsgRecord> arrayList);
|
void onMsgInfoListUpdate(ArrayList<MsgRecord> arrayList);
|
||||||
|
|
||||||
void onMsgQRCodeStatusChanged(int i2);
|
void onMsgQRCodeStatusChanged(int i);
|
||||||
|
|
||||||
void onMsgRecall(int i2, String str, long j2);
|
void onMsgRecall(int i, String str, long j);
|
||||||
|
|
||||||
void onMsgSecurityNotify(MsgRecord msgRecord);
|
void onMsgSecurityNotify(MsgRecord msgRecord);
|
||||||
|
|
||||||
void onMsgSettingUpdate(MsgSetting msgSetting);
|
void onMsgSettingUpdate(MsgSetting msgSetting);
|
||||||
|
|
||||||
|
void onMsgWithRichLinkInfoUpdate(ArrayList<MsgRecord> arrayList);
|
||||||
|
|
||||||
void onNtFirstViewMsgSyncEnd();
|
void onNtFirstViewMsgSyncEnd();
|
||||||
|
|
||||||
void onNtMsgSyncEnd();
|
void onNtMsgSyncEnd();
|
||||||
@ -92,11 +98,11 @@ public interface IKernelMsgListener {
|
|||||||
|
|
||||||
void onReadFeedEventUpdate(FirstViewDirectMsgNotifyInfo firstViewDirectMsgNotifyInfo);
|
void onReadFeedEventUpdate(FirstViewDirectMsgNotifyInfo firstViewDirectMsgNotifyInfo);
|
||||||
|
|
||||||
void onRecvGroupGuildFlag(int i2);
|
void onRecvGroupGuildFlag(int i);
|
||||||
|
|
||||||
void onRecvMsg(ArrayList<MsgRecord> arrayList);
|
void onRecvMsg(ArrayList<MsgRecord> arrayList);
|
||||||
|
|
||||||
void onRecvMsgSvrRspTransInfo(long j2, Contact contact, int i2, int i3, String str, byte[] bArr);
|
void onRecvMsgSvrRspTransInfo(long j, Contact contact, int i, int i2, String str, byte[] bArr);
|
||||||
|
|
||||||
void onRecvOnlineFileMsg(ArrayList<MsgRecord> arrayList);
|
void onRecvOnlineFileMsg(ArrayList<MsgRecord> arrayList);
|
||||||
|
|
||||||
@ -104,7 +110,9 @@ public interface IKernelMsgListener {
|
|||||||
|
|
||||||
void onRecvSysMsg(ArrayList<Byte> arrayList);
|
void onRecvSysMsg(ArrayList<Byte> arrayList);
|
||||||
|
|
||||||
void onRecvUDCFlag(int i2);
|
void onRecvUDCFlag(int i);
|
||||||
|
|
||||||
|
void onRedTouchChanged();
|
||||||
|
|
||||||
void onRichMediaDownloadComplete(FileTransNotifyInfo fileTransNotifyInfo);
|
void onRichMediaDownloadComplete(FileTransNotifyInfo fileTransNotifyInfo);
|
||||||
|
|
||||||
@ -114,9 +122,9 @@ public interface IKernelMsgListener {
|
|||||||
|
|
||||||
void onSearchGroupFileInfoUpdate(SearchGroupFileResult searchGroupFileResult);
|
void onSearchGroupFileInfoUpdate(SearchGroupFileResult searchGroupFileResult);
|
||||||
|
|
||||||
void onSendMsgError(long j2, Contact contact, int i2, String str);
|
void onSendMsgError(long j, Contact contact, int i, String str);
|
||||||
|
|
||||||
void onSysMsgNotification(int i2, long j2, long j3, ArrayList<Byte> arrayList);
|
void onSysMsgNotification(int i, long j, long j2, boolean z, ArrayList<Byte> arrayList);
|
||||||
|
|
||||||
void onTempChatInfoUpdate(TempChatInfo tempChatInfo);
|
void onTempChatInfoUpdate(TempChatInfo tempChatInfo);
|
||||||
|
|
||||||
@ -128,9 +136,11 @@ public interface IKernelMsgListener {
|
|||||||
|
|
||||||
void onUserOnlineStatusChanged(boolean z);
|
void onUserOnlineStatusChanged(boolean z);
|
||||||
|
|
||||||
|
void onUserSecQualityChanged(QueryUserSecQualityRsp queryUserSecQualityRsp);
|
||||||
|
|
||||||
void onUserTabStatusChanged(ArrayList<TabStatusInfo> arrayList);
|
void onUserTabStatusChanged(ArrayList<TabStatusInfo> arrayList);
|
||||||
|
|
||||||
void onlineStatusBigIconDownloadPush(int i2, long j2, String str);
|
void onlineStatusBigIconDownloadPush(int i, long j, String str);
|
||||||
|
|
||||||
void onlineStatusSmallIconDownloadPush(int i2, long j2, String str);
|
void onlineStatusSmallIconDownloadPush(int i, long j, String str);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.tencent.qqnt.kernel.nativeinterface;
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import com.tencent.qqnt.kernelpublic.nativeinterface.Contact;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.tencent.qqnt.kernel.nativeinterface;
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import com.tencent.qqnt.kernelpublic.nativeinterface.Contact;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public interface IKernelRichMediaService {
|
public interface IKernelRichMediaService {
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public class MemberCommonInfo {
|
||||||
|
public long memberUin;
|
||||||
|
public int privilege;
|
||||||
|
public int shutUpTime;
|
||||||
|
public int uinFlag;
|
||||||
|
public int uinFlagExt;
|
||||||
|
public int uinMobileFlag;
|
||||||
|
|
||||||
|
public long getMemberUin() {
|
||||||
|
return this.memberUin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPrivilege() {
|
||||||
|
return this.privilege;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getShutUpTime() {
|
||||||
|
return this.shutUpTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUinFlag() {
|
||||||
|
return this.uinFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUinFlagExt() {
|
||||||
|
return this.uinFlagExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUinMobileFlag() {
|
||||||
|
return this.uinMobileFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberUin(long j2) {
|
||||||
|
this.memberUin = j2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrivilege(int i2) {
|
||||||
|
this.privilege = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShutUpTime(int i2) {
|
||||||
|
this.shutUpTime = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUinFlag(int i2) {
|
||||||
|
this.uinFlag = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUinFlagExt(int i2) {
|
||||||
|
this.uinFlagExt = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUinMobileFlag(int i2) {
|
||||||
|
this.uinMobileFlag = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "MemberCommonInfo{memberUin=" + this.memberUin + ",uinFlag=" + this.uinFlag + ",uinFlagExt=" + this.uinFlagExt + ",uinMobileFlag=" + this.uinMobileFlag + ",shutUpTime=" + this.shutUpTime + ",privilege=" + this.privilege + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public class MemberCommonInfoFilter {
|
||||||
|
public int memberUin;
|
||||||
|
public int privilege;
|
||||||
|
public int shutUpTime;
|
||||||
|
public int uinFlag;
|
||||||
|
public int uinFlagExt;
|
||||||
|
public int uinMobileFlag;
|
||||||
|
|
||||||
|
public int getMemberUin() {
|
||||||
|
return this.memberUin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPrivilege() {
|
||||||
|
return this.privilege;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getShutUpTime() {
|
||||||
|
return this.shutUpTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUinFlag() {
|
||||||
|
return this.uinFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUinFlagExt() {
|
||||||
|
return this.uinFlagExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUinMobileFlag() {
|
||||||
|
return this.uinMobileFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberUin(int i2) {
|
||||||
|
this.memberUin = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrivilege(int i2) {
|
||||||
|
this.privilege = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShutUpTime(int i2) {
|
||||||
|
this.shutUpTime = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUinFlag(int i2) {
|
||||||
|
this.uinFlag = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUinFlagExt(int i2) {
|
||||||
|
this.uinFlagExt = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUinMobileFlag(int i2) {
|
||||||
|
this.uinMobileFlag = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "MemberCommonInfoFilter{memberUin=" + this.memberUin + ",uinFlag=" + this.uinFlag + ",uinFlagExt=" + this.uinFlagExt + ",uinMobileFlag=" + this.uinMobileFlag + ",shutUpTime=" + this.shutUpTime + ",privilege=" + this.privilege + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class MemberExtInfo {
|
||||||
|
public int activeDay;
|
||||||
|
public int cmdUinFlagExt3Grocery;
|
||||||
|
public int level;
|
||||||
|
public int point;
|
||||||
|
public long specialTitleExpireTime;
|
||||||
|
public long uin;
|
||||||
|
public String strName = "";
|
||||||
|
public String nickName = "";
|
||||||
|
public String specialTitle = "";
|
||||||
|
public byte[] msgNeedField = new byte[0];
|
||||||
|
public ArrayList<MemberIcon> memberIconList = new ArrayList<>();
|
||||||
|
|
||||||
|
public int getActiveDay() {
|
||||||
|
return this.activeDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCmdUinFlagExt3Grocery() {
|
||||||
|
return this.cmdUinFlagExt3Grocery;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return this.level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<MemberIcon> getMemberIconList() {
|
||||||
|
return this.memberIconList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getMsgNeedField() {
|
||||||
|
return this.msgNeedField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickName() {
|
||||||
|
return this.nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPoint() {
|
||||||
|
return this.point;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpecialTitle() {
|
||||||
|
return this.specialTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSpecialTitleExpireTime() {
|
||||||
|
return this.specialTitleExpireTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStrName() {
|
||||||
|
return this.strName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUin() {
|
||||||
|
return this.uin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActiveDay(int i2) {
|
||||||
|
this.activeDay = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCmdUinFlagExt3Grocery(int i2) {
|
||||||
|
this.cmdUinFlagExt3Grocery = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevel(int i2) {
|
||||||
|
this.level = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberIconList(ArrayList<MemberIcon> arrayList) {
|
||||||
|
this.memberIconList = arrayList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsgNeedField(byte[] bArr) {
|
||||||
|
this.msgNeedField = bArr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickName(String str) {
|
||||||
|
this.nickName = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoint(int i2) {
|
||||||
|
this.point = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpecialTitle(String str) {
|
||||||
|
this.specialTitle = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpecialTitleExpireTime(long j2) {
|
||||||
|
this.specialTitleExpireTime = j2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStrName(String str) {
|
||||||
|
this.strName = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUin(long j2) {
|
||||||
|
this.uin = j2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "MemberExtInfo{uin=" + this.uin + ",point=" + this.point + ",activeDay=" + this.activeDay + ",level=" + this.level + ",strName=" + this.strName + ",nickName=" + this.nickName + ",specialTitle=" + this.specialTitle + ",specialTitleExpireTime=" + this.specialTitleExpireTime + ",msgNeedField=" + this.msgNeedField + ",cmdUinFlagExt3Grocery=" + this.cmdUinFlagExt3Grocery + ",memberIconList=" + this.memberIconList + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,171 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public class MemberExtInfoFilter {
|
||||||
|
public int cmdUinFlagExt3Grocery;
|
||||||
|
public int dataTime;
|
||||||
|
public int levelName;
|
||||||
|
public int levelNameNew;
|
||||||
|
public int memberIcon;
|
||||||
|
public int memberInfoSeq;
|
||||||
|
public int memberLevelInfoActiveDay;
|
||||||
|
public int memberLevelInfoLevel;
|
||||||
|
public int memberLevelInfoName;
|
||||||
|
public int memberLevelInfoPoint;
|
||||||
|
public int memberLevelInfoUin;
|
||||||
|
public int msgNeedField;
|
||||||
|
public int nickName;
|
||||||
|
public int specialTitle;
|
||||||
|
public int sysShowFlag;
|
||||||
|
public int timeToUpdate;
|
||||||
|
public int userShowFlag;
|
||||||
|
public int userShowFlagNew;
|
||||||
|
|
||||||
|
public int getCmdUinFlagExt3Grocery() {
|
||||||
|
return this.cmdUinFlagExt3Grocery;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDataTime() {
|
||||||
|
return this.dataTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevelName() {
|
||||||
|
return this.levelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevelNameNew() {
|
||||||
|
return this.levelNameNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberIcon() {
|
||||||
|
return this.memberIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberInfoSeq() {
|
||||||
|
return this.memberInfoSeq;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberLevelInfoActiveDay() {
|
||||||
|
return this.memberLevelInfoActiveDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberLevelInfoLevel() {
|
||||||
|
return this.memberLevelInfoLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberLevelInfoName() {
|
||||||
|
return this.memberLevelInfoName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberLevelInfoPoint() {
|
||||||
|
return this.memberLevelInfoPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberLevelInfoUin() {
|
||||||
|
return this.memberLevelInfoUin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMsgNeedField() {
|
||||||
|
return this.msgNeedField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNickName() {
|
||||||
|
return this.nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSpecialTitle() {
|
||||||
|
return this.specialTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSysShowFlag() {
|
||||||
|
return this.sysShowFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimeToUpdate() {
|
||||||
|
return this.timeToUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserShowFlag() {
|
||||||
|
return this.userShowFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserShowFlagNew() {
|
||||||
|
return this.userShowFlagNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCmdUinFlagExt3Grocery(int i2) {
|
||||||
|
this.cmdUinFlagExt3Grocery = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataTime(int i2) {
|
||||||
|
this.dataTime = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevelName(int i2) {
|
||||||
|
this.levelName = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevelNameNew(int i2) {
|
||||||
|
this.levelNameNew = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberIcon(int i2) {
|
||||||
|
this.memberIcon = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberInfoSeq(int i2) {
|
||||||
|
this.memberInfoSeq = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberLevelInfoActiveDay(int i2) {
|
||||||
|
this.memberLevelInfoActiveDay = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberLevelInfoLevel(int i2) {
|
||||||
|
this.memberLevelInfoLevel = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberLevelInfoName(int i2) {
|
||||||
|
this.memberLevelInfoName = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberLevelInfoPoint(int i2) {
|
||||||
|
this.memberLevelInfoPoint = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberLevelInfoUin(int i2) {
|
||||||
|
this.memberLevelInfoUin = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsgNeedField(int i2) {
|
||||||
|
this.msgNeedField = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickName(int i2) {
|
||||||
|
this.nickName = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpecialTitle(int i2) {
|
||||||
|
this.specialTitle = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSysShowFlag(int i2) {
|
||||||
|
this.sysShowFlag = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeToUpdate(int i2) {
|
||||||
|
this.timeToUpdate = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserShowFlag(int i2) {
|
||||||
|
this.userShowFlag = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserShowFlagNew(int i2) {
|
||||||
|
this.userShowFlagNew = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "MemberExtInfoFilter{memberLevelInfoUin=" + this.memberLevelInfoUin + ",memberLevelInfoPoint=" + this.memberLevelInfoPoint + ",memberLevelInfoActiveDay=" + this.memberLevelInfoActiveDay + ",memberLevelInfoLevel=" + this.memberLevelInfoLevel + ",memberLevelInfoName=" + this.memberLevelInfoName + ",levelName=" + this.levelName + ",dataTime=" + this.dataTime + ",userShowFlag=" + this.userShowFlag + ",sysShowFlag=" + this.sysShowFlag + ",timeToUpdate=" + this.timeToUpdate + ",nickName=" + this.nickName + ",specialTitle=" + this.specialTitle + ",levelNameNew=" + this.levelNameNew + ",userShowFlagNew=" + this.userShowFlagNew + ",msgNeedField=" + this.msgNeedField + ",cmdUinFlagExt3Grocery=" + this.cmdUinFlagExt3Grocery + ",memberIcon=" + this.memberIcon + ",memberInfoSeq=" + this.memberInfoSeq + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public class MemberIcon {
|
||||||
|
public int bizId;
|
||||||
|
public byte[] exInfo = new byte[0];
|
||||||
|
public long expireTime;
|
||||||
|
public int resId;
|
||||||
|
|
||||||
|
public int getBizId() {
|
||||||
|
return this.bizId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getExInfo() {
|
||||||
|
return this.exInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpireTime() {
|
||||||
|
return this.expireTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getResId() {
|
||||||
|
return this.resId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "MemberIcon{resId=" + this.resId + ",expireTime=" + this.expireTime + ",bizId=" + this.bizId + ",exInfo=" + this.exInfo + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,51 +1,146 @@
|
|||||||
package com.tencent.qqnt.kernel.nativeinterface;
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
public final class MemberInfo implements IKernelModel {
|
import com.tencent.qqnt.kernelpublic.nativeinterface.MemberRole;
|
||||||
String avatarPath;
|
|
||||||
String cardName;
|
|
||||||
int cardType;
|
|
||||||
boolean isDelete;
|
|
||||||
boolean isSpecialConcerned;
|
|
||||||
String nick;
|
|
||||||
String qid;
|
|
||||||
String remark;
|
|
||||||
MemberRole role;
|
|
||||||
long serialVersionUID;
|
|
||||||
int shutUpTime;
|
|
||||||
String uid;
|
|
||||||
long uin;
|
|
||||||
|
|
||||||
public MemberInfo() {
|
public final class MemberInfo implements IKernelModel {
|
||||||
this.serialVersionUID = 1L;
|
public int bigClubFlag;
|
||||||
this.uid = "";
|
public int bigClubLevel;
|
||||||
this.qid = "";
|
public int cardNameId;
|
||||||
this.nick = "";
|
public int cardType;
|
||||||
this.remark = "";
|
public int creditLevel;
|
||||||
this.cardName = "";
|
public int globalGroupLevel;
|
||||||
this.role = MemberRole.values()[0];
|
public int globalGroupPoint;
|
||||||
this.avatarPath = "";
|
public boolean isDelete;
|
||||||
|
public boolean isRobot;
|
||||||
|
public boolean isSpecialConcerned;
|
||||||
|
public boolean isSpecialShielded;
|
||||||
|
public int joinTime;
|
||||||
|
public int lastSpeakTime;
|
||||||
|
public int memberFlag;
|
||||||
|
public int memberFlagExt;
|
||||||
|
public int memberFlagExt2;
|
||||||
|
public int memberLevel;
|
||||||
|
public int memberMobileFlag;
|
||||||
|
public int memberTitleId;
|
||||||
|
public int mssVipType;
|
||||||
|
public int richFlag;
|
||||||
|
public int shutUpTime;
|
||||||
|
public long specialTitleExpireTime;
|
||||||
|
public long uin;
|
||||||
|
public int userShowFlag;
|
||||||
|
public int userShowFlagNew;
|
||||||
|
long serialVersionUID = 1;
|
||||||
|
public String uid = "";
|
||||||
|
public String qid = "";
|
||||||
|
public String nick = "";
|
||||||
|
public String remark = "";
|
||||||
|
public String cardName = "";
|
||||||
|
public MemberRole role = MemberRole.values()[0];
|
||||||
|
public String avatarPath = "";
|
||||||
|
public byte[] groupHonor = new byte[0];
|
||||||
|
public String memberSpecialTitle = "";
|
||||||
|
public String autoRemark = "";
|
||||||
|
|
||||||
|
public String getAutoRemark() {
|
||||||
|
return this.autoRemark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAvatarPath() {
|
public String getAvatarPath() {
|
||||||
return this.avatarPath;
|
return this.avatarPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getBigClubFlag() {
|
||||||
|
return this.bigClubFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBigClubLevel() {
|
||||||
|
return this.bigClubLevel;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCardName() {
|
public String getCardName() {
|
||||||
return this.cardName;
|
return this.cardName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCardNameId() {
|
||||||
|
return this.cardNameId;
|
||||||
|
}
|
||||||
|
|
||||||
public int getCardType() {
|
public int getCardType() {
|
||||||
return this.cardType;
|
return this.cardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCreditLevel() {
|
||||||
|
return this.creditLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGlobalGroupLevel() {
|
||||||
|
return this.globalGroupLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGlobalGroupPoint() {
|
||||||
|
return this.globalGroupPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getGroupHonor() {
|
||||||
|
return this.groupHonor;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getIsDelete() {
|
public boolean getIsDelete() {
|
||||||
return this.isDelete;
|
return this.isDelete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getIsRobot() {
|
||||||
|
return this.isRobot;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getIsSpecialConcerned() {
|
public boolean getIsSpecialConcerned() {
|
||||||
return this.isSpecialConcerned;
|
return this.isSpecialConcerned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getIsSpecialShielded() {
|
||||||
|
return this.isSpecialShielded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getJoinTime() {
|
||||||
|
return this.joinTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLastSpeakTime() {
|
||||||
|
return this.lastSpeakTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberFlag() {
|
||||||
|
return this.memberFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberFlagExt() {
|
||||||
|
return this.memberFlagExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberFlagExt2() {
|
||||||
|
return this.memberFlagExt2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberLevel() {
|
||||||
|
return this.memberLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberMobileFlag() {
|
||||||
|
return this.memberMobileFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMemberSpecialTitle() {
|
||||||
|
return this.memberSpecialTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberTitleId() {
|
||||||
|
return this.memberTitleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMssVipType() {
|
||||||
|
return this.mssVipType;
|
||||||
|
}
|
||||||
|
|
||||||
public String getNick() {
|
public String getNick() {
|
||||||
return this.nick;
|
return this.nick;
|
||||||
}
|
}
|
||||||
@ -58,6 +153,10 @@ public final class MemberInfo implements IKernelModel {
|
|||||||
return this.remark;
|
return this.remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRichFlag() {
|
||||||
|
return this.richFlag;
|
||||||
|
}
|
||||||
|
|
||||||
public MemberRole getRole() {
|
public MemberRole getRole() {
|
||||||
return this.role;
|
return this.role;
|
||||||
}
|
}
|
||||||
@ -66,6 +165,10 @@ public final class MemberInfo implements IKernelModel {
|
|||||||
return this.shutUpTime;
|
return this.shutUpTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getSpecialTitleExpireTime() {
|
||||||
|
return this.specialTitleExpireTime;
|
||||||
|
}
|
||||||
|
|
||||||
public String getUid() {
|
public String getUid() {
|
||||||
return this.uid;
|
return this.uid;
|
||||||
}
|
}
|
||||||
@ -74,26 +177,114 @@ public final class MemberInfo implements IKernelModel {
|
|||||||
return this.uin;
|
return this.uin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getUserShowFlag() {
|
||||||
|
return this.userShowFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserShowFlagNew() {
|
||||||
|
return this.userShowFlagNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoRemark(String str) {
|
||||||
|
this.autoRemark = str;
|
||||||
|
}
|
||||||
|
|
||||||
public void setAvatarPath(String str) {
|
public void setAvatarPath(String str) {
|
||||||
this.avatarPath = str;
|
this.avatarPath = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBigClubFlag(int i2) {
|
||||||
|
this.bigClubFlag = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBigClubLevel(int i2) {
|
||||||
|
this.bigClubLevel = i2;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCardName(String str) {
|
public void setCardName(String str) {
|
||||||
this.cardName = str;
|
this.cardName = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCardNameId(int i2) {
|
||||||
|
this.cardNameId = i2;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCardType(int i2) {
|
public void setCardType(int i2) {
|
||||||
this.cardType = i2;
|
this.cardType = i2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCreditLevel(int i2) {
|
||||||
|
this.creditLevel = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGlobalGroupLevel(int i2) {
|
||||||
|
this.globalGroupLevel = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGlobalGroupPoint(int i2) {
|
||||||
|
this.globalGroupPoint = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupHonor(byte[] bArr) {
|
||||||
|
this.groupHonor = bArr;
|
||||||
|
}
|
||||||
|
|
||||||
public void setIsDelete(boolean z) {
|
public void setIsDelete(boolean z) {
|
||||||
this.isDelete = z;
|
this.isDelete = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIsRobot(boolean z) {
|
||||||
|
this.isRobot = z;
|
||||||
|
}
|
||||||
|
|
||||||
public void setIsSpecialConcerned(boolean z) {
|
public void setIsSpecialConcerned(boolean z) {
|
||||||
this.isSpecialConcerned = z;
|
this.isSpecialConcerned = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIsSpecialShielded(boolean z) {
|
||||||
|
this.isSpecialShielded = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJoinTime(int i2) {
|
||||||
|
this.joinTime = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastSpeakTime(int i2) {
|
||||||
|
this.lastSpeakTime = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberFlag(int i2) {
|
||||||
|
this.memberFlag = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberFlagExt(int i2) {
|
||||||
|
this.memberFlagExt = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberFlagExt2(int i2) {
|
||||||
|
this.memberFlagExt2 = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberLevel(int i2) {
|
||||||
|
this.memberLevel = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberMobileFlag(int i2) {
|
||||||
|
this.memberMobileFlag = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberSpecialTitle(String str) {
|
||||||
|
this.memberSpecialTitle = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberTitleId(int i2) {
|
||||||
|
this.memberTitleId = i2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMssVipType(int i2) {
|
||||||
|
this.mssVipType = i2;
|
||||||
|
}
|
||||||
|
|
||||||
public void setNick(String str) {
|
public void setNick(String str) {
|
||||||
this.nick = str;
|
this.nick = str;
|
||||||
}
|
}
|
||||||
@ -106,6 +297,10 @@ public final class MemberInfo implements IKernelModel {
|
|||||||
this.remark = str;
|
this.remark = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRichFlag(int i2) {
|
||||||
|
this.richFlag = i2;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRole(MemberRole memberRole) {
|
public void setRole(MemberRole memberRole) {
|
||||||
this.role = memberRole;
|
this.role = memberRole;
|
||||||
}
|
}
|
||||||
@ -114,6 +309,10 @@ public final class MemberInfo implements IKernelModel {
|
|||||||
this.shutUpTime = i2;
|
this.shutUpTime = i2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSpecialTitleExpireTime(long j2) {
|
||||||
|
this.specialTitleExpireTime = j2;
|
||||||
|
}
|
||||||
|
|
||||||
public void setUid(String str) {
|
public void setUid(String str) {
|
||||||
this.uid = str;
|
this.uid = str;
|
||||||
}
|
}
|
||||||
@ -122,30 +321,16 @@ public final class MemberInfo implements IKernelModel {
|
|||||||
this.uin = j2;
|
this.uin = j2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public void setUserShowFlag(int i2) {
|
||||||
return "MemberInfo{uid=" + this.uid + ",qid=" + this.qid + ",uin=" + this.uin + ",nick=" + this.nick + ",remark=" + this.remark + ",cardType=" + this.cardType + ",cardName=" + this.cardName + ",role=" + this.role + ",avatarPath=" + this.avatarPath + ",shutUpTime=" + this.shutUpTime + ",isDelete=" + this.isDelete + ",isSpecialConcerned=" + this.isSpecialConcerned + ",}";
|
this.userShowFlag = i2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MemberInfo(String str, String str2, long j2, String str3, String str4, int i2, String str5, MemberRole memberRole, String str6, int i3, boolean z, boolean z2) {
|
public void setUserShowFlagNew(int i2) {
|
||||||
this.serialVersionUID = 1L;
|
this.userShowFlagNew = i2;
|
||||||
this.uid = "";
|
|
||||||
this.qid = "";
|
|
||||||
this.nick = "";
|
|
||||||
this.remark = "";
|
|
||||||
this.cardName = "";
|
|
||||||
this.role = MemberRole.values()[0];
|
|
||||||
this.avatarPath = "";
|
|
||||||
this.uid = str;
|
|
||||||
this.qid = str2;
|
|
||||||
this.uin = j2;
|
|
||||||
this.nick = str3;
|
|
||||||
this.remark = str4;
|
|
||||||
this.cardType = i2;
|
|
||||||
this.cardName = str5;
|
|
||||||
this.role = memberRole;
|
|
||||||
this.avatarPath = str6;
|
|
||||||
this.shutUpTime = i3;
|
|
||||||
this.isDelete = z;
|
|
||||||
this.isSpecialConcerned = z2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "MemberInfo{uid=" + this.uid + ",qid=" + this.qid + ",uin=" + this.uin + ",nick=" + this.nick + ",remark=" + this.remark + ",cardType=" + this.cardType + ",cardName=" + this.cardName + ",role=" + this.role + ",avatarPath=" + this.avatarPath + ",shutUpTime=" + this.shutUpTime + ",isDelete=" + this.isDelete + ",isSpecialConcerned=" + this.isSpecialConcerned + ",isRobot=" + this.isRobot + ",groupHonor=" + this.groupHonor + ",memberLevel=" + this.memberLevel + ",globalGroupLevel=" + this.globalGroupLevel + ",globalGroupPoint=" + this.globalGroupPoint + ",memberTitleId=" + this.memberTitleId + ",memberSpecialTitle=" + this.memberSpecialTitle + ",specialTitleExpireTime=" + this.specialTitleExpireTime + ",userShowFlag=" + this.userShowFlag + ",userShowFlagNew=" + this.userShowFlagNew + ",richFlag=" + this.richFlag + ",mssVipType=" + this.mssVipType + ",bigClubLevel=" + this.bigClubLevel + ",bigClubFlag=" + this.bigClubFlag + ",autoRemark=" + this.autoRemark + ",creditLevel=" + this.creditLevel + ",joinTime=" + this.joinTime + ",lastSpeakTime=" + this.lastSpeakTime + ",memberFlag=" + this.memberFlag + ",memberFlagExt=" + this.memberFlagExt + ",memberMobileFlag=" + this.memberMobileFlag + ",memberFlagExt2=" + this.memberFlagExt2 + ",isSpecialShielded=" + this.isSpecialShielded + ",cardNameId=" + this.cardNameId + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public class MemberLevelName {
|
||||||
|
public int level;
|
||||||
|
public String strName = "";
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return this.level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStrName() {
|
||||||
|
return this.strName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "MemberLevelName{level=" + this.level + ",strName=" + this.strName + ",}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.tencent.qqnt.kernel.nativeinterface;
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
import com.tencent.qqnt.kernelpublic.nativeinterface.Contact;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public class QueryUserSecQualityRsp {
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.tencent.qqnt.kernel.nativeinterface;
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
|
||||||
|
import com.tencent.qqnt.kernelpublic.nativeinterface.Contact;
|
||||||
|
|
||||||
public final class UnreadCntInfo {
|
public final class UnreadCntInfo {
|
||||||
UnreadCnt allUnreadCnt;
|
UnreadCnt allUnreadCnt;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
package com.tencent.qqnt.kernel.nativeinterface;
|
package com.tencent.qqnt.kernelpublic.nativeinterface;
|
||||||
|
|
||||||
|
import com.tencent.qqnt.kernel.nativeinterface.IKernelModel;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.tencent.qqnt.kernelpublic.nativeinterface;
|
||||||
|
|
||||||
|
public enum MemberRole {
|
||||||
|
UNSPECIFIED,
|
||||||
|
STRANGER,
|
||||||
|
MEMBER,
|
||||||
|
ADMIN,
|
||||||
|
OWNER
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.tencent.qqnt.msg.api;
|
|||||||
|
|
||||||
import com.tencent.mobileqq.qroute.QRouteApi;
|
import com.tencent.mobileqq.qroute.QRouteApi;
|
||||||
import com.tencent.qqnt.kernel.nativeinterface.*;
|
import com.tencent.qqnt.kernel.nativeinterface.*;
|
||||||
|
import com.tencent.qqnt.kernelpublic.nativeinterface.Contact;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -9,7 +10,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import kotlin.Pair;
|
|
||||||
import kotlinx.coroutines.flow.Flow;
|
import kotlinx.coroutines.flow.Flow;
|
||||||
|
|
||||||
public interface IMsgService extends QRouteApi {
|
public interface IMsgService extends QRouteApi {
|
||||||
|
@ -26,7 +26,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("com.android.tools:r8:8.2.47")
|
classpath("com.android.tools:r8:8.3.37")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,8 +34,9 @@ rootProject.name = "Shamrock"
|
|||||||
include(
|
include(
|
||||||
":app",
|
":app",
|
||||||
":xposed",
|
":xposed",
|
||||||
":qqinterface"
|
":qqinterface",
|
||||||
|
":protobuf",
|
||||||
|
":processor",
|
||||||
|
":annotations",
|
||||||
|
":kritor"
|
||||||
)
|
)
|
||||||
include(":protobuf")
|
|
||||||
include(":processor")
|
|
||||||
include(":annotations")
|
|
||||||
|
@ -60,9 +60,10 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly ("de.robv.android.xposed:api:82")
|
compileOnly("de.robv.android.xposed:api:82")
|
||||||
compileOnly (project(":qqinterface"))
|
compileOnly(project(":qqinterface"))
|
||||||
|
|
||||||
|
implementation(project(":kritor"))
|
||||||
implementation(project(":protobuf"))
|
implementation(project(":protobuf"))
|
||||||
implementation(project(":annotations"))
|
implementation(project(":annotations"))
|
||||||
ksp(project(":processor"))
|
ksp(project(":processor"))
|
||||||
@ -72,19 +73,20 @@ dependencies {
|
|||||||
DEPENDENCY_ANDROIDX.forEach {
|
DEPENDENCY_ANDROIDX.forEach {
|
||||||
implementation(it)
|
implementation(it)
|
||||||
}
|
}
|
||||||
implementation(DEPENDENCY_PROTOBUF)
|
|
||||||
|
|
||||||
implementation(room("runtime"))
|
implementation(room("runtime"))
|
||||||
kapt(room("compiler"))
|
kapt(room("compiler"))
|
||||||
implementation(room("ktx"))
|
implementation(room("ktx"))
|
||||||
|
|
||||||
implementation(kotlinx("io-jvm", "0.1.16"))
|
implementation(kotlinx("io-jvm", "0.1.16"))
|
||||||
implementation(kotlinx("serialization-protobuf", "1.6.2"))
|
|
||||||
|
|
||||||
implementation(ktor("client", "core"))
|
implementation(ktor("client", "core"))
|
||||||
implementation(ktor("client", "okhttp"))
|
implementation(ktor("client", "okhttp"))
|
||||||
implementation(ktor("serialization", "kotlinx-json"))
|
implementation(ktor("serialization", "kotlinx-json"))
|
||||||
implementation(ktor("network", "tls-certificates"))
|
|
||||||
|
implementation(grpc("protobuf", "1.62.2"))
|
||||||
|
implementation(grpc("kotlin-stub", "1.4.1"))
|
||||||
|
implementation(grpc("okhttp", "1.62.2"))
|
||||||
|
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("junit:junit:4.13.2")
|
||||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||||
@ -92,3 +94,9 @@ dependencies {
|
|||||||
androidTestImplementation(platform("androidx.compose:compose-bom:2023.06.01"))
|
androidTestImplementation(platform("androidx.compose:compose-bom:2023.06.01"))
|
||||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
|
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinCompile>().all {
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
43
xposed/src/main/assets/config.properties
Normal file
43
xposed/src/main/assets/config.properties
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# Shamrock Config
|
||||||
|
|
||||||
|
# 资源上传群组
|
||||||
|
resource_group=883536416
|
||||||
|
|
||||||
|
# 强制使用平板模式
|
||||||
|
force_tablet=false
|
||||||
|
|
||||||
|
# 被动(反向)RPC开关
|
||||||
|
passive_rpc=false
|
||||||
|
# 被动(反向)RPC地址
|
||||||
|
rpc_address=
|
||||||
|
# 第一个被动RPC鉴权token
|
||||||
|
rpc_address.ticket=
|
||||||
|
# 如果有多个请使用
|
||||||
|
# 我是第二个地址
|
||||||
|
#rpc_address.1=
|
||||||
|
# 第二个被动RPC鉴权token
|
||||||
|
#rpc_address.1.ticket=
|
||||||
|
|
||||||
|
# 主动(正向)RPC开关
|
||||||
|
active_rpc=false
|
||||||
|
# 主动(正向)RPC端口
|
||||||
|
rpc_port=5700
|
||||||
|
# 主动RPC鉴权token
|
||||||
|
active_ticket=
|
||||||
|
# 多鉴权token支持
|
||||||
|
# 第二个主动RPC鉴权token
|
||||||
|
#active_ticket.1=
|
||||||
|
|
||||||
|
# 自回复开关
|
||||||
|
#alive_reply=false
|
||||||
|
# 自回复消息
|
||||||
|
enable_self_message=false
|
||||||
|
|
||||||
|
# 旧BDH兼容开关
|
||||||
|
enable_old_bdh=true
|
||||||
|
|
||||||
|
# 反JVM调用栈跟踪
|
||||||
|
anti_jvm_trace=true
|
||||||
|
|
||||||
|
# 调试模式
|
||||||
|
#debug=false
|
64
xposed/src/main/java/kritor/auth/AuthInterceptor.kt
Normal file
64
xposed/src/main/java/kritor/auth/AuthInterceptor.kt
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package kritor.auth
|
||||||
|
|
||||||
|
import io.grpc.ForwardingServerCallListener
|
||||||
|
import io.grpc.Metadata
|
||||||
|
import io.grpc.ServerCall
|
||||||
|
import io.grpc.ServerCallHandler
|
||||||
|
import io.grpc.ServerInterceptor
|
||||||
|
import moe.fuqiuluo.shamrock.config.ActiveTicket
|
||||||
|
import moe.fuqiuluo.shamrock.config.ShamrockConfig
|
||||||
|
|
||||||
|
object AuthInterceptor: ServerInterceptor {
|
||||||
|
/**
|
||||||
|
* Intercept [ServerCall] dispatch by the `next` [ServerCallHandler]. General
|
||||||
|
* semantics of [ServerCallHandler.startCall] apply and the returned
|
||||||
|
* [io.grpc.ServerCall.Listener] must not be `null`.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* If the implementation throws an exception, `call` will be closed with an error.
|
||||||
|
* Implementations must not throw an exception if they started processing that may use `call` on another thread.
|
||||||
|
*
|
||||||
|
* @param call object to receive response messages
|
||||||
|
* @param headers which can contain extra call metadata from [ClientCall.start],
|
||||||
|
* e.g. authentication credentials.
|
||||||
|
* @param next next processor in the interceptor chain
|
||||||
|
* @return listener for processing incoming messages for `call`, never `null`.
|
||||||
|
*/
|
||||||
|
override fun <ReqT : Any?, RespT : Any?> interceptCall(
|
||||||
|
call: ServerCall<ReqT, RespT>,
|
||||||
|
headers: Metadata?,
|
||||||
|
next: ServerCallHandler<ReqT, RespT>
|
||||||
|
): ServerCall.Listener<ReqT> {
|
||||||
|
val methodName = call.methodDescriptor.fullMethodName
|
||||||
|
val ticket = getAllTicket()
|
||||||
|
if (ticket.isNotEmpty() && !methodName.startsWith("Auth")) {
|
||||||
|
val ticketHeader = headers?.get(Metadata.Key.of("ticket", Metadata.ASCII_STRING_MARSHALLER))
|
||||||
|
if (ticketHeader == null || ticketHeader !in ticket) {
|
||||||
|
call.close(io.grpc.Status.UNAUTHENTICATED.withDescription("Invalid ticket"), Metadata())
|
||||||
|
return object: ServerCall.Listener<ReqT>() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return object: ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT>(next.startCall(call, headers)) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAllTicket(): List<String> {
|
||||||
|
val result = arrayListOf<String>()
|
||||||
|
val activeTicketName = ActiveTicket.name()
|
||||||
|
var index = 0
|
||||||
|
while (true) {
|
||||||
|
val ticket = ShamrockConfig.getProperty(activeTicketName + if (index == 0) "" else ".$index", null)
|
||||||
|
if (ticket.isNullOrEmpty()) {
|
||||||
|
if (index == 0) {
|
||||||
|
return result
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.add(ticket)
|
||||||
|
}
|
||||||
|
index++
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
164
xposed/src/main/java/kritor/client/KritorClient.kt
Normal file
164
xposed/src/main/java/kritor/client/KritorClient.kt
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
@file:OptIn(DelicateCoroutinesApi::class)
|
||||||
|
package kritor.client
|
||||||
|
|
||||||
|
import com.google.protobuf.ByteString
|
||||||
|
import io.grpc.CallOptions
|
||||||
|
import io.grpc.Channel
|
||||||
|
import io.grpc.ClientCall
|
||||||
|
import io.grpc.ClientInterceptor
|
||||||
|
import io.grpc.ForwardingClientCall
|
||||||
|
import io.grpc.Metadata
|
||||||
|
import io.grpc.ManagedChannel
|
||||||
|
import io.grpc.ManagedChannelBuilder
|
||||||
|
import io.grpc.MethodDescriptor
|
||||||
|
import io.kritor.common.Request
|
||||||
|
import io.kritor.common.Response
|
||||||
|
import io.kritor.event.EventServiceGrpcKt
|
||||||
|
import io.kritor.event.EventStructure
|
||||||
|
import io.kritor.event.EventType
|
||||||
|
import io.kritor.reverse.ReverseServiceGrpcKt
|
||||||
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.asExecutor
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
|
import kotlinx.coroutines.flow.channelFlow
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kritor.handlers.handleGrpc
|
||||||
|
import moe.fuqiuluo.shamrock.helper.Level
|
||||||
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
|
import moe.fuqiuluo.shamrock.internals.GlobalEventTransmitter
|
||||||
|
import moe.fuqiuluo.shamrock.tools.ShamrockVersion
|
||||||
|
import qq.service.ticket.TicketHelper
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
|
internal class KritorClient(
|
||||||
|
val host: String,
|
||||||
|
val port: Int
|
||||||
|
) {
|
||||||
|
private lateinit var channel: ManagedChannel
|
||||||
|
|
||||||
|
private lateinit var channelJob: Job
|
||||||
|
private val senderChannel = MutableSharedFlow<Response>()
|
||||||
|
|
||||||
|
fun start() {
|
||||||
|
runCatching {
|
||||||
|
if (::channel.isInitialized && isActive()){
|
||||||
|
channel.shutdown()
|
||||||
|
}
|
||||||
|
val interceptor = object : ClientInterceptor {
|
||||||
|
override fun <ReqT, RespT> interceptCall(method: MethodDescriptor<ReqT, RespT>, callOptions: CallOptions, next: Channel): ClientCall<ReqT, RespT> {
|
||||||
|
return object : ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
|
||||||
|
override fun start(responseListener: Listener<RespT>, headers: Metadata) {
|
||||||
|
headers.merge(Metadata().apply {
|
||||||
|
put(Metadata.Key.of("kritor-self-uin", Metadata.ASCII_STRING_MARSHALLER), TicketHelper.getUin())
|
||||||
|
put(Metadata.Key.of("kritor-self-uid", Metadata.ASCII_STRING_MARSHALLER), TicketHelper.getUid())
|
||||||
|
put(Metadata.Key.of("kritor-self-version", Metadata.ASCII_STRING_MARSHALLER), "OpenShamrock-$ShamrockVersion")
|
||||||
|
})
|
||||||
|
super.start(responseListener, headers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
channel = ManagedChannelBuilder
|
||||||
|
.forAddress(host, port)
|
||||||
|
.usePlaintext()
|
||||||
|
.enableRetry() // 允许尝试
|
||||||
|
.executor(Dispatchers.IO.asExecutor()) // 使用协程的调度器
|
||||||
|
.intercept(interceptor)
|
||||||
|
.build()
|
||||||
|
}.onFailure {
|
||||||
|
LogCenter.log("KritorClient start failed: ${it.stackTraceToString()}", Level.ERROR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun listen(retryCnt: Int = -1) {
|
||||||
|
if (::channelJob.isInitialized && channelJob.isActive) {
|
||||||
|
channelJob.cancel()
|
||||||
|
}
|
||||||
|
channelJob = GlobalScope.launch(Dispatchers.IO) {
|
||||||
|
runCatching {
|
||||||
|
val stub = ReverseServiceGrpcKt.ReverseServiceCoroutineStub(channel)
|
||||||
|
registerEvent(EventType.EVENT_TYPE_MESSAGE)
|
||||||
|
registerEvent(EventType.EVENT_TYPE_CORE_EVENT)
|
||||||
|
registerEvent(EventType.EVENT_TYPE_REQUEST)
|
||||||
|
registerEvent(EventType.EVENT_TYPE_NOTICE)
|
||||||
|
stub.reverseStream(channelFlow {
|
||||||
|
senderChannel.collect { send(it) }
|
||||||
|
}).collect {
|
||||||
|
onReceive(it)
|
||||||
|
}
|
||||||
|
}.onFailure {
|
||||||
|
LogCenter.log("KritorClient listen failed, retry after 15s: ${it.stackTraceToString()}", Level.WARN)
|
||||||
|
}
|
||||||
|
delay(15.seconds)
|
||||||
|
LogCenter.log("KritorClient listen retrying, retryCnt = $retryCnt", Level.WARN)
|
||||||
|
if (retryCnt != 0) listen(retryCnt - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun registerEvent(eventType: EventType) {
|
||||||
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
|
runCatching {
|
||||||
|
EventServiceGrpcKt.EventServiceCoroutineStub(channel).registerPassiveListener(channelFlow {
|
||||||
|
when(eventType) {
|
||||||
|
EventType.EVENT_TYPE_MESSAGE -> GlobalEventTransmitter.onMessageEvent {
|
||||||
|
send(EventStructure.newBuilder().apply {
|
||||||
|
this.type = EventType.EVENT_TYPE_MESSAGE
|
||||||
|
this.message = it.second
|
||||||
|
}.build())
|
||||||
|
}
|
||||||
|
EventType.EVENT_TYPE_CORE_EVENT -> {}
|
||||||
|
EventType.EVENT_TYPE_NOTICE -> GlobalEventTransmitter.onNoticeEvent {
|
||||||
|
send(EventStructure.newBuilder().apply {
|
||||||
|
this.type = EventType.EVENT_TYPE_NOTICE
|
||||||
|
this.notice = it
|
||||||
|
}.build())
|
||||||
|
}
|
||||||
|
EventType.EVENT_TYPE_REQUEST -> GlobalEventTransmitter.onRequestEvent {
|
||||||
|
send(EventStructure.newBuilder().apply {
|
||||||
|
this.type = EventType.EVENT_TYPE_REQUEST
|
||||||
|
this.request = it
|
||||||
|
}.build())
|
||||||
|
}
|
||||||
|
EventType.UNRECOGNIZED -> {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}.onFailure {
|
||||||
|
LogCenter.log("KritorClient registerEvent failed: ${it.stackTraceToString()}", Level.ERROR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun onReceive(request: Request) = GlobalScope.launch {
|
||||||
|
//LogCenter.log("KritorClient onReceive: $request")
|
||||||
|
runCatching {
|
||||||
|
val rsp = handleGrpc(request.cmd, request.buf.toByteArray())
|
||||||
|
senderChannel.emit(Response.newBuilder()
|
||||||
|
.setCmd(request.cmd)
|
||||||
|
.setCode(Response.ResponseCode.SUCCESS)
|
||||||
|
.setMsg("success")
|
||||||
|
.setSeq(request.seq)
|
||||||
|
.setBuf(ByteString.copyFrom(rsp))
|
||||||
|
.build())
|
||||||
|
}.onFailure {
|
||||||
|
senderChannel.emit(Response.newBuilder()
|
||||||
|
.setCmd(request.cmd)
|
||||||
|
.setCode(Response.ResponseCode.INTERNAL)
|
||||||
|
.setMsg(it.stackTraceToString())
|
||||||
|
.setSeq(request.seq)
|
||||||
|
.setBuf(ByteString.EMPTY)
|
||||||
|
.build())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isActive(): Boolean {
|
||||||
|
return !channel.isShutdown
|
||||||
|
}
|
||||||
|
|
||||||
|
fun close() {
|
||||||
|
channel.shutdown()
|
||||||
|
}
|
||||||
|
}
|
6
xposed/src/main/java/kritor/handlers/GrpcHandlers.kt
Normal file
6
xposed/src/main/java/kritor/handlers/GrpcHandlers.kt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package kritor.handlers
|
||||||
|
|
||||||
|
internal object GrpcHandlers {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
70
xposed/src/main/java/kritor/server/KritorServer.kt
Normal file
70
xposed/src/main/java/kritor/server/KritorServer.kt
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
@file:OptIn(ExperimentalCoroutinesApi::class)
|
||||||
|
package kritor.server
|
||||||
|
|
||||||
|
import io.grpc.Grpc
|
||||||
|
import io.grpc.Metadata
|
||||||
|
import io.grpc.InsecureServerCredentials
|
||||||
|
import io.grpc.ServerCall
|
||||||
|
import io.grpc.ServerCallHandler
|
||||||
|
import io.grpc.ServerInterceptor
|
||||||
|
import io.grpc.ForwardingServerCall.SimpleForwardingServerCall;
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
|
import kotlinx.coroutines.asExecutor
|
||||||
|
import kritor.auth.AuthInterceptor
|
||||||
|
import kritor.service.*
|
||||||
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
|
import moe.fuqiuluo.shamrock.tools.ShamrockVersion
|
||||||
|
import qq.service.ticket.TicketHelper
|
||||||
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
|
||||||
|
class KritorServer(
|
||||||
|
private val port: Int
|
||||||
|
): CoroutineScope {
|
||||||
|
|
||||||
|
private val serverInterceptor = object : ServerInterceptor {
|
||||||
|
override fun <ReqT, RespT> interceptCall(
|
||||||
|
call: ServerCall<ReqT, RespT>, headers: Metadata, next: ServerCallHandler<ReqT, RespT>
|
||||||
|
): ServerCall.Listener<ReqT> {
|
||||||
|
return next.startCall(object : SimpleForwardingServerCall<ReqT, RespT>(call) {
|
||||||
|
override fun sendHeaders(headers: Metadata?) {
|
||||||
|
headers?.apply {
|
||||||
|
put(Metadata.Key.of("kritor-self-uin", Metadata.ASCII_STRING_MARSHALLER), TicketHelper.getUin())
|
||||||
|
put(Metadata.Key.of("kritor-self-uid", Metadata.ASCII_STRING_MARSHALLER), TicketHelper.getUid())
|
||||||
|
put(Metadata.Key.of("kritor-self-version", Metadata.ASCII_STRING_MARSHALLER), "OpenShamrock-$ShamrockVersion")
|
||||||
|
}
|
||||||
|
super.sendHeaders(headers)
|
||||||
|
}
|
||||||
|
}, headers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val server = Grpc.newServerBuilderForPort(port, InsecureServerCredentials.create())
|
||||||
|
.executor(Dispatchers.IO.asExecutor())
|
||||||
|
.intercept(AuthInterceptor)
|
||||||
|
.intercept(serverInterceptor)
|
||||||
|
.addService(AuthenticationService)
|
||||||
|
.addService(CoreService)
|
||||||
|
.addService(FriendService)
|
||||||
|
.addService(GroupService)
|
||||||
|
.addService(GroupFileService)
|
||||||
|
.addService(MessageService)
|
||||||
|
.addService(EventService)
|
||||||
|
.addService(WebService)
|
||||||
|
.addService(DeveloperService)
|
||||||
|
.addService(QsignService)
|
||||||
|
.build()!!
|
||||||
|
|
||||||
|
fun start(block: Boolean = false) {
|
||||||
|
LogCenter.log("KritorServer started at port $port.")
|
||||||
|
server.start()
|
||||||
|
|
||||||
|
if (block) {
|
||||||
|
server.awaitTermination()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val coroutineContext: CoroutineContext =
|
||||||
|
Dispatchers.IO.limitedParallelism(12)
|
||||||
|
}
|
60
xposed/src/main/java/kritor/service/AuthenticationService.kt
Normal file
60
xposed/src/main/java/kritor/service/AuthenticationService.kt
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
import io.grpc.Status
|
||||||
|
import io.grpc.StatusRuntimeException
|
||||||
|
import io.kritor.authentication.*
|
||||||
|
import io.kritor.authentication.AuthenticateResponse.AuthenticateResponseCode
|
||||||
|
import kritor.auth.AuthInterceptor
|
||||||
|
import moe.fuqiuluo.shamrock.config.ActiveTicket
|
||||||
|
import moe.fuqiuluo.shamrock.config.ShamrockConfig
|
||||||
|
import qq.service.QQInterfaces
|
||||||
|
|
||||||
|
internal object AuthenticationService: AuthenticationServiceGrpcKt.AuthenticationServiceCoroutineImplBase() {
|
||||||
|
@Grpc("AuthenticationService", "Authenticate")
|
||||||
|
override suspend fun authenticate(request: AuthenticateRequest): AuthenticateResponse {
|
||||||
|
if (QQInterfaces.app.account != request.account) {
|
||||||
|
return AuthenticateResponse.newBuilder().apply {
|
||||||
|
code = AuthenticateResponseCode.NO_ACCOUNT
|
||||||
|
msg = "No such account"
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
val activeTicketName = ActiveTicket.name()
|
||||||
|
var index = 0
|
||||||
|
while (true) {
|
||||||
|
val ticket = ShamrockConfig.getProperty(activeTicketName + if (index == 0) "" else ".$index", null)
|
||||||
|
if (ticket.isNullOrEmpty()) {
|
||||||
|
if (index == 0) {
|
||||||
|
return AuthenticateResponse.newBuilder().apply {
|
||||||
|
code = AuthenticateResponseCode.OK
|
||||||
|
msg = "OK"
|
||||||
|
}.build()
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else if (ticket == request.ticket) {
|
||||||
|
return AuthenticateResponse.newBuilder().apply {
|
||||||
|
code = AuthenticateResponseCode.OK
|
||||||
|
msg = "OK"
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
index++
|
||||||
|
}
|
||||||
|
|
||||||
|
return AuthenticateResponse.newBuilder().apply {
|
||||||
|
code = AuthenticateResponseCode.NO_TICKET
|
||||||
|
msg = "Invalid ticket"
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("AuthenticationService", "GetAuthenticationState")
|
||||||
|
override suspend fun getAuthenticationState(request: GetAuthenticationStateRequest): GetAuthenticationStateResponse {
|
||||||
|
if (request.account != QQInterfaces.app.account) {
|
||||||
|
throw StatusRuntimeException(Status.CANCELLED.withDescription("No such account"))
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetAuthenticationStateResponse.newBuilder().apply {
|
||||||
|
isRequired = AuthInterceptor.getAllTicket().isNotEmpty()
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
}
|
101
xposed/src/main/java/kritor/service/CoreService.kt
Normal file
101
xposed/src/main/java/kritor/service/CoreService.kt
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
import android.util.Base64
|
||||||
|
import com.tencent.mobileqq.app.QQAppInterface
|
||||||
|
import io.grpc.Status
|
||||||
|
import io.grpc.StatusRuntimeException
|
||||||
|
import io.kritor.core.*
|
||||||
|
import moe.fuqiuluo.shamrock.tools.ShamrockVersion
|
||||||
|
import moe.fuqiuluo.shamrock.utils.DownloadUtils
|
||||||
|
import moe.fuqiuluo.shamrock.utils.FileUtils
|
||||||
|
import moe.fuqiuluo.shamrock.utils.MD5
|
||||||
|
import mqq.app.MobileQQ
|
||||||
|
import qq.service.QQInterfaces.Companion.app
|
||||||
|
import qq.service.contact.ContactHelper
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
internal object CoreService : CoreServiceGrpcKt.CoreServiceCoroutineImplBase() {
|
||||||
|
@Grpc("CoreService", "GetVersion")
|
||||||
|
override suspend fun getVersion(request: GetVersionRequest): GetVersionResponse {
|
||||||
|
return GetVersionResponse.newBuilder().apply {
|
||||||
|
this.version = ShamrockVersion
|
||||||
|
this.appName = "Shamrock"
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("CoreService", "GetCurrentAccount")
|
||||||
|
override suspend fun getCurrentAccount(request: GetCurrentAccountRequest): GetCurrentAccountResponse {
|
||||||
|
return GetCurrentAccountResponse.newBuilder().apply {
|
||||||
|
this.accountName = if (app is QQAppInterface) app.currentNickname else "unknown"
|
||||||
|
this.accountUid = app.currentUid ?: ""
|
||||||
|
this.accountUin = (app.currentUin ?: "0").toLong()
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("CoreService", "DownloadFile")
|
||||||
|
override suspend fun downloadFile(request: DownloadFileRequest): DownloadFileResponse {
|
||||||
|
val headerMap = mutableMapOf(
|
||||||
|
"User-Agent" to "Shamrock"
|
||||||
|
)
|
||||||
|
if (request.hasHeaders()) {
|
||||||
|
request.headers.split("[\r\n]").forEach {
|
||||||
|
val pair = it.split("=")
|
||||||
|
if (pair.size >= 2) {
|
||||||
|
val (k, v) = pair
|
||||||
|
headerMap[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var tmp = FileUtils.getTmpFile("cache")
|
||||||
|
if (request.hasBase64()) {
|
||||||
|
val bytes = Base64.decode(request.base64, Base64.DEFAULT)
|
||||||
|
tmp.writeBytes(bytes)
|
||||||
|
} else if (request.hasUrl()) {
|
||||||
|
if (!DownloadUtils.download(
|
||||||
|
urlAdr = request.url,
|
||||||
|
dest = tmp,
|
||||||
|
headers = headerMap,
|
||||||
|
threadCount = if (request.hasThreadCnt()) request.threadCnt else 3
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("download failed"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tmp = if (!request.hasFileName()) FileUtils.renameByMd5(tmp)
|
||||||
|
else tmp.parentFile!!.resolve(request.fileName).also {
|
||||||
|
tmp.renameTo(it)
|
||||||
|
}
|
||||||
|
if (request.hasRootPath()) {
|
||||||
|
tmp = File(request.rootPath).resolve(tmp.name).also {
|
||||||
|
tmp.renameTo(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DownloadFileResponse.newBuilder().apply {
|
||||||
|
this.fileMd5 = MD5.genFileMd5Hex(tmp.absolutePath)
|
||||||
|
this.fileAbsolutePath = tmp.absolutePath
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("CoreService", "SwitchAccount")
|
||||||
|
override suspend fun switchAccount(request: SwitchAccountRequest): SwitchAccountResponse {
|
||||||
|
val uin = when (request.accountCase!!) {
|
||||||
|
SwitchAccountRequest.AccountCase.ACCOUNT_UID -> ContactHelper.getUinByUidAsync(request.accountUid)
|
||||||
|
SwitchAccountRequest.AccountCase.ACCOUNT_UIN -> request.accountUin.toString()
|
||||||
|
SwitchAccountRequest.AccountCase.ACCOUNT_NOT_SET -> throw StatusRuntimeException(
|
||||||
|
Status.INVALID_ARGUMENT.withDescription(
|
||||||
|
"account not found"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val account = MobileQQ.getMobileQQ().allAccounts.firstOrNull { it.uin == uin }
|
||||||
|
?: throw StatusRuntimeException(Status.NOT_FOUND.withDescription("account not found"))
|
||||||
|
runCatching {
|
||||||
|
app.switchAccount(account, null)
|
||||||
|
}.onFailure {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withCause(it).withDescription("failed to switch account"))
|
||||||
|
}
|
||||||
|
return SwitchAccountResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
}
|
67
xposed/src/main/java/kritor/service/DeveloperService.kt
Normal file
67
xposed/src/main/java/kritor/service/DeveloperService.kt
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
import com.google.protobuf.ByteString
|
||||||
|
import io.kritor.developer.*
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
import kotlinx.coroutines.withTimeoutOrNull
|
||||||
|
import moe.fuqiuluo.shamrock.utils.FileUtils
|
||||||
|
import moe.fuqiuluo.shamrock.utils.MMKVFetcher
|
||||||
|
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||||
|
import qq.service.QQInterfaces
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
internal object DeveloperService: DeveloperServiceGrpcKt.DeveloperServiceCoroutineImplBase() {
|
||||||
|
@Grpc("DeveloperService", "Shell")
|
||||||
|
override suspend fun shell(request: ShellRequest): ShellResponse {
|
||||||
|
if (request.commandList.isEmpty()) return ShellResponse.newBuilder().setIsSuccess(false).build()
|
||||||
|
val runtime = Runtime.getRuntime()
|
||||||
|
val result = withTimeoutOrNull(5000L) {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
runtime.exec(request.commandList.toTypedArray(), null, File(request.directory)).apply { waitFor() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ShellResponse.newBuilder().apply {
|
||||||
|
if (result == null) {
|
||||||
|
isSuccess = false
|
||||||
|
} else {
|
||||||
|
isSuccess = true
|
||||||
|
result.inputStream.use {
|
||||||
|
data = it.readBytes().toString(Charsets.UTF_8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("DeveloperService", "ClearCache")
|
||||||
|
override suspend fun clearCache(request: ClearCacheRequest): ClearCacheResponse {
|
||||||
|
FileUtils.clearCache()
|
||||||
|
MMKVFetcher.mmkvWithId("audio2silk")
|
||||||
|
.clear()
|
||||||
|
return ClearCacheResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("DeveloperService", "GetDeviceBattery")
|
||||||
|
override suspend fun getDeviceBattery(request: GetDeviceBatteryRequest): GetDeviceBatteryResponse {
|
||||||
|
return GetDeviceBatteryResponse.newBuilder().apply {
|
||||||
|
PlatformUtils.getDeviceBattery().let {
|
||||||
|
this.battery = it.battery
|
||||||
|
this.scale = it.scale
|
||||||
|
this.status = it.status
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("DeveloperService", "SendPacket")
|
||||||
|
override suspend fun sendPacket(request: SendPacketRequest): SendPacketResponse {
|
||||||
|
return SendPacketResponse.newBuilder().apply {
|
||||||
|
val fromServiceMsg = QQInterfaces.sendBufferAW(request.command, request.isProtobuf, request.requestBuffer.toByteArray())
|
||||||
|
if (fromServiceMsg?.wupBuffer == null) {
|
||||||
|
this.isSuccess = false
|
||||||
|
} else {
|
||||||
|
this.isSuccess = true
|
||||||
|
this.responseBuffer = ByteString.copyFrom(fromServiceMsg.wupBuffer)
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
}
|
43
xposed/src/main/java/kritor/service/EventService.kt
Normal file
43
xposed/src/main/java/kritor/service/EventService.kt
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
import io.grpc.Status
|
||||||
|
import io.grpc.StatusRuntimeException
|
||||||
|
import io.kritor.event.EventServiceGrpcKt
|
||||||
|
import io.kritor.event.EventStructure
|
||||||
|
import io.kritor.event.EventType
|
||||||
|
import io.kritor.event.RequestPushEvent
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.channelFlow
|
||||||
|
import moe.fuqiuluo.shamrock.internals.GlobalEventTransmitter
|
||||||
|
|
||||||
|
internal object EventService : EventServiceGrpcKt.EventServiceCoroutineImplBase() {
|
||||||
|
override fun registerActiveListener(request: RequestPushEvent): Flow<EventStructure> {
|
||||||
|
return channelFlow {
|
||||||
|
when (request.type!!) {
|
||||||
|
EventType.EVENT_TYPE_CORE_EVENT -> {}
|
||||||
|
EventType.EVENT_TYPE_MESSAGE -> GlobalEventTransmitter.onMessageEvent {
|
||||||
|
send(EventStructure.newBuilder().apply {
|
||||||
|
this.type = EventType.EVENT_TYPE_MESSAGE
|
||||||
|
this.message = it.second
|
||||||
|
}.build())
|
||||||
|
}
|
||||||
|
|
||||||
|
EventType.EVENT_TYPE_NOTICE -> GlobalEventTransmitter.onRequestEvent {
|
||||||
|
send(EventStructure.newBuilder().apply {
|
||||||
|
this.type = EventType.EVENT_TYPE_NOTICE
|
||||||
|
this.request = it
|
||||||
|
}.build())
|
||||||
|
}
|
||||||
|
|
||||||
|
EventType.EVENT_TYPE_REQUEST -> GlobalEventTransmitter.onNoticeEvent {
|
||||||
|
send(EventStructure.newBuilder().apply {
|
||||||
|
this.type = EventType.EVENT_TYPE_NOTICE
|
||||||
|
this.notice = it
|
||||||
|
}.build())
|
||||||
|
}
|
||||||
|
|
||||||
|
EventType.UNRECOGNIZED -> throw StatusRuntimeException(Status.INVALID_ARGUMENT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
244
xposed/src/main/java/kritor/service/FriendService.kt
Normal file
244
xposed/src/main/java/kritor/service/FriendService.kt
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import com.tencent.mobileqq.profilecard.api.IProfileCardBlacklistApi
|
||||||
|
import com.tencent.mobileqq.profilecard.api.IProfileProtocolConst
|
||||||
|
import com.tencent.mobileqq.profilecard.api.IProfileProtocolService
|
||||||
|
import com.tencent.mobileqq.qroute.QRoute
|
||||||
|
import io.grpc.Status
|
||||||
|
import io.grpc.StatusRuntimeException
|
||||||
|
import io.kritor.friend.*
|
||||||
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||||
|
import kotlinx.coroutines.withTimeoutOrNull
|
||||||
|
import qq.service.QQInterfaces
|
||||||
|
import qq.service.contact.ContactHelper
|
||||||
|
import qq.service.friend.FriendHelper
|
||||||
|
import kotlin.coroutines.resume
|
||||||
|
|
||||||
|
internal object FriendService : FriendServiceGrpcKt.FriendServiceCoroutineImplBase() {
|
||||||
|
@Grpc("FriendService", "GetFriendList")
|
||||||
|
override suspend fun getFriendList(request: GetFriendListRequest): GetFriendListResponse {
|
||||||
|
val friendList = FriendHelper.getFriendList(if (request.hasRefresh()) request.refresh else false).onFailure {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.INTERNAL
|
||||||
|
.withDescription(it.stackTraceToString())
|
||||||
|
)
|
||||||
|
}.getOrThrow()
|
||||||
|
|
||||||
|
return GetFriendListResponse.newBuilder().apply {
|
||||||
|
friendList.forEach {
|
||||||
|
this.addFriendsInfo(FriendInfo.newBuilder().apply {
|
||||||
|
uin = it.uin.toLong()
|
||||||
|
uid = ContactHelper.getUidByUinAsync(uin)
|
||||||
|
qid = ""
|
||||||
|
nick = it.name ?: ""
|
||||||
|
remark = it.remark ?: ""
|
||||||
|
age = it.age
|
||||||
|
level = 0
|
||||||
|
gender = it.gender.toInt()
|
||||||
|
groupId = it.groupid
|
||||||
|
|
||||||
|
ext = ExtInfo.newBuilder().build()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("FriendService", "GetFriendProfileCard")
|
||||||
|
override suspend fun getFriendProfileCard(request: GetFriendProfileCardRequest): GetFriendProfileCardResponse {
|
||||||
|
return GetFriendProfileCardResponse.newBuilder().apply {
|
||||||
|
request.targetUinsList.forEach {
|
||||||
|
ContactHelper.getProfileCard(it).getOrThrow().let { info ->
|
||||||
|
addFriendsProfileCard(ProfileCard.newBuilder().apply {
|
||||||
|
this.uin = info.uin.toLong()
|
||||||
|
this.uid = ContactHelper.getUidByUinAsync(info.uin.toLong())
|
||||||
|
this.nick = info.strNick
|
||||||
|
this.remark = info.strReMark
|
||||||
|
this.level = info.iQQLevel
|
||||||
|
this.birthday = info.lBirthday
|
||||||
|
this.loginDay = info.lLoginDays.toInt()
|
||||||
|
this.voteCnt = info.lVoteCount.toInt()
|
||||||
|
this.qid = info.qid ?: ""
|
||||||
|
this.isSchoolVerified = info.schoolVerifiedFlag
|
||||||
|
|
||||||
|
this.ext = ExtInfo.newBuilder().apply {
|
||||||
|
this.bigVip = info.bBigClubVipOpen == 1.toByte()
|
||||||
|
this.hollywoodVip = info.bHollywoodVipOpen == 1.toByte()
|
||||||
|
this.qqVip = info.bQQVipOpen == 1.toByte()
|
||||||
|
this.superVip = info.bSuperQQOpen == 1.toByte()
|
||||||
|
this.voted = info.bVoted == 1.toByte()
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
request.targetUidsList.forEach {
|
||||||
|
ContactHelper.getProfileCard(ContactHelper.getUinByUidAsync(it).toLong()).getOrThrow().let { info ->
|
||||||
|
addFriendsProfileCard(ProfileCard.newBuilder().apply {
|
||||||
|
this.uin = info.uin.toLong()
|
||||||
|
this.uid = it
|
||||||
|
this.nick = info.strNick
|
||||||
|
this.remark = info.strReMark
|
||||||
|
this.level = info.iQQLevel
|
||||||
|
this.birthday = info.lBirthday
|
||||||
|
this.loginDay = info.lLoginDays.toInt()
|
||||||
|
this.voteCnt = info.lVoteCount.toInt()
|
||||||
|
this.qid = info.qid ?: ""
|
||||||
|
this.isSchoolVerified = info.schoolVerifiedFlag
|
||||||
|
|
||||||
|
this.ext = ExtInfo.newBuilder().apply {
|
||||||
|
this.bigVip = info.bBigClubVipOpen == 1.toByte()
|
||||||
|
this.hollywoodVip = info.bHollywoodVipOpen == 1.toByte()
|
||||||
|
this.qqVip = info.bQQVipOpen == 1.toByte()
|
||||||
|
this.superVip = info.bSuperQQOpen == 1.toByte()
|
||||||
|
this.voted = info.bVoted == 1.toByte()
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("FriendService", "GetStrangerProfileCard")
|
||||||
|
override suspend fun getStrangerProfileCard(request: GetStrangerProfileCardRequest): GetStrangerProfileCardResponse {
|
||||||
|
return GetStrangerProfileCardResponse.newBuilder().apply {
|
||||||
|
request.targetUinsList.forEach {
|
||||||
|
ContactHelper.refreshAndGetProfileCard(it).getOrThrow().let { info ->
|
||||||
|
addStrangersProfileCard(ProfileCard.newBuilder().apply {
|
||||||
|
this.uin = info.uin.toLong()
|
||||||
|
this.uid = ContactHelper.getUidByUinAsync(info.uin.toLong())
|
||||||
|
this.nick = info.strNick
|
||||||
|
this.level = info.iQQLevel
|
||||||
|
this.birthday = info.lBirthday
|
||||||
|
this.loginDay = info.lLoginDays.toInt()
|
||||||
|
this.voteCnt = info.lVoteCount.toInt()
|
||||||
|
this.qid = info.qid ?: ""
|
||||||
|
this.isSchoolVerified = info.schoolVerifiedFlag
|
||||||
|
|
||||||
|
this.ext = ExtInfo.newBuilder().apply {
|
||||||
|
this.bigVip = info.bBigClubVipOpen == 1.toByte()
|
||||||
|
this.hollywoodVip = info.bHollywoodVipOpen == 1.toByte()
|
||||||
|
this.qqVip = info.bQQVipOpen == 1.toByte()
|
||||||
|
this.superVip = info.bSuperQQOpen == 1.toByte()
|
||||||
|
this.voted = info.bVoted == 1.toByte()
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
request.targetUidsList.forEach {
|
||||||
|
ContactHelper.refreshAndGetProfileCard(ContactHelper.getUinByUidAsync(it).toLong()).getOrThrow()
|
||||||
|
.let { info ->
|
||||||
|
addStrangersProfileCard(ProfileCard.newBuilder().apply {
|
||||||
|
this.uin = info.uin.toLong()
|
||||||
|
this.uid = it
|
||||||
|
this.nick = info.strNick
|
||||||
|
this.level = info.iQQLevel
|
||||||
|
this.birthday = info.lBirthday
|
||||||
|
this.loginDay = info.lLoginDays.toInt()
|
||||||
|
this.voteCnt = info.lVoteCount.toInt()
|
||||||
|
this.qid = info.qid ?: ""
|
||||||
|
this.isSchoolVerified = info.schoolVerifiedFlag
|
||||||
|
|
||||||
|
this.ext = ExtInfo.newBuilder().apply {
|
||||||
|
this.bigVip = info.bBigClubVipOpen == 1.toByte()
|
||||||
|
this.hollywoodVip = info.bHollywoodVipOpen == 1.toByte()
|
||||||
|
this.qqVip = info.bQQVipOpen == 1.toByte()
|
||||||
|
this.superVip = info.bSuperQQOpen == 1.toByte()
|
||||||
|
this.voted = info.bVoted == 1.toByte()
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("FriendService", "SetProfileCard")
|
||||||
|
override suspend fun setProfileCard(request: SetProfileCardRequest): SetProfileCardResponse {
|
||||||
|
val bundle = Bundle()
|
||||||
|
val service = QQInterfaces.app
|
||||||
|
.getRuntimeService(IProfileProtocolService::class.java, "all")
|
||||||
|
if (request.hasNick()) {
|
||||||
|
bundle.putString(IProfileProtocolConst.KEY_NICK, request.nick)
|
||||||
|
}
|
||||||
|
if (request.hasCompany()) {
|
||||||
|
bundle.putString(IProfileProtocolConst.KEY_COMPANY, request.company)
|
||||||
|
}
|
||||||
|
if (request.hasEmail()) {
|
||||||
|
bundle.putString(IProfileProtocolConst.KEY_EMAIL, request.email)
|
||||||
|
}
|
||||||
|
if (request.hasCollege()) {
|
||||||
|
bundle.putString(IProfileProtocolConst.KEY_COLLEGE, request.college)
|
||||||
|
}
|
||||||
|
if (request.hasPersonalNote()) {
|
||||||
|
bundle.putString(IProfileProtocolConst.KEY_PERSONAL_NOTE, request.personalNote)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.hasBirthday()) {
|
||||||
|
bundle.putInt(IProfileProtocolConst.KEY_BIRTHDAY, request.birthday)
|
||||||
|
}
|
||||||
|
if (request.hasAge()) {
|
||||||
|
bundle.putInt(IProfileProtocolConst.KEY_AGE, request.age)
|
||||||
|
}
|
||||||
|
|
||||||
|
service.setProfileDetail(bundle)
|
||||||
|
return super.setProfileCard(request)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("FriendService", "IsBlackListUser")
|
||||||
|
override suspend fun isBlackListUser(request: IsBlackListUserRequest): IsBlackListUserResponse {
|
||||||
|
val uin = when (request.targetCase!!) {
|
||||||
|
IsBlackListUserRequest.TargetCase.TARGET_UIN -> request.targetUin.toString()
|
||||||
|
IsBlackListUserRequest.TargetCase.TARGET_UID -> ContactHelper.getUinByUidAsync(request.targetUid)
|
||||||
|
IsBlackListUserRequest.TargetCase.TARGET_NOT_SET -> throw StatusRuntimeException(
|
||||||
|
Status.INVALID_ARGUMENT
|
||||||
|
.withDescription("account not set")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val blacklistApi = QRoute.api(IProfileCardBlacklistApi::class.java)
|
||||||
|
val isBlack = withTimeoutOrNull(5000) {
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
|
blacklistApi.isBlackOrBlackedUin(uin) {
|
||||||
|
continuation.resume(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: false
|
||||||
|
return IsBlackListUserResponse.newBuilder().setIsBlackListUser(isBlack).build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("FriendService", "VoteUser")
|
||||||
|
override suspend fun voteUser(request: VoteUserRequest): VoteUserResponse {
|
||||||
|
ContactHelper.voteUser(
|
||||||
|
when (request.targetCase!!) {
|
||||||
|
VoteUserRequest.TargetCase.TARGET_UIN -> request.targetUin
|
||||||
|
VoteUserRequest.TargetCase.TARGET_UID -> ContactHelper.getUinByUidAsync(request.targetUid).toLong()
|
||||||
|
VoteUserRequest.TargetCase.TARGET_NOT_SET -> throw StatusRuntimeException(
|
||||||
|
Status.INVALID_ARGUMENT
|
||||||
|
.withDescription("account not set")
|
||||||
|
)
|
||||||
|
}, request.voteCount
|
||||||
|
).onFailure {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.INTERNAL
|
||||||
|
.withDescription(it.stackTraceToString())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return VoteUserResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("FriendService", "GetUidByUin")
|
||||||
|
override suspend fun getUidByUin(request: GetUidByUinRequest): GetUidByUinResponse {
|
||||||
|
return GetUidByUinResponse.newBuilder().apply {
|
||||||
|
request.targetUinsList.forEach {
|
||||||
|
putUidMap(it, ContactHelper.getUidByUinAsync(it))
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("FriendService", "GetUinByUid")
|
||||||
|
override suspend fun getUinByUid(request: GetUinByUidRequest): GetUinByUidResponse {
|
||||||
|
return GetUinByUidResponse.newBuilder().apply {
|
||||||
|
request.targetUidsList.forEach {
|
||||||
|
putUinMap(it, ContactHelper.getUinByUidAsync(it).toLong())
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
}
|
133
xposed/src/main/java/kritor/service/GroupFileService.kt
Normal file
133
xposed/src/main/java/kritor/service/GroupFileService.kt
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
import io.grpc.Status
|
||||||
|
import io.grpc.StatusRuntimeException
|
||||||
|
import io.kritor.file.*
|
||||||
|
import moe.fuqiuluo.shamrock.tools.decodeToOidb
|
||||||
|
import moe.fuqiuluo.shamrock.tools.slice
|
||||||
|
import moe.fuqiuluo.symbols.decodeProtobuf
|
||||||
|
import protobuf.auto.toByteArray
|
||||||
|
import protobuf.oidb.cmd0x6d7.CreateFolderReq
|
||||||
|
import protobuf.oidb.cmd0x6d7.DeleteFolderReq
|
||||||
|
import protobuf.oidb.cmd0x6d7.Oidb0x6d7ReqBody
|
||||||
|
import protobuf.oidb.cmd0x6d7.Oidb0x6d7RespBody
|
||||||
|
import protobuf.oidb.cmd0x6d7.RenameFolderReq
|
||||||
|
import qq.service.QQInterfaces
|
||||||
|
import qq.service.file.GroupFileHelper
|
||||||
|
import qq.service.file.GroupFileHelper.getGroupFileSystemInfo
|
||||||
|
import tencent.im.oidb.cmd0x6d6.oidb_0x6d6
|
||||||
|
import tencent.im.oidb.oidb_sso
|
||||||
|
|
||||||
|
internal object GroupFileService : GroupFileServiceGrpcKt.GroupFileServiceCoroutineImplBase() {
|
||||||
|
@Grpc("GroupFileService", "CreateFolder")
|
||||||
|
override suspend fun createFolder(request: CreateFolderRequest): CreateFolderResponse {
|
||||||
|
val data = Oidb0x6d7ReqBody(
|
||||||
|
createFolder = CreateFolderReq(
|
||||||
|
groupCode = request.groupId.toULong(),
|
||||||
|
appId = 3u,
|
||||||
|
parentFolderId = "/",
|
||||||
|
folderName = request.name
|
||||||
|
)
|
||||||
|
).toByteArray()
|
||||||
|
val fromServiceMsg = QQInterfaces.sendOidbAW("OidbSvc.0x6d7_0", 1751, 0, data)
|
||||||
|
?: throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to send oidb request"))
|
||||||
|
if (fromServiceMsg.wupBuffer == null) {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("oidb request failed"))
|
||||||
|
}
|
||||||
|
val oidbPkg = fromServiceMsg.decodeToOidb()
|
||||||
|
val rsp = oidbPkg.bytes_bodybuffer.get()
|
||||||
|
.toByteArray()
|
||||||
|
.decodeProtobuf<Oidb0x6d7RespBody>()
|
||||||
|
if (rsp.createFolder?.retCode != 0) {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to create folder: ${rsp.createFolder?.retCode}"))
|
||||||
|
}
|
||||||
|
return CreateFolderResponse.newBuilder().apply {
|
||||||
|
this.id = rsp.createFolder?.folderInfo?.folderId ?: ""
|
||||||
|
this.usedSpace = 0
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupFileService", "DeleteFolder")
|
||||||
|
override suspend fun deleteFolder(request: DeleteFolderRequest): DeleteFolderResponse {
|
||||||
|
val fromServiceMsg = QQInterfaces.sendOidbAW(
|
||||||
|
"OidbSvc.0x6d7_1", 1751, 1, Oidb0x6d7ReqBody(
|
||||||
|
deleteFolder = DeleteFolderReq(
|
||||||
|
groupCode = request.groupId.toULong(),
|
||||||
|
appId = 3u,
|
||||||
|
folderId = request.folderId
|
||||||
|
)
|
||||||
|
).toByteArray()
|
||||||
|
) ?: throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to send oidb request"))
|
||||||
|
if (fromServiceMsg.wupBuffer == null) {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("oidb request failed"))
|
||||||
|
}
|
||||||
|
val oidbPkg = fromServiceMsg.decodeToOidb()
|
||||||
|
val rsp = oidbPkg.bytes_bodybuffer.get().toByteArray().decodeProtobuf<Oidb0x6d7RespBody>()
|
||||||
|
if (rsp.deleteFolder?.retCode != 0) {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to delete folder: ${rsp.deleteFolder?.retCode}"))
|
||||||
|
}
|
||||||
|
return DeleteFolderResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupFileService", "DeleteFile")
|
||||||
|
override suspend fun deleteFile(request: DeleteFileRequest): DeleteFileResponse {
|
||||||
|
val oidb0x6d6ReqBody = oidb_0x6d6.ReqBody().apply {
|
||||||
|
delete_file_req.set(oidb_0x6d6.DeleteFileReqBody().apply {
|
||||||
|
uint64_group_code.set(request.groupId)
|
||||||
|
uint32_app_id.set(3)
|
||||||
|
uint32_bus_id.set(request.busId)
|
||||||
|
str_parent_folder_id.set("/")
|
||||||
|
str_file_id.set(request.fileId)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
val fromServiceMsg = QQInterfaces.sendOidbAW("OidbSvc.0x6d6_3", 1750, 3, oidb0x6d6ReqBody.toByteArray())
|
||||||
|
?: throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to send oidb request"))
|
||||||
|
if (fromServiceMsg.wupBuffer == null) {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("oidb request failed"))
|
||||||
|
}
|
||||||
|
val oidbPkg = fromServiceMsg.decodeToOidb()
|
||||||
|
val rsp = oidb_0x6d6.RspBody().apply {
|
||||||
|
mergeFrom(oidbPkg.bytes_bodybuffer.get().toByteArray())
|
||||||
|
}
|
||||||
|
if (rsp.delete_file_rsp.int32_ret_code.get() != 0) {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to delete file: ${rsp.delete_file_rsp.int32_ret_code.get()}"))
|
||||||
|
}
|
||||||
|
return DeleteFileResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupFileService", "RenameFolder")
|
||||||
|
override suspend fun renameFolder(request: RenameFolderRequest): RenameFolderResponse {
|
||||||
|
val fromServiceMsg = QQInterfaces.sendOidbAW(
|
||||||
|
"OidbSvc.0x6d7_3", 1751, 3, Oidb0x6d7ReqBody(
|
||||||
|
renameFolder = RenameFolderReq(
|
||||||
|
groupCode = request.groupId.toULong(),
|
||||||
|
appId = 3u,
|
||||||
|
folderId = request.folderId,
|
||||||
|
folderName = request.name
|
||||||
|
)
|
||||||
|
).toByteArray()
|
||||||
|
) ?: throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to send oidb request"))
|
||||||
|
if (fromServiceMsg.wupBuffer == null) {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("oidb request failed"))
|
||||||
|
}
|
||||||
|
val oidbPkg = fromServiceMsg.decodeToOidb()
|
||||||
|
val rsp = oidbPkg.bytes_bodybuffer.get().toByteArray().decodeProtobuf<Oidb0x6d7RespBody>()
|
||||||
|
if (rsp.renameFolder?.retCode != 0) {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to rename folder: ${rsp.renameFolder?.retCode}"))
|
||||||
|
}
|
||||||
|
return RenameFolderResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupFileService", "GetFileSystemInfo")
|
||||||
|
override suspend fun getFileSystemInfo(request: GetFileSystemInfoRequest): GetFileSystemInfoResponse {
|
||||||
|
return getGroupFileSystemInfo(request.groupId)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupFileService", "GetFileList")
|
||||||
|
override suspend fun getFileList(request: GetFileListRequest): GetFileListResponse {
|
||||||
|
return if (request.hasFolderId())
|
||||||
|
GroupFileHelper.getGroupFiles(request.groupId, request.folderId)
|
||||||
|
else
|
||||||
|
GroupFileHelper.getGroupFiles(request.groupId)
|
||||||
|
}
|
||||||
|
}
|
403
xposed/src/main/java/kritor/service/GroupService.kt
Normal file
403
xposed/src/main/java/kritor/service/GroupService.kt
Normal file
@ -0,0 +1,403 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
import io.grpc.Status
|
||||||
|
import io.grpc.StatusRuntimeException
|
||||||
|
import io.kritor.group.*
|
||||||
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
|
import moe.fuqiuluo.shamrock.helper.TroopHonorHelper.decodeHonor
|
||||||
|
import moe.fuqiuluo.shamrock.tools.ifNullOrEmpty
|
||||||
|
import qq.service.contact.ContactHelper
|
||||||
|
import qq.service.group.GroupHelper
|
||||||
|
import tencent.im.troop.honor.troop_honor
|
||||||
|
|
||||||
|
internal object GroupService : GroupServiceGrpcKt.GroupServiceCoroutineImplBase() {
|
||||||
|
@Grpc("GroupService", "BanMember")
|
||||||
|
override suspend fun banMember(request: BanMemberRequest): BanMemberResponse {
|
||||||
|
if (!GroupHelper.isAdmin(request.groupId.toString())) {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.PERMISSION_DENIED
|
||||||
|
.withDescription("You are not admin of this group")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupHelper.banMember(
|
||||||
|
request.groupId, when (request.targetCase!!) {
|
||||||
|
BanMemberRequest.TargetCase.TARGET_UIN -> request.targetUin
|
||||||
|
BanMemberRequest.TargetCase.TARGET_UID -> ContactHelper.getUinByUidAsync(request.targetUid).toLong()
|
||||||
|
else -> throw StatusRuntimeException(
|
||||||
|
Status.INVALID_ARGUMENT
|
||||||
|
.withDescription("target not set")
|
||||||
|
)
|
||||||
|
}, request.duration
|
||||||
|
)
|
||||||
|
|
||||||
|
return BanMemberResponse.newBuilder().apply {
|
||||||
|
groupId = request.groupId
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "PokeMember")
|
||||||
|
override suspend fun pokeMember(request: PokeMemberRequest): PokeMemberResponse {
|
||||||
|
GroupHelper.pokeMember(
|
||||||
|
request.groupId, when (request.targetCase!!) {
|
||||||
|
PokeMemberRequest.TargetCase.TARGET_UIN -> request.targetUin
|
||||||
|
PokeMemberRequest.TargetCase.TARGET_UID -> ContactHelper.getUinByUidAsync(request.targetUid).toLong()
|
||||||
|
else -> throw StatusRuntimeException(
|
||||||
|
Status.INVALID_ARGUMENT
|
||||||
|
.withDescription("target not set")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return PokeMemberResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "KickMember")
|
||||||
|
override suspend fun kickMember(request: KickMemberRequest): KickMemberResponse {
|
||||||
|
if (!GroupHelper.isAdmin(request.groupId.toString())) {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.PERMISSION_DENIED
|
||||||
|
.withDescription("You are not admin of this group")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
GroupHelper.kickMember(
|
||||||
|
request.groupId,
|
||||||
|
request.rejectAddRequest,
|
||||||
|
if (request.hasKickReason()) request.kickReason else "",
|
||||||
|
when (request.targetCase!!) {
|
||||||
|
KickMemberRequest.TargetCase.TARGET_UIN -> request.targetUin
|
||||||
|
KickMemberRequest.TargetCase.TARGET_UID -> ContactHelper.getUinByUidAsync(request.targetUid).toLong()
|
||||||
|
else -> throw StatusRuntimeException(
|
||||||
|
Status.INVALID_ARGUMENT
|
||||||
|
.withDescription("target not set")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return KickMemberResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "LeaveGroup")
|
||||||
|
override suspend fun leaveGroup(request: LeaveGroupRequest): LeaveGroupResponse {
|
||||||
|
GroupHelper.resignTroop(request.groupId.toString())
|
||||||
|
return LeaveGroupResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "ModifyMemberCard")
|
||||||
|
override suspend fun modifyMemberCard(request: ModifyMemberCardRequest): ModifyMemberCardResponse {
|
||||||
|
if (!GroupHelper.isAdmin(request.groupId.toString())) {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.PERMISSION_DENIED
|
||||||
|
.withDescription("You are not admin of this group")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
GroupHelper.modifyGroupMemberCard(
|
||||||
|
request.groupId, when (request.targetCase!!) {
|
||||||
|
ModifyMemberCardRequest.TargetCase.TARGET_UIN -> request.targetUin
|
||||||
|
ModifyMemberCardRequest.TargetCase.TARGET_UID -> ContactHelper.getUinByUidAsync(request.targetUid)
|
||||||
|
.toLong()
|
||||||
|
|
||||||
|
else -> throw StatusRuntimeException(
|
||||||
|
Status.INVALID_ARGUMENT
|
||||||
|
.withDescription("target not set")
|
||||||
|
)
|
||||||
|
}, request.card
|
||||||
|
)
|
||||||
|
return ModifyMemberCardResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "ModifyGroupName")
|
||||||
|
override suspend fun modifyGroupName(request: ModifyGroupNameRequest): ModifyGroupNameResponse {
|
||||||
|
if (!GroupHelper.isAdmin(request.groupId.toString())) {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.PERMISSION_DENIED
|
||||||
|
.withDescription("You are not admin of this group")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupHelper.modifyTroopName(request.groupId.toString(), request.groupName)
|
||||||
|
|
||||||
|
return ModifyGroupNameResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "ModifyGroupRemark")
|
||||||
|
override suspend fun modifyGroupRemark(request: ModifyGroupRemarkRequest): ModifyGroupRemarkResponse {
|
||||||
|
GroupHelper.modifyGroupRemark(request.groupId, request.remark)
|
||||||
|
|
||||||
|
return ModifyGroupRemarkResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "SetGroupAdmin")
|
||||||
|
override suspend fun setGroupAdmin(request: SetGroupAdminRequest): SetGroupAdminResponse {
|
||||||
|
if (!GroupHelper.isOwner(request.groupId.toString())) {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.PERMISSION_DENIED
|
||||||
|
.withDescription("You are not admin of this group")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupHelper.setGroupAdmin(
|
||||||
|
request.groupId, when (request.targetCase!!) {
|
||||||
|
SetGroupAdminRequest.TargetCase.TARGET_UIN -> request.targetUin
|
||||||
|
SetGroupAdminRequest.TargetCase.TARGET_UID -> ContactHelper.getUinByUidAsync(request.targetUid).toLong()
|
||||||
|
else -> throw StatusRuntimeException(
|
||||||
|
Status.INVALID_ARGUMENT
|
||||||
|
.withDescription("target not set")
|
||||||
|
)
|
||||||
|
}, request.isAdmin
|
||||||
|
)
|
||||||
|
|
||||||
|
return SetGroupAdminResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "SetGroupUniqueTitle")
|
||||||
|
override suspend fun setGroupUniqueTitle(request: SetGroupUniqueTitleRequest): SetGroupUniqueTitleResponse {
|
||||||
|
if (!GroupHelper.isAdmin(request.groupId.toString())) {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.PERMISSION_DENIED
|
||||||
|
.withDescription("You are not admin of this group")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupHelper.setGroupUniqueTitle(
|
||||||
|
request.groupId.toString(), when (request.targetCase!!) {
|
||||||
|
SetGroupUniqueTitleRequest.TargetCase.TARGET_UIN -> request.targetUin
|
||||||
|
SetGroupUniqueTitleRequest.TargetCase.TARGET_UID -> ContactHelper.getUinByUidAsync(request.targetUid)
|
||||||
|
.toLong()
|
||||||
|
|
||||||
|
else -> throw StatusRuntimeException(
|
||||||
|
Status.INVALID_ARGUMENT
|
||||||
|
.withDescription("target not set")
|
||||||
|
)
|
||||||
|
}.toString(), request.uniqueTitle
|
||||||
|
)
|
||||||
|
|
||||||
|
return SetGroupUniqueTitleResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "SetGroupWholeBan")
|
||||||
|
override suspend fun setGroupWholeBan(request: SetGroupWholeBanRequest): SetGroupWholeBanResponse {
|
||||||
|
if (!GroupHelper.isAdmin(request.groupId.toString())) {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.PERMISSION_DENIED
|
||||||
|
.withDescription("You are not admin of this group")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupHelper.setGroupWholeBan(request.groupId, request.isBan)
|
||||||
|
return SetGroupWholeBanResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "GetGroupInfo")
|
||||||
|
override suspend fun getGroupInfo(request: GetGroupInfoRequest): GetGroupInfoResponse {
|
||||||
|
val groupInfo = GroupHelper.getGroupInfo(request.groupId.toString(), true).onFailure {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to get group info").withCause(it))
|
||||||
|
}.getOrThrow()
|
||||||
|
return GetGroupInfoResponse.newBuilder().apply {
|
||||||
|
this.groupInfo = GroupInfo.newBuilder().apply {
|
||||||
|
groupId = groupInfo.troopcode.toLong()
|
||||||
|
groupName =
|
||||||
|
groupInfo.troopname.ifNullOrEmpty { groupInfo.troopRemark }.ifNullOrEmpty { groupInfo.newTroopName }
|
||||||
|
?: ""
|
||||||
|
groupRemark = groupInfo.troopRemark ?: ""
|
||||||
|
owner = groupInfo.troopowneruin?.toLong() ?: 0
|
||||||
|
addAllAdmins(GroupHelper.getAdminList(groupId))
|
||||||
|
maxMemberCount = groupInfo.wMemberMax
|
||||||
|
memberCount = groupInfo.wMemberNum
|
||||||
|
groupUin = groupInfo.troopuin?.toLong() ?: 0
|
||||||
|
}.build()
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "GetGroupList")
|
||||||
|
override suspend fun getGroupList(request: GetGroupListRequest): GetGroupListResponse {
|
||||||
|
val groupList = GroupHelper.getGroupList(if (request.hasRefresh()) request.refresh else false).onFailure {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to get group list").withCause(it))
|
||||||
|
}.getOrThrow()
|
||||||
|
return GetGroupListResponse.newBuilder().apply {
|
||||||
|
groupList.forEach { groupInfo ->
|
||||||
|
this.addGroupsInfo(GroupInfo.newBuilder().apply {
|
||||||
|
groupId = groupInfo.troopcode.ifNullOrEmpty { groupInfo.uin }.ifNullOrEmpty { groupInfo.troopuin }?.toLong() ?: 0
|
||||||
|
groupName = groupInfo.troopname.ifNullOrEmpty { groupInfo.troopRemark }
|
||||||
|
.ifNullOrEmpty { groupInfo.newTroopName }
|
||||||
|
?: ""
|
||||||
|
groupRemark = groupInfo.troopRemark ?: ""
|
||||||
|
owner = groupInfo.troopowneruin?.toLong() ?: 0
|
||||||
|
addAllAdmins(GroupHelper.getAdminList(groupId))
|
||||||
|
maxMemberCount = groupInfo.wMemberMax
|
||||||
|
memberCount = groupInfo.wMemberNum
|
||||||
|
groupUin = groupInfo.troopuin?.toLong() ?: 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "GetGroupMemberInfo")
|
||||||
|
override suspend fun getGroupMemberInfo(request: GetGroupMemberInfoRequest): GetGroupMemberInfoResponse {
|
||||||
|
val memberInfo = GroupHelper.getTroopMemberInfoByUin(
|
||||||
|
request.groupId.toString(), when (request.targetCase!!) {
|
||||||
|
GetGroupMemberInfoRequest.TargetCase.TARGET_UID -> request.targetUin
|
||||||
|
GetGroupMemberInfoRequest.TargetCase.TARGET_UIN -> ContactHelper.getUinByUidAsync(request.targetUid).toLong()
|
||||||
|
else -> throw StatusRuntimeException(
|
||||||
|
Status.INVALID_ARGUMENT
|
||||||
|
.withDescription("target not set")
|
||||||
|
)
|
||||||
|
}.toString()
|
||||||
|
).onFailure {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.INTERNAL.withDescription("unable to get group member info").withCause(it)
|
||||||
|
)
|
||||||
|
}.getOrThrow()
|
||||||
|
return GetGroupMemberInfoResponse.newBuilder().apply {
|
||||||
|
groupMemberInfo = GroupMemberInfo.newBuilder().apply {
|
||||||
|
uid =
|
||||||
|
if (request.targetCase == GetGroupMemberInfoRequest.TargetCase.TARGET_UID) request.targetUid else ContactHelper.getUidByUinAsync(
|
||||||
|
request.targetUin
|
||||||
|
)
|
||||||
|
uin = memberInfo.memberuin?.toLong() ?: 0
|
||||||
|
nick = memberInfo.troopnick
|
||||||
|
.ifNullOrEmpty { memberInfo.hwName }
|
||||||
|
.ifNullOrEmpty { memberInfo.troopColorNick }
|
||||||
|
.ifNullOrEmpty { memberInfo.friendnick } ?: ""
|
||||||
|
age = memberInfo.age.toInt()
|
||||||
|
uniqueTitle = memberInfo.mUniqueTitle ?: ""
|
||||||
|
uniqueTitleExpireTime = memberInfo.mUniqueTitleExpire.toLong()
|
||||||
|
card = memberInfo.troopnick.ifNullOrEmpty { memberInfo.friendnick } ?: ""
|
||||||
|
joinTime = memberInfo.join_time
|
||||||
|
lastActiveTime = memberInfo.last_active_time
|
||||||
|
level = memberInfo.level
|
||||||
|
shutUpTime = memberInfo.gagTimeStamp
|
||||||
|
|
||||||
|
distance = memberInfo.distance
|
||||||
|
addAllHonors((memberInfo.honorList ?: "")
|
||||||
|
.split("|")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.map { it.toInt() })
|
||||||
|
unfriendly = false
|
||||||
|
cardChangeable = GroupHelper.isAdmin(request.groupId.toString())
|
||||||
|
}.build()
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "GetGroupMemberList")
|
||||||
|
override suspend fun getGroupMemberList(request: GetGroupMemberListRequest): GetGroupMemberListResponse {
|
||||||
|
val memberList = GroupHelper.getGroupMemberList(
|
||||||
|
request.groupId,
|
||||||
|
if (request.hasRefresh()) request.refresh else false
|
||||||
|
).onFailure {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.INTERNAL.withDescription("unable to get group member list").withCause(it)
|
||||||
|
)
|
||||||
|
}.getOrThrow()
|
||||||
|
return GetGroupMemberListResponse.newBuilder().apply {
|
||||||
|
memberList.values.forEach { memberInfo ->
|
||||||
|
this.addGroupMembersInfo(GroupMemberInfo.newBuilder().apply {
|
||||||
|
uid = memberInfo.uid
|
||||||
|
uin = memberInfo.uin
|
||||||
|
nick = memberInfo.nick ?: ""
|
||||||
|
age = 0
|
||||||
|
uniqueTitle = memberInfo.memberSpecialTitle ?: ""
|
||||||
|
uniqueTitleExpireTime = memberInfo.specialTitleExpireTime
|
||||||
|
card = memberInfo.cardName.ifNullOrEmpty { memberInfo.nick } ?: ""
|
||||||
|
joinTime = memberInfo.joinTime.toLong()
|
||||||
|
lastActiveTime = memberInfo.lastSpeakTime.toLong()
|
||||||
|
level = memberInfo.memberLevel
|
||||||
|
shutUpTime = memberInfo.shutUpTime.toLong()
|
||||||
|
|
||||||
|
distance = 0
|
||||||
|
addAllHonors(memberInfo.groupHonor.let { bytes ->
|
||||||
|
val honor = troop_honor.GroupUserCardHonor()
|
||||||
|
honor.mergeFrom(bytes)
|
||||||
|
honor.id.get()
|
||||||
|
})
|
||||||
|
unfriendly = false
|
||||||
|
cardChangeable = memberInfo.role == com.tencent.qqnt.kernelpublic.nativeinterface.MemberRole.ADMIN
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "GetProhibitedUserList")
|
||||||
|
override suspend fun getProhibitedUserList(request: GetProhibitedUserListRequest): GetProhibitedUserListResponse {
|
||||||
|
val prohibitedList = GroupHelper.getProhibitedMemberList(request.groupId).onFailure {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.INTERNAL.withDescription("unable to get prohibited user list").withCause(it)
|
||||||
|
)
|
||||||
|
}.getOrThrow()
|
||||||
|
return GetProhibitedUserListResponse.newBuilder().apply {
|
||||||
|
prohibitedList.forEach {
|
||||||
|
this.addProhibitedUsersInfo(ProhibitedUserInfo.newBuilder().apply {
|
||||||
|
uid = ContactHelper.getUidByUinAsync(it.memberUin)
|
||||||
|
uin = it.memberUin
|
||||||
|
prohibitedTime = it.shutuptimestap.toLong()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "GetRemainCountAtAll")
|
||||||
|
override suspend fun getRemainCountAtAll(request: GetRemainCountAtAllRequest): GetRemainCountAtAllResponse {
|
||||||
|
val remainAtAllRsp = GroupHelper.getGroupRemainAtAllRemain(request.groupId).onFailure {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to get remain count").withCause(it))
|
||||||
|
}.getOrThrow()
|
||||||
|
return GetRemainCountAtAllResponse.newBuilder().apply {
|
||||||
|
accessAtAll = remainAtAllRsp.bool_can_at_all.get()
|
||||||
|
remainCountForGroup = remainAtAllRsp.uint32_remain_at_all_count_for_group.get()
|
||||||
|
remainCountForSelf = remainAtAllRsp.uint32_remain_at_all_count_for_uin.get()
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "GetNotJoinedGroupInfo")
|
||||||
|
override suspend fun getNotJoinedGroupInfo(request: GetNotJoinedGroupInfoRequest): GetNotJoinedGroupInfoResponse {
|
||||||
|
val groupInfo = GroupHelper.getNotJoinedGroupInfo(request.groupId).onFailure {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.INTERNAL.withDescription("unable to get not joined group info").withCause(it)
|
||||||
|
)
|
||||||
|
}.getOrThrow()
|
||||||
|
return GetNotJoinedGroupInfoResponse.newBuilder().apply {
|
||||||
|
this.groupInfo = NotJoinedGroupInfo.newBuilder().apply {
|
||||||
|
groupId = groupInfo.groupId
|
||||||
|
groupName = groupInfo.groupName
|
||||||
|
owner = groupInfo.owner
|
||||||
|
maxMemberCount = groupInfo.maxMember
|
||||||
|
memberCount = groupInfo.memberCount
|
||||||
|
groupDesc = groupInfo.groupDesc
|
||||||
|
createTime = groupInfo.createTime
|
||||||
|
groupFlag = groupInfo.groupFlag
|
||||||
|
groupFlagExt = groupInfo.groupFlagExt
|
||||||
|
}.build()
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("GroupService", "GetGroupHonor")
|
||||||
|
override suspend fun getGroupHonor(request: GetGroupHonorRequest): GetGroupHonorResponse {
|
||||||
|
return GetGroupHonorResponse.newBuilder().apply {
|
||||||
|
GroupHelper.getGroupMemberList(request.groupId, true).onFailure {
|
||||||
|
throw StatusRuntimeException(
|
||||||
|
Status.INTERNAL.withDescription("unable to get group member list").withCause(it)
|
||||||
|
)
|
||||||
|
}.onSuccess { memberList ->
|
||||||
|
memberList.values.forEach { member ->
|
||||||
|
member.groupHonor.let { bytes ->
|
||||||
|
val honor = troop_honor.GroupUserCardHonor()
|
||||||
|
honor.mergeFrom(bytes)
|
||||||
|
honor.id.get()
|
||||||
|
}.forEach {
|
||||||
|
val honor = decodeHonor(member.uin, it, 0)
|
||||||
|
if (honor != null) {
|
||||||
|
addGroupHonorsInfo(GroupHonorInfo.newBuilder().apply {
|
||||||
|
uid = member.uid
|
||||||
|
uin = member.uin
|
||||||
|
nick = member.nick.ifEmpty {
|
||||||
|
member.cardName
|
||||||
|
} ?: ""
|
||||||
|
honorName = honor.honorName
|
||||||
|
avatar = honor.honorIconUrl
|
||||||
|
id = honor.honorId
|
||||||
|
description = honor.honorUrl
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
}
|
475
xposed/src/main/java/kritor/service/MessageService.kt
Normal file
475
xposed/src/main/java/kritor/service/MessageService.kt
Normal file
@ -0,0 +1,475 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
import com.tencent.mobileqq.qroute.QRoute
|
||||||
|
import com.tencent.qqnt.kernelpublic.nativeinterface.Contact
|
||||||
|
import com.tencent.qqnt.kernel.nativeinterface.MsgConstant
|
||||||
|
import com.tencent.qqnt.kernel.nativeinterface.MsgRecord
|
||||||
|
import com.tencent.qqnt.msg.api.IMsgService
|
||||||
|
import io.grpc.Status
|
||||||
|
import io.grpc.StatusRuntimeException
|
||||||
|
import io.kritor.common.*
|
||||||
|
import io.kritor.message.*
|
||||||
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||||
|
import kotlinx.coroutines.withTimeoutOrNull
|
||||||
|
import moe.fuqiuluo.shamrock.helper.Level
|
||||||
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
|
import protobuf.auto.toByteArray
|
||||||
|
import protobuf.message.*
|
||||||
|
import protobuf.message.element.GeneralFlags
|
||||||
|
import protobuf.message.routing.C2C
|
||||||
|
import protobuf.message.routing.Grp
|
||||||
|
import qq.service.QQInterfaces
|
||||||
|
import qq.service.contact.longPeer
|
||||||
|
import qq.service.internals.NTServiceFetcher
|
||||||
|
import qq.service.msg.*
|
||||||
|
import qq.service.msg.ForwardMessageHelper
|
||||||
|
import qq.service.msg.MessageHelper
|
||||||
|
import kotlin.coroutines.resume
|
||||||
|
import kotlin.random.Random
|
||||||
|
import kotlin.random.nextUInt
|
||||||
|
|
||||||
|
internal object MessageService : MessageServiceGrpcKt.MessageServiceCoroutineImplBase() {
|
||||||
|
@Grpc("MessageService", "SendMessage")
|
||||||
|
override suspend fun sendMessage(request: SendMessageRequest): SendMessageResponse {
|
||||||
|
val contact = request.contact.let {
|
||||||
|
MessageHelper.generateContact(
|
||||||
|
when (it.scene!!) {
|
||||||
|
Scene.GROUP -> MsgConstant.KCHATTYPEGROUP
|
||||||
|
Scene.FRIEND -> MsgConstant.KCHATTYPEC2C
|
||||||
|
Scene.GUILD -> MsgConstant.KCHATTYPEGUILD
|
||||||
|
Scene.STRANGER_FROM_GROUP -> MsgConstant.KCHATTYPETEMPC2CFROMGROUP
|
||||||
|
Scene.NEARBY -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.STRANGER -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.UNRECOGNIZED -> throw StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Unrecognized scene"))
|
||||||
|
}, it.peer, it.subPeer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val uniseq = MessageHelper.generateMsgId(contact.chatType)
|
||||||
|
return SendMessageResponse.newBuilder().apply {
|
||||||
|
this.messageId = MessageHelper.sendMessage(
|
||||||
|
contact,
|
||||||
|
NtMsgConvertor.convertToNtMsgs(contact, uniseq, request.elementsList),
|
||||||
|
request.retryCount,
|
||||||
|
uniseq
|
||||||
|
).onFailure {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withCause(it))
|
||||||
|
}.getOrThrow().toString()
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "SendMessageByResId")
|
||||||
|
override suspend fun sendMessageByResId(request: SendMessageByResIdRequest): SendMessageByResIdResponse {
|
||||||
|
val contact = request.contact
|
||||||
|
val req = PbSendMsgReq(
|
||||||
|
routingHead = when (request.contact.scene) {
|
||||||
|
Scene.GROUP -> RoutingHead(grp = Grp(contact.longPeer().toUInt()))
|
||||||
|
Scene.FRIEND -> RoutingHead(c2c = C2C(contact.longPeer().toUInt()))
|
||||||
|
else -> RoutingHead(grp = Grp(contact.longPeer().toUInt()))
|
||||||
|
},
|
||||||
|
contentHead = ContentHead(1, 0, 0, 0),
|
||||||
|
msgBody = MsgBody(
|
||||||
|
richText = RichText(
|
||||||
|
elements = arrayListOf(
|
||||||
|
Elem(
|
||||||
|
generalFlags = GeneralFlags(
|
||||||
|
longTextFlag = 1u,
|
||||||
|
longTextResid = request.resId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
msgSeq = Random.nextUInt(),
|
||||||
|
msgRand = Random.nextUInt(),
|
||||||
|
msgVia = 0u
|
||||||
|
)
|
||||||
|
QQInterfaces.sendBuffer("MessageSvc.PbSendMsg", true, req.toByteArray())
|
||||||
|
return SendMessageByResIdResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "SetMessageReaded")
|
||||||
|
override suspend fun setMessageReaded(request: SetMessageReadRequest): SetMessageReadResponse {
|
||||||
|
val contact = request.contact
|
||||||
|
val kernelService = NTServiceFetcher.kernelService
|
||||||
|
val sessionService = kernelService.wrapperSession
|
||||||
|
val service = sessionService.msgService
|
||||||
|
val chatType = when (contact.scene!!) {
|
||||||
|
Scene.GROUP -> MsgConstant.KCHATTYPEGROUP
|
||||||
|
Scene.FRIEND -> MsgConstant.KCHATTYPEC2C
|
||||||
|
Scene.GUILD -> MsgConstant.KCHATTYPEGUILD
|
||||||
|
Scene.STRANGER_FROM_GROUP -> MsgConstant.KCHATTYPETEMPC2CFROMGROUP
|
||||||
|
Scene.NEARBY -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.STRANGER -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.UNRECOGNIZED -> throw StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Unrecognized scene"))
|
||||||
|
}
|
||||||
|
service.clearMsgRecords(
|
||||||
|
Contact(
|
||||||
|
chatType,
|
||||||
|
contact.peer,
|
||||||
|
contact.subPeer
|
||||||
|
), null)
|
||||||
|
return SetMessageReadResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "RecallMessage")
|
||||||
|
override suspend fun recallMessage(request: RecallMessageRequest): RecallMessageResponse {
|
||||||
|
val contact = request.contact.let {
|
||||||
|
MessageHelper.generateContact(
|
||||||
|
when (it.scene!!) {
|
||||||
|
Scene.GROUP -> MsgConstant.KCHATTYPEGROUP
|
||||||
|
Scene.FRIEND -> MsgConstant.KCHATTYPEC2C
|
||||||
|
Scene.GUILD -> MsgConstant.KCHATTYPEGUILD
|
||||||
|
Scene.STRANGER_FROM_GROUP -> MsgConstant.KCHATTYPETEMPC2CFROMGROUP
|
||||||
|
Scene.NEARBY -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.STRANGER -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.UNRECOGNIZED -> throw StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Unrecognized scene"))
|
||||||
|
}, it.peer, it.subPeer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val kernelService = NTServiceFetcher.kernelService
|
||||||
|
val sessionService = kernelService.wrapperSession
|
||||||
|
val service = sessionService.msgService
|
||||||
|
service.recallMsg(contact, arrayListOf(request.messageId.toLong())) { code, msg ->
|
||||||
|
if (code != 0) {
|
||||||
|
LogCenter.log("消息撤回失败: $code:$msg", Level.WARN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RecallMessageResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "GetMessage")
|
||||||
|
override suspend fun getMessage(request: GetMessageRequest): GetMessageResponse {
|
||||||
|
val contact = request.contact.let {
|
||||||
|
MessageHelper.generateContact(
|
||||||
|
when (it.scene!!) {
|
||||||
|
Scene.GROUP -> MsgConstant.KCHATTYPEGROUP
|
||||||
|
Scene.FRIEND -> MsgConstant.KCHATTYPEC2C
|
||||||
|
Scene.GUILD -> MsgConstant.KCHATTYPEGUILD
|
||||||
|
Scene.STRANGER_FROM_GROUP -> MsgConstant.KCHATTYPETEMPC2CFROMGROUP
|
||||||
|
Scene.NEARBY -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.STRANGER -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.UNRECOGNIZED -> throw StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Unrecognized scene"))
|
||||||
|
}, it.peer, it.subPeer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val msg: MsgRecord = withTimeoutOrNull(5000) {
|
||||||
|
val service = QRoute.api(IMsgService::class.java)
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
|
service.getMsgsByMsgId(contact, arrayListOf(request.messageId.toLong())) { code, _, msgRecords ->
|
||||||
|
if (code == 0 && msgRecords.isNotEmpty()) {
|
||||||
|
continuation.resume(msgRecords.first())
|
||||||
|
} else {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continuation.invokeOnCancellation {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: throw StatusRuntimeException(Status.NOT_FOUND.withDescription("Message not found"))
|
||||||
|
|
||||||
|
return GetMessageResponse.newBuilder().apply {
|
||||||
|
this.message = PushMessageBody.newBuilder().apply {
|
||||||
|
this.messageId = msg.msgId.toString()
|
||||||
|
this.contact = request.contact
|
||||||
|
this.sender = Sender.newBuilder().apply {
|
||||||
|
this.uid = msg.senderUid ?: ""
|
||||||
|
this.uin = msg.senderUin
|
||||||
|
this.nick = msg.sendNickName ?: ""
|
||||||
|
}.build()
|
||||||
|
this.messageSeq = msg.msgSeq
|
||||||
|
this.addAllElements(msg.elements.toKritorReqMessages(contact))
|
||||||
|
}.build()
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "GetMessageBySeq")
|
||||||
|
override suspend fun getMessageBySeq(request: GetMessageBySeqRequest): GetMessageBySeqResponse {
|
||||||
|
val contact = request.contact.let {
|
||||||
|
MessageHelper.generateContact(
|
||||||
|
when (it.scene!!) {
|
||||||
|
Scene.GROUP -> MsgConstant.KCHATTYPEGROUP
|
||||||
|
Scene.FRIEND -> MsgConstant.KCHATTYPEC2C
|
||||||
|
Scene.GUILD -> MsgConstant.KCHATTYPEGUILD
|
||||||
|
Scene.STRANGER_FROM_GROUP -> MsgConstant.KCHATTYPETEMPC2CFROMGROUP
|
||||||
|
Scene.NEARBY -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.STRANGER -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.UNRECOGNIZED -> throw StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Unrecognized scene"))
|
||||||
|
}, it.peer, it.subPeer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val msg: MsgRecord = withTimeoutOrNull(5000) {
|
||||||
|
val service = QRoute.api(IMsgService::class.java)
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
|
service.getMsgsBySeqAndCount(contact, request.messageSeq, 1, true) { code, _, msgRecords ->
|
||||||
|
if (code == 0 && msgRecords.isNotEmpty()) {
|
||||||
|
continuation.resume(msgRecords.first())
|
||||||
|
} else {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continuation.invokeOnCancellation {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: throw StatusRuntimeException(Status.NOT_FOUND.withDescription("Message not found"))
|
||||||
|
|
||||||
|
return GetMessageBySeqResponse.newBuilder().apply {
|
||||||
|
this.message = PushMessageBody.newBuilder().apply {
|
||||||
|
this.messageId = msg.msgId.toString()
|
||||||
|
this.contact = request.contact
|
||||||
|
this.sender = Sender.newBuilder().apply {
|
||||||
|
this.uin = msg.senderUin
|
||||||
|
this.nick = msg.sendNickName ?: ""
|
||||||
|
this.uid = msg.senderUid ?: ""
|
||||||
|
}.build()
|
||||||
|
this.messageSeq = msg.msgSeq
|
||||||
|
this.addAllElements(msg.elements.toKritorReqMessages(contact))
|
||||||
|
}.build()
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "GetHistoryMessage")
|
||||||
|
override suspend fun getHistoryMessage(request: GetHistoryMessageRequest): GetHistoryMessageResponse {
|
||||||
|
val contact = request.contact.let {
|
||||||
|
MessageHelper.generateContact(
|
||||||
|
when (it.scene!!) {
|
||||||
|
Scene.GROUP -> MsgConstant.KCHATTYPEGROUP
|
||||||
|
Scene.FRIEND -> MsgConstant.KCHATTYPEC2C
|
||||||
|
Scene.GUILD -> MsgConstant.KCHATTYPEGUILD
|
||||||
|
Scene.STRANGER_FROM_GROUP -> MsgConstant.KCHATTYPETEMPC2CFROMGROUP
|
||||||
|
Scene.NEARBY -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.STRANGER -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.UNRECOGNIZED -> throw StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Unrecognized scene"))
|
||||||
|
}, it.peer, it.subPeer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val msgs: List<MsgRecord> = withTimeoutOrNull(5000) {
|
||||||
|
val service = QRoute.api(IMsgService::class.java)
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
|
service.getMsgs(contact, request.startMessageId.toLong(), request.count, true) { code, _, msgRecords ->
|
||||||
|
if (code == 0 && msgRecords.isNotEmpty()) {
|
||||||
|
continuation.resume(msgRecords)
|
||||||
|
} else {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continuation.invokeOnCancellation {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: throw StatusRuntimeException(Status.NOT_FOUND.withDescription("Messages not found"))
|
||||||
|
|
||||||
|
return GetHistoryMessageResponse.newBuilder().apply {
|
||||||
|
msgs.forEach {
|
||||||
|
addMessages(PushMessageBody.newBuilder().apply {
|
||||||
|
this.messageId = it.msgId.toString()
|
||||||
|
this.contact = request.contact
|
||||||
|
this.sender = Sender.newBuilder().apply {
|
||||||
|
this.uin = it.senderUin
|
||||||
|
this.nick = it.sendNickName ?: ""
|
||||||
|
this.uid = it.senderUid ?: ""
|
||||||
|
}.build()
|
||||||
|
this.messageSeq = it.msgSeq
|
||||||
|
this.addAllElements(it.elements.toKritorReqMessages(contact))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "UploadForwardMessage")
|
||||||
|
override suspend fun uploadForwardMessage(request: UploadForwardMessageRequest): UploadForwardMessageResponse {
|
||||||
|
val contact = request.contact.let {
|
||||||
|
MessageHelper.generateContact(
|
||||||
|
when (it.scene!!) {
|
||||||
|
Scene.GROUP -> MsgConstant.KCHATTYPEGROUP
|
||||||
|
Scene.FRIEND -> MsgConstant.KCHATTYPEC2C
|
||||||
|
Scene.GUILD -> MsgConstant.KCHATTYPEGUILD
|
||||||
|
Scene.STRANGER_FROM_GROUP -> MsgConstant.KCHATTYPETEMPC2CFROMGROUP
|
||||||
|
Scene.NEARBY -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.STRANGER -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.UNRECOGNIZED -> throw StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Unrecognized scene"))
|
||||||
|
}, it.peer, it.subPeer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val forwardMessage = ForwardMessageHelper.uploadMultiMsg(
|
||||||
|
contact,
|
||||||
|
request.messagesList
|
||||||
|
).onFailure {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withCause(it))
|
||||||
|
}.getOrThrow()
|
||||||
|
|
||||||
|
return UploadForwardMessageResponse.newBuilder().apply {
|
||||||
|
this.resId = forwardMessage.resId
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "DownloadForwardMessage")
|
||||||
|
override suspend fun downloadForwardMessage(request: DownloadForwardMessageRequest): DownloadForwardMessageResponse {
|
||||||
|
return DownloadForwardMessageResponse.newBuilder().apply {
|
||||||
|
this.addAllMessages(
|
||||||
|
MessageHelper.getForwardMsg(request.resId).onFailure {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withCause(it))
|
||||||
|
}.getOrThrow().map { detail ->
|
||||||
|
PushMessageBody.newBuilder().apply {
|
||||||
|
this.time = detail.time.toLong()
|
||||||
|
this.messageId = detail.qqMsgId.toString()
|
||||||
|
this.messageSeq = detail.msgSeq
|
||||||
|
this.contact = io.kritor.common.Contact.newBuilder().apply {
|
||||||
|
this.scene = when (detail.msgType) {
|
||||||
|
MsgConstant.KCHATTYPEC2C -> Scene.FRIEND
|
||||||
|
MsgConstant.KCHATTYPEGROUP -> Scene.GROUP
|
||||||
|
MsgConstant.KCHATTYPEGUILD -> Scene.GUILD
|
||||||
|
MsgConstant.KCHATTYPETEMPC2CFROMGROUP -> Scene.STRANGER_FROM_GROUP
|
||||||
|
MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN -> Scene.NEARBY
|
||||||
|
else -> Scene.STRANGER
|
||||||
|
}
|
||||||
|
this.peer = detail.peerId.toString()
|
||||||
|
}.build()
|
||||||
|
this.sender = Sender.newBuilder().apply {
|
||||||
|
this.uin = detail.sender.userId
|
||||||
|
this.nick = detail.sender.nickName
|
||||||
|
this.uid = detail.sender.uid
|
||||||
|
}.build()
|
||||||
|
detail.message?.elements?.toKritorResponseMessages(
|
||||||
|
Contact(
|
||||||
|
detail.msgType,
|
||||||
|
detail.peerId.toString(),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
)?.let {
|
||||||
|
this.addAllElements(it)
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "DeleteEssenceMessage")
|
||||||
|
override suspend fun deleteEssenceMessage(request: DeleteEssenceMessageRequest): DeleteEssenceMessageResponse {
|
||||||
|
val contact = MessageHelper.generateContact(MsgConstant.KCHATTYPEGROUP, request.groupId.toString())
|
||||||
|
val msg: MsgRecord = withTimeoutOrNull(5000) {
|
||||||
|
val service = QRoute.api(IMsgService::class.java)
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
|
service.getMsgsByMsgId(contact, arrayListOf(request.messageId.toLong())) { code, _, msgRecords ->
|
||||||
|
if (code == 0 && msgRecords.isNotEmpty()) {
|
||||||
|
continuation.resume(msgRecords.first())
|
||||||
|
} else {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continuation.invokeOnCancellation {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: throw StatusRuntimeException(Status.NOT_FOUND.withDescription("Message not found"))
|
||||||
|
if (MessageHelper.deleteEssenceMessage(request.groupId, msg.msgSeq, msg.msgRandom) == null)
|
||||||
|
throw StatusRuntimeException(Status.NOT_FOUND.withDescription("delete essence message failed"))
|
||||||
|
return DeleteEssenceMessageResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "GetEssenceMessageList")
|
||||||
|
override suspend fun getEssenceMessageList(request: GetEssenceMessageListRequest): GetEssenceMessageListResponse {
|
||||||
|
val contact = MessageHelper.generateContact(MsgConstant.KCHATTYPEGROUP, request.groupId.toString())
|
||||||
|
return GetEssenceMessageListResponse.newBuilder().apply {
|
||||||
|
MessageHelper.getEssenceMessageList(request.groupId, request.page, request.pageSize).onFailure {
|
||||||
|
throw StatusRuntimeException(Status.INTERNAL.withCause(it))
|
||||||
|
}.getOrThrow().forEach {
|
||||||
|
addMessages(EssenceMessageBody.newBuilder().apply {
|
||||||
|
withTimeoutOrNull(5000) {
|
||||||
|
val service = QRoute.api(IMsgService::class.java)
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
|
service.getMsgsBySeqAndCount(contact, it.messageSeq, 1, true) { code, _, msgRecords ->
|
||||||
|
if (code == 0 && msgRecords.isNotEmpty()) {
|
||||||
|
continuation.resume(msgRecords.first())
|
||||||
|
} else {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continuation.invokeOnCancellation {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}?.let {
|
||||||
|
this.messageId = it.msgId.toString()
|
||||||
|
}
|
||||||
|
this.messageSeq = it.messageSeq
|
||||||
|
this.messageTime = it.senderTime
|
||||||
|
this.senderNick = it.senderNick
|
||||||
|
this.senderUin = it.senderId
|
||||||
|
this.operationTime = it.operatorTime
|
||||||
|
this.operatorNick = it.operatorNick
|
||||||
|
this.operatorUin = it.operatorId
|
||||||
|
this.jsonElements = it.messageContent.toString()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "SetEssenceMessage")
|
||||||
|
override suspend fun setEssenceMessage(request: SetEssenceMessageRequest): SetEssenceMessageResponse {
|
||||||
|
val contact = MessageHelper.generateContact(MsgConstant.KCHATTYPEGROUP, request.groupId.toString())
|
||||||
|
val msg: MsgRecord = withTimeoutOrNull(5000) {
|
||||||
|
val service = QRoute.api(IMsgService::class.java)
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
|
service.getMsgsByMsgId(contact, arrayListOf(request.messageId.toLong())) { code, _, msgRecords ->
|
||||||
|
if (code == 0 && msgRecords.isNotEmpty()) {
|
||||||
|
continuation.resume(msgRecords.first())
|
||||||
|
} else {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continuation.invokeOnCancellation {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: throw StatusRuntimeException(Status.NOT_FOUND.withDescription("Message not found"))
|
||||||
|
if (MessageHelper.setEssenceMessage(request.groupId, msg.msgSeq, msg.msgRandom) == null) {
|
||||||
|
throw StatusRuntimeException(Status.NOT_FOUND.withDescription("set essence message failed"))
|
||||||
|
}
|
||||||
|
return SetEssenceMessageResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("MessageService", "ReactMessageWithEmoji")
|
||||||
|
override suspend fun reactMessageWithEmoji(request: ReactMessageWithEmojiRequest): ReactMessageWithEmojiResponse {
|
||||||
|
val contact = request.contact.let {
|
||||||
|
MessageHelper.generateContact(
|
||||||
|
when (it.scene!!) {
|
||||||
|
Scene.GROUP -> MsgConstant.KCHATTYPEGROUP
|
||||||
|
Scene.FRIEND -> MsgConstant.KCHATTYPEC2C
|
||||||
|
Scene.GUILD -> MsgConstant.KCHATTYPEGUILD
|
||||||
|
Scene.STRANGER_FROM_GROUP -> MsgConstant.KCHATTYPETEMPC2CFROMGROUP
|
||||||
|
Scene.NEARBY -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.STRANGER -> MsgConstant.KCHATTYPETEMPC2CFROMUNKNOWN
|
||||||
|
Scene.UNRECOGNIZED -> throw StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Unrecognized scene"))
|
||||||
|
}, it.peer, it.subPeer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val msg: MsgRecord = withTimeoutOrNull(5000) {
|
||||||
|
val service = QRoute.api(IMsgService::class.java)
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
|
service.getMsgsByMsgId(contact, arrayListOf(request.messageId.toLong())) { code, _, msgRecords ->
|
||||||
|
if (code == 0 && msgRecords.isNotEmpty()) {
|
||||||
|
continuation.resume(msgRecords.first())
|
||||||
|
} else {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continuation.invokeOnCancellation {
|
||||||
|
continuation.resume(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: throw StatusRuntimeException(Status.NOT_FOUND.withDescription("Message not found"))
|
||||||
|
MessageHelper.setGroupMessageCommentFace(
|
||||||
|
request.contact.longPeer(),
|
||||||
|
msg.msgSeq.toULong(),
|
||||||
|
request.faceId.toString(),
|
||||||
|
request.isSet
|
||||||
|
)
|
||||||
|
return ReactMessageWithEmojiResponse.newBuilder().build()
|
||||||
|
}
|
||||||
|
}
|
33
xposed/src/main/java/kritor/service/QsignService.kt
Normal file
33
xposed/src/main/java/kritor/service/QsignService.kt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
import com.google.protobuf.ByteString
|
||||||
|
import com.tencent.mobileqq.fe.FEKit
|
||||||
|
import com.tencent.mobileqq.qsec.qsecdandelionsdk.Dandelion
|
||||||
|
import io.kritor.developer.*
|
||||||
|
|
||||||
|
|
||||||
|
internal object QsignService: QsignServiceGrpcKt.QsignServiceCoroutineImplBase() {
|
||||||
|
@Grpc("QsignService", "Sign")
|
||||||
|
override suspend fun sign(request: SignRequest): SignResponse {
|
||||||
|
return SignResponse.newBuilder().apply {
|
||||||
|
val result = FEKit.getInstance().getSign(request.command, request.buffer.toByteArray(), request.seq, request.uin)
|
||||||
|
this.secSig = ByteString.copyFrom(result.sign)
|
||||||
|
this.secDeviceToken = ByteString.copyFrom(result.token)
|
||||||
|
this.secExtra = ByteString.copyFrom(result.extra)
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("QsignService", "Energy")
|
||||||
|
override suspend fun energy(request: EnergyRequest): EnergyResponse {
|
||||||
|
return EnergyResponse.newBuilder().apply {
|
||||||
|
this.result = ByteString.copyFrom(Dandelion.getInstance().fly(request.data, request.salt.toByteArray()))
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("QsignService", "GetCmdWhitelist")
|
||||||
|
override suspend fun getCmdWhitelist(request: GetCmdWhitelistRequest): GetCmdWhitelistResponse {
|
||||||
|
return GetCmdWhitelistResponse.newBuilder().apply {
|
||||||
|
addAllCommands(FEKit.getInstance().cmdWhiteList)
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
}
|
58
xposed/src/main/java/kritor/service/WebService.kt
Normal file
58
xposed/src/main/java/kritor/service/WebService.kt
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package kritor.service
|
||||||
|
|
||||||
|
import io.grpc.Status
|
||||||
|
import io.grpc.StatusRuntimeException
|
||||||
|
import io.kritor.web.*
|
||||||
|
import qq.service.ticket.TicketHelper
|
||||||
|
|
||||||
|
internal object WebService: WebServiceGrpcKt.WebServiceCoroutineImplBase() {
|
||||||
|
@Grpc("WebService", "GetCookies")
|
||||||
|
override suspend fun getCookies(request: GetCookiesRequest): GetCookiesResponse {
|
||||||
|
return GetCookiesResponse.newBuilder().apply {
|
||||||
|
if (request.domain.isNullOrEmpty()) {
|
||||||
|
this.cookie = TicketHelper.getCookie()
|
||||||
|
} else {
|
||||||
|
this.cookie = TicketHelper.getCookie(request.domain)
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("WebService", "GetCredentials")
|
||||||
|
override suspend fun getCredentials(request: GetCredentialsRequest): GetCredentialsResponse {
|
||||||
|
return GetCredentialsResponse.newBuilder().apply {
|
||||||
|
if (request.domain.isNullOrEmpty()) {
|
||||||
|
val uin = TicketHelper.getUin()
|
||||||
|
val skey = TicketHelper.getRealSkey(uin)
|
||||||
|
val pskey = TicketHelper.getPSKey(uin)
|
||||||
|
this.cookie = "o_cookie=$uin; ied_qq=o$uin; pac_uid=1_$uin; uin=o$uin; skey=$skey; p_uin=o$uin; p_skey=$pskey;"
|
||||||
|
this.bkn = TicketHelper.getCSRF(pskey)
|
||||||
|
} else {
|
||||||
|
val uin = TicketHelper.getUin()
|
||||||
|
val skey = TicketHelper.getRealSkey(uin)
|
||||||
|
val pskey = TicketHelper.getPSKey(uin, request.domain) ?: ""
|
||||||
|
val pt4token = TicketHelper.getPt4Token(uin, request.domain) ?: ""
|
||||||
|
this.cookie = "o_cookie=$uin; ied_qq=o$uin; pac_uid=1_$uin; uin=o$uin; skey=$skey; p_uin=o$uin; p_skey=$pskey; pt4_token=$pt4token;"
|
||||||
|
this.bkn = TicketHelper.getCSRF(pskey)
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("WebService", "GetCSRFToken")
|
||||||
|
override suspend fun getCSRFToken(request: GetCSRFTokenRequest): GetCSRFTokenResponse {
|
||||||
|
return GetCSRFTokenResponse.newBuilder().apply {
|
||||||
|
if (request.domain.isNullOrEmpty()) {
|
||||||
|
this.bkn = TicketHelper.getCSRF()
|
||||||
|
} else {
|
||||||
|
this.bkn = TicketHelper.getCSRF(TicketHelper.getUin(), request.domain)
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Grpc("WebService", "GetHttpCookies")
|
||||||
|
override suspend fun getHttpCookies(request: GetHttpCookiesRequest): GetHttpCookiesResponse {
|
||||||
|
return GetHttpCookiesResponse.newBuilder().apply {
|
||||||
|
this.cookie = TicketHelper.getHttpCookies(request.appid, request.daid, request.jumpUrl)
|
||||||
|
?: throw StatusRuntimeException(Status.INTERNAL.withDescription("unable to get http cookies"))
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package moe.fuqiuluo.shamrock.config
|
||||||
|
|
||||||
|
object ActiveTicket: ConfigKey<String>() {
|
||||||
|
override fun name(): String = "active_ticket"
|
||||||
|
|
||||||
|
override fun default(): String = ""
|
||||||
|
}
|
@ -10,3 +10,6 @@ abstract class ConfigKey<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal inline fun <reified Type, reified T: ConfigKey<Type>> T.get(): Type {
|
||||||
|
return ShamrockConfig[this]
|
||||||
|
}
|
||||||
|
@ -2,5 +2,5 @@ package moe.fuqiuluo.shamrock.config
|
|||||||
|
|
||||||
object EnableOldBDH: ConfigKey<Boolean>() {
|
object EnableOldBDH: ConfigKey<Boolean>() {
|
||||||
override fun name() = "enable_old_bdh"
|
override fun name() = "enable_old_bdh"
|
||||||
override fun default() = false
|
override fun default() = true
|
||||||
}
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package moe.fuqiuluo.shamrock.config
|
package moe.fuqiuluo.shamrock.config
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
|
import moe.fuqiuluo.shamrock.xposed.loader.LuoClassloader.moduleLoader
|
||||||
import mqq.app.MobileQQ
|
import mqq.app.MobileQQ
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
|
|
||||||
@ -12,15 +14,29 @@ private val configFile = configDir.resolve("config.prop")
|
|||||||
|
|
||||||
private val configKeys = setOf(
|
private val configKeys = setOf(
|
||||||
ActiveRPC,
|
ActiveRPC,
|
||||||
|
AntiJvmTrace,
|
||||||
ForceTablet,
|
ForceTablet,
|
||||||
PassiveRPC,
|
PassiveRPC,
|
||||||
ResourceGroup,
|
ResourceGroup,
|
||||||
RPCAddress,
|
RPCAddress,
|
||||||
RPCPort
|
RPCPort,
|
||||||
|
AliveReply,
|
||||||
)
|
)
|
||||||
|
|
||||||
internal object ShamrockConfig: Properties() {
|
internal object ShamrockConfig: Properties() {
|
||||||
init {
|
init {
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
moduleLoader.getResourceAsStream("assets/config.properties")?.use {
|
||||||
|
configDir.resolve("default.prop").outputStream().use { output ->
|
||||||
|
it.copyTo(output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
moduleLoader.getResourceAsStream("assets/config.properties")?.use {
|
||||||
|
configFile.outputStream().use { output ->
|
||||||
|
it.copyTo(output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (configFile.exists()) configFile.inputStream().use {
|
if (configFile.exists()) configFile.inputStream().use {
|
||||||
load(it)
|
load(it)
|
||||||
}
|
}
|
||||||
@ -39,13 +55,34 @@ internal object ShamrockConfig: Properties() {
|
|||||||
fun updateConfig(intent: Intent? = null) {
|
fun updateConfig(intent: Intent? = null) {
|
||||||
intent?.let {
|
intent?.let {
|
||||||
for (key in configKeys) {
|
for (key in configKeys) {
|
||||||
|
when (key.default()) {
|
||||||
|
is String -> {
|
||||||
val value = intent.getStringExtra(key.name())
|
val value = intent.getStringExtra(key.name())
|
||||||
if (value != null) setProperty(key.name(), value)
|
if (value != null) setProperty(key.name(), value)
|
||||||
}
|
}
|
||||||
|
is Boolean -> {
|
||||||
|
val value = intent.getBooleanExtra(key.name(), key.default() as Boolean)
|
||||||
|
setProperty(key.name(), value.toString())
|
||||||
|
}
|
||||||
|
is Int -> {
|
||||||
|
val value = intent.getIntExtra(key.name(), key.default() as Int)
|
||||||
|
setProperty(key.name(), value.toString())
|
||||||
|
}
|
||||||
|
is Long -> {
|
||||||
|
val value = intent.getLongExtra(key.name(), key.default() as Long)
|
||||||
|
setProperty(key.name(), value.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getProperty(ActiveTicket.name()).isNullOrEmpty()) {
|
||||||
|
setProperty(ActiveTicket.name(), "") // 初始化ticket
|
||||||
|
}
|
||||||
|
|
||||||
setProperty(IsInit.name(), "true")
|
setProperty(IsInit.name(), "true")
|
||||||
}
|
}
|
||||||
configFile.outputStream().use {
|
configFile.outputStream().use {
|
||||||
store(it, "Shamrock Config ${System.currentTimeMillis()}")
|
store(it, "Shamrock Config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
package moe.fuqiuluo.shamrock.helper
|
|
||||||
|
|
||||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
||||||
import moe.fuqiuluo.shamrock.internals.NTServiceFetcher
|
|
||||||
import kotlin.coroutines.resume
|
|
||||||
|
|
||||||
internal object ContactHelper {
|
|
||||||
suspend fun getUinByUidAsync(uid: String): String {
|
|
||||||
if (uid.isBlank() || uid == "0") {
|
|
||||||
return "0"
|
|
||||||
}
|
|
||||||
|
|
||||||
val kernelService = NTServiceFetcher.kernelService
|
|
||||||
val sessionService = kernelService.wrapperSession
|
|
||||||
|
|
||||||
return suspendCancellableCoroutine { continuation ->
|
|
||||||
sessionService.uixConvertService.getUin(hashSetOf(uid)) {
|
|
||||||
continuation.resume(it)
|
|
||||||
}
|
|
||||||
}[uid]?.toString() ?: "0"
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun getUidByUinAsync(peerId: Long): String {
|
|
||||||
val kernelService = NTServiceFetcher.kernelService
|
|
||||||
val sessionService = kernelService.wrapperSession
|
|
||||||
return suspendCancellableCoroutine { continuation ->
|
|
||||||
sessionService.uixConvertService.getUid(hashSetOf(peerId)) {
|
|
||||||
continuation.resume(it)
|
|
||||||
}
|
|
||||||
}[peerId]!!
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,7 +14,10 @@ import moe.fuqiuluo.shamrock.tools.toast
|
|||||||
import moe.fuqiuluo.shamrock.xposed.helper.AppTalker
|
import moe.fuqiuluo.shamrock.xposed.helper.AppTalker
|
||||||
import mqq.app.MobileQQ
|
import mqq.app.MobileQQ
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
import java.util.Timer
|
||||||
|
import java.util.TimerTask
|
||||||
|
|
||||||
internal enum class Level(
|
internal enum class Level(
|
||||||
val id: Byte
|
val id: Byte
|
||||||
@ -31,7 +34,29 @@ internal object LogCenter {
|
|||||||
// 格式化时间
|
// 格式化时间
|
||||||
SimpleDateFormat("yyyy-MM-dd").format(Date())
|
SimpleDateFormat("yyyy-MM-dd").format(Date())
|
||||||
}_"
|
}_"
|
||||||
private val LogFile = MobileQQ.getContext().getExternalFilesDir(null)!!
|
private var LogFile = generateLogFile()
|
||||||
|
|
||||||
|
private val format = SimpleDateFormat("[HH:mm:ss] ")
|
||||||
|
private val timer = Timer()
|
||||||
|
|
||||||
|
init {
|
||||||
|
val now = Calendar.getInstance()
|
||||||
|
val tomorrowMidnight = Calendar.getInstance().apply {
|
||||||
|
add(Calendar.DAY_OF_YEAR, 1)
|
||||||
|
set(Calendar.HOUR_OF_DAY, 0)
|
||||||
|
set(Calendar.MINUTE, 0)
|
||||||
|
set(Calendar.SECOND, 0)
|
||||||
|
set(Calendar.MILLISECOND, 0)
|
||||||
|
}
|
||||||
|
val delay = tomorrowMidnight.timeInMillis - now.timeInMillis
|
||||||
|
timer.scheduleAtFixedRate(object : TimerTask() {
|
||||||
|
override fun run() {
|
||||||
|
LogFile = generateLogFile()
|
||||||
|
}
|
||||||
|
}, delay, 24 * 60 * 60 * 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun generateLogFile() = MobileQQ.getContext().getExternalFilesDir(null)!!
|
||||||
.parentFile!!.resolve("Tencent/Shamrock/log").also {
|
.parentFile!!.resolve("Tencent/Shamrock/log").also {
|
||||||
if (it.exists()) it.delete()
|
if (it.exists()) it.delete()
|
||||||
it.mkdirs()
|
it.mkdirs()
|
||||||
@ -49,8 +74,6 @@ internal object LogCenter {
|
|||||||
return@let result
|
return@let result
|
||||||
}
|
}
|
||||||
|
|
||||||
private val format = SimpleDateFormat("[HH:mm:ss] ")
|
|
||||||
|
|
||||||
fun log(string: String, level: Level = Level.INFO, toast: Boolean = false) {
|
fun log(string: String, level: Level = Level.INFO, toast: Boolean = false) {
|
||||||
if (!ShamrockConfig[DebugMode] && level == Level.DEBUG) {
|
if (!ShamrockConfig[DebugMode] && level == Level.DEBUG) {
|
||||||
return
|
return
|
||||||
|
@ -0,0 +1,579 @@
|
|||||||
|
@file:OptIn(DelicateCoroutinesApi::class)
|
||||||
|
|
||||||
|
package moe.fuqiuluo.shamrock.internals
|
||||||
|
|
||||||
|
import com.tencent.qqnt.kernel.nativeinterface.MsgElement
|
||||||
|
import com.tencent.qqnt.kernel.nativeinterface.MsgRecord
|
||||||
|
import io.kritor.event.*
|
||||||
|
import io.kritor.common.PushMessageBody
|
||||||
|
import io.kritor.common.Contact
|
||||||
|
import io.kritor.common.Scene
|
||||||
|
import io.kritor.common.Sender
|
||||||
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.flow.FlowCollector
|
||||||
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import qq.service.QQInterfaces
|
||||||
|
import qq.service.contact.ContactHelper
|
||||||
|
import qq.service.msg.toKritorEventMessages
|
||||||
|
|
||||||
|
internal object GlobalEventTransmitter : QQInterfaces() {
|
||||||
|
private val MessageEventFlow by lazy {
|
||||||
|
MutableSharedFlow<Pair<MsgRecord, PushMessageBody>>()
|
||||||
|
}
|
||||||
|
private val noticeEventFlow by lazy {
|
||||||
|
MutableSharedFlow<NoticeEvent>()
|
||||||
|
}
|
||||||
|
private val requestEventFlow by lazy {
|
||||||
|
MutableSharedFlow<RequestEvent>()
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun pushNotice(noticeEvent: NoticeEvent) = noticeEventFlow.emit(noticeEvent)
|
||||||
|
|
||||||
|
private suspend fun pushRequest(requestEvent: RequestEvent) = requestEventFlow.emit(requestEvent)
|
||||||
|
|
||||||
|
private suspend fun transMessageEvent(record: MsgRecord, message: PushMessageBody) =
|
||||||
|
MessageEventFlow.emit(record to message)
|
||||||
|
|
||||||
|
object MessageTransmitter {
|
||||||
|
suspend fun transGroupMessage(
|
||||||
|
record: MsgRecord,
|
||||||
|
elements: ArrayList<MsgElement>,
|
||||||
|
): Boolean {
|
||||||
|
transMessageEvent(record, PushMessageBody.newBuilder().apply {
|
||||||
|
this.time = record.msgTime
|
||||||
|
this.messageId = record.msgId.toString()
|
||||||
|
this.messageSeq = record.msgSeq
|
||||||
|
this.contact = Contact.newBuilder().apply {
|
||||||
|
this.scene = Scene.GROUP
|
||||||
|
this.peer = record.peerUin.toString()
|
||||||
|
this.subPeer = record.peerUid
|
||||||
|
}.build()
|
||||||
|
this.sender = Sender.newBuilder().apply {
|
||||||
|
this.uin = record.senderUin
|
||||||
|
this.uid = record.senderUid
|
||||||
|
this.nick = record.sendNickName
|
||||||
|
}.build()
|
||||||
|
this.addAllElements(elements.toKritorEventMessages(record))
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transPrivateMessage(
|
||||||
|
record: MsgRecord,
|
||||||
|
elements: ArrayList<MsgElement>,
|
||||||
|
): Boolean {
|
||||||
|
transMessageEvent(record, PushMessageBody.newBuilder().apply {
|
||||||
|
this.time = record.msgTime
|
||||||
|
this.messageId = record.msgId.toString()
|
||||||
|
this.messageSeq = record.msgSeq
|
||||||
|
this.contact = Contact.newBuilder().apply {
|
||||||
|
this.scene = Scene.FRIEND
|
||||||
|
this.peer = record.senderUid
|
||||||
|
this.subPeer = record.senderUid
|
||||||
|
}.build()
|
||||||
|
this.sender = Sender.newBuilder().apply {
|
||||||
|
this.uin = record.senderUin
|
||||||
|
this.uid = record.senderUid
|
||||||
|
this.nick = record.sendNickName
|
||||||
|
}.build()
|
||||||
|
this.addAllElements(elements.toKritorEventMessages(record))
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transTempMessage(
|
||||||
|
record: MsgRecord,
|
||||||
|
elements: ArrayList<MsgElement>,
|
||||||
|
groupCode: Long,
|
||||||
|
fromNick: String,
|
||||||
|
): Boolean {
|
||||||
|
transMessageEvent(record, PushMessageBody.newBuilder().apply {
|
||||||
|
this.time = record.msgTime
|
||||||
|
this.messageId = record.msgId.toString()
|
||||||
|
this.messageSeq = record.msgSeq
|
||||||
|
this.contact = Contact.newBuilder().apply {
|
||||||
|
this.scene = if (groupCode > 0) Scene.STRANGER_FROM_GROUP else Scene.STRANGER
|
||||||
|
this.peer = record.senderUid
|
||||||
|
this.subPeer = groupCode.toString()
|
||||||
|
}.build()
|
||||||
|
this.sender = Sender.newBuilder().apply {
|
||||||
|
this.uin = record.senderUin
|
||||||
|
this.uid = record.senderUid
|
||||||
|
this.nick = record.sendNickName
|
||||||
|
}.build()
|
||||||
|
this.addAllElements(elements.toKritorEventMessages(record))
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transGuildMessage(
|
||||||
|
record: MsgRecord,
|
||||||
|
elements: ArrayList<MsgElement>,
|
||||||
|
): Boolean {
|
||||||
|
transMessageEvent(record, PushMessageBody.newBuilder().apply {
|
||||||
|
this.time = record.msgTime
|
||||||
|
this.messageId = record.msgId.toString()
|
||||||
|
this.messageSeq = record.msgSeq
|
||||||
|
this.contact = Contact.newBuilder().apply {
|
||||||
|
this.scene = Scene.GUILD
|
||||||
|
this.peer = record.guildId ?: ""
|
||||||
|
this.subPeer = record.channelId ?: ""
|
||||||
|
}.build()
|
||||||
|
this.sender = Sender.newBuilder().apply {
|
||||||
|
this.uin = record.senderUin
|
||||||
|
this.uid = record.senderUid
|
||||||
|
this.nick = record.sendNickName
|
||||||
|
}.build()
|
||||||
|
this.addAllElements(elements.toKritorEventMessages(record))
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件通知 通知器
|
||||||
|
**/
|
||||||
|
object FileNoticeTransmitter {
|
||||||
|
/**
|
||||||
|
* 推送私聊文件事件
|
||||||
|
*/
|
||||||
|
suspend fun transPrivateFileEvent(
|
||||||
|
msgTime: Long,
|
||||||
|
senderUid: String,
|
||||||
|
senderUin: Long,
|
||||||
|
fileId: String,
|
||||||
|
fileSubId: String,
|
||||||
|
fileName: String,
|
||||||
|
fileSize: Long,
|
||||||
|
expireTime: Long,
|
||||||
|
url: String
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.PRIVATE_FILE_UPLOADED
|
||||||
|
this.time = msgTime
|
||||||
|
this.privateFileUploaded = PrivateFileUploadedNotice.newBuilder().apply {
|
||||||
|
this.fileId = fileId
|
||||||
|
this.fileName = fileName
|
||||||
|
this.operatorUid = senderUid
|
||||||
|
this.operatorUin = senderUin
|
||||||
|
this.fileSize = fileSize
|
||||||
|
this.expireTime = expireTime
|
||||||
|
this.fileSubId = fileSubId.toInt() // todo(这玩意真的是一个数字?)
|
||||||
|
this.fileUrl = url
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送私聊文件事件
|
||||||
|
*/
|
||||||
|
suspend fun transGroupFileEvent(
|
||||||
|
msgTime: Long,
|
||||||
|
senderUid: String,
|
||||||
|
senderUin: Long,
|
||||||
|
groupId: Long,
|
||||||
|
uuid: String,
|
||||||
|
fileName: String,
|
||||||
|
fileSize: Long,
|
||||||
|
bizId: Int,
|
||||||
|
url: String
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_FILE_UPLOADED
|
||||||
|
this.time = msgTime
|
||||||
|
this.groupFileUploaded = GroupFileUploadedNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupId
|
||||||
|
this.operatorUid = senderUid
|
||||||
|
this.operatorUin = senderUin
|
||||||
|
this.fileId = uuid
|
||||||
|
this.fileName = fileName
|
||||||
|
this.fileSize = fileSize
|
||||||
|
this.fileSubId = bizId
|
||||||
|
this.fileUrl = url
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群聊通知 通知器
|
||||||
|
*/
|
||||||
|
object GroupNoticeTransmitter {
|
||||||
|
suspend fun transGroupSign(
|
||||||
|
time: Long,
|
||||||
|
target: Long,
|
||||||
|
action: String,
|
||||||
|
rankImg: String,
|
||||||
|
groupCode: Long
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_SIGN_IN
|
||||||
|
this.time = time
|
||||||
|
this.groupSignIn = GroupSignInNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupCode
|
||||||
|
this.targetUid = ContactHelper.getUidByUinAsync(target)
|
||||||
|
this.targetUin = target
|
||||||
|
this.action = action
|
||||||
|
this.rankImage = rankImg
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transGroupPoke(
|
||||||
|
time: Long,
|
||||||
|
operator: Long,
|
||||||
|
target: Long,
|
||||||
|
action: String,
|
||||||
|
suffix: String,
|
||||||
|
actionImg: String,
|
||||||
|
groupCode: Long
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_POKE
|
||||||
|
this.time = time
|
||||||
|
this.groupPoke = GroupPokeNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupCode
|
||||||
|
this.action = action
|
||||||
|
this.targetUid = ContactHelper.getUidByUinAsync(target)
|
||||||
|
this.targetUin = target
|
||||||
|
this.operatorUid = ContactHelper.getUidByUinAsync(operator)
|
||||||
|
this.operatorUin = operator
|
||||||
|
this.suffix = suffix
|
||||||
|
this.actionImage = actionImg
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transGroupMemberNumIncreased(
|
||||||
|
time: Long,
|
||||||
|
target: Long,
|
||||||
|
targetUid: String,
|
||||||
|
groupCode: Long,
|
||||||
|
operator: Long,
|
||||||
|
operatorUid: String,
|
||||||
|
type: GroupMemberIncreasedNotice.GroupMemberIncreasedType
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_MEMBER_INCREASE
|
||||||
|
this.time = time
|
||||||
|
this.groupMemberIncrease = GroupMemberIncreasedNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupCode
|
||||||
|
this.operatorUid = operatorUid
|
||||||
|
this.operatorUin = operator
|
||||||
|
this.targetUid = targetUid
|
||||||
|
this.targetUin = target
|
||||||
|
this.type = type
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transGroupMemberNumDecreased(
|
||||||
|
time: Long,
|
||||||
|
target: Long,
|
||||||
|
targetUid: String,
|
||||||
|
groupCode: Long,
|
||||||
|
operator: Long,
|
||||||
|
operatorUid: String,
|
||||||
|
type: GroupMemberDecreasedNotice.GroupMemberDecreasedType
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_MEMBER_DECREASE
|
||||||
|
this.time = time
|
||||||
|
this.groupMemberDecrease = GroupMemberDecreasedNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupCode
|
||||||
|
this.operatorUid = operatorUid
|
||||||
|
this.operatorUin = operator
|
||||||
|
this.targetUid = targetUid
|
||||||
|
this.targetUin = target
|
||||||
|
this.type = type
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transGroupAdminChanged(
|
||||||
|
msgTime: Long,
|
||||||
|
target: Long,
|
||||||
|
targetUid: String,
|
||||||
|
groupCode: Long,
|
||||||
|
setAdmin: Boolean
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_ADMIN_CHANGED
|
||||||
|
this.time = msgTime
|
||||||
|
this.groupAdminChanged = GroupAdminChangedNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupCode
|
||||||
|
this.targetUid = targetUid
|
||||||
|
this.targetUin = target
|
||||||
|
this.isAdmin = setAdmin
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transGroupWholeBan(
|
||||||
|
msgTime: Long,
|
||||||
|
groupCode: Long,
|
||||||
|
operatorUid: String,
|
||||||
|
operator: Long,
|
||||||
|
isOpen: Boolean
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_WHOLE_BAN
|
||||||
|
this.time = msgTime
|
||||||
|
this.groupWholeBan = GroupWholeBanNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupCode
|
||||||
|
this.isBan = isOpen
|
||||||
|
this.operatorUid = operatorUid
|
||||||
|
this.operatorUin = operator
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transGroupBan(
|
||||||
|
msgTime: Long,
|
||||||
|
operator: Long,
|
||||||
|
operatorUid: String,
|
||||||
|
target: Long,
|
||||||
|
targetUid: String,
|
||||||
|
groupCode: Long,
|
||||||
|
duration: Int
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_MEMBER_BAN
|
||||||
|
this.time = msgTime
|
||||||
|
this.groupMemberBan = GroupMemberBanNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupCode
|
||||||
|
this.operatorUid = operatorUid
|
||||||
|
this.operatorUin = operator
|
||||||
|
this.targetUid = targetUid
|
||||||
|
this.targetUin = target
|
||||||
|
this.duration = duration
|
||||||
|
this.type = if (duration > 0) GroupMemberBanNotice.GroupMemberBanType.BAN
|
||||||
|
else GroupMemberBanNotice.GroupMemberBanType.LIFT_BAN
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transGroupMsgRecall(
|
||||||
|
time: Long,
|
||||||
|
operator: Long,
|
||||||
|
operatorUid: String,
|
||||||
|
target: Long,
|
||||||
|
targetUid: String,
|
||||||
|
groupCode: Long,
|
||||||
|
msgId: Long,
|
||||||
|
tipText: String
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_RECALL
|
||||||
|
this.time = time
|
||||||
|
this.groupRecall = GroupRecallNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupCode
|
||||||
|
this.operatorUid = operatorUid
|
||||||
|
this.operatorUin = operator
|
||||||
|
this.targetUid = targetUid
|
||||||
|
this.targetUin = target
|
||||||
|
this.messageId = msgId.toString()
|
||||||
|
this.tipText = tipText
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transCardChange(
|
||||||
|
time: Long,
|
||||||
|
targetId: Long,
|
||||||
|
newCard: String,
|
||||||
|
groupId: Long
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_CARD_CHANGED
|
||||||
|
this.time = time
|
||||||
|
this.groupCardChanged = GroupCardChangedNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupId
|
||||||
|
this.targetUin = targetId
|
||||||
|
this.newCard = newCard
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transTitleChange(
|
||||||
|
time: Long,
|
||||||
|
targetUin: Long,
|
||||||
|
title: String,
|
||||||
|
groupId: Long
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_MEMBER_UNIQUE_TITLE_CHANGED
|
||||||
|
this.time = time
|
||||||
|
this.groupMemberUniqueTitleChanged = GroupUniqueTitleChangedNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupId
|
||||||
|
this.targetUid = ContactHelper.getUidByUinAsync(targetUin)
|
||||||
|
this.targetUin = targetUin
|
||||||
|
this.title = title
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transEssenceChange(
|
||||||
|
time: Long,
|
||||||
|
senderUin: Long,
|
||||||
|
operatorUin: Long,
|
||||||
|
msgId: Long,
|
||||||
|
groupId: Long,
|
||||||
|
subType: UInt
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.GROUP_ESSENCE_CHANGED
|
||||||
|
this.time = time
|
||||||
|
this.groupEssenceChanged = GroupEssenceMessageNotice.newBuilder().apply {
|
||||||
|
this.groupId = groupId
|
||||||
|
this.messageId = msgId.toString()
|
||||||
|
this.targetUid = ContactHelper.getUidByUinAsync(targetUin)
|
||||||
|
this.targetUin = senderUin
|
||||||
|
this.operatorUid = ContactHelper.getUidByUinAsync(operatorUin)
|
||||||
|
this.operatorUin = operatorUin
|
||||||
|
this.isSet = subType.toInt() == 1
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私聊通知 通知器
|
||||||
|
*/
|
||||||
|
object PrivateNoticeTransmitter {
|
||||||
|
suspend fun transPrivatePoke(
|
||||||
|
msgTime: Long,
|
||||||
|
operator: Long,
|
||||||
|
action: String?,
|
||||||
|
suffix: String?,
|
||||||
|
actionImg: String?
|
||||||
|
): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.PRIVATE_POKE
|
||||||
|
this.time = msgTime
|
||||||
|
this.privatePoke = PrivatePokeNotice.newBuilder().apply {
|
||||||
|
this.action = action ?: ""
|
||||||
|
this.operatorUid = ContactHelper.getUidByUinAsync(operator)
|
||||||
|
this.operatorUin = operator
|
||||||
|
this.suffix = suffix ?: ""
|
||||||
|
this.actionImage = actionImg ?: ""
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transPrivateRecall(time: Long, operator: Long, msgId: Long, tipText: String): Boolean {
|
||||||
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
|
this.type = NoticeEvent.NoticeType.PRIVATE_RECALL
|
||||||
|
this.time = time
|
||||||
|
this.privateRecall = PrivateRecallNotice.newBuilder().apply {
|
||||||
|
this.operatorUin = operator
|
||||||
|
this.messageId = msgId.toString()
|
||||||
|
this.tipText = tipText
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求 通知器
|
||||||
|
*/
|
||||||
|
object RequestTransmitter {
|
||||||
|
suspend fun transFriendApp(time: Long, applierUid: String, operator: Long, tipText: String, flag: String): Boolean {
|
||||||
|
pushRequest(RequestEvent.newBuilder().apply {
|
||||||
|
this.type = RequestEvent.RequestType.FRIEND_APPLY
|
||||||
|
this.time = time
|
||||||
|
this.requestId = flag
|
||||||
|
this.friendApply = FriendApplyRequest.newBuilder().apply {
|
||||||
|
this.applierUid = applierUid
|
||||||
|
this.applierUin = operator
|
||||||
|
this.message = tipText
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transGroupApply(
|
||||||
|
time: Long,
|
||||||
|
applierUin: Long,
|
||||||
|
applierUid: String,
|
||||||
|
reason: String,
|
||||||
|
groupCode: Long,
|
||||||
|
flag: String
|
||||||
|
): Boolean {
|
||||||
|
pushRequest(RequestEvent.newBuilder().apply {
|
||||||
|
this.type = RequestEvent.RequestType.GROUP_APPLY
|
||||||
|
this.time = time
|
||||||
|
this.requestId = flag
|
||||||
|
this.groupApply = GroupApplyRequest.newBuilder().apply {
|
||||||
|
this.applierUid = applierUid
|
||||||
|
this.applierUin = applierUin
|
||||||
|
this.groupId = groupCode
|
||||||
|
this.reason = reason
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun transGroupInvite(
|
||||||
|
time: Long,
|
||||||
|
inviterUid: String,
|
||||||
|
inviterUin: Long,
|
||||||
|
groupCode: Long,
|
||||||
|
flag: String
|
||||||
|
): Boolean {
|
||||||
|
pushRequest(RequestEvent.newBuilder().apply {
|
||||||
|
this.type = RequestEvent.RequestType.GROUP_APPLY
|
||||||
|
this.time = time
|
||||||
|
this.requestId = flag
|
||||||
|
this.invitedGroup = InvitedJoinGroupRequest.newBuilder().apply {
|
||||||
|
this.inviterUid = inviterUid
|
||||||
|
this.inviterUin = inviterUin
|
||||||
|
this.groupId = groupCode
|
||||||
|
}.build()
|
||||||
|
}.build())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend inline fun onMessageEvent(collector: FlowCollector<Pair<MsgRecord, PushMessageBody>>) {
|
||||||
|
MessageEventFlow.collect {
|
||||||
|
GlobalScope.launch {
|
||||||
|
collector.emit(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend inline fun onNoticeEvent(collector: FlowCollector<NoticeEvent>) {
|
||||||
|
noticeEventFlow.collect {
|
||||||
|
GlobalScope.launch {
|
||||||
|
collector.emit(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend inline fun onRequestEvent(collector: FlowCollector<RequestEvent>) {
|
||||||
|
requestEventFlow.collect {
|
||||||
|
GlobalScope.launch {
|
||||||
|
collector.emit(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -47,8 +47,8 @@ fun ByteArray.slice(off: Int, length: Int = size - off): ByteArray {
|
|||||||
.let { s -> if (uppercase) s.lowercase(Locale.getDefault()) else s }
|
.let { s -> if (uppercase) s.lowercase(Locale.getDefault()) else s }
|
||||||
} ?: "null"
|
} ?: "null"
|
||||||
|
|
||||||
fun String?.ifNullOrEmpty(defaultValue: String?): String? {
|
fun String?.ifNullOrEmpty(defaultValue: () -> String?): String? {
|
||||||
return if (this.isNullOrEmpty()) defaultValue else this
|
return if (this.isNullOrEmpty()) defaultValue() else this
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmOverloads fun String.hex2ByteArray(replace: Boolean = false): ByteArray {
|
@JvmOverloads fun String.hex2ByteArray(replace: Boolean = false): ByteArray {
|
||||||
|
33
xposed/src/main/java/moe/fuqiuluo/shamrock/tools/Trpc.kt
Normal file
33
xposed/src/main/java/moe/fuqiuluo/shamrock/tools/Trpc.kt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package moe.fuqiuluo.shamrock.tools
|
||||||
|
|
||||||
|
import com.tencent.qphone.base.remote.FromServiceMsg
|
||||||
|
import moe.fuqiuluo.shamrock.helper.Level
|
||||||
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
|
import moe.fuqiuluo.shamrock.utils.DeflateTools
|
||||||
|
import moe.fuqiuluo.symbols.decodeProtobuf
|
||||||
|
import protobuf.oidb.TrpcOidb
|
||||||
|
import tencent.im.oidb.oidb_sso
|
||||||
|
|
||||||
|
fun FromServiceMsg.decodeToOidb(): oidb_sso.OIDBSSOPkg {
|
||||||
|
return kotlin.runCatching {
|
||||||
|
oidb_sso.OIDBSSOPkg().mergeFrom(wupBuffer.slice(4).let {
|
||||||
|
if (it[0] == 0x78.toByte()) DeflateTools.uncompress(it) else it
|
||||||
|
})
|
||||||
|
}.getOrElse {
|
||||||
|
oidb_sso.OIDBSSOPkg().mergeFrom(wupBuffer.let {
|
||||||
|
if (it[0] == 0x78.toByte()) DeflateTools.uncompress(it) else it
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun FromServiceMsg.decodeToTrpcOidb(): TrpcOidb {
|
||||||
|
return kotlin.runCatching {
|
||||||
|
wupBuffer.slice(4).let {
|
||||||
|
if (it[0] == 0x78.toByte()) DeflateTools.uncompress(it) else it
|
||||||
|
}.decodeProtobuf<TrpcOidb>()
|
||||||
|
}.getOrElse {
|
||||||
|
wupBuffer.let {
|
||||||
|
if (it[0] == 0x78.toByte()) DeflateTools.uncompress(it) else it
|
||||||
|
}.decodeProtobuf<TrpcOidb>()
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ import com.arthenica.ffmpegkit.FFmpegKit
|
|||||||
import com.arthenica.ffmpegkit.FFprobeKit
|
import com.arthenica.ffmpegkit.FFprobeKit
|
||||||
import com.arthenica.ffmpegkit.ReturnCode
|
import com.arthenica.ffmpegkit.ReturnCode
|
||||||
import com.tencent.qqnt.kernel.nativeinterface.QQNTWrapperUtil
|
import com.tencent.qqnt.kernel.nativeinterface.QQNTWrapperUtil
|
||||||
import qq.service.contact.LocalCacheHelper
|
import qq.service.internals.LocalCacheHelper
|
||||||
import moe.fuqiuluo.shamrock.helper.Level
|
import moe.fuqiuluo.shamrock.helper.Level
|
||||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -33,7 +33,7 @@ object DownloadUtils {
|
|||||||
threadCount: Int = MAX_THREAD,
|
threadCount: Int = MAX_THREAD,
|
||||||
headers: Map<String, String> = mapOf()
|
headers: Map<String, String> = mapOf()
|
||||||
): Boolean {
|
): Boolean {
|
||||||
var threadCnt = if(threadCount == 0) MAX_THREAD else threadCount
|
var threadCnt = if(threadCount == 0 || threadCount < 0) MAX_THREAD else threadCount
|
||||||
val url = URL(urlAdr)
|
val url = URL(urlAdr)
|
||||||
val connection = withContext(Dispatchers.IO) { url.openConnection() } as HttpURLConnection
|
val connection = withContext(Dispatchers.IO) { url.openConnection() } as HttpURLConnection
|
||||||
headers.forEach { (k, v) ->
|
headers.forEach { (k, v) ->
|
||||||
|
@ -6,17 +6,21 @@ import android.content.Context
|
|||||||
import android.content.Context.BATTERY_SERVICE
|
import android.content.Context.BATTERY_SERVICE
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
|
import android.content.pm.ApplicationInfo
|
||||||
import android.content.pm.PackageInfo
|
import android.content.pm.PackageInfo
|
||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
import moe.fuqiuluo.shamrock.tools.ShamrockVersion
|
||||||
import mqq.app.MobileQQ
|
import mqq.app.MobileQQ
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
|
|
||||||
internal object PlatformUtils {
|
internal object PlatformUtils {
|
||||||
const val QQ_9_0_8_VER = 5540
|
const val QQ_9_0_8_VER = 5540
|
||||||
|
const val QQ_9_0_65_VER = 6566
|
||||||
|
|
||||||
fun getQUA(): String {
|
fun getQUA(): String {
|
||||||
return "V1_AND_SQ_${getQQVersion(MobileQQ.getContext())}_${getQQVersionCode()}_YYB_D"
|
return "V1_AND_SQ_${getQQVersion(MobileQQ.getContext())}_${getQQVersionCode()}_YYB_D"
|
||||||
@ -69,6 +73,15 @@ internal object PlatformUtils {
|
|||||||
return MobileQQ.getMobileQQ().qqProcessName == "com.tencent.tim"
|
return MobileQQ.getMobileQQ().qqProcessName == "com.tencent.tim"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isApkInDebug(context: Context): Boolean {
|
||||||
|
try {
|
||||||
|
val info = context.applicationInfo
|
||||||
|
return (info.flags and ApplicationInfo.FLAG_DEBUGGABLE) != 0
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun killProcess(context: Context, processName: String) {
|
fun killProcess(context: Context, processName: String) {
|
||||||
for (processInfo in (context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).runningAppProcesses) {
|
for (processInfo in (context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager).runningAppProcesses) {
|
||||||
if (processInfo.processName == processName) {
|
if (processInfo.processName == processName) {
|
||||||
|
@ -7,6 +7,7 @@ import android.content.pm.PackageManager
|
|||||||
import android.content.pm.VersionedPackage
|
import android.content.pm.VersionedPackage
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import com.tencent.qphone.base.remote.ToServiceMsg
|
||||||
import de.robv.android.xposed.XC_MethodReplacement
|
import de.robv.android.xposed.XC_MethodReplacement
|
||||||
import de.robv.android.xposed.XSharedPreferences
|
import de.robv.android.xposed.XSharedPreferences
|
||||||
import de.robv.android.xposed.XposedHelpers
|
import de.robv.android.xposed.XposedHelpers
|
||||||
@ -21,6 +22,8 @@ import moe.fuqiuluo.shamrock.xposed.XposedEntry
|
|||||||
import moe.fuqiuluo.shamrock.xposed.loader.LuoClassloader
|
import moe.fuqiuluo.shamrock.xposed.loader.LuoClassloader
|
||||||
import moe.fuqiuluo.shamrock.xposed.loader.NativeLoader
|
import moe.fuqiuluo.shamrock.xposed.loader.NativeLoader
|
||||||
import moe.fuqiuluo.symbols.XposedHook
|
import moe.fuqiuluo.symbols.XposedHook
|
||||||
|
import mqq.app.MobileQQ
|
||||||
|
import qq.service.QQInterfaces
|
||||||
|
|
||||||
@XposedHook(priority = 0)
|
@XposedHook(priority = 0)
|
||||||
class AntiDetection: IAction {
|
class AntiDetection: IAction {
|
||||||
@ -36,6 +39,17 @@ class AntiDetection: IAction {
|
|||||||
if (ShamrockConfig[AntiJvmTrace])
|
if (ShamrockConfig[AntiJvmTrace])
|
||||||
antiTrace()
|
antiTrace()
|
||||||
antiMemoryWalking()
|
antiMemoryWalking()
|
||||||
|
//antiO3Report()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun antiO3Report() {
|
||||||
|
QQInterfaces.app.javaClass.hookMethod("sendToService").before {
|
||||||
|
val toServiceMsg = it.args[0] as ToServiceMsg?
|
||||||
|
if (toServiceMsg != null && toServiceMsg.serviceCmd.startsWith("trpc.o3")) {
|
||||||
|
LogCenter.log("拦截trpc.o3环境上报包", Level.WARN)
|
||||||
|
it.result = null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun antiGetPackageGidsDetection(ctx: Context) {
|
private fun antiGetPackageGidsDetection(ctx: Context) {
|
||||||
|
@ -11,7 +11,7 @@ import moe.fuqiuluo.shamrock.tools.hookMethod
|
|||||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||||
import moe.fuqiuluo.shamrock.helper.Level
|
import moe.fuqiuluo.shamrock.helper.Level
|
||||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
import moe.fuqiuluo.shamrock.internals.NTServiceFetcher
|
import qq.service.internals.NTServiceFetcher
|
||||||
import moe.fuqiuluo.shamrock.xposed.loader.NativeLoader
|
import moe.fuqiuluo.shamrock.xposed.loader.NativeLoader
|
||||||
import moe.fuqiuluo.symbols.XposedHook
|
import moe.fuqiuluo.symbols.XposedHook
|
||||||
|
|
||||||
|
@ -4,12 +4,57 @@ package moe.fuqiuluo.shamrock.xposed.actions
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kritor.client.KritorClient
|
||||||
|
import kritor.server.KritorServer
|
||||||
|
import moe.fuqiuluo.shamrock.config.ActiveRPC
|
||||||
|
import moe.fuqiuluo.shamrock.config.PassiveRPC
|
||||||
|
import moe.fuqiuluo.shamrock.config.RPCAddress
|
||||||
|
import moe.fuqiuluo.shamrock.config.RPCPort
|
||||||
|
import moe.fuqiuluo.shamrock.config.ShamrockConfig
|
||||||
|
import moe.fuqiuluo.shamrock.config.get
|
||||||
|
import moe.fuqiuluo.shamrock.helper.Level
|
||||||
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
import moe.fuqiuluo.symbols.Process
|
import moe.fuqiuluo.symbols.Process
|
||||||
import moe.fuqiuluo.symbols.XposedHook
|
import moe.fuqiuluo.symbols.XposedHook
|
||||||
|
|
||||||
|
private lateinit var server: KritorServer
|
||||||
|
private lateinit var client: KritorClient
|
||||||
|
|
||||||
@XposedHook(Process.MAIN, priority = 10)
|
@XposedHook(Process.MAIN, priority = 10)
|
||||||
internal class InitRemoteService : IAction {
|
internal class InitRemoteService : IAction {
|
||||||
override fun invoke(ctx: Context) {
|
override fun invoke(ctx: Context) {
|
||||||
|
GlobalScope.launch {
|
||||||
|
runCatching {
|
||||||
|
if (ActiveRPC.get()) {
|
||||||
|
if (!::server.isInitialized) {
|
||||||
|
server = KritorServer(RPCPort.get())
|
||||||
|
server.start()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogCenter.log("ActiveRPC is disabled, KritorServer will not be started.")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PassiveRPC.get()) {
|
||||||
|
if (!::client.isInitialized) {
|
||||||
|
val hostAndPort = RPCAddress.get().split(":").let {
|
||||||
|
it.first() to it.last().toInt()
|
||||||
|
}
|
||||||
|
LogCenter.log("Connect RPC to ${hostAndPort.first}:${hostAndPort.second}")
|
||||||
|
client = KritorClient(hostAndPort.first, hostAndPort.second)
|
||||||
|
client.start()
|
||||||
|
client.listen()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
LogCenter.log("PassiveRPC is disabled, KritorServer will not be started.")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}.onFailure {
|
||||||
|
LogCenter.log("Start RPC failed: ${it.message}", Level.ERROR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,13 @@ import qq.service.QQInterfaces
|
|||||||
|
|
||||||
object SwitchStatus: IInteract, QQInterfaces() {
|
object SwitchStatus: IInteract, QQInterfaces() {
|
||||||
override fun invoke(intent: Intent) {
|
override fun invoke(intent: Intent) {
|
||||||
|
if (app.isLogin) {
|
||||||
AppTalker.talk("switch_status") {
|
AppTalker.talk("switch_status") {
|
||||||
put("account", app.currentAccountUin)
|
put("account", app.currentAccountUin)
|
||||||
put("nickname", if (app is QQAppInterface) app.currentNickname else "unknown")
|
put("nickname", if (app is QQAppInterface) (app.currentNickname ?: "unknown") else "unknown")
|
||||||
put("voice", NativeLoader.isVoiceLoaded)
|
put("voice", NativeLoader.isVoiceLoaded)
|
||||||
put("core_version", ShamrockVersion)
|
put("core_version", ShamrockVersion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -34,8 +34,6 @@ internal object NativeLoader {
|
|||||||
XposedBridge.log("[Shamrock] 反射检测到 Android x86")
|
XposedBridge.log("[Shamrock] 反射检测到 Android x86")
|
||||||
true
|
true
|
||||||
} else false
|
} else false
|
||||||
}.onFailure {
|
|
||||||
XposedBridge.log("[Shamrock] ${it.stackTraceToString()}")
|
|
||||||
}.getOrElse { false }
|
}.getOrElse { false }
|
||||||
|
|
||||||
private fun getLibFilePath(name: String): String {
|
private fun getLibFilePath(name: String): String {
|
||||||
|
@ -1,15 +1,140 @@
|
|||||||
package qq.service
|
package qq.service
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import com.tencent.common.app.AppInterface
|
||||||
|
import com.tencent.mobileqq.pb.ByteStringMicro
|
||||||
|
import com.tencent.qphone.base.remote.FromServiceMsg
|
||||||
|
import com.tencent.qphone.base.remote.ToServiceMsg
|
||||||
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||||
|
import kotlinx.coroutines.withTimeoutOrNull
|
||||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||||
import mqq.app.MobileQQ
|
import mqq.app.MobileQQ
|
||||||
|
import protobuf.auto.toByteArray
|
||||||
|
import protobuf.oidb.TrpcOidb
|
||||||
|
import qq.service.internals.MSFHandler
|
||||||
|
import tencent.im.oidb.oidb_sso
|
||||||
|
import kotlin.time.Duration
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
abstract class QQInterfaces {
|
abstract class QQInterfaces {
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val app = if (PlatformUtils.isMqqPackage())
|
val app = (if (PlatformUtils.isMqqPackage())
|
||||||
MobileQQ.getMobileQQ().waitAppRuntime()
|
MobileQQ.getMobileQQ().waitAppRuntime()
|
||||||
else
|
else
|
||||||
MobileQQ.getMobileQQ().waitAppRuntime(null)
|
MobileQQ.getMobileQQ().waitAppRuntime(null)) as AppInterface
|
||||||
|
|
||||||
|
fun sendToServiceMsg(to: ToServiceMsg) {
|
||||||
|
app.sendToService(to)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun sendToServiceMsgAW(
|
||||||
|
to: ToServiceMsg,
|
||||||
|
timeout: Duration = 30.seconds
|
||||||
|
): FromServiceMsg? {
|
||||||
|
val seq = MSFHandler.nextSeq()
|
||||||
|
to.addAttribute("shamrock_uid", seq)
|
||||||
|
val resp: Pair<ToServiceMsg, FromServiceMsg>? = withTimeoutOrNull(timeout) {
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
|
GlobalScope.launch {
|
||||||
|
MSFHandler.registerResp(seq, continuation)
|
||||||
|
sendToServiceMsg(to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resp == null) {
|
||||||
|
MSFHandler.unregisterResp(seq)
|
||||||
|
}
|
||||||
|
return resp?.second
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sendExtra(cmd: String, builder: (Bundle) -> Unit) {
|
||||||
|
val toServiceMsg = createToServiceMsg(cmd)
|
||||||
|
builder(toServiceMsg.extraData)
|
||||||
|
app.sendToService(toServiceMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun createToServiceMsg(cmd: String): ToServiceMsg {
|
||||||
|
return ToServiceMsg("mobileqq.service", app.currentAccountUin, cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sendOidb(cmd: String, command: Int, service: Int, data: ByteArray, trpc: Boolean = false) {
|
||||||
|
val to = createToServiceMsg(cmd)
|
||||||
|
if (trpc) {
|
||||||
|
val oidb = TrpcOidb(
|
||||||
|
cmd = command,
|
||||||
|
service = service,
|
||||||
|
buffer = data,
|
||||||
|
flag = 1
|
||||||
|
)
|
||||||
|
to.putWupBuffer(oidb.toByteArray())
|
||||||
|
} else {
|
||||||
|
val oidb = oidb_sso.OIDBSSOPkg()
|
||||||
|
oidb.uint32_command.set(command)
|
||||||
|
oidb.uint32_service_type.set(service)
|
||||||
|
oidb.bytes_bodybuffer.set(ByteStringMicro.copyFrom(data))
|
||||||
|
oidb.str_client_version.set(PlatformUtils.getClientVersion(MobileQQ.getContext()))
|
||||||
|
to.putWupBuffer(oidb.toByteArray())
|
||||||
|
}
|
||||||
|
to.addAttribute("req_pb_protocol_flag", true)
|
||||||
|
app.sendToService(to)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sendBuffer(
|
||||||
|
cmd: String,
|
||||||
|
isProto: Boolean,
|
||||||
|
data: ByteArray,
|
||||||
|
) {
|
||||||
|
val toServiceMsg = createToServiceMsg(cmd)
|
||||||
|
toServiceMsg.putWupBuffer(data)
|
||||||
|
toServiceMsg.addAttribute("req_pb_protocol_flag", isProto)
|
||||||
|
sendToServiceMsg(toServiceMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
@DelicateCoroutinesApi
|
||||||
|
suspend fun sendBufferAW(
|
||||||
|
cmd: String,
|
||||||
|
isProto: Boolean,
|
||||||
|
data: ByteArray,
|
||||||
|
timeout: Duration = 30.seconds
|
||||||
|
): FromServiceMsg? {
|
||||||
|
val toServiceMsg = createToServiceMsg(cmd)
|
||||||
|
toServiceMsg.putWupBuffer(data)
|
||||||
|
toServiceMsg.addAttribute("req_pb_protocol_flag", isProto)
|
||||||
|
return sendToServiceMsgAW(toServiceMsg, timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
@DelicateCoroutinesApi
|
||||||
|
suspend fun sendOidbAW(
|
||||||
|
cmd: String,
|
||||||
|
command: Int,
|
||||||
|
service: Int,
|
||||||
|
data: ByteArray,
|
||||||
|
trpc: Boolean = false,
|
||||||
|
timeout: Duration = 30.seconds
|
||||||
|
): FromServiceMsg? {
|
||||||
|
val to = createToServiceMsg(cmd)
|
||||||
|
if (trpc) {
|
||||||
|
val oidb = TrpcOidb(
|
||||||
|
cmd = command,
|
||||||
|
service = service,
|
||||||
|
buffer = data,
|
||||||
|
flag = 1
|
||||||
|
)
|
||||||
|
to.putWupBuffer(oidb.toByteArray())
|
||||||
|
} else {
|
||||||
|
val oidb = oidb_sso.OIDBSSOPkg()
|
||||||
|
oidb.uint32_command.set(command)
|
||||||
|
oidb.uint32_service_type.set(service)
|
||||||
|
oidb.bytes_bodybuffer.set(ByteStringMicro.copyFrom(data))
|
||||||
|
oidb.str_client_version.set(PlatformUtils.getClientVersion(MobileQQ.getContext()))
|
||||||
|
to.putWupBuffer(oidb.toByteArray())
|
||||||
|
}
|
||||||
|
to.addAttribute("req_pb_protocol_flag", true)
|
||||||
|
return sendToServiceMsgAW(to, timeout)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user