├── .gitignore ├── LICENSE ├── README.md ├── ToolQ-Core ├── README.md ├── build.gradle ├── libs │ └── Tars.jar └── src │ └── main │ ├── java │ └── com │ │ ├── qq │ │ ├── pb │ │ │ ├── ByteStringMicro.java │ │ │ ├── CodedInputStreamMicro.java │ │ │ ├── CodedOutputStreamMicro.java │ │ │ ├── InvalidProtocolBufferMicroException.java │ │ │ ├── MessageMicro.java │ │ │ ├── PBBoolField.java │ │ │ ├── PBBytesField.java │ │ │ ├── PBDoubleField.java │ │ │ ├── PBEnumField.java │ │ │ ├── PBField.java │ │ │ ├── PBFixed32Field.java │ │ │ ├── PBFixed64Field.java │ │ │ ├── PBFloatField.java │ │ │ ├── PBInt32Field.java │ │ │ ├── PBInt64Field.java │ │ │ ├── PBPrimitiveField.java │ │ │ ├── PBRepeatField.java │ │ │ ├── PBRepeatMessageField.java │ │ │ ├── PBSFixed32Field.java │ │ │ ├── PBSFixed64Field.java │ │ │ ├── PBSInt32Field.java │ │ │ ├── PBSInt64Field.java │ │ │ ├── PBStringField.java │ │ │ ├── PBUInt32Field.java │ │ │ ├── PBUInt64Field.java │ │ │ └── WireFormatMicro.java │ │ └── taf │ │ │ ├── Jce.java │ │ │ ├── Num.java │ │ │ ├── RequestPacket.java │ │ │ ├── client │ │ │ ├── ClientPow.java │ │ │ └── PowValue.java │ │ │ └── jce │ │ │ ├── JceDecodeException.java │ │ │ ├── JceEncodeException.java │ │ │ ├── JceInputStream.java │ │ │ ├── JceOutputStream.java │ │ │ ├── JceStruct.java │ │ │ └── JceUtil.java │ │ └── toolq │ │ ├── BotConfig.java │ │ ├── ToolQ.java │ │ ├── helper │ │ ├── android │ │ │ └── Android.java │ │ ├── bot │ │ │ ├── BotRecorder.java │ │ │ ├── BotStatus.java │ │ │ ├── IQQ.java │ │ │ ├── LoginResult.java │ │ │ ├── MsgStatus.java │ │ │ ├── OperationCenter.java │ │ │ ├── QQAccount.java │ │ │ ├── packet │ │ │ │ ├── IWaiter.java │ │ │ │ ├── Packet.java │ │ │ │ └── Waiter.java │ │ │ └── tlv │ │ │ │ └── TlvBuilder.java │ │ ├── exception │ │ │ ├── AccountException.java │ │ │ └── ToolException.java │ │ ├── jce │ │ │ └── JceHelper.java │ │ ├── packet │ │ │ ├── ByteBuilder.java │ │ │ └── ByteReader.java │ │ └── vector │ │ │ └── SafeVector.java │ │ ├── qq │ │ ├── ecdh │ │ │ └── ECDHCrypt.java │ │ └── protocol │ │ │ ├── AndroidQQ.java │ │ │ ├── device │ │ │ └── IDeviceLock.java │ │ │ ├── jce │ │ │ ├── MsgType0x210.java │ │ │ ├── favorite │ │ │ │ ├── Favorite.java │ │ │ │ ├── ReqHead.java │ │ │ │ └── RespHead.java │ │ │ ├── friend │ │ │ │ ├── FriendInfo.java │ │ │ │ ├── FriendListSubSrvRspCode.java │ │ │ │ ├── GetFriendList.java │ │ │ │ ├── GroupInfo.java │ │ │ │ ├── VipBaseInfo.java │ │ │ │ └── VipOpenInfo.java │ │ │ ├── friendlist │ │ │ │ ├── AddFriend.java │ │ │ │ ├── GetAutoInfo.java │ │ │ │ ├── GetFriendListReq.java │ │ │ │ ├── GetFriendListResp.java │ │ │ │ ├── GetMultiTroopInfo.java │ │ │ │ ├── GetTroopAppointRemark.java │ │ │ │ ├── GetTroopListReqV2Simplify.java │ │ │ │ ├── GetTroopListRespV2.java │ │ │ │ ├── GetUserAddFriendSetting.java │ │ │ │ └── info │ │ │ │ │ ├── TroopInfoV2.java │ │ │ │ │ ├── stFavoriteGroup.java │ │ │ │ │ ├── stGroupRankInfo.java │ │ │ │ │ ├── stLevelRankPair.java │ │ │ │ │ ├── stTroopNum.java │ │ │ │ │ ├── stTroopNumSimplify.java │ │ │ │ │ └── stTroopRemarkInfo.java │ │ │ ├── group │ │ │ │ ├── GetTroopMemberList.java │ │ │ │ ├── ModifyGroupCard.java │ │ │ │ ├── QzoneUserInfo.java │ │ │ │ ├── TroopMemberInfo.java │ │ │ │ └── UinInfo.java │ │ │ ├── kqq │ │ │ │ └── GroupMng.java │ │ │ ├── pushPack │ │ │ │ ├── CPicInfo.java │ │ │ │ ├── MsgInfo.java │ │ │ │ ├── SvcReqPushMsg.java │ │ │ │ ├── TempMsgHead.java │ │ │ │ ├── UinPairMsg.java │ │ │ │ └── shareData.java │ │ │ ├── statsvc │ │ │ │ ├── Register.java │ │ │ │ └── RequestPushForceOffline.java │ │ │ └── summary │ │ │ │ ├── HeartInfo.java │ │ │ │ ├── ReqHead.java │ │ │ │ ├── RespHead.java │ │ │ │ ├── SummaryCard.java │ │ │ │ └── UserLocaleInfo.java │ │ │ ├── packet │ │ │ └── WtLogin.java │ │ │ └── protobuf │ │ │ ├── DeviceReport.java │ │ │ ├── LongMsg.java │ │ │ ├── SubMsgType0x1a.java │ │ │ ├── SubMsgType0xc1.java │ │ │ ├── SyncCookie.java │ │ │ ├── friendlist │ │ │ └── SummaryCardBusiEntry.java │ │ │ ├── group_member_info.java │ │ │ ├── highway │ │ │ └── CSDataHighwayHead.java │ │ │ ├── message │ │ │ ├── SyncFlag.java │ │ │ ├── hummer_commelem.java │ │ │ ├── im_msg_body.java │ │ │ ├── im_msg_head.java │ │ │ ├── im_receipt.java │ │ │ ├── msg_comm.java │ │ │ ├── msg_ctrl.java │ │ │ ├── msg_svc.java │ │ │ └── obj_msg.java │ │ │ ├── oidb │ │ │ ├── OIDBSSOPkg.java │ │ │ ├── cmd0x352.java │ │ │ ├── cmd0x388.java │ │ │ └── oidb_0x89a.java │ │ │ ├── onlinepush │ │ │ ├── OnlinePushTrans.java │ │ │ └── msg_onlinepush.java │ │ │ ├── pushmsg │ │ │ ├── Submsgtype0x8a.java │ │ │ ├── apollo_game_status.java │ │ │ └── apollo_push_msgInfo.java │ │ │ ├── tips │ │ │ └── TroopTips0x857.java │ │ │ └── troop_honor.java │ │ └── utils │ │ ├── BytesUtil.java │ │ ├── HbRSA.java │ │ ├── HexUtil.java │ │ ├── JsonUtil.java │ │ ├── MD5.java │ │ ├── NumberUtil.java │ │ ├── PacketUtil.java │ │ ├── QQUtil.java │ │ ├── StringUtil.java │ │ ├── TeaUtil.java │ │ ├── ZipUtil.java │ │ └── crypts │ │ ├── Base64.java │ │ ├── Crypter.java │ │ ├── CrypterUtil.java │ │ └── RC4.java │ ├── kotlin │ └── com │ │ └── toolq │ │ ├── ToolQManager.kt │ │ ├── helper │ │ ├── bot │ │ │ ├── BotEvent.kt │ │ │ ├── BotSocketClient.kt │ │ │ ├── BotSocketListener.kt │ │ │ ├── Center.kt │ │ │ ├── HandleEvent.kt │ │ │ ├── HeartBeat.kt │ │ │ ├── IBotEvent.kt │ │ │ ├── MessageBuilder.kt │ │ │ ├── MsgInfo.kt │ │ │ ├── msg │ │ │ │ ├── MsgHelper.kt │ │ │ │ └── MsgSender.kt │ │ │ ├── protocol │ │ │ │ └── HttpQQ.kt │ │ │ ├── tqcode │ │ │ │ ├── TQAt.kt │ │ │ │ ├── TQCode.kt │ │ │ │ ├── TQCommonFace.kt │ │ │ │ ├── TQDice.kt │ │ │ │ ├── TQFace.kt │ │ │ │ ├── TQFlashImage.kt │ │ │ │ ├── TQFlashText.kt │ │ │ │ ├── TQImage.kt │ │ │ │ ├── TQJson.kt │ │ │ │ ├── TQMFace.kt │ │ │ │ ├── TQMora.kt │ │ │ │ ├── TQPoke.kt │ │ │ │ ├── TQPtt.kt │ │ │ │ ├── TQShake.kt │ │ │ │ ├── TQText.kt │ │ │ │ ├── TQValue.kt │ │ │ │ ├── TQXml.kt │ │ │ │ └── exception │ │ │ │ │ └── TQCodeException.kt │ │ │ └── tqcodev2 │ │ │ │ └── ToolQCodeParser.kt │ │ ├── captcha │ │ │ ├── OkHttpClientUtils.kt │ │ │ └── TenCentCaptchaUtils.kt │ │ ├── logger │ │ │ ├── LoggerEvent.kt │ │ │ └── TLog.kt │ │ ├── packet │ │ │ └── TencentPacktHelper.kt │ │ ├── server │ │ │ ├── ToolQResponse.kt │ │ │ └── ToolQServer.kt │ │ ├── socket │ │ │ ├── ConnectException.kt │ │ │ ├── SocketAddress.kt │ │ │ ├── SocketClient.kt │ │ │ ├── SocketClientException.kt │ │ │ └── SocketListener.kt │ │ └── thread │ │ │ ├── IResultThread.kt │ │ │ ├── ResultThread.kt │ │ │ └── ThreadManager.kt │ │ ├── qq │ │ ├── dataClass │ │ │ ├── AddFriendResult.kt │ │ │ ├── AutoInfo.kt │ │ │ ├── FriendAdder.kt │ │ │ ├── FriendInfo.kt │ │ │ ├── GroupInfo.kt │ │ │ ├── GroupMemberInfo.kt │ │ │ ├── Key.kt │ │ │ ├── MultiTroopInfo.kt │ │ │ ├── Nick.kt │ │ │ ├── ProtocolMode.kt │ │ │ ├── QPayBalance.kt │ │ │ ├── QPayHbGate.kt │ │ │ ├── QPayHbPack.kt │ │ │ ├── QPayWallet.kt │ │ │ ├── TroopMemberInfo.kt │ │ │ ├── TroopUserAppointInfo.kt │ │ │ ├── UserFriendInfo.kt │ │ │ ├── UserInfo.kt │ │ │ └── VipInfo.kt │ │ └── protocol │ │ │ ├── Tlv.kt │ │ │ ├── friendlist │ │ │ └── GetFriendList.kt │ │ │ ├── highway │ │ │ ├── HighWay.kt │ │ │ └── utils │ │ │ │ └── HighwayUtil.kt │ │ │ ├── msg │ │ │ └── GetMsgEvent.kt │ │ │ └── pay │ │ │ ├── HbType.kt │ │ │ └── LuckyPacket.kt │ │ ├── resource │ │ └── TString.kt │ │ └── utils │ │ ├── BotUtils.kt │ │ ├── CacheUtil.kt │ │ ├── DesECBUtil.kt │ │ ├── FaceUtil.kt │ │ ├── FileUtil.kt │ │ ├── GZipUtil.kt │ │ ├── ImageUtil.kt │ │ ├── KotlinUtil.kt │ │ ├── OkhttpUtil.kt │ │ ├── RandomUtil.kt │ │ ├── SocketUtil.kt │ │ ├── ToolQUtil.kt │ │ └── XmlUtil.kt │ └── resources │ └── log4j2.xml ├── ToolQ-Windows ├── build.gradle.kts ├── libs │ └── org.eclipse.swt.win32.win32.x86_64-4.3.jar └── src │ └── main │ ├── java │ └── com │ │ └── toolq │ │ └── utils │ │ └── SwtUtil.java │ ├── kotlin │ ├── com │ │ └── toolq │ │ │ ├── helper │ │ │ └── bot │ │ │ │ └── IBotFunctionWindow.kt │ │ │ └── win │ │ │ ├── GUIUtil.kt │ │ │ ├── InitManager.kt │ │ │ └── RabbitMain.kt │ └── test │ │ ├── Config.kt │ │ ├── HandleMsg.kt │ │ └── Main.kt │ └── resources │ └── log4j2.xml ├── build.gradle ├── config.example.json ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | out/ 3 | *.iml 4 | 5 | .gradle/ 6 | build/ 7 | 8 | target/ 9 | *.log 10 | hs_err_pid* 11 | 12 | !libs/ 13 | data/ 14 | *.dev.json 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 二次元编程私有许可证版本1.0(ToolQ) 2 | ================================= 3 | 4 | 1.定义 5 | -------------- 6 | 7 | 1.1. "贡献"是指 8 | a)在项目初期的情况下,初始代码及文档,以及 9 | b)项目初期后的每个贡献者: 10 | 1、对程序的更改。 11 | 2、对程序的添加。 12 | 3、对于本项目,被负责人采纳的建议 13 | 14 | 此类更改或对程序的添加其最终版权将归属于ACGP社团 15 | 包括对项目的附加内容,这些内容包括: 16 | 1、独立的模块 17 | 2、计划与思路 18 | 19 | 1.2. "贡献者"是指 20 | a)在为社团的成员的情况下,分发程序的任何个人或实体。 21 | 1.3. "福利" 22 | a)在项目处于稳定盈利的情况下,每位贡献者将以贡献的大小进行分红。 23 | b)非盈利项目无福利分红 24 | c)建议性贡献者/测试员,只享受建议/测试一个版本的福利 25 | 26 | 27 | 2.许可授予 28 | a)在不违反本协议条款的前提下,每位贡献者都将享有特有福利 29 | b)采用二次元编程私有许可证的项目最终解释权归二次元编程社团所有 30 | c)未经项目创建者或二次元编程社团许可不得将项目进行二改或分发 31 | 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #ToolQ 2 | 3 | ### 项目已迁移到Ore项目(ToolQ2.0) 4 | 5 | ### 该协议仍然会不定期更新维护(懒 6 | 7 | 文档 : https://www.luololi.cn/sdk 8 | 9 | # 该协议已开源,请勿将该协议应用于商业用途 10 | 11 | # 这个是二次元编程社团为数不多的开源项目,欢迎大家加入二次元编程社团!!! 12 | 13 | # 邮箱反馈:1372362033@qq.com 14 | 15 | ![](https://img.shields.io/badge/Java-1.8-green.svg) 16 | 17 | # 本项目将使用阿里规范作为开发规范 18 | 安装阿里规范的方式如下: 19 | * 在线安装: 20 | 打开IDEA,点击File->Settings->Plugins,
21 | 搜索Alibaba Java Coding Guidelines点击install进行安装 22 | 23 | ## 鸣谢 24 | 25 | - QG真心提供的技术支持 26 | - 伏秋洛提供的肝(bushi 27 | - 以及二次元编程社团的贡献 28 | 29 |
30 | 31 | ## 常见问题 32 | 如果存在中文乱码问题: 33 | 34 | 可以Appearance&Behavior -> Appearance -> UI Options -> Name 里面设置成微软雅黑(microsoft yahei light)或者自己喜欢的其他字体哦。 35 | 36 | ## 代码追溯 37 | 如果你会提交代码,那么请你必须完成以下操作。 38 | 39 | 打开IDEA,File->Settings->Editor->File and Code Templates 40 | 41 | 对Class、interface、Enum等文件在#parse("File Header.java")的下面加入:
42 | /**
43 | \* @date ${YEAR}-${MONTH}-${DAY} ${HOUR}:${MINUTE} 44 |
\* @author 名字 45 |
\* ${description}
46 | */ 47 | 48 | ## 本项目使用 49 | [MPL协议](https://www.mozilla.org/en-US/MPL/) 50 | 与 51 | [ToolQ 专用许可证](https://github.com/zhangshikj/ToolQ/blob/main/LICENSE) 52 | 进行授权,请在贡献前阅读!
53 | -------------------------------------------------------------------------------- /ToolQ-Core/README.md: -------------------------------------------------------------------------------- 1 | #ToolQ-Core 2 | 3 | ![](https://img.shields.io/badge/Java-1.8-green.svg) 4 | 5 | # 该模块仅仅提供协议实现,及部分框架Api,如需对接框架请参见ToolQ-SDK 6 | -------------------------------------------------------------------------------- /ToolQ-Core/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'org.jetbrains.kotlin.jvm' version '1.4.30' 4 | } 5 | 6 | group = "com.toolq" 7 | version = "1.0.5-SNAPSHOT" 8 | 9 | sourceCompatibility = 1.8 10 | targetCompatibility = 1.8 11 | 12 | dependencies { 13 | implementation "com.google.protobuf:protobuf-java:3.12.1" 14 | // Json处理依赖 15 | implementation "com.google.code.gson:gson:2.8.6" 16 | // OkHttp 17 | implementation "com.squareup.okhttp3:okhttp:4.9.0" 18 | // RSA算法依赖 19 | implementation "org.bouncycastle:bcprov-jdk15on:1.46" 20 | 21 | implementation fileTree(include : ["*.jar"], dir : "libs") 22 | } 23 | 24 | tasks.withType(JavaCompile) { 25 | options.encoding = "UTF-8" 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /ToolQ-Core/libs/Tars.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d8kzdzt/ToolQ/4f7358fab8afff8cdeb8bf37529bae78105c0b3d/ToolQ-Core/libs/Tars.jar -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/InvalidProtocolBufferMicroException.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 12:44 6 | */ 7 | public class InvalidProtocolBufferMicroException extends RuntimeException { 8 | public InvalidProtocolBufferMicroException(String str) { 9 | super(str); 10 | } 11 | 12 | public InvalidProtocolBufferMicroException(Exception e) { 13 | super(e); 14 | } 15 | 16 | static InvalidProtocolBufferMicroException invalidEndTag() { 17 | return new InvalidProtocolBufferMicroException("Protocol message end-group tag did not match expected tag."); 18 | } 19 | 20 | static InvalidProtocolBufferMicroException invalidTag() { 21 | return new InvalidProtocolBufferMicroException("Protocol message contained an invalid tag (zero)."); 22 | } 23 | 24 | static InvalidProtocolBufferMicroException invalidWireType() { 25 | return new InvalidProtocolBufferMicroException("Protocol message tag had invalid wire type."); 26 | } 27 | 28 | static InvalidProtocolBufferMicroException malformedVarint() { 29 | return new InvalidProtocolBufferMicroException("CodedInputStream encountered a malformed varint."); 30 | } 31 | 32 | static InvalidProtocolBufferMicroException negativeSize() { 33 | return new InvalidProtocolBufferMicroException("CodedInputStream encountered an embedded string or message which claimed to have negative size."); 34 | } 35 | 36 | static InvalidProtocolBufferMicroException recursionLimitExceeded() { 37 | return new InvalidProtocolBufferMicroException("Protocol message had too many levels of nesting. May be malicious. Use CodedInputStream.setRecursionLimit() to increase the depth limit."); 38 | } 39 | 40 | static InvalidProtocolBufferMicroException sizeLimitExceeded() { 41 | return new InvalidProtocolBufferMicroException("Protocol message was too large. May be malicious. Use CodedInputStream.setSizeLimit() to increase the size limit."); 42 | } 43 | 44 | static InvalidProtocolBufferMicroException truncatedMessage() { 45 | return new InvalidProtocolBufferMicroException("While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could mean either than the input has been truncated or that an embedded message misreported its own length."); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBBoolField.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 13:24 6 | */ 7 | public final class PBBoolField extends PBPrimitiveField { 8 | public static final PBBoolField __repeatHelper__ = new PBBoolField(false, false); 9 | private boolean value = false; 10 | 11 | public PBBoolField(boolean z, boolean z2) { 12 | set(z, z2); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Boolean) { 17 | this.value = (Boolean) obj; 18 | } else { 19 | this.value = false; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeBoolSize(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Boolean bool) { 32 | return CodedOutputStreamMicro.computeBoolSize(i, bool); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBBoolField pBBoolField = (PBBoolField) pBField; 37 | set(pBBoolField.value, pBBoolField.has()); 38 | } 39 | 40 | public boolean get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readBool(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Boolean readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readBool(); 51 | } 52 | 53 | public void set(boolean z) { 54 | set(z, true); 55 | } 56 | 57 | public void set(boolean z, boolean z2) { 58 | this.value = z; 59 | setHasFlag(z2); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeBool(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Boolean bool) { 69 | codedOutputStreamMicro.writeBool(i, bool); 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return String.valueOf(value); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBBytesField.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | import com.toolq.utils.HexUtil; 4 | 5 | /** 6 | * @author luoluo 7 | * @date 2020/11/8 13:30 8 | */ 9 | public final class PBBytesField extends PBPrimitiveField { 10 | public static final PBBytesField __repeatHelper__ = new PBBytesField(ByteStringMicro.EMPTY, false); 11 | private ByteStringMicro value = ByteStringMicro.EMPTY; 12 | 13 | public PBBytesField(ByteStringMicro byteStringMicro, boolean z) { 14 | set(byteStringMicro, z); 15 | } 16 | 17 | public void clear(Object obj) { 18 | if (obj instanceof ByteStringMicro) { 19 | this.value = (ByteStringMicro) obj; 20 | } else { 21 | this.value = ByteStringMicro.EMPTY; 22 | } 23 | setHasFlag(false); 24 | } 25 | 26 | public int computeSize(int i) { 27 | if (has()) { 28 | return CodedOutputStreamMicro.computeBytesSize(i, this.value); 29 | } 30 | return 0; 31 | } 32 | 33 | protected int computeSizeDirectly(int i, ByteStringMicro byteStringMicro) { 34 | return CodedOutputStreamMicro.computeBytesSize(i, byteStringMicro); 35 | } 36 | 37 | protected void copyFrom(PBField pBField) { 38 | PBBytesField pBBytesField = (PBBytesField) pBField; 39 | set(pBBytesField.value, pBBytesField.has()); 40 | } 41 | 42 | public ByteStringMicro get() { 43 | return this.value; 44 | } 45 | 46 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 47 | this.value = codedInputStreamMicro.readBytes(); 48 | setHasFlag(true); 49 | } 50 | 51 | protected ByteStringMicro readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 52 | return codedInputStreamMicro.readBytes(); 53 | } 54 | 55 | public void set(ByteStringMicro byteStringMicro) { 56 | set(byteStringMicro, true); 57 | } 58 | 59 | public void set(byte[] bytes) { 60 | set(ByteStringMicro.copyFrom(bytes), true); 61 | } 62 | 63 | public void set(byte[] bytes, boolean b) { 64 | set(ByteStringMicro.copyFrom(bytes), b); 65 | } 66 | 67 | public void set(String s) { 68 | set(s.getBytes()); 69 | } 70 | 71 | public void set(String s, boolean z) { 72 | set(s.getBytes(), z); 73 | } 74 | 75 | public void set(ByteStringMicro byteStringMicro, boolean z) { 76 | this.value = byteStringMicro; 77 | setHasFlag(z); 78 | } 79 | 80 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 81 | if (has()) { 82 | codedOutputStreamMicro.writeBytes(i, this.value); 83 | } 84 | } 85 | 86 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, ByteStringMicro byteStringMicro) { 87 | codedOutputStreamMicro.writeBytes(i, byteStringMicro); 88 | } 89 | 90 | public boolean isEmpty() { 91 | return this.value.isEmpty(); 92 | } 93 | 94 | @Override 95 | public String toString() { 96 | return toHex(); 97 | } 98 | 99 | public String toHex() { 100 | return HexUtil.bytesToHexString(value.toByteArray()); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBDoubleField.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 13:31 6 | */ 7 | public final class PBDoubleField extends PBPrimitiveField { 8 | public static final PBDoubleField __repeatHelper__ = new PBDoubleField(0.0d, false); 9 | private double value = 0.0d; 10 | 11 | public PBDoubleField(double d, boolean z) { 12 | set(d, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Double) { 17 | this.value = (Double) obj; 18 | } else { 19 | this.value = 0.0d; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeDoubleSize(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Double d) { 32 | return CodedOutputStreamMicro.computeDoubleSize(i, d); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBDoubleField pBDoubleField = (PBDoubleField) pBField; 37 | set(pBDoubleField.value, pBDoubleField.has()); 38 | } 39 | 40 | public double get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readDouble(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Double readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readDouble(); 51 | } 52 | 53 | public void set(double d) { 54 | set(d, true); 55 | } 56 | 57 | public void set(double d, boolean z) { 58 | this.value = d; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeDouble(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Double d) { 69 | codedOutputStreamMicro.writeDouble(i, d); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBEnumField.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 13:33 6 | */ 7 | public final class PBEnumField extends PBPrimitiveField { 8 | public static final PBEnumField __repeatHelper__ = new PBEnumField(0, false); 9 | private int value = 0; 10 | 11 | public PBEnumField(int i, boolean z) { 12 | set(i, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Integer) { 17 | this.value = (Integer) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeEnumSize(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Integer num) { 32 | return CodedOutputStreamMicro.computeEnumSize(i, num); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBEnumField pBEnumField = (PBEnumField) pBField; 37 | set(pBEnumField.value, pBEnumField.has()); 38 | } 39 | 40 | public int get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readEnum(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Integer readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readEnum(); 51 | } 52 | 53 | public void set(int i) { 54 | set(i, true); 55 | } 56 | 57 | public void set(int i, boolean z) { 58 | this.value = i; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeEnum(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Integer num) { 69 | codedOutputStreamMicro.writeEnum(i, num); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBFixed32Field.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 13:34 6 | */ 7 | public final class PBFixed32Field extends PBPrimitiveField { 8 | public static final PBFixed32Field __repeatHelper__ = new PBFixed32Field(0, false); 9 | private int value = 0; 10 | 11 | public PBFixed32Field(int i, boolean z) { 12 | set(i, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Integer) { 17 | this.value = (Integer) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeFixed32Size(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Integer num) { 32 | return CodedOutputStreamMicro.computeFixed32Size(i, num); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBFixed32Field pBFixed32Field = (PBFixed32Field) pBField; 37 | set(pBFixed32Field.value, pBFixed32Field.has()); 38 | } 39 | 40 | public int get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readFixed32(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Integer readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readFixed32(); 51 | } 52 | 53 | public void set(int i) { 54 | set(i, true); 55 | } 56 | 57 | public void set(int i, boolean z) { 58 | this.value = i; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeFixed32(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Integer num) { 69 | codedOutputStreamMicro.writeFixed32(i, num); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBFixed64Field.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 13:35 6 | */ 7 | public final class PBFixed64Field extends PBPrimitiveField { 8 | public static final PBFixed64Field __repeatHelper__ = new PBFixed64Field(0, false); 9 | private long value = 0; 10 | 11 | public PBFixed64Field(long j, boolean z) { 12 | set(j, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Long) { 17 | this.value = (Long) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeFixed64Size(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Long l) { 32 | return CodedOutputStreamMicro.computeFixed64Size(i, l); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBFixed64Field pBFixed64Field = (PBFixed64Field) pBField; 37 | set(pBFixed64Field.value, pBFixed64Field.has()); 38 | } 39 | 40 | public long get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readFixed64(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Long readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readFixed64(); 51 | } 52 | 53 | public void set(long j) { 54 | set(j, true); 55 | } 56 | 57 | public void set(long j, boolean z) { 58 | this.value = j; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeFixed64(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Long l) { 69 | codedOutputStreamMicro.writeFixed64(i, l); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBFloatField.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 14:45 6 | */ 7 | public final class PBFloatField extends PBPrimitiveField { 8 | public static final PBFloatField __repeatHelper__ = new PBFloatField(0.0f, false); 9 | private float value = 0.0f; 10 | 11 | public PBFloatField(float f, boolean z) { 12 | set(f, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Float) { 17 | this.value = (Float) obj; 18 | } else { 19 | this.value = 0.0f; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeFloatSize(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Float f) { 32 | return CodedOutputStreamMicro.computeFloatSize(i, f); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBFloatField pBFloatField = (PBFloatField) pBField; 37 | set(pBFloatField.value, pBFloatField.has()); 38 | } 39 | 40 | public float get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readFloat(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Float readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readFloat(); 51 | } 52 | 53 | public void set(float f) { 54 | set(f, true); 55 | } 56 | 57 | public void set(float f, boolean z) { 58 | this.value = f; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeFloat(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Float f) { 69 | codedOutputStreamMicro.writeFloat(i, f); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBInt32Field.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 15:03 6 | */ 7 | public final class PBInt32Field extends PBPrimitiveField { 8 | public static final PBInt32Field __repeatHelper__ = new PBInt32Field(0, false); 9 | private int value = 0; 10 | 11 | public PBInt32Field(int i, boolean z) { 12 | set(i, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Integer) { 17 | this.value = (Integer) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeInt32Size(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Integer num) { 32 | return CodedOutputStreamMicro.computeInt32Size(i, num); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBInt32Field pBInt32Field = (PBInt32Field) pBField; 37 | set(pBInt32Field.value, pBInt32Field.has()); 38 | } 39 | 40 | public int get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readInt32(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Integer readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readInt32(); 51 | } 52 | 53 | public void set(int i) { 54 | set(i, true); 55 | } 56 | 57 | public void set(int i, boolean z) { 58 | this.value = i; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeInt32(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Integer num) { 69 | codedOutputStreamMicro.writeInt32(i, num); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBInt64Field.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 15:04 6 | */ 7 | public final class PBInt64Field extends PBPrimitiveField { 8 | public static final PBInt64Field __repeatHelper__ = new PBInt64Field(0, false); 9 | private long value = 0; 10 | 11 | public PBInt64Field(long j, boolean z) { 12 | set(j, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Long) { 17 | this.value = (Long) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeInt64Size(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Long l) { 32 | return CodedOutputStreamMicro.computeInt64Size(i, l.longValue()); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBInt64Field pBInt64Field = (PBInt64Field) pBField; 37 | set(pBInt64Field.value, pBInt64Field.has()); 38 | } 39 | 40 | public long get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readInt64(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Long readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readInt64(); 51 | } 52 | 53 | public void set(long j) { 54 | set(j, true); 55 | } 56 | 57 | public void set(long j, boolean z) { 58 | this.value = j; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeInt64(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Long l) { 69 | codedOutputStreamMicro.writeInt64(i, l); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBPrimitiveField.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 13:00 6 | */ 7 | public abstract class PBPrimitiveField extends PBField { 8 | private boolean hasFlag = false; 9 | 10 | public final boolean has() { 11 | return this.hasFlag; 12 | } 13 | 14 | public final T setHasFlag(boolean z) { 15 | this.hasFlag = z; 16 | return (T) this; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBRepeatField.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | import com.toolq.utils.RandomUtil; 4 | 5 | import java.util.*; 6 | 7 | public final class PBRepeatField extends PBField> { 8 | private final PBField helper; 9 | private List value = Collections.emptyList(); 10 | 11 | public PBRepeatField(PBField pBField) { 12 | this.helper = pBField; 13 | } 14 | 15 | public void add(T t) { 16 | get().add(t); 17 | } 18 | 19 | public void addAll(Collection collection) { 20 | get().addAll(collection); 21 | } 22 | 23 | public void clear(Object obj) { 24 | this.value = Collections.emptyList(); 25 | } 26 | 27 | public int computeSize(int i) { 28 | return computeSizeDirectly(i, this.value); 29 | } 30 | 31 | protected int computeSizeDirectly(int i, List list) { 32 | int i2 = 0; 33 | Iterator it = list.iterator(); 34 | while (true) { 35 | int i3 = i2; 36 | if (!it.hasNext()) { 37 | return i3; 38 | } 39 | i2 = this.helper.computeSizeDirectly(i, it.next()) + i3; 40 | } 41 | } 42 | 43 | protected void copyFrom(PBField> pBField) { 44 | PBRepeatField pBRepeatField = (PBRepeatField) pBField; 45 | if (pBRepeatField.isEmpty()) { 46 | this.value = Collections.emptyList(); 47 | return; 48 | } 49 | List list = get(); 50 | list.clear(); 51 | list.addAll(pBRepeatField.value); 52 | } 53 | 54 | public T get(int i) { 55 | return this.value.get(i); 56 | } 57 | 58 | public T rand() { 59 | return get(RandomUtil.randInt(0, size() - 1)); 60 | } 61 | 62 | public List get() { 63 | if (this.value == Collections.emptyList()) { 64 | this.value = new ArrayList(); 65 | } 66 | return this.value; 67 | } 68 | 69 | public boolean has() { 70 | return !isEmpty(); 71 | } 72 | 73 | public boolean isEmpty() { 74 | return this.value.isEmpty(); 75 | } 76 | 77 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 78 | add(this.helper.readFromDirectly(codedInputStreamMicro)); 79 | } 80 | 81 | protected List readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 82 | throw new RuntimeException("PBRepeatField not support readFromDirectly method."); 83 | } 84 | 85 | public void remove(int i) { 86 | get().remove(i); 87 | } 88 | 89 | public void set(int i, T t) { 90 | this.value.set(i, t); 91 | } 92 | 93 | public void set(List list) { 94 | this.value = list; 95 | } 96 | 97 | public int size() { 98 | return this.value.size(); 99 | } 100 | 101 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 102 | writeToDirectly(codedOutputStreamMicro, i, this.value); 103 | } 104 | 105 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, List list) { 106 | for (T writeToDirectly : list) { 107 | this.helper.writeToDirectly(codedOutputStreamMicro, i, writeToDirectly); 108 | } 109 | } 110 | 111 | @Override 112 | public String toString() { 113 | return value.toString(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBSFixed32Field.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 15:08 6 | */ 7 | public final class PBSFixed32Field extends PBPrimitiveField { 8 | public static final PBSFixed32Field __repeatHelper__ = new PBSFixed32Field(0, false); 9 | private int value = 0; 10 | 11 | public PBSFixed32Field(int i, boolean z) { 12 | set(i, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Integer) { 17 | this.value = (Integer) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeSFixed32Size(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Integer num) { 32 | return CodedOutputStreamMicro.computeSFixed32Size(i, num); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBSFixed32Field pBSFixed32Field = (PBSFixed32Field) pBField; 37 | set(pBSFixed32Field.value, pBSFixed32Field.has()); 38 | } 39 | 40 | public int get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readSFixed32(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Integer readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readSFixed32(); 51 | } 52 | 53 | public void set(int i) { 54 | set(i, true); 55 | } 56 | 57 | public void set(int i, boolean z) { 58 | this.value = i; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeSFixed32(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Integer num) { 69 | codedOutputStreamMicro.writeSFixed32(i, num); 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBSFixed64Field.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 15:14 6 | */ 7 | public final class PBSFixed64Field extends PBPrimitiveField { 8 | public static final PBSFixed64Field __repeatHelper__ = new PBSFixed64Field(0, false); 9 | private long value = 0; 10 | 11 | public PBSFixed64Field(long j, boolean z) { 12 | set(j, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Long) { 17 | this.value = (Long) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeSFixed64Size(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Long l) { 32 | return CodedOutputStreamMicro.computeSFixed64Size(i, l.longValue()); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBSFixed64Field pBSFixed64Field = (PBSFixed64Field) pBField; 37 | set(pBSFixed64Field.value, pBSFixed64Field.has()); 38 | } 39 | 40 | public long get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readSFixed64(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Long readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return Long.valueOf(codedInputStreamMicro.readSFixed64()); 51 | } 52 | 53 | public void set(long j) { 54 | set(j, true); 55 | } 56 | 57 | public void set(long j, boolean z) { 58 | this.value = j; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeSFixed64(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Long l) { 69 | codedOutputStreamMicro.writeSFixed64(i, l.longValue()); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBSInt32Field.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 15:14 6 | */ 7 | public final class PBSInt32Field extends PBPrimitiveField { 8 | public static final PBSInt32Field __repeatHelper__ = new PBSInt32Field(0, false); 9 | private int value = 0; 10 | 11 | public PBSInt32Field(int i, boolean z) { 12 | set(i, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Integer) { 17 | this.value = (Integer) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeSInt32Size(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Integer num) { 32 | return CodedOutputStreamMicro.computeSInt32Size(i, num); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBSInt32Field pBSInt32Field = (PBSInt32Field) pBField; 37 | set(pBSInt32Field.value, pBSInt32Field.has()); 38 | } 39 | 40 | public int get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readSInt32(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Integer readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readSInt32(); 51 | } 52 | 53 | public void set(int i) { 54 | set(i, true); 55 | } 56 | 57 | public void set(int i, boolean z) { 58 | this.value = i; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeSInt32(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Integer num) { 69 | codedOutputStreamMicro.writeSInt32(i, num); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBSInt64Field.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 15:15 6 | */ 7 | public final class PBSInt64Field extends PBPrimitiveField { 8 | public static final PBSInt64Field __repeatHelper__ = new PBSInt64Field(0, false); 9 | private long value = 0; 10 | 11 | public PBSInt64Field(long j, boolean z) { 12 | set(j, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Long) { 17 | this.value = (Long) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeSInt64Size(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Long l) { 32 | return CodedOutputStreamMicro.computeSInt64Size(i, l.longValue()); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBSInt64Field pBSInt64Field = (PBSInt64Field) pBField; 37 | set(pBSInt64Field.value, pBSInt64Field.has()); 38 | } 39 | 40 | public long get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readSInt64(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Long readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readSInt64(); 51 | } 52 | 53 | public void set(long j) { 54 | set(j, true); 55 | } 56 | 57 | public void set(long j, boolean z) { 58 | this.value = j; 59 | setHasFlag(z); 60 | } 61 | 62 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 63 | if (has()) { 64 | codedOutputStreamMicro.writeSInt64(i, this.value); 65 | } 66 | } 67 | 68 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Long l) { 69 | codedOutputStreamMicro.writeSInt64(i, l); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBStringField.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 15:16 6 | */ 7 | public final class PBStringField extends PBPrimitiveField { 8 | public static final PBStringField __repeatHelper__ = new PBStringField("", false); 9 | private String value = ""; 10 | 11 | public PBStringField(String str, boolean z) { 12 | set(str, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof String) { 17 | this.value = (String) obj; 18 | } else { 19 | this.value = ""; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (!has()) { 26 | return 0; 27 | } 28 | if (this.value != null) { 29 | return CodedOutputStreamMicro.computeStringSize(i, this.value); 30 | } 31 | throw new RuntimeException(this + " encounter string null, null for PBStringField is forbidden!"); 32 | } 33 | 34 | protected int computeSizeDirectly(int i, String str) { 35 | return CodedOutputStreamMicro.computeStringSize(i, str); 36 | } 37 | 38 | protected void copyFrom(PBField pBField) { 39 | PBStringField pBStringField = (PBStringField) pBField; 40 | set(pBStringField.value, pBStringField.has()); 41 | } 42 | 43 | public String get() { 44 | return this.value; 45 | } 46 | 47 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 48 | this.value = codedInputStreamMicro.readString(); 49 | setHasFlag(true); 50 | } 51 | 52 | protected String readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 53 | return codedInputStreamMicro.readString(); 54 | } 55 | 56 | public void set(String str) { 57 | set(str, true); 58 | } 59 | 60 | public void set(String str, boolean z) { 61 | this.value = str; 62 | setHasFlag(z); 63 | } 64 | 65 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 66 | if (has()) { 67 | codedOutputStreamMicro.writeString(i, this.value); 68 | } 69 | } 70 | 71 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, String str) { 72 | codedOutputStreamMicro.writeString(i, str); 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return "PBStringField{" + 78 | "value='" + value + '\'' + 79 | '}'; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBUInt32Field.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 15:17 6 | */ 7 | public final class PBUInt32Field extends PBPrimitiveField { 8 | public static final PBUInt32Field __repeatHelper__ = new PBUInt32Field(0, false); 9 | private int value = 0; 10 | 11 | public PBUInt32Field(int i, boolean z) { 12 | set(i, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Integer) { 17 | this.value = (Integer) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeUInt32Size(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Integer num) { 32 | return CodedOutputStreamMicro.computeUInt32Size(i, num); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBUInt32Field pBUInt32Field = (PBUInt32Field) pBField; 37 | set(pBUInt32Field.value, pBUInt32Field.has()); 38 | } 39 | 40 | public int get() { 41 | return this.value; 42 | } 43 | 44 | public long getUInt() { 45 | return Integer.toUnsignedLong(this.value); 46 | } 47 | 48 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 49 | this.value = codedInputStreamMicro.readUInt32(); 50 | setHasFlag(true); 51 | } 52 | 53 | protected Integer readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 54 | return codedInputStreamMicro.readUInt32(); 55 | } 56 | 57 | public void set(PBUInt32Field i) { 58 | set(i.get()); 59 | } 60 | 61 | public void set(int i) { 62 | set(i, true); 63 | } 64 | 65 | public void set(int i, boolean z) { 66 | this.value = i; 67 | setHasFlag(z); 68 | } 69 | 70 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 71 | if (has()) { 72 | codedOutputStreamMicro.writeUInt32(i, this.value); 73 | } 74 | } 75 | 76 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Integer num) { 77 | codedOutputStreamMicro.writeUInt32(i, num); 78 | } 79 | 80 | @Override 81 | public String toString() { 82 | return String.valueOf(get()); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/PBUInt64Field.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 15:17 6 | */ 7 | public final class PBUInt64Field extends PBPrimitiveField { 8 | public static final PBUInt64Field __repeatHelper__ = new PBUInt64Field(0, false); 9 | private long value = 0; 10 | 11 | public PBUInt64Field(long j, boolean z) { 12 | set(j, z); 13 | } 14 | 15 | public void clear(Object obj) { 16 | if (obj instanceof Long) { 17 | this.value = (Long) obj; 18 | } else { 19 | this.value = 0; 20 | } 21 | setHasFlag(false); 22 | } 23 | 24 | public int computeSize(int i) { 25 | if (has()) { 26 | return CodedOutputStreamMicro.computeUInt64Size(i, this.value); 27 | } 28 | return 0; 29 | } 30 | 31 | protected int computeSizeDirectly(int i, Long l) { 32 | return CodedOutputStreamMicro.computeUInt64Size(i, l); 33 | } 34 | 35 | protected void copyFrom(PBField pBField) { 36 | PBUInt64Field pBUInt64Field = (PBUInt64Field) pBField; 37 | set(pBUInt64Field.value, pBUInt64Field.has()); 38 | } 39 | 40 | public long get() { 41 | return this.value; 42 | } 43 | 44 | public void readFrom(CodedInputStreamMicro codedInputStreamMicro) { 45 | this.value = codedInputStreamMicro.readUInt64(); 46 | setHasFlag(true); 47 | } 48 | 49 | protected Long readFromDirectly(CodedInputStreamMicro codedInputStreamMicro) { 50 | return codedInputStreamMicro.readUInt64(); 51 | } 52 | 53 | public void set(PBUInt64Field j) { 54 | set(j.get()); 55 | } 56 | 57 | public void set(long j) { 58 | set(j, true); 59 | } 60 | 61 | public void set(long j, boolean z) { 62 | this.value = j; 63 | setHasFlag(z); 64 | } 65 | 66 | public void writeTo(CodedOutputStreamMicro codedOutputStreamMicro, int i) { 67 | if (has()) { 68 | codedOutputStreamMicro.writeUInt64(i, this.value); 69 | } 70 | } 71 | 72 | protected void writeToDirectly(CodedOutputStreamMicro codedOutputStreamMicro, int i, Long l) { 73 | codedOutputStreamMicro.writeUInt64(i, l); 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | return String.valueOf(value); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/pb/WireFormatMicro.java: -------------------------------------------------------------------------------- 1 | package com.qq.pb; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/11/8 12:53 6 | */ 7 | public final class WireFormatMicro { 8 | static final int MESSAGE_SET_ITEM = 1; 9 | static final int MESSAGE_SET_ITEM_END_TAG = makeTag(1, 4); 10 | static final int MESSAGE_SET_ITEM_TAG = makeTag(1, 3); 11 | static final int MESSAGE_SET_MESSAGE = 3; 12 | static final int MESSAGE_SET_MESSAGE_TAG = makeTag(3, 2); 13 | static final int MESSAGE_SET_TYPE_ID = 2; 14 | static final int MESSAGE_SET_TYPE_ID_TAG = makeTag(2, 0); 15 | static final int TAG_TYPE_BITS = 3; 16 | static final int TAG_TYPE_MASK = 7; 17 | static final int WIRETYPE_END_GROUP = 4; 18 | static final int WIRETYPE_FIXED32 = 5; 19 | static final int WIRETYPE_FIXED64 = 1; 20 | static final int WIRETYPE_LENGTH_DELIMITED = 2; 21 | static final int WIRETYPE_START_GROUP = 3; 22 | static final int WIRETYPE_VARINT = 0; 23 | 24 | public static int getTagFieldNumber(int i) { 25 | return i >>> 3; 26 | } 27 | 28 | static int getTagWireType(int i) { 29 | return i & 7; 30 | } 31 | 32 | static int makeTag(int i, int i2) { 33 | return (i << 3) | i2; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/taf/Jce.java: -------------------------------------------------------------------------------- 1 | package com.qq.taf; 2 | 3 | import com.qq.taf.jce.JceStruct; 4 | import com.toolq.helper.jce.JceHelper; 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/10/30 20:23 9 | */ 10 | public class Jce extends JceStruct { 11 | public T getSelf() { 12 | return (T) this; 13 | } 14 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/taf/Num.java: -------------------------------------------------------------------------------- 1 | package com.qq.taf; 2 | 3 | public @interface Num { 4 | int order(); 5 | String desc() default ""; 6 | String method() default ""; 7 | } 8 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/taf/jce/JceDecodeException.java: -------------------------------------------------------------------------------- 1 | package com.qq.taf.jce; 2 | 3 | /** 4 | * @author 秋洛 5 | */ 6 | public class JceDecodeException extends RuntimeException { 7 | public JceDecodeException(String string) { 8 | super(string); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/taf/jce/JceEncodeException.java: -------------------------------------------------------------------------------- 1 | package com.qq.taf.jce; 2 | 3 | /** 4 | * @author 秋洛 5 | */ 6 | public class JceEncodeException extends RuntimeException { 7 | public JceEncodeException(String string) 8 | { 9 | super(string); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/qq/taf/jce/JceStruct.java: -------------------------------------------------------------------------------- 1 | package com.qq.taf.jce; 2 | 3 | import java.io.Serializable; 4 | 5 | public abstract class JceStruct implements Serializable { 6 | public static final byte BYTE = 0; 7 | public static final byte SHORT = 1; 8 | public static final byte INT = 2; 9 | public static final byte LONG = 3; 10 | public static final byte FLOAT = 4; 11 | public static final byte DOUBLE = 5; 12 | public static final byte STRING1 = 6; 13 | public static final byte STRING4 = 7; 14 | public static final byte MAP = 8; 15 | public static final byte LIST = 9; 16 | public static final byte STRUCT_BEGIN = 10; 17 | public static final byte STRUCT_END = 11; 18 | public static final byte ZERO_TAG = 12; 19 | public static final byte SIMPLE_LIST = 13; 20 | public static final int JCE_MAX_STRING_LENGTH = 104857600; 21 | 22 | public void writeTo(JceOutputStream out){} 23 | 24 | public void readFrom(JceInputStream input){} 25 | 26 | public JceStruct newInit(){ 27 | return null; 28 | } 29 | 30 | public JceStruct read(byte[] b){ 31 | readFrom(new JceInputStream(b)); 32 | return this; 33 | } 34 | 35 | public byte[] toByteArray() { 36 | JceOutputStream os = new JceOutputStream(); 37 | writeTo(os); 38 | return os.toByteArray(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/bot/BotStatus.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/10/2 0:28 6 | */ 7 | public enum BotStatus { 8 | /** 9 | * 机器人因为冻结,密码错误等各种原因无法登录,导致已销毁 10 | */ 11 | destroyed, 12 | /** 13 | * 已登录但没有上线 14 | */ 15 | hasLogged, 16 | /** 17 | * 在线 18 | */ 19 | online, 20 | /** 21 | * 未登录 22 | */ 23 | notLoggedIn, 24 | /** 25 | * Bot被另外一个设备登录,导致本设备掉线 26 | */ 27 | remoteLanding, 28 | /** 29 | * 报废状态 30 | * 31 | * 产生原因: 32 | * ToolQ网络连接突然断开 33 | * 被手动shut 34 | */ 35 | ruin, 36 | /** 37 | * 正在断线重连 38 | */ 39 | reconnecting 40 | } 41 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/bot/IQQ.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot; 2 | 3 | public interface IQQ { 4 | /** 5 | * 协议应用标识 6 | */ 7 | long appId(); 8 | 9 | /** 10 | * 基础标识 11 | */ 12 | int subAppId(); 13 | 14 | /** 15 | * Ping版本 16 | */ 17 | int pingVersion(); 18 | 19 | /** 20 | * IP版本 21 | */ 22 | int ipVersion(); 23 | 24 | /** 25 | * OICQ版本 26 | */ 27 | int ssoVersion(); 28 | 29 | /** 30 | * 协议Tlv版本 31 | */ 32 | int msfSsoVersion(); 33 | 34 | int tgtgVersion(); 35 | int miscBitmap(); 36 | int subSigMap(); 37 | int dbVersion(); 38 | 39 | /** 40 | * 协议发布时间 41 | */ 42 | int buildTime(); 43 | int localId(); 44 | int protocolVersion(); 45 | 46 | /** 47 | * 登录方法 48 | * 1 密码登录 49 | */ 50 | int loginType(); 51 | 52 | boolean isGuidAvailable(); 53 | boolean isGuidFromFileNull(); 54 | boolean isGuidChange(); 55 | 56 | /** 57 | * 构建版本 58 | */ 59 | String buildVersion(); 60 | 61 | /** 62 | * 上传协议版本 63 | */ 64 | String agreementVersion(); 65 | 66 | /** 67 | * 协议应用包名 68 | */ 69 | String packageName(); 70 | 71 | /** 72 | * 协议版本号 73 | */ 74 | String packageVersion(); 75 | 76 | /** 77 | * 协议组件标识 78 | */ 79 | byte[] tencentSdkMd5(); 80 | } 81 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/bot/LoginResult.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/10/2 13:07 6 | */ 7 | public enum LoginResult { 8 | /** 9 | * 登陆成功 10 | */ 11 | Success, 12 | /** 13 | * 密码错误 14 | */ 15 | PasswordWrong, 16 | /** 17 | * 滑块超时操作 18 | */ 19 | SliderTimeOut, 20 | /** 21 | * 因为未知原因登录失败,请查看日志 22 | */ 23 | Fail, 24 | /** 25 | * 滑块Ticket获取错误 26 | * 错误原因 : 27 | * 1,IMEI(androidId)不合法 28 | * 2,QQ协议信息错误 29 | * 3,多次恶意登录 30 | * 4,该设备不是QQ常用登录设备 31 | */ 32 | SliderGetTicketWrong, 33 | /** 34 | * 该账号被回收 35 | */ 36 | Reclaimed, 37 | /** 38 | * 上线失败,已登录但上线失败 39 | */ 40 | FailedToGoOnline, 41 | /** 42 | * 协议包错误,一般错误为tlv格式或ssover等错误 43 | */ 44 | ProtocolWrong, 45 | /** 46 | * 被冻结 47 | */ 48 | Freeze, 49 | /** 50 | * 短信请求次数过多 51 | */ 52 | TooManySMSWrong, 53 | /** 54 | * 验证码格式错误 55 | * 56 | * 多平台框架向ToolQ-sdk丢了一个为空的验证码字符串 57 | */ 58 | VerificationCodeFormatError, 59 | /** 60 | * 短信验证码错误 61 | */ 62 | SMSWrong, 63 | /** 64 | * 网络环境错误 65 | */ 66 | NetWorkError 67 | } 68 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/bot/MsgStatus.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot; 2 | 3 | public enum MsgStatus { 4 | /** 5 | * 忽略消息 6 | * 将消息交给下一个消息处理器处理 7 | * 在并发插件机制下无效 8 | */ 9 | IGNORE, 10 | /** 11 | * 劫持消息 12 | * 该消息处理器劫持该消息 13 | * 接下来所有消息处理器将不会处理该消息 14 | * 在并发消息处理机制下无效 15 | */ 16 | HIJACK 17 | } 18 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/bot/QQAccount.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot; 2 | 3 | import com.toolq.helper.exception.AccountException; 4 | import com.toolq.helper.packet.ByteBuilder; 5 | import com.toolq.utils.MD5; 6 | import com.toolq.utils.QQUtil; 7 | 8 | /** 9 | * @author luoluo 10 | * @date 2020/10/1 21:28 11 | */ 12 | public final class QQAccount { 13 | public QQAccount(long qq, String password) { 14 | if(!QQUtil.checkAccount(qq, password)) throw new AccountException(); 15 | this.long_qq = qq; 16 | this.str_password = password; 17 | this.bytes_md5_password = MD5.toMD5Byte(password); 18 | this.bytes_md5_passwordWithQQ = new ByteBuilder(bytes_md5_password) 19 | .writeLong(qq) 20 | .md5(); 21 | } 22 | 23 | private final long long_qq; 24 | private final String str_password; 25 | private final byte[] bytes_md5_password; 26 | private final byte[] bytes_md5_passwordWithQQ; 27 | /** 28 | * 支付密码 29 | */ 30 | private String payWord; 31 | 32 | /** 33 | * 获取QQ号 34 | */ 35 | public long getUser() { 36 | return long_qq; 37 | } 38 | 39 | /** 40 | * 获取密码MD5 41 | */ 42 | public byte[] getMd5Password() { 43 | return bytes_md5_password; 44 | } 45 | 46 | /** 47 | * 获取密码与QQ的MD5 48 | */ 49 | public byte[] getMd5PasswordWithQQ() { 50 | return bytes_md5_passwordWithQQ; 51 | } 52 | 53 | /** 54 | * 需要被保护!!! 55 | * 56 | * 获取密码 57 | */ 58 | public String getPassword() { 59 | return str_password; 60 | } 61 | 62 | public String getPayWord() { 63 | return payWord; 64 | } 65 | 66 | public void setPayWord(String payWord) { 67 | this.payWord = payWord; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/bot/packet/IWaiter.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.packet; 2 | 3 | public interface IWaiter { 4 | boolean check(Packet packet); 5 | } 6 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/bot/packet/Packet.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.packet; 2 | 3 | import com.toolq.helper.packet.ByteBuilder; 4 | import com.toolq.helper.packet.ByteReader; 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/10/7 4:42 9 | */ 10 | public final class Packet { 11 | public Packet(String cmd, byte[] body, int ssoSeq) { 12 | this.cmd = cmd; 13 | this.body = body; 14 | this.ssoSeq = ssoSeq; 15 | } 16 | 17 | private final String cmd; 18 | private final byte[] body; 19 | private final int ssoSeq; 20 | 21 | public int getSsoSeq() { 22 | return ssoSeq; 23 | } 24 | 25 | public byte[] getBody() { 26 | return body; 27 | } 28 | 29 | public byte[] getBodyWithLength() { 30 | return new ByteBuilder().writeInt(body.length + 4).writeBytes(body).toByteArray(); 31 | } 32 | 33 | public ByteReader toByteReader() { 34 | return new ByteReader(getBody()); 35 | } 36 | 37 | public String getCmd() { 38 | return cmd; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/bot/packet/Waiter.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.packet; 2 | 3 | import com.toolq.helper.logger.TLog; 4 | import com.toolq.helper.packet.JceCouple; 5 | import com.toolq.helper.thread.ThreadManager; 6 | 7 | import java.util.Random; 8 | import java.util.concurrent.ArrayBlockingQueue; 9 | import java.util.concurrent.BlockingQueue; 10 | 11 | /** 12 | * 同一个Waiter禁止重复使用,以免出现线程安全问题 13 | */ 14 | public abstract class Waiter implements IWaiter { 15 | public Waiter(String cmd) { 16 | if(cmd == null) throw new RuntimeException("WaiterCmd can't be null."); 17 | this.cmd = cmd; 18 | } 19 | 20 | /** 21 | * 包的名字 22 | */ 23 | private final String cmd; 24 | public final BlockingQueue queue = new ArrayBlockingQueue<>(1); 25 | /** 26 | * 包的内容 27 | */ 28 | public Packet packet; 29 | public final long id = new Random().nextLong() + (System.currentTimeMillis() / 1000); 30 | /** 31 | * 是否已经接到了包 32 | */ 33 | private boolean used = false; 34 | 35 | public boolean wait(Object randomId) { 36 | return wait(randomId, 3 * 1000); 37 | } 38 | 39 | /** 40 | * 堵塞线程,开始等包 41 | * 42 | * @param randomId 等包随机id 43 | * @param timeout 等包超时时间 44 | * @return 是否等包成功 45 | */ 46 | public boolean wait(Object randomId, long timeout) { 47 | try { 48 | TLog.INSTANCE.info(randomId); 49 | if(isUsed()) 50 | return true; 51 | ThreadManager.getInstance().addTask(() -> { 52 | long start = System.currentTimeMillis(); 53 | while (!isUsed()) { 54 | if(System.currentTimeMillis() >= start + timeout) { 55 | setUsed(true); 56 | queue.add(false); 57 | break; 58 | } 59 | } 60 | }); 61 | return queue.take(); 62 | } catch(InterruptedException e) { 63 | return false; 64 | } 65 | } 66 | 67 | public void push() { 68 | queue.add(true); 69 | } 70 | 71 | public Packet getPacket() { 72 | return packet; 73 | } 74 | 75 | public void setPacket(Packet packet) { 76 | this.packet = packet; 77 | } 78 | 79 | public String getCmd() { 80 | return cmd; 81 | } 82 | 83 | public boolean isUsed() { 84 | return used; 85 | } 86 | 87 | public void setUsed(boolean used) { 88 | this.used = used; 89 | } 90 | 91 | public boolean hasBody() { 92 | return (packet != null && packet.getBody() != null); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/bot/tlv/TlvBuilder.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tlv; 2 | 3 | import com.toolq.helper.packet.ByteBuilder; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | /** 8 | * Tlv包构建器 9 | * 10 | * @author luoluo 11 | * @date 2020/10/4 23:17 12 | */ 13 | public class TlvBuilder extends ByteBuilder { 14 | private final int ver; 15 | 16 | /** 17 | * @param tlvVersion tlv标识 18 | */ 19 | public TlvBuilder(int tlvVersion) { 20 | this.ver = tlvVersion; 21 | } 22 | 23 | @Override 24 | public byte[] toByteArray() { 25 | byte[] data = super.toByteArray(); 26 | ByteBuffer buffer = ByteBuffer.allocate(data.length + 4); 27 | buffer.putShort((short) ver); 28 | buffer.putShort((short) data.length); 29 | buffer.put(data); 30 | return buffer.array(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/exception/AccountException.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.exception; 2 | 3 | import com.toolq.resource.TString; 4 | 5 | /** 6 | * @author luoluo 7 | * @date 2020/10/1 21:46 8 | */ 9 | public final class AccountException extends ToolException { 10 | public AccountException() { 11 | super(TString.bot_account_error.get()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/exception/ToolException.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.exception; 2 | 3 | public class ToolException extends RuntimeException { 4 | public ToolException(String msg) { 5 | super(msg); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/jce/JceHelper.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.jce; 2 | 3 | import com.qq.jce.wup.UniPacket; 4 | import com.qq.taf.Jce; 5 | import com.toolq.helper.logger.TLog; 6 | import com.toolq.resource.TString; 7 | 8 | /** 9 | * @author luoluo 10 | * @date 2020/10/31 0:38 11 | */ 12 | public final class JceHelper { 13 | public static T decodePacket(byte[] src, String FuncName, T t){ 14 | try{ 15 | if(!(t instanceof Jce)) { 16 | TLog.INSTANCE.warn(TString.jce_packet_type_error.get()); 17 | return null; 18 | } 19 | UniPacket uniPacket = decodePacket(src); 20 | if(uniPacket != null) { 21 | return uniPacket.getByClass(FuncName, t); 22 | } 23 | }catch (Exception e){ 24 | TLog.INSTANCE.error(e); 25 | } 26 | return null; 27 | } 28 | 29 | public static UniPacket decodePacket(byte[] src){ 30 | try{ 31 | UniPacket uniPacket = new UniPacket(true); 32 | uniPacket.setEncodeName("UTF-8"); 33 | uniPacket.decode(src); 34 | return uniPacket; 35 | }catch (Exception e){ 36 | TLog.INSTANCE.error(e); 37 | return null; 38 | } 39 | } 40 | 41 | public static byte[] encodePacket(T t, String ServantName, String funcName, String mapName, int requestId){ 42 | try{ 43 | if(!(t instanceof Jce)) { 44 | TLog.INSTANCE.warn(TString.jce_packet_type_error.get()); 45 | return null; 46 | } 47 | UniPacket uniPacket = new UniPacket(true); 48 | uniPacket.setEncodeName("UTF-8"); 49 | uniPacket.useVersion3(); 50 | uniPacket.setFuncName(funcName); 51 | uniPacket.setServantName(ServantName); 52 | uniPacket.put(mapName, t); 53 | uniPacket.setRequestId(requestId); 54 | return uniPacket.encode(); 55 | }catch (Exception e){ 56 | TLog.INSTANCE.error(e); 57 | return null; 58 | } 59 | } 60 | 61 | public static byte[] encodePacket(Jce[] jce, String ServantName, String funcName, String[] mapName, int requestId){ 62 | try { 63 | UniPacket uniPacket = new UniPacket(true); 64 | uniPacket.setEncodeName("UTF-8"); 65 | uniPacket.useVersion3(); 66 | uniPacket.setFuncName(funcName); 67 | uniPacket.setServantName(ServantName); 68 | for (int i = 0;i < jce.length; i++) { 69 | uniPacket.put(mapName[i], jce[i]); 70 | } 71 | uniPacket.setRequestId(requestId); 72 | return uniPacket.encode(); 73 | } catch (Exception e) { 74 | TLog.INSTANCE.error(e); 75 | return null; 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/helper/vector/SafeVector.java: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.vector; 2 | 3 | import java.util.Collection; 4 | import java.util.Vector; 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/10/7 4:55 9 | */ 10 | public final class SafeVector extends Vector { 11 | public SafeVector(int initialCapacity, int capacityIncrement) { 12 | super(initialCapacity, capacityIncrement); 13 | } 14 | 15 | public SafeVector(int initialCapacity) { 16 | super(initialCapacity, 0); 17 | } 18 | 19 | public SafeVector() { 20 | super(10); 21 | } 22 | 23 | public SafeVector(Collection c) { 24 | super(c); 25 | } 26 | 27 | @Override 28 | public synchronized void addElement(E obj) { 29 | if(size() > Integer.MAX_VALUE - 100) 30 | super.clear(); 31 | super.addElement(obj); 32 | } 33 | 34 | @Override 35 | public synchronized boolean add(E e) { 36 | if(size() > Integer.MAX_VALUE - 100) 37 | super.clear(); 38 | return super.add(e); 39 | } 40 | 41 | @Override 42 | public void add(int index, E element) { 43 | if(size() > Integer.MAX_VALUE - 100) 44 | super.clear(); 45 | super.add(index, element); 46 | } 47 | 48 | @Override 49 | public boolean remove(Object o) { 50 | synchronized(this) { 51 | super.remove(o); 52 | if(super.contains(o)) 53 | this.remove(o); 54 | return true; 55 | } 56 | } 57 | 58 | @Override 59 | public synchronized E remove(int index) { 60 | synchronized(this) { 61 | return super.remove(index); 62 | } 63 | } 64 | 65 | @Override 66 | protected synchronized void removeRange(int fromIndex, int toIndex) { 67 | synchronized(this) { 68 | super.removeRange(fromIndex, toIndex); 69 | } 70 | } 71 | 72 | @Override 73 | public synchronized boolean removeElement(Object obj) { 74 | synchronized(this) { 75 | super.removeElement(obj); 76 | if(super.contains(obj)) 77 | this.removeElement(obj); 78 | return true; 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/AndroidQQ.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol; 2 | 3 | import com.toolq.helper.bot.IQQ; 4 | import com.toolq.utils.HexUtil; 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/10/3 21:43 9 | */ 10 | public class AndroidQQ implements IQQ { 11 | private static final AndroidQQ Instance = new AndroidQQ(); 12 | 13 | public static AndroidQQ getInstance() { 14 | return Instance; 15 | } 16 | 17 | public AndroidQQ() {} 18 | 19 | @Override 20 | public long appId() { 21 | return 0x2002f77f; 22 | } 23 | 24 | @Override 25 | public int subAppId() { 26 | return 16; 27 | } 28 | 29 | @Override 30 | public int pingVersion() { 31 | return 1; 32 | } 33 | 34 | @Override 35 | public int ipVersion() { 36 | return 0x1; 37 | } 38 | 39 | @Override 40 | public int ssoVersion() { 41 | return 1536; 42 | } 43 | 44 | @Override 45 | public int msfSsoVersion() { 46 | return 12; 47 | } 48 | 49 | @Override 50 | public int tgtgVersion() { 51 | return 4; 52 | } 53 | 54 | @Override 55 | public int miscBitmap() { 56 | return 0x0af7ff7c; 57 | } 58 | 59 | @Override 60 | public int subSigMap() { 61 | return 66560; 62 | } 63 | 64 | @Override 65 | public int dbVersion() { 66 | return 1; 67 | } 68 | 69 | @Override 70 | public int buildTime() { 71 | return 0x5f433810; 72 | } 73 | 74 | @Override 75 | public int localId() { 76 | return 2052; 77 | } 78 | 79 | @Override 80 | public int protocolVersion() { 81 | return 8001; 82 | } 83 | 84 | @Override 85 | public int loginType() { 86 | return 1; 87 | } 88 | 89 | @Override 90 | public boolean isGuidAvailable() { 91 | return true; 92 | } 93 | 94 | @Override 95 | public boolean isGuidFromFileNull() { 96 | return false; 97 | } 98 | 99 | @Override 100 | public boolean isGuidChange() { 101 | return false; 102 | } 103 | 104 | @Override 105 | public String buildVersion() { 106 | return "6.0.0.2436"; 107 | } 108 | 109 | @Override 110 | public String agreementVersion() { 111 | return "|454001228437590|A8.4.8.94cf45ad"; 112 | } 113 | 114 | @Override 115 | public String packageName() { 116 | return "com.tencent.mobileqq"; 117 | } 118 | 119 | @Override 120 | public String packageVersion() { 121 | return "8.4.8"; 122 | } 123 | 124 | @Override 125 | public byte[] tencentSdkMd5() { 126 | return HexUtil.hexStringToBytes("A6B745BF24A2C277527716F6F36EB68D"); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/MsgType0x210.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | 6 | public class MsgType0x210 extends Jce { 7 | static byte[] cache_pb_src = new byte[0]; 8 | public long uSubMsgType; 9 | public byte[] vProtobuf; 10 | 11 | public void readFrom(JceInputStream jceInputStream) { 12 | this.uSubMsgType = jceInputStream.read(this.uSubMsgType, 0, true); 13 | this.vProtobuf = jceInputStream.read(cache_pb_src, 10, false); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/favorite/Favorite.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.favorite; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | import com.qq.taf.jce.JceStruct; 7 | 8 | public class Favorite { 9 | 10 | public final static class Req extends Jce { 11 | public int cOpType = 0; 12 | public int emSource = 65535; 13 | public int iCount = 1; 14 | public long lMID; 15 | public ReqHead stHeader; 16 | 17 | @Override 18 | public void writeTo(JceOutputStream jceOutputStream) { 19 | jceOutputStream.write(this.stHeader, 0); 20 | jceOutputStream.write(this.lMID, 1); 21 | jceOutputStream.write(this.cOpType, 2); 22 | jceOutputStream.write(this.emSource, 3); 23 | jceOutputStream.write(this.iCount, 4); 24 | } 25 | } 26 | 27 | 28 | public final static class Resp extends Jce { 29 | static final RespHead cache_stHeader = new RespHead(); 30 | static byte[] cache_vNotice; 31 | public byte cOpType; 32 | public long lMID; 33 | public RespHead stHeader; 34 | public byte[] vNotice; 35 | 36 | @Override 37 | public void readFrom(JceInputStream jceInputStream) { 38 | this.stHeader = (RespHead) jceInputStream.read(cache_stHeader, 0, true); 39 | this.lMID = jceInputStream.read(this.lMID, 1, true); 40 | this.cOpType = jceInputStream.read(this.cOpType, 2, true); 41 | if (cache_vNotice == null) { 42 | cache_vNotice = new byte[1]; 43 | } 44 | this.vNotice = jceInputStream.read(cache_vNotice, 3, false); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/favorite/ReqHead.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.favorite; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceOutputStream; 5 | import com.qq.taf.jce.JceStruct; 6 | 7 | public class ReqHead extends Jce implements Cloneable { 8 | public byte bReqType = 1; 9 | public byte bTriggered = 0; 10 | public int iSeq; 11 | public long lUIN; 12 | public short shVersion = 1; 13 | public byte[] vCookies; 14 | 15 | @Override 16 | public void writeTo(JceOutputStream jceOutputStream) { 17 | jceOutputStream.write(this.lUIN, 0); 18 | jceOutputStream.write(this.shVersion, 1); 19 | jceOutputStream.write(this.iSeq, 2); 20 | jceOutputStream.write(this.bReqType, 3); 21 | jceOutputStream.write(this.bTriggered, 4); 22 | if (this.vCookies != null) { 23 | jceOutputStream.write(this.vCookies, 5); 24 | } 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/favorite/RespHead.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.favorite; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | 6 | public class RespHead extends Jce { 7 | public int iReplyCode; 8 | public int iSeq; 9 | public long lUIN; 10 | public short shVersion; 11 | public String strResult = ""; 12 | 13 | @Override 14 | public void readFrom(JceInputStream jceInputStream) { 15 | this.shVersion = jceInputStream.read(this.shVersion, 0, true); 16 | this.iSeq = jceInputStream.read(this.iSeq, 1, true); 17 | this.lUIN = jceInputStream.read(this.lUIN, 2, true); 18 | this.iReplyCode = jceInputStream.read(this.iReplyCode, 3, true); 19 | this.strResult = jceInputStream.readString(4, false); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friend/FriendListSubSrvRspCode.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friend; 2 | 3 | import com.qq.taf.jce.JceInputStream; 4 | import com.qq.taf.jce.JceOutputStream; 5 | import com.qq.taf.jce.JceStruct; 6 | 7 | public class FriendListSubSrvRspCode extends JceStruct { 8 | public short wGetIntimateInfoRspCode; 9 | public short wGetMutualMarkRspCode; 10 | 11 | public FriendListSubSrvRspCode() { 12 | } 13 | 14 | @Override 15 | public void writeTo(JceOutputStream jceOutputStream) { 16 | jceOutputStream.write(this.wGetMutualMarkRspCode, 0); 17 | jceOutputStream.write(this.wGetIntimateInfoRspCode, 1); 18 | } 19 | 20 | @Override 21 | public void readFrom(JceInputStream jceInputStream) { 22 | this.wGetMutualMarkRspCode = jceInputStream.read(this.wGetMutualMarkRspCode, 0, false); 23 | this.wGetIntimateInfoRspCode = jceInputStream.read(this.wGetIntimateInfoRspCode, 1, false); 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friend/GroupInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friend; 2 | import com.qq.taf.jce.JceInputStream; 3 | import com.qq.taf.jce.JceStruct; 4 | 5 | public class GroupInfo extends JceStruct { 6 | public int friend_count; 7 | public byte groupId; 8 | public String groupname = ""; 9 | public int online_friend_count; 10 | public byte seqid; 11 | public int sqqOnLine_count; 12 | 13 | @Override 14 | public void readFrom(JceInputStream jceInputStream) { 15 | this.groupId = jceInputStream.read(this.groupId, 0, true); 16 | this.groupname = jceInputStream.readString(1, true); 17 | this.friend_count = jceInputStream.read(this.friend_count, 2, true); 18 | this.online_friend_count = jceInputStream.read(this.online_friend_count, 3, true); 19 | this.seqid = jceInputStream.read(this.seqid, 4, false); 20 | this.sqqOnLine_count = jceInputStream.read(this.sqqOnLine_count, 5, false); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friend/VipBaseInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friend; 2 | 3 | import com.qq.taf.jce.JceInputStream; 4 | import com.qq.taf.jce.JceStruct; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | public class VipBaseInfo extends JceStruct { 10 | static final boolean assertionsDisabled; 11 | static Map cache_mOpenInfo = new HashMap(); 12 | public int iGrayNameplateFlag; 13 | public int iNameplateVipType; 14 | public Map mOpenInfo; 15 | 16 | static { 17 | boolean z = false; 18 | if (!VipBaseInfo.class.desiredAssertionStatus()) { 19 | z = true; 20 | } 21 | assertionsDisabled = z; 22 | cache_mOpenInfo.put(0, new VipOpenInfo()); 23 | } 24 | 25 | @Override 26 | public void readFrom(JceInputStream jceInputStream) { 27 | this.mOpenInfo = (Map) jceInputStream.readV2(cache_mOpenInfo, 0, true); 28 | this.iNameplateVipType = jceInputStream.read(this.iNameplateVipType, 1, false); 29 | this.iGrayNameplateFlag = jceInputStream.read(this.iGrayNameplateFlag, 2, false); 30 | } 31 | 32 | /** 33 | * mOpenInfo={ 34 | * 1=VipOpenInfo{ QQ会员 35 | * bOpen=true, 36 | * iVipFlag=0, 37 | * iVipLevel=7, 38 | * iVipType=0, 39 | * lNameplateId=0 40 | * }, 41 | * 2=VipOpenInfo{ 42 | * bOpen=false, 43 | * iVipFlag=0, 44 | * iVipLevel=0, 45 | * iVipType=0, 46 | * lNameplateId=0 47 | * }, 48 | * 3=VipOpenInfo{ 超级VIP 49 | * bOpen=true, 50 | * iVipFlag=0, 51 | * iVipLevel=7, 52 | * iVipType=0, 53 | * lNameplateId=0 54 | * }, 55 | * 7=VipOpenInfo{ 大会员 56 | * bOpen=true, 57 | * iVipFlag=0, 58 | * iVipLevel=4, 59 | * iVipType=0, 60 | * lNameplateId=0 61 | * } 62 | * } 63 | */ 64 | } 65 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friend/VipOpenInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friend; 2 | 3 | import com.qq.taf.jce.JceInputStream; 4 | import com.qq.taf.jce.JceStruct; 5 | 6 | public class VipOpenInfo extends JceStruct { 7 | public boolean bOpen; 8 | public int iVipFlag; 9 | public int iVipLevel = -1; 10 | public int iVipType = -1; 11 | public long lNameplateId; 12 | 13 | @Override 14 | public void readFrom(JceInputStream jceInputStream) { 15 | this.bOpen = jceInputStream.read(this.bOpen, 0, true); 16 | this.iVipType = jceInputStream.read(this.iVipType, 1, true); 17 | this.iVipLevel = jceInputStream.read(this.iVipLevel, 2, true); 18 | this.iVipFlag = jceInputStream.read(this.iVipFlag, 3, false); 19 | this.lNameplateId = jceInputStream.read(this.lNameplateId, 4, false); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/GetAutoInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | public class GetAutoInfo { 8 | public static final class Req extends Jce { 9 | public byte cType = 1; 10 | public long dwFriendUin; 11 | public int sourceID = 3999; 12 | public int sourceSubID = 0; 13 | public long uin; 14 | 15 | public void writeTo(JceOutputStream out) { 16 | out.write(this.uin, 0); 17 | out.write(this.dwFriendUin, 1); 18 | out.write(this.cType, 2); 19 | out.write(this.sourceID, 3); 20 | out.write(this.sourceSubID, 4); 21 | } 22 | } 23 | 24 | public static final class Resp extends Jce { 25 | public byte cGroupID; 26 | public short errorCode; 27 | public int result; 28 | public String strGroupName = ""; 29 | public String strRemark = ""; 30 | 31 | public void readFrom(JceInputStream input) { 32 | this.result = input.read(this.result, 0, true); 33 | this.errorCode = input.read(this.errorCode, 1, true); 34 | this.strRemark = input.readString(2, true); 35 | this.cGroupID = input.read(this.cGroupID, 3, true); 36 | this.strGroupName = input.readString(4, true); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/GetFriendListReq.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceOutputStream; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class GetFriendListReq extends Jce { 9 | static ArrayList cache_uinList = new ArrayList<>(); 10 | static byte[] cache_vec0xd50Req = new byte[1]; 11 | static byte[] cache_vec0xd6bReq = new byte[1]; 12 | static ArrayList cache_vecSnsTypelist = new ArrayList<>(); 13 | public int eAppType = 0; 14 | public short getfriendCount; 15 | public byte getgroupCount; 16 | public byte groupid; 17 | public byte groupstartIndex; 18 | public byte ifGetBothFlag; 19 | public byte ifGetDOVId; 20 | public byte ifGetGroupInfo; 21 | public byte ifGetMSFGroup; 22 | public byte ifReflush; 23 | public byte ifShowTermType; 24 | public int reqtype; 25 | public short startIndex; 26 | public long uin; 27 | public ArrayList uinList; 28 | public byte[] vec0xd50Req; 29 | public byte[] vec0xd6bReq; 30 | public ArrayList vecSnsTypelist; 31 | public long version; 32 | 33 | public void writeTo(JceOutputStream out) { 34 | out.write(this.reqtype, 0); 35 | out.write(this.ifReflush, 1); 36 | out.write(this.uin, 2); 37 | out.write(this.startIndex, 3); 38 | out.write(this.getfriendCount, 4); 39 | out.write(this.groupid, 5); 40 | out.write(this.ifGetGroupInfo, 6); 41 | out.write(this.groupstartIndex, 7); 42 | out.write(this.getgroupCount, 8); 43 | out.write(this.ifGetMSFGroup, 9); 44 | out.write(this.ifShowTermType, 10); 45 | out.write(this.version, 11); 46 | if (this.uinList != null) { 47 | out.write(this.uinList, 12); 48 | } 49 | out.write(this.eAppType, 13); 50 | out.write(this.ifGetDOVId, 14); 51 | out.write(this.ifGetBothFlag, 15); 52 | if (this.vec0xd50Req != null) { 53 | out.write(this.vec0xd50Req, 16); 54 | } 55 | if (this.vec0xd6bReq != null) { 56 | out.write(this.vec0xd6bReq, 17); 57 | } 58 | if (this.vecSnsTypelist != null) { 59 | out.write(this.vecSnsTypelist, 18); 60 | } 61 | } 62 | 63 | static { 64 | cache_uinList.add(0L); 65 | cache_vec0xd50Req[0] = 0; 66 | cache_vec0xd6bReq[0] = 0; 67 | cache_vecSnsTypelist.add(0L); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/GetMultiTroopInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | import com.toolq.qq.protocol.jce.friendlist.info.TroopInfoV2; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @author luoluo 13 | * @date 2020/10/31 9:55 14 | */ 15 | public class GetMultiTroopInfo extends Jce { 16 | static ArrayList cache_troopInfo; 17 | 18 | public byte richInfo = 0; 19 | public long uin = 0; 20 | public ArrayList groupCode = new ArrayList<>(); 21 | 22 | public void setRichInfo(byte richInfo) { 23 | this.richInfo = richInfo; 24 | } 25 | 26 | public void setUin(long uin) { 27 | this.uin = uin; 28 | } 29 | 30 | public void addGroupCode(long groupId) { 31 | groupCode.add(groupId); 32 | } 33 | 34 | @Override 35 | public void writeTo(JceOutputStream out) { 36 | out.write(uin, 0); 37 | out.write(groupCode, 1); 38 | out.write(richInfo, 2); 39 | } 40 | 41 | public int result = -999; 42 | public short errorCode; 43 | public List troopInfo; 44 | 45 | @Override 46 | public void readFrom(JceInputStream input) { 47 | this.result = input.read(result, 1, true); 48 | this.errorCode = input.read(errorCode, 2, true); 49 | if (cache_troopInfo == null) { 50 | cache_troopInfo = new ArrayList<>(); 51 | cache_troopInfo.add(new TroopInfoV2()); 52 | } 53 | this.troopInfo = (ArrayList) input.readV2(cache_troopInfo, 3, true); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/GetTroopAppointRemark.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | import com.toolq.qq.protocol.jce.friendlist.info.stTroopRemarkInfo; 7 | 8 | import java.util.ArrayList; 9 | 10 | public class GetTroopAppointRemark { 11 | public static final class Req extends Jce { 12 | public long GroupCode; 13 | public long GroupUin; 14 | public byte cRichCardNameVer; 15 | public byte cRichInfo; 16 | public long uin; 17 | public ArrayList vecUinList; 18 | 19 | public void writeTo(JceOutputStream out) { 20 | out.write(this.uin, 0); 21 | out.write(this.GroupCode, 1); 22 | out.write(this.GroupUin, 3); 23 | out.write(this.vecUinList, 4); 24 | out.write(this.cRichInfo, 5); 25 | out.write(this.cRichCardNameVer, 6); 26 | } 27 | } 28 | 29 | public static final class Resp extends Jce { 30 | static int cache_result; 31 | static ArrayList cache_vecTroopRemark; 32 | public long GroupCode; 33 | public long GroupUin; 34 | public short errorCode; 35 | public long office_mode; 36 | public int result; 37 | public long uin; 38 | public ArrayList vecTroopRemark; 39 | 40 | public void readFrom(JceInputStream jceInputStream) { 41 | this.uin = jceInputStream.read(this.uin, 0, true); 42 | this.GroupCode = jceInputStream.read(this.GroupCode, 1, true); 43 | this.GroupUin = jceInputStream.read(this.GroupUin, 2, true); 44 | if (cache_vecTroopRemark == null) { 45 | cache_vecTroopRemark = new ArrayList<>(); 46 | cache_vecTroopRemark.add(new stTroopRemarkInfo()); 47 | } 48 | this.vecTroopRemark = (ArrayList) jceInputStream.readV2(cache_vecTroopRemark, 3, true); 49 | this.result = jceInputStream.read(this.result, 4, true); 50 | this.errorCode = jceInputStream.read(this.errorCode, 5, false); 51 | this.office_mode = jceInputStream.read(this.office_mode, 6, false); 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return "Resp{" + 57 | "GroupCode=" + GroupCode + 58 | ", GroupUin=" + GroupUin + 59 | ", errorCode=" + errorCode + 60 | ", office_mode=" + office_mode + 61 | ", result=" + result + 62 | ", uin=" + uin + 63 | ", vecTroopRemark=" + vecTroopRemark + 64 | '}'; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/GetTroopListReqV2Simplify.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceOutputStream; 5 | import com.toolq.qq.protocol.jce.friendlist.info.stTroopNumSimplify; 6 | 7 | import java.util.ArrayList; 8 | 9 | public final class GetTroopListReqV2Simplify extends Jce { 10 | static ArrayList cache_vecGroupInfo = new ArrayList<>(); 11 | public byte bGetLongGroupName; 12 | public byte bGetMSFMsgFlag; 13 | public byte bGroupFlagExt; 14 | public long dwCompanyId; 15 | public int shVersion; 16 | public long uin; 17 | public byte[] vecCookies; 18 | public ArrayList vecGroupInfo; 19 | public long versionNum; 20 | 21 | public GetTroopListReqV2Simplify(long j, byte b, byte[] bArr, ArrayList arrayList, byte b2, int i, long j2, long j3, byte b3) { 22 | this.uin = j; 23 | this.bGetMSFMsgFlag = b; 24 | this.vecCookies = bArr; 25 | this.vecGroupInfo = arrayList; 26 | this.bGroupFlagExt = b2; 27 | this.shVersion = i; 28 | this.dwCompanyId = j2; 29 | this.versionNum = j3; 30 | this.bGetLongGroupName = b3; 31 | } 32 | 33 | public void writeTo(JceOutputStream jceOutputStream) { 34 | jceOutputStream.write(this.uin, 0); 35 | jceOutputStream.write(this.bGetMSFMsgFlag, 1); 36 | if (this.vecCookies != null) { 37 | jceOutputStream.write(this.vecCookies, 2); 38 | } 39 | if (this.vecGroupInfo != null) { 40 | jceOutputStream.write(this.vecGroupInfo, 3); 41 | } 42 | jceOutputStream.write(this.bGroupFlagExt, 4); 43 | jceOutputStream.write(this.shVersion, 5); 44 | jceOutputStream.write(this.dwCompanyId, 6); 45 | jceOutputStream.write(this.versionNum, 7); 46 | jceOutputStream.write(this.bGetLongGroupName, 8); 47 | } 48 | 49 | static { 50 | cache_vecGroupInfo.add(new stTroopNumSimplify()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/GetUserAddFriendSetting.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist; 2 | 3 | import com.qq.taf.*; 4 | import com.qq.taf.jce.*; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Arrays; 8 | 9 | public class GetUserAddFriendSetting { 10 | public static final class Req extends Jce { 11 | public byte[] name; 12 | public byte[] name1; 13 | public long queryUin; 14 | public int sourceID = 3999; 15 | public int sourceSubID = 0; 16 | public long uin; 17 | public long version; 18 | 19 | public void writeTo(JceOutputStream out) { 20 | out.write(this.uin, 0); 21 | out.write(this.queryUin, 1); 22 | out.write(this.sourceID, 2); 23 | out.write(this.sourceSubID, 3); 24 | if (this.name != null) { 25 | out.write(this.name, 4); 26 | } 27 | out.write(this.version, 5); 28 | if (this.name1 != null) { 29 | out.write(this.name1, 6); 30 | } 31 | } 32 | } 33 | 34 | public static final class Resp extends Jce { 35 | static byte[] cache_name; 36 | static byte[] cache_name1; 37 | static ArrayList cache_vecStrUserQuestion; 38 | public boolean contact_bothway_friend; 39 | public short errorCode; 40 | public byte[] name; 41 | public byte[] name1; 42 | public long queryUin; 43 | public int queryUinSetting; 44 | public int result; 45 | public long uin; 46 | public ArrayList vecStrUserQuestion; 47 | 48 | public void readFrom(JceInputStream input) { 49 | this.uin = input.read(this.uin, 0, true); 50 | this.queryUin = input.read(this.queryUin, 1, true); 51 | this.queryUinSetting = input.read(this.queryUinSetting, 2, true); 52 | if (cache_vecStrUserQuestion == null) { 53 | cache_vecStrUserQuestion = new ArrayList<>(); 54 | cache_vecStrUserQuestion.add(""); 55 | } 56 | this.vecStrUserQuestion = (ArrayList) input.readV2(cache_vecStrUserQuestion, 3, false); 57 | this.result = input.read(this.result, 4, true); 58 | this.errorCode = input.read(this.errorCode, 5, false); 59 | if (cache_name == null) { 60 | cache_name = new byte[1]; 61 | } 62 | this.name = input.read(cache_name, 6, false); 63 | this.contact_bothway_friend = input.read(this.contact_bothway_friend, 7, false); 64 | if (cache_name1 == null) { 65 | cache_name1 = new byte[1]; 66 | } 67 | this.name1 = input.read(cache_name1, 8, false); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/info/TroopInfoV2.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist.info; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | /** 8 | * @author luoluo 9 | * @date 2020/10/31 11:30 10 | */ 11 | public class TroopInfoV2 extends Jce { 12 | public byte groupOption; 13 | public long certificationType; 14 | public long groupClassExt; 15 | public long groupCode; 16 | public long groupFlagExt; 17 | public long groupOwnerUin; 18 | public long groupUin; 19 | public int memberNum; 20 | public String fingerMemo = ""; 21 | public String groupMemo = ""; 22 | public String groupName = ""; 23 | public int groupFace; 24 | 25 | @Override 26 | public void writeTo(JceOutputStream out) { 27 | out.write(this.groupUin, 0); 28 | out.write(this.groupCode, 1); 29 | out.write(this.groupName, 2); 30 | out.write(this.groupMemo, 3); 31 | out.write(this.groupOwnerUin, 4); 32 | out.write(this.groupClassExt, 5); 33 | out.write(this.groupFace, 6); 34 | if (this.fingerMemo != null) { 35 | out.write(this.fingerMemo, 7); 36 | } 37 | out.write(this.groupOption, 8); 38 | out.write(this.memberNum, 9); 39 | out.write(this.groupFlagExt, 10); 40 | out.write(this.certificationType, 11); 41 | } 42 | 43 | @Override 44 | public void readFrom(JceInputStream input) { 45 | this.groupUin = input.read(this.groupUin, 0, true); 46 | this.groupCode = input.read(this.groupCode, 1, true); 47 | this.groupName = input.readString(2, true); 48 | this.groupMemo = input.readString(3, true); 49 | this.groupOwnerUin = input.read(this.groupOwnerUin, 4, false); 50 | this.groupClassExt = input.read(this.groupClassExt, 5, false); 51 | this.groupFace = input.read(this.groupFace, 6, false); 52 | this.fingerMemo = input.readString(7, false); 53 | this.groupOption = input.read(this.groupOption, 8, false); 54 | this.memberNum = input.read(this.memberNum, 9, false); 55 | this.groupFlagExt = input.read(this.groupFlagExt, 10, false); 56 | this.certificationType = input.read(this.certificationType, 11, false); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/info/stFavoriteGroup.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist.info; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | public final class stFavoriteGroup extends Jce { 8 | public long dwGroupCode; 9 | public long dwOpenTimestamp; 10 | public long dwSnsFlag = 1; 11 | public long dwTimestamp; 12 | 13 | public void writeTo(JceOutputStream jceOutputStream) { 14 | jceOutputStream.write(this.dwGroupCode, 0); 15 | jceOutputStream.write(this.dwTimestamp, 1); 16 | jceOutputStream.write(this.dwSnsFlag, 2); 17 | jceOutputStream.write(this.dwOpenTimestamp, 3); 18 | } 19 | 20 | public void readFrom(JceInputStream jceInputStream) { 21 | this.dwGroupCode = jceInputStream.read(this.dwGroupCode, 0, true); 22 | this.dwTimestamp = jceInputStream.read(this.dwTimestamp, 1, false); 23 | this.dwSnsFlag = jceInputStream.read(this.dwSnsFlag, 2, false); 24 | this.dwOpenTimestamp = jceInputStream.read(this.dwOpenTimestamp, 3, false); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/info/stGroupRankInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist.info; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | import java.util.ArrayList; 8 | 9 | public final class stGroupRankInfo extends Jce { 10 | static ArrayList cache_vecRankMap = new ArrayList<>(); 11 | static ArrayList cache_vecRankMapNew = new ArrayList<>(); 12 | public byte cGroupRankSysFlag; 13 | public byte cGroupRankUserFlag; 14 | public byte cGroupRankUserFlagNew; 15 | public long dwGroupCode; 16 | public long dwGroupRankSeq; 17 | public long dwOfficeMode; 18 | public String strAdminName = ""; 19 | public String strOwnerName = ""; 20 | public ArrayList vecRankMap; 21 | public ArrayList vecRankMapNew; 22 | 23 | public void writeTo(JceOutputStream jceOutputStream) { 24 | jceOutputStream.write(this.dwGroupCode, 0); 25 | jceOutputStream.write(this.cGroupRankSysFlag, 1); 26 | jceOutputStream.write(this.cGroupRankUserFlag, 2); 27 | if (this.vecRankMap != null) { 28 | jceOutputStream.write(this.vecRankMap, 3); 29 | } 30 | jceOutputStream.write(this.dwGroupRankSeq, 4); 31 | if (this.strOwnerName != null) { 32 | jceOutputStream.write(this.strOwnerName, 5); 33 | } 34 | if (this.strAdminName != null) { 35 | jceOutputStream.write(this.strAdminName, 6); 36 | } 37 | jceOutputStream.write(this.dwOfficeMode, 7); 38 | jceOutputStream.write(this.cGroupRankUserFlagNew, 8); 39 | if (this.vecRankMapNew != null) { 40 | jceOutputStream.write(this.vecRankMapNew, 9); 41 | } 42 | } 43 | 44 | static { 45 | cache_vecRankMap.add(new stLevelRankPair()); 46 | cache_vecRankMapNew.add(new stLevelRankPair()); 47 | } 48 | 49 | public void readFrom(JceInputStream jceInputStream) { 50 | this.dwGroupCode = jceInputStream.read(this.dwGroupCode, 0, true); 51 | this.cGroupRankSysFlag = jceInputStream.read(this.cGroupRankSysFlag, 1, false); 52 | this.cGroupRankUserFlag = jceInputStream.read(this.cGroupRankUserFlag, 2, false); 53 | this.vecRankMap = (ArrayList) jceInputStream.readV2(cache_vecRankMap, 3, false); 54 | this.dwGroupRankSeq = jceInputStream.read(this.dwGroupRankSeq, 4, false); 55 | this.strOwnerName = jceInputStream.readString(5, false); 56 | this.strAdminName = jceInputStream.readString(6, false); 57 | this.dwOfficeMode = jceInputStream.read(this.dwOfficeMode, 7, false); 58 | this.cGroupRankUserFlagNew = jceInputStream.read(this.cGroupRankUserFlagNew, 8, false); 59 | this.vecRankMapNew = (ArrayList) jceInputStream.readV2(cache_vecRankMapNew, 9, false); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/info/stLevelRankPair.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist.info; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | public final class stLevelRankPair extends Jce { 8 | public long dwLevel; 9 | public String strRank = ""; 10 | 11 | public void writeTo(JceOutputStream jceOutputStream) { 12 | jceOutputStream.write(this.dwLevel, 0); 13 | if (this.strRank != null) { 14 | jceOutputStream.write(this.strRank, 1); 15 | } 16 | } 17 | 18 | public void readFrom(JceInputStream jceInputStream) { 19 | this.dwLevel = jceInputStream.read(this.dwLevel, 0, false); 20 | this.strRank = jceInputStream.readString(1, false); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/friendlist/info/stTroopNumSimplify.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.friendlist.info; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | public final class stTroopNumSimplify extends Jce { 8 | public long GroupCode; 9 | public long dwGroupFlagExt; 10 | public long dwGroupInfoExtSeq; 11 | public long dwGroupInfoSeq; 12 | public long dwGroupRankSeq; 13 | 14 | public void writeTo(JceOutputStream jceOutputStream) { 15 | jceOutputStream.write(this.GroupCode, 0); 16 | jceOutputStream.write(this.dwGroupInfoSeq, 1); 17 | jceOutputStream.write(this.dwGroupFlagExt, 2); 18 | jceOutputStream.write(this.dwGroupRankSeq, 3); 19 | jceOutputStream.write(this.dwGroupInfoExtSeq, 4); 20 | } 21 | 22 | public void readFrom(JceInputStream jceInputStream) { 23 | this.GroupCode = jceInputStream.read(this.GroupCode, 0, true); 24 | this.dwGroupInfoSeq = jceInputStream.read(this.dwGroupInfoSeq, 1, false); 25 | this.dwGroupFlagExt = jceInputStream.read(this.dwGroupFlagExt, 2, false); 26 | this.dwGroupRankSeq = jceInputStream.read(this.dwGroupRankSeq, 3, false); 27 | this.dwGroupInfoExtSeq = jceInputStream.read(this.dwGroupInfoExtSeq, 4, false); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/group/GetTroopMemberList.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.group; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | import java.util.ArrayList; 8 | 9 | public class GetTroopMemberList { 10 | public static final class Req extends Jce { 11 | public long GetListAppointTime; 12 | public long GroupCode; 13 | public long GroupUin; 14 | public long NextUin; 15 | public long ReqType; 16 | public long Version; 17 | public byte cRichCardNameVer; 18 | public long uin; 19 | 20 | @Override 21 | public void writeTo(JceOutputStream jceOutputStream) { 22 | jceOutputStream.write(this.uin, 0); 23 | jceOutputStream.write(this.GroupCode, 1); 24 | jceOutputStream.write(this.NextUin, 2); 25 | jceOutputStream.write(this.GroupUin, 3); 26 | jceOutputStream.write(this.Version, 4); 27 | jceOutputStream.write(this.ReqType, 5); 28 | jceOutputStream.write(this.GetListAppointTime, 6); 29 | jceOutputStream.write(this.cRichCardNameVer, 7); 30 | } 31 | } 32 | 33 | public static final class Resp extends Jce { 34 | static ArrayList cache_vecTroopMember = new ArrayList<>(); 35 | public long GroupCode; 36 | public long GroupUin; 37 | public long NextGetTime; 38 | public long NextUin; 39 | public short errorCode; 40 | public long office_mode; 41 | public int result; 42 | public long uin; 43 | public ArrayList vecTroopMember; 44 | 45 | static { 46 | cache_vecTroopMember.add(new TroopMemberInfo()); 47 | } 48 | 49 | @Override 50 | public void readFrom(JceInputStream jceInputStream) { 51 | this.uin = jceInputStream.read(this.uin, 0, true); 52 | this.GroupCode = jceInputStream.read(this.GroupCode, 1, true); 53 | this.GroupUin = jceInputStream.read(this.GroupUin, 2, true); 54 | this.vecTroopMember = (ArrayList) jceInputStream.readV2(cache_vecTroopMember, 3, true); 55 | this.NextUin = jceInputStream.read(this.NextUin, 4, true); 56 | this.result = jceInputStream.read(this.result, 5, true); 57 | this.errorCode = jceInputStream.read(this.errorCode, 6, false); 58 | this.office_mode = jceInputStream.read(this.office_mode, 7, false); 59 | this.NextGetTime = jceInputStream.read(this.NextGetTime, 8, false); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/group/ModifyGroupCard.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.group; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | import java.util.ArrayList; 8 | 9 | public class ModifyGroupCard { 10 | public static final class Req extends Jce { 11 | public long groupCode; 12 | public long newSeq; 13 | public long zero; 14 | public ArrayList uinInfo; 15 | 16 | @Override 17 | public void writeTo(JceOutputStream jceOutputStream) { 18 | jceOutputStream.write(this.zero, 0); 19 | jceOutputStream.write(this.groupCode, 1); 20 | jceOutputStream.write(this.newSeq, 2); 21 | jceOutputStream.write(this.uinInfo, 3); 22 | } 23 | } 24 | 25 | public static final class Resp extends Jce { 26 | static ArrayList cache_vecUin = new ArrayList<>(); 27 | public String ErrorString = ""; 28 | public long groupCode; 29 | public long groupUin; 30 | public int result; 31 | public ArrayList uins; 32 | 33 | static { 34 | cache_vecUin.add(0L); 35 | } 36 | 37 | @Override 38 | public void readFrom(JceInputStream jceInputStream) { 39 | this.result = jceInputStream.read(this.result, 0, true); 40 | this.groupUin = jceInputStream.read(this.groupUin, 1, true); 41 | this.groupCode = jceInputStream.read(this.groupCode, 2, true); 42 | this.uins = (ArrayList) jceInputStream.readV2(cache_vecUin, 3, true); 43 | this.ErrorString = jceInputStream.readString(4, false); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/group/QzoneUserInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.group; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | public class QzoneUserInfo extends Jce { 10 | static Map cache_extendInfo = new HashMap<>(); 11 | public int eStarState; 12 | public Map extendInfo; 13 | 14 | static { 15 | cache_extendInfo.put("", ""); 16 | } 17 | 18 | @Override 19 | public void readFrom(JceInputStream jceInputStream) { 20 | this.eStarState = jceInputStream.read(this.eStarState, 0, false); 21 | this.extendInfo = (Map) jceInputStream.readV2(cache_extendInfo, 1, false); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/group/UinInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.group; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | public class UinInfo extends Jce { 8 | public byte gender; 9 | public long flag; 10 | public long uin; 11 | public String email = ""; 12 | public String name = ""; 13 | public String phone = ""; 14 | public String remark = ""; 15 | 16 | @Override 17 | public void writeTo(JceOutputStream jceOutputStream) { 18 | jceOutputStream.write(this.uin, 0); 19 | jceOutputStream.write(this.flag, 1); 20 | jceOutputStream.write(this.name, 2); 21 | jceOutputStream.write(this.gender, 3); 22 | jceOutputStream.write(this.phone, 4); 23 | jceOutputStream.write(this.email, 5); 24 | jceOutputStream.write(this.remark, 6); 25 | } 26 | 27 | @Override 28 | public void readFrom(JceInputStream jceInputStream) { 29 | this.uin = jceInputStream.read(this.uin, 0, true); 30 | this.flag = jceInputStream.read(this.flag, 1, true); 31 | this.name = jceInputStream.readString(2, true); 32 | this.gender = jceInputStream.read(this.gender, 3, true); 33 | this.phone = jceInputStream.readString(4, true); 34 | this.email = jceInputStream.readString(5, true); 35 | this.remark = jceInputStream.readString(6, true); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/pushPack/CPicInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.pushPack; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | public final class CPicInfo extends Jce { 8 | static byte[] cache_vHost; 9 | static byte[] cache_vPath; 10 | public byte[] vHost; 11 | public byte[] vPath; 12 | 13 | public void writeTo(JceOutputStream jceOutputStream) { 14 | jceOutputStream.write(this.vPath, 0); 15 | if (this.vHost != null) { 16 | jceOutputStream.write(this.vHost, 1); 17 | } 18 | } 19 | 20 | public void readFrom(JceInputStream jceInputStream) { 21 | if (cache_vPath == null) { 22 | cache_vPath = new byte[1]; 23 | } 24 | this.vPath = jceInputStream.read(cache_vPath, 0, true); 25 | if (cache_vHost == null) { 26 | cache_vHost = new byte[1]; 27 | } 28 | this.vHost = jceInputStream.read(cache_vHost, 1, false); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/pushPack/SvcReqPushMsg.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.pushPack; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | import com.toolq.qq.protocol.protobuf.message.msg_comm; 7 | 8 | import java.util.ArrayList; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | public final class SvcReqPushMsg extends Jce { 13 | static Map cache_mPreviews = new HashMap<>(); 14 | static ArrayList cache_vMsgInfos = new ArrayList<>(); 15 | static byte[] cache_vSyncCookie = new byte[1]; 16 | static ArrayList cache_vUinPairMsg = new ArrayList<>(); 17 | public long lUin; 18 | public Map mPreviews; 19 | public int svrip; 20 | public long uMsgTime; 21 | public ArrayList vMsgInfos; 22 | public byte[] vSyncCookie; 23 | public ArrayList vUinPairMsg; 24 | public int wGeneralFlag; 25 | public int wUserActive; 26 | 27 | public void writeTo(JceOutputStream jceOutputStream) { 28 | jceOutputStream.write(this.lUin, 0); 29 | jceOutputStream.write(this.uMsgTime, 1); 30 | jceOutputStream.write(this.vMsgInfos, 2); 31 | jceOutputStream.write(this.svrip, 3); 32 | if (this.vSyncCookie != null) { 33 | jceOutputStream.write(this.vSyncCookie, 4); 34 | } 35 | if (this.vUinPairMsg != null) { 36 | jceOutputStream.write(this.vUinPairMsg, 5); 37 | } 38 | if (this.mPreviews != null) { 39 | jceOutputStream.write(this.mPreviews, 6); 40 | } 41 | jceOutputStream.write(this.wUserActive, 7); 42 | jceOutputStream.write(this.wGeneralFlag, 12); 43 | } 44 | 45 | static { 46 | cache_vMsgInfos.add(new MsgInfo()); 47 | cache_vSyncCookie[0] = 0; 48 | cache_vUinPairMsg.add(new UinPairMsg()); 49 | byte[] bArr = new byte[1]; 50 | cache_mPreviews.put("", bArr); 51 | } 52 | 53 | public void readFrom(JceInputStream jceInputStream) { 54 | this.lUin = jceInputStream.read(this.lUin, 0, true); 55 | this.uMsgTime = jceInputStream.read(this.uMsgTime, 1, true); 56 | this.vMsgInfos = (ArrayList) jceInputStream.readV2(cache_vMsgInfos, 2, true); 57 | this.svrip = jceInputStream.read(this.svrip, 3, true); 58 | this.vSyncCookie = jceInputStream.read(cache_vSyncCookie, 4, false); 59 | this.vUinPairMsg = (ArrayList) jceInputStream.readV2(cache_vUinPairMsg, 5, false); 60 | this.mPreviews = (Map) jceInputStream.readV2(cache_mPreviews, 6, false); 61 | this.wUserActive = jceInputStream.read(this.wUserActive, 7, false); 62 | this.wGeneralFlag = jceInputStream.read(this.wGeneralFlag, 12, false); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/pushPack/TempMsgHead.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.pushPack; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | public final class TempMsgHead extends Jce { 8 | public int c2c_type; 9 | public int service_type; 10 | 11 | public void writeTo(JceOutputStream jceOutputStream) { 12 | jceOutputStream.write(this.c2c_type, 0); 13 | jceOutputStream.write(this.service_type, 1); 14 | } 15 | 16 | public void readFrom(JceInputStream jceInputStream) { 17 | this.c2c_type = jceInputStream.read(this.c2c_type, 0, false); 18 | this.service_type = jceInputStream.read(this.service_type, 1, false); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/pushPack/UinPairMsg.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.pushPack; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | import java.util.ArrayList; 8 | 9 | public final class UinPairMsg extends Jce { 10 | static ArrayList cache_vMsgInfos; 11 | public long lPeerUin; 12 | public long uLastReadTime; 13 | public long uMsgCompleted; 14 | public ArrayList vMsgInfos; 15 | 16 | public void writeTo(JceOutputStream jceOutputStream) { 17 | jceOutputStream.write(this.uLastReadTime, 1); 18 | jceOutputStream.write(this.lPeerUin, 2); 19 | jceOutputStream.write(this.uMsgCompleted, 3); 20 | if (this.vMsgInfos != null) { 21 | jceOutputStream.write(this.vMsgInfos, 4); 22 | } 23 | } 24 | 25 | public void readFrom(JceInputStream jceInputStream) { 26 | this.uLastReadTime = jceInputStream.read(this.uLastReadTime, 1, false); 27 | this.lPeerUin = jceInputStream.read(this.lPeerUin, 2, false); 28 | this.uMsgCompleted = jceInputStream.read(this.uMsgCompleted, 3, false); 29 | if (cache_vMsgInfos == null) { 30 | cache_vMsgInfos = new ArrayList<>(); 31 | cache_vMsgInfos.add(new MsgInfo()); 32 | } 33 | this.vMsgInfos = (ArrayList) jceInputStream.readV2(cache_vMsgInfos, 4, false); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/pushPack/shareData.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.pushPack; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | public final class shareData extends Jce { 8 | public String msgtail = ""; 9 | public String picurl = ""; 10 | public String pkgname = ""; 11 | public String url = ""; 12 | 13 | public void writeTo(JceOutputStream jceOutputStream) { 14 | jceOutputStream.write(this.pkgname, 0); 15 | jceOutputStream.write(this.msgtail, 1); 16 | jceOutputStream.write(this.picurl, 2); 17 | jceOutputStream.write(this.url, 3); 18 | } 19 | 20 | public void readFrom(JceInputStream jceInputStream) { 21 | this.pkgname = jceInputStream.readString(0, true); 22 | this.msgtail = jceInputStream.readString(1, true); 23 | this.picurl = jceInputStream.readString(2, true); 24 | this.url = jceInputStream.readString(3, true); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/statsvc/RequestPushForceOffline.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.statsvc; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | 6 | public class RequestPushForceOffline extends Jce { 7 | public byte bSameDevice; 8 | public long lUin; 9 | public String strTips = ""; 10 | public String strTitle = ""; 11 | 12 | public void readFrom(JceInputStream jceInputStream) { 13 | this.lUin = jceInputStream.read(this.lUin, 0, true); 14 | this.strTitle = jceInputStream.readString(1, false); 15 | this.strTips = jceInputStream.readString(2, false); 16 | this.bSameDevice = jceInputStream.read(this.bSameDevice, 3, false); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/summary/HeartInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.summary; 2 | 3 | import com.qq.taf.jce.JceInputStream; 4 | import com.qq.taf.jce.JceOutputStream; 5 | import com.qq.taf.jce.JceStruct; 6 | 7 | public class HeartInfo extends JceStruct { 8 | public int iHeartCount; 9 | 10 | public HeartInfo() { 11 | } 12 | 13 | public HeartInfo(int i) { 14 | this.iHeartCount = i; 15 | } 16 | 17 | @Override 18 | public void writeTo(JceOutputStream jceOutputStream) { 19 | jceOutputStream.write(this.iHeartCount, 0); 20 | } 21 | 22 | @Override 23 | public void readFrom(JceInputStream jceInputStream) { 24 | this.iHeartCount = jceInputStream.read(this.iHeartCount, 0, false); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/summary/ReqHead.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.summary; 2 | 3 | import com.qq.taf.Jce; 4 | import com.qq.taf.jce.JceInputStream; 5 | import com.qq.taf.jce.JceOutputStream; 6 | 7 | public class ReqHead extends Jce { 8 | public int iVersion = 1; 9 | 10 | public ReqHead(int i) { 11 | this.iVersion = i; 12 | } 13 | 14 | @Override 15 | public void writeTo(JceOutputStream jceOutputStream) { 16 | jceOutputStream.write(this.iVersion, 0); 17 | } 18 | 19 | @Override 20 | public void readFrom(JceInputStream jceInputStream) { 21 | this.iVersion = jceInputStream.read(this.iVersion, 0, true); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/summary/RespHead.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.summary; 2 | 3 | import com.qq.taf.jce.JceInputStream; 4 | import com.qq.taf.jce.JceStruct; 5 | 6 | import java.util.Arrays; 7 | 8 | /** 9 | * @author luoluo 10 | * @date 2020/8/26 22:20 11 | */ 12 | public class RespHead extends JceStruct { 13 | static byte[] cache_vCookies; 14 | public int iResult; 15 | public int iVersion; 16 | public String strErrorMsg = ""; 17 | public byte[] vCookies; 18 | 19 | @Override 20 | public void readFrom(JceInputStream jceInputStream) { 21 | this.iVersion = jceInputStream.read(this.iVersion, 0, true); 22 | this.iResult = jceInputStream.read(this.iResult, 1, true); 23 | this.strErrorMsg = jceInputStream.readString(2, true); 24 | if (cache_vCookies == null) { 25 | cache_vCookies = new byte[1]; 26 | } 27 | this.vCookies = jceInputStream.read(cache_vCookies, 3, false); 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "RespHead{" + 33 | "iResult=" + iResult + 34 | ", iVersion=" + iVersion + 35 | ", strErrorMsg='" + strErrorMsg + '\'' + 36 | ", vCookies=" + Arrays.toString(vCookies) + 37 | '}'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/jce/summary/UserLocaleInfo.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.jce.summary; 2 | 3 | import com.qq.taf.jce.JceInputStream; 4 | import com.qq.taf.jce.JceOutputStream; 5 | import com.qq.taf.jce.JceStruct; 6 | 7 | public class UserLocaleInfo extends JceStruct { 8 | public long latitude; 9 | public long longitude; 10 | 11 | @Override 12 | public void writeTo(JceOutputStream jceOutputStream) { 13 | jceOutputStream.write(this.longitude, 1); 14 | jceOutputStream.write(this.latitude, 2); 15 | } 16 | 17 | @Override 18 | public void readFrom(JceInputStream jceInputStream) { 19 | this.longitude = jceInputStream.read(this.longitude, 1, false); 20 | this.latitude = jceInputStream.read(this.latitude, 2, false); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/DeviceReport.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf; 2 | 3 | import com.qq.pb.ByteStringMicro; 4 | import com.qq.pb.MessageMicro; 5 | import com.qq.pb.PBBytesField; 6 | import com.qq.pb.PBField; 7 | import com.toolq.helper.android.Android; 8 | 9 | public class DeviceReport extends MessageMicro { 10 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{10, 18, 26, 34, 42, 50, 58, 66, 74}, 11 | new String[]{"bytes_bootloader", "bytes_version", "bytes_codename", "bytes_incremental", "bytes_fingerprint", "bytes_boot_id", "bytes_android_id", "bytes_baseband", "bytes_inner_ver"}, 12 | new Object[]{ByteStringMicro.EMPTY, ByteStringMicro.EMPTY, ByteStringMicro.EMPTY, ByteStringMicro.EMPTY, ByteStringMicro.EMPTY, ByteStringMicro.EMPTY, ByteStringMicro.EMPTY, ByteStringMicro.EMPTY, ByteStringMicro.EMPTY}, 13 | DeviceReport.class); 14 | 15 | public final PBBytesField bytes_bootloader = PBField.initBytes("unknown"); 16 | 17 | public final PBBytesField bytes_version = PBField.initBytes("Linux version 4.19.113-perf-gb3dd08fa2aaa (builder@c5-miui-ota-bd143.bj) (clang version 8.0.12 for Android NDK) #1 SMP PREEMPT Thu Feb 4 04:37:10 CST 2021;"); 18 | public final PBBytesField bytes_codename = PBField.initBytes("REL"); 19 | public final PBBytesField bytes_incremental = PBField.initBytes("20.8.13"); 20 | public final PBBytesField bytes_fingerprint = PBField.initBytes("Xiaomi/vangogh/vangogh:11/RKQ1.200826.002/21.2.4:user/release-keys"); 21 | public final PBBytesField bytes_boot_id = PBField.initBytes(""); 22 | public final PBBytesField bytes_android_id = PBField.initBytes(Android.androidId); 23 | public final PBBytesField bytes_baseband = PBField.initBytes(""); 24 | public final PBBytesField bytes_inner_ver = PBField.initBytes("21.2.4"); 25 | } 26 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/SubMsgType0x1a.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf; 2 | 3 | import com.qq.pb.*; 4 | 5 | public final class SubMsgType0x1a { 6 | public static final class MsgBody extends MessageMicro { 7 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{10, 16, 24, 32, 40, 50, 56, 64, 72, 80}, new String[]{"bytes_file_key", "uint32_from_uin", "uint32_to_uin", "uint32_status", "uint32_ttl", "string_desc", "uint32_type", "uint32_capture_times", "uint64_from_uin", "uint64_to_uin"}, new Object[]{ByteStringMicro.EMPTY, 0, 0, 0, 0, "", 0, 0, 0L, 0L}, MsgBody.class); 8 | public final PBBytesField bytes_file_key = PBField.initBytes(ByteStringMicro.EMPTY); 9 | public final PBStringField string_desc = PBField.initString(""); 10 | public final PBUInt32Field uint32_capture_times = PBField.initUInt32(0); 11 | public final PBUInt32Field uint32_from_uin = PBField.initUInt32(0); 12 | public final PBUInt32Field uint32_status = PBField.initUInt32(0); 13 | public final PBUInt32Field uint32_to_uin = PBField.initUInt32(0); 14 | public final PBUInt32Field uint32_ttl = PBField.initUInt32(0); 15 | public final PBUInt32Field uint32_type = PBField.initUInt32(0); 16 | public final PBUInt64Field uint64_from_uin = PBField.initUInt64(0); 17 | public final PBUInt64Field uint64_to_uin = PBField.initUInt64(0); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/SyncCookie.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf; 2 | 3 | import com.qq.pb.ByteStringMicro; 4 | import com.qq.pb.MessageMicro; 5 | import com.qq.pb.PBField; 6 | import com.qq.pb.PBUInt64Field; 7 | import com.toolq.utils.RandomUtil; 8 | 9 | public class SyncCookie extends MessageMicro { 10 | private static final int val = RandomUtil.randInt(1458467940, 269578051); 11 | 12 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap( 13 | new int[]{10, 16, 24, 32, 40, 48, 56, 64, 74, 80, 88, 98}, 14 | new String[]{"createTime", "sendTime", "random", "rand", "uint32_ttl", "uint32_type", "uint32_encrypt_prehead_length", "uint32_encrypt_type", "bytes_encrypt_key", "uint32_read_times", "uint32_left_time", "not_online_image"}, 15 | new Object[]{0L, 0L, 0L, 0L, 0, 0, 0, 0, ByteStringMicro.EMPTY, 0, 0, null}, 16 | SyncCookie.class); 17 | 18 | public final PBUInt64Field createTime = PBField.initUInt64(0); 19 | public final PBUInt64Field sendTime = PBField.initUInt64(0); 20 | public final PBUInt64Field random = PBField.initUInt64(0); 21 | public final PBUInt64Field rand = PBField.initUInt64(0); 22 | 23 | 24 | // 废弃 25 | } 26 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/message/SyncFlag.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf.message; 2 | 3 | public enum SyncFlag { 4 | START, 5 | CONTINUE, 6 | STOP, 7 | FINISH 8 | } 9 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/message/im_msg_head.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf.message; 2 | 3 | import com.qq.pb.*; 4 | 5 | public class im_msg_head { 6 | public static final class InstCtrl extends MessageMicro { 7 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{10, 18, 26}, new String[]{"rpt_msg_send_to_inst", "rpt_msg_exclude_inst", "msg_from_inst"}, new Object[]{null, null, null}, InstCtrl.class); 8 | public im_msg_head.InstInfo msg_from_inst = new im_msg_head.InstInfo(); 9 | public final PBRepeatMessageField rpt_msg_exclude_inst = PBField.initRepeatMessage(im_msg_head.InstInfo.class); 10 | public final PBRepeatMessageField rpt_msg_send_to_inst = PBField.initRepeatMessage(im_msg_head.InstInfo.class); 11 | } 12 | 13 | public static final class InstInfo extends MessageMicro { 14 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8, 16, 24, 80}, new String[]{"uint32_apppid", "uint32_instid", "uint32_platform", "enum_device_type"}, new Object[]{0, 0, 0, 0}, InstInfo.class); 15 | public final PBEnumField enum_device_type = PBField.initEnum(0); 16 | public final PBUInt32Field uint32_apppid = PBField.initUInt32(0); 17 | public final PBUInt32Field uint32_instid = PBField.initUInt32(0); 18 | public final PBUInt32Field uint32_platform = PBField.initUInt32(0); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/message/im_receipt.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf.message; 2 | 3 | import com.qq.pb.*; 4 | 5 | public final class im_receipt { 6 | public static final class ReceiptInfo extends MessageMicro { 7 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8}, new String[]{"uint64_read_time"}, new Object[]{0L}, ReceiptInfo.class); 8 | public final PBUInt64Field uint64_read_time = PBField.initUInt64(0); 9 | } 10 | 11 | public static final class ReceiptResp extends MessageMicro { 12 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8, 18}, new String[]{"command", "receipt_info"}, new Object[]{1, null}, ReceiptResp.class); 13 | public final PBEnumField command = PBField.initEnum(1); 14 | public im_receipt.ReceiptInfo receipt_info = new im_receipt.ReceiptInfo(); 15 | } 16 | 17 | public static final class ReceiptReq extends MessageMicro { 18 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8, 18}, new String[]{"command", "msg_info"}, new Object[]{1, null}, ReceiptReq.class); 19 | public final PBEnumField command = PBField.initEnum(1); 20 | public im_receipt.MsgInfo msg_info = new im_receipt.MsgInfo(); 21 | } 22 | 23 | public static final class MsgInfo extends MessageMicro { 24 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8, 16, 24, 32}, new String[]{"uint64_from_uin", "uint64_to_uin", "uint32_msg_seq", "uint32_msg_random"}, new Object[]{0L, 0L, 0, 0}, MsgInfo.class); 25 | public final PBUInt32Field uint32_msg_random = PBField.initUInt32(0); 26 | public final PBUInt32Field uint32_msg_seq = PBField.initUInt32(0); 27 | public final PBUInt64Field uint64_from_uin = PBField.initUInt64(0); 28 | public final PBUInt64Field uint64_to_uin = PBField.initUInt64(0); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/message/msg_ctrl.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf.message; 2 | 3 | import com.qq.pb.*; 4 | 5 | public final class msg_ctrl { 6 | public static final class MsgCtrl extends MessageMicro { 7 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8, 18}, new String[]{"msg_flag", "resv_resv_info"}, new Object[]{0, null}, MsgCtrl.class); 8 | public final PBUInt32Field msg_flag = PBField.initUInt32(0); 9 | public msg_ctrl.ResvResvInfo resv_resv_info = new msg_ctrl.ResvResvInfo(); 10 | } 11 | 12 | public static final class ResvResvInfo extends MessageMicro { 13 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8, 18, 24, 32, 40, 48, 56, 64}, new String[]{"uint32_flag", "bytes_reserv1", "uint64_reserv2", "uint64_reserv3", "uint32_create_time", "uint32_pic_height", "uint32_pic_width", "uint32_resv_flag"}, new Object[]{0, ByteStringMicro.EMPTY, 0L, 0L, 0, 0, 0, 0}, ResvResvInfo.class); 14 | public final PBBytesField bytes_reserv1 = PBField.initBytes(ByteStringMicro.EMPTY); 15 | public final PBUInt32Field uint32_create_time = PBField.initUInt32(0); 16 | public final PBUInt32Field uint32_flag = PBField.initUInt32(0); 17 | public final PBUInt32Field uint32_pic_height = PBField.initUInt32(0); 18 | public final PBUInt32Field uint32_pic_width = PBField.initUInt32(0); 19 | public final PBUInt32Field uint32_resv_flag = PBField.initUInt32(0); 20 | public final PBUInt64Field uint64_reserv2 = PBField.initUInt64(0); 21 | public final PBUInt64Field uint64_reserv3 = PBField.initUInt64(0); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/oidb/OIDBSSOPkg.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf.oidb; 2 | 3 | import com.qq.pb.*; 4 | 5 | public class OIDBSSOPkg extends MessageMicro { 6 | public static final int BYTES_BODYBUFFER_FIELD_NUMBER = 4; 7 | public static final int STR_CLIENT_VERSION_FIELD_NUMBER = 6; 8 | public static final int STR_ERROR_MSG_FIELD_NUMBER = 5; 9 | public static final int UINT32_COMMAND_FIELD_NUMBER = 1; 10 | public static final int UINT32_RESULT_FIELD_NUMBER = 3; 11 | public static final int UINT32_SERVICE_TYPE_FIELD_NUMBER = 2; 12 | 13 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8, 16, 24, 34, 42, 50}, new String[]{"uint32_command", "uint32_service_type", "uint32_result", "bytes_bodybuffer", "str_error_msg", "str_client_version"}, new Object[]{0, 0, 0, ByteStringMicro.EMPTY, "", ""}, OIDBSSOPkg.class); 14 | public final PBBytesField bytes_bodybuffer = PBField.initBytes(ByteStringMicro.EMPTY); 15 | public final PBStringField str_client_version = PBField.initString(""); 16 | public final PBStringField str_error_msg = PBField.initString(""); 17 | public final PBUInt32Field uint32_command = PBField.initUInt32(0); 18 | public final PBUInt32Field uint32_result = PBField.initUInt32(0); 19 | public final PBUInt32Field uint32_service_type = PBField.initUInt32(0); 20 | } 21 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/onlinepush/msg_onlinepush.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf.onlinepush; 2 | 3 | import com.qq.pb.*; 4 | import com.toolq.qq.protocol.protobuf.message.msg_comm; 5 | 6 | public final class msg_onlinepush { 7 | public static final class PbPushMsg extends MessageMicro { 8 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{10, 16, 26, 32, 72, 80}, new String[]{"msg", "svrip", "bytes_push_token", "ping_flag", "uint32_general_flag", "uint64_bind_uin"}, new Object[]{null, 0, ByteStringMicro.EMPTY, 0, 0, 0L}, PbPushMsg.class); 9 | 10 | public final PBBytesField bytes_push_token = PBField.initBytes(ByteStringMicro.EMPTY); 11 | public msg_comm.Msg msg = new msg_comm.Msg(); 12 | 13 | public final PBUInt32Field ping_flag = PBField.initUInt32(0); 14 | public final PBInt32Field svrip = PBField.initInt32(0); 15 | public final PBUInt32Field uint32_general_flag = PBField.initUInt32(0); 16 | public final PBUInt64Field uint64_bind_uin = PBField.initUInt64(0); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/pushmsg/Submsgtype0x8a.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf.pushmsg; 2 | 3 | import com.qq.pb.*; 4 | import com.toolq.qq.protocol.protobuf.tips.TroopTips0x857; 5 | 6 | public final class Submsgtype0x8a { 7 | public static final class ReqBody extends MessageMicro { 8 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{10, 16, 24, 32, 42}, new String[]{"msg_info", "uint32_app_id", "uint32_inst_id", "uint32_long_message_flag", "bytes_reserved"}, new Object[]{null, 0, 0, 0, ByteStringMicro.EMPTY}, ReqBody.class); 9 | public final PBBytesField bytes_reserved = PBField.initBytes(ByteStringMicro.EMPTY); 10 | public final PBRepeatMessageField msg_info = PBField.initRepeatMessage(Submsgtype0x8a.MsgInfo.class); 11 | public final PBUInt32Field uint32_app_id = PBField.initUInt32(0); 12 | public final PBUInt32Field uint32_inst_id = PBField.initUInt32(0); 13 | public final PBUInt32Field uint32_long_message_flag = PBField.initUInt32(0); 14 | } 15 | 16 | public static final class MsgInfo extends MessageMicro { 17 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8, 16, 24, 32, 40, 48, 56, 64, 72, 96, 106}, new String[]{"uint64_from_uin", "uint64_to_uin", "uint32_msg_seq", "uint64_msg_uid", "uint64_msg_time", "uint32_msg_random", "uint32_pkg_num", "uint32_pkg_index", "uint32_div_seq", "uint32_flag", "msg_wording_info"}, new Object[]{0L, 0L, 0, 0L, 0L, 0, 0, 0, 0, 0, null}, MsgInfo.class); 18 | public Submsgtype0x8a.WithDrawWordingInfo msg_wording_info = new Submsgtype0x8a.WithDrawWordingInfo(); 19 | public final PBUInt32Field uint32_div_seq = PBField.initUInt32(0); 20 | public final PBUInt32Field uint32_flag = PBField.initUInt32(0); 21 | public final PBUInt32Field uint32_msg_random = PBField.initUInt32(0); 22 | public final PBUInt32Field uint32_msg_seq = PBField.initUInt32(0); 23 | public final PBUInt32Field uint32_pkg_index = PBField.initUInt32(0); 24 | public final PBUInt32Field uint32_pkg_num = PBField.initUInt32(0); 25 | public final PBUInt64Field uint64_from_uin = PBField.initUInt64(0); 26 | public final PBUInt64Field uint64_msg_time = PBField.initUInt64(0); 27 | public final PBUInt64Field uint64_msg_uid = PBField.initUInt64(0); 28 | public final PBUInt64Field uint64_to_uin = PBField.initUInt64(0); 29 | } 30 | 31 | public static final class WithDrawWordingInfo extends MessageMicro { 32 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8, 18}, new String[]{"int32_item_id", "string_item_name"}, new Object[]{0, ""}, WithDrawWordingInfo.class); 33 | public final PBInt32Field int32_item_id = PBField.initInt32(0); 34 | public final PBStringField string_item_name = PBField.initString(""); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/qq/protocol/protobuf/troop_honor.java: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.protobuf; 2 | 3 | import com.qq.pb.MessageMicro; 4 | import com.qq.pb.PBField; 5 | import com.qq.pb.PBRepeatField; 6 | import com.qq.pb.PBUInt32Field; 7 | 8 | public class troop_honor { 9 | public static final class GroupUserCardHonor extends MessageMicro { 10 | static final MessageMicro.FieldMap __fieldMap__ = MessageMicro.initFieldMap(new int[]{8, 16}, new String[]{"id", "level"}, new Object[]{0, 0}, GroupUserCardHonor.class); 11 | public final PBRepeatField id = PBField.initRepeat(PBUInt32Field.__repeatHelper__); 12 | public final PBUInt32Field level = PBField.initUInt32(0); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/utils/BytesUtil.java: -------------------------------------------------------------------------------- 1 | package com.toolq.utils; 2 | 3 | import java.util.Arrays; 4 | import java.util.Random; 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/10/1 11:54 9 | */ 10 | public class BytesUtil { 11 | public static byte[] byteMerger(byte[] first, byte[] second) { 12 | byte[] result = Arrays.copyOf(first, first.length + second.length); 13 | System.arraycopy(second, 0, result, first.length, second.length); 14 | return result; 15 | } 16 | 17 | public static byte[] int16_to_buf(int i) { 18 | byte[] out = new byte[2]; 19 | out[1] = (byte) i; 20 | out[0] = (byte) (i >> 8); 21 | return out; 22 | } 23 | 24 | public static byte[] int32_to_buf(int i) { 25 | byte[] out = new byte[4]; 26 | out[3] = (byte) i; 27 | out[2] = (byte) (i >> 8); 28 | out[1] = (byte) (i >> 16); 29 | out[0] = (byte) (i >> 24); 30 | return out; 31 | } 32 | 33 | public static byte[] int64_to_buf(long j) { 34 | byte[] out = new byte[8]; 35 | out[7] = (byte) ((int) (j)); 36 | out[6] = (byte) ((int) (j >> 8)); 37 | out[5] = (byte) ((int) (j >> 16)); 38 | out[4] = (byte) ((int) (j >> 24)); 39 | out[3] = (byte) ((int) (j >> 32)); 40 | out[2] = (byte) ((int) (j >> 40)); 41 | out[1] = (byte) ((int) (j >> 48)); 42 | out[0] = (byte) ((int) (j >> 56)); 43 | return out; 44 | } 45 | 46 | public static byte[] int64_to_buf32(long j) { 47 | byte[] out = new byte[4]; 48 | out[3] = (byte) ((int) (j)); 49 | out[2] = (byte) ((int) (j >> 8)); 50 | out[1] = (byte) ((int) (j >> 16)); 51 | out[0] = (byte) ((int) (j >> 24)); 52 | return out; 53 | } 54 | 55 | public static int buf_to_int8(byte[] bArr, int i) { 56 | return bArr[i] & 255; 57 | } 58 | 59 | public static int buf_to_int16(byte[] bArr, int i) { 60 | return ((bArr[i] << 8) & 65280) + ((bArr[i + 1]) & 255); 61 | } 62 | 63 | public static int buf_to_int32(byte[] bArr, int i) { 64 | return ((bArr[i] << 24) & -16777216) + ((bArr[i + 1] << 16) & 16711680) + ((bArr[i + 2] << 8) & 65280) + ((bArr[i + 3]) & 255); 65 | } 66 | 67 | public static long buf_to_int64(byte[] bArr, int i) { 68 | return ((((long) bArr[i]) << 56) & -72057594037927936L) + ((((long) bArr[i + 1]) << 48) & 71776119061217280L) + ((((long) bArr[i + 2]) << 40) & 280375465082880L) + ((((long) bArr[i + 3]) << 32) & 1095216660480L) + ((((long) bArr[i + 4]) << 24) & 4278190080L) + ((((long) bArr[i + 5]) << 16) & 16711680) + ((((long) bArr[i + 6]) << 8) & 65280) + ((((long) bArr[i + 7])) & 255); 69 | } 70 | 71 | public static byte[] subByte(byte[] b, int off, int length){ 72 | if (b != null && b.length > 0){ 73 | byte[] b1 = new byte[length]; 74 | System.arraycopy(b, off, b1, 0, length); 75 | return b1; 76 | } 77 | return null; 78 | } 79 | 80 | public static byte[] randomKey(int size){ 81 | byte[] key = new byte[size]; 82 | new Random().nextBytes(key); 83 | return key; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/utils/HexUtil.java: -------------------------------------------------------------------------------- 1 | package com.toolq.utils; 2 | 3 | public class HexUtil { 4 | private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; 5 | 6 | public static String bytesToHexString(byte[] input){ 7 | if (input == null) 8 | throw new IllegalArgumentException("input should not be null"); 9 | StringBuilder builder = new StringBuilder(input.length * 2); 10 | for (byte b : input) { 11 | builder.append(HEX_DIGITS[b >>> 4 & 0xf]); 12 | builder.append(HEX_DIGITS[b & 0xf]); 13 | } 14 | return builder.toString(); 15 | } 16 | 17 | public static byte[] hexStringToBytes(String input){ 18 | if (input == null) 19 | throw new IllegalArgumentException("input should not be null"); 20 | input = input.replace(" ", "").replace("\n", "").replace("\t", ""); 21 | if(input.length() % 2 != 0) 22 | throw new IllegalArgumentException("input should be divisible by four"); 23 | String alphabet = new String(HEX_DIGITS); 24 | String temp = input.toUpperCase(); 25 | byte[] output = new byte[temp.length() / 2]; 26 | for (int i = 0; i < output.length; i++) { 27 | int highByte = alphabet.indexOf(temp.charAt(i * 2)); 28 | int lowByte = alphabet.indexOf(temp.charAt(i * 2 + 1)); 29 | if(highByte == -1 || lowByte == -1) 30 | throw new IllegalArgumentException("input contiain illegal character"); 31 | output[i] = (byte) (highByte << 4 | lowByte); 32 | } 33 | return output; 34 | } 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/utils/JsonUtil.java: -------------------------------------------------------------------------------- 1 | package com.toolq.utils; 2 | 3 | import com.google.gson.*; 4 | import com.google.gson.stream.JsonReader; 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/10/2 15:07 9 | */ 10 | public class JsonUtil { 11 | private static final JsonParser parser = new JsonParser(); 12 | 13 | public static boolean isJsonObject(String JSON) { 14 | return parser.parse(JSON) instanceof JsonObject; 15 | } 16 | 17 | public static JsonObject parseJsonObject(String JSON) { 18 | return (JsonObject) parser.parse(JSON); 19 | } 20 | 21 | public static JsonArray parseJsonArray(String JSON) { 22 | return (JsonArray) parser.parse(JSON); 23 | } 24 | 25 | public static String formatJson(String json) { 26 | Gson gson = new GsonBuilder().setPrettyPrinting().create(); 27 | JsonParser jp = new JsonParser(); 28 | JsonElement je = jp.parse(json); 29 | return gson.toJson(je); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/utils/NumberUtil.java: -------------------------------------------------------------------------------- 1 | package com.toolq.utils; 2 | 3 | public class NumberUtil { 4 | public static long toULong(long j) { 5 | return Long.parseLong(Long.toUnsignedString(j)); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/utils/QQUtil.java: -------------------------------------------------------------------------------- 1 | package com.toolq.utils; 2 | 3 | import java.security.SecureRandom; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Random; 7 | 8 | /** 9 | * @author luoluo 10 | * @date 2020/10/1 21:50 11 | */ 12 | public class QQUtil { 13 | public static boolean checkAccount(Long qq, String password) { 14 | return qq != null && password != null && qq >= 10000 && qq <= 4000000000L; 15 | } 16 | 17 | public static boolean isRightQQ(Long qq) { 18 | return checkAccount(qq, ""); 19 | } 20 | 21 | public static String randomAndroidId() { 22 | StringBuilder builder = new StringBuilder(); 23 | for (int i = 0; i < 15; i++) { 24 | builder.append(new Random().nextInt(10)); 25 | } 26 | return builder.toString(); 27 | } 28 | 29 | public static long ipToLong(String ip) { 30 | String[] ipArray = ip.split("\\."); 31 | long[] ipNums = new long[4]; 32 | for(int i = 0; i < 4; ++i) { 33 | ipNums[i] = Long.parseLong(ipArray[i].trim()); 34 | } 35 | return ipNums[0] * 256L * 256L * 256L 36 | + ipNums[1] * 256L * 256L 37 | + ipNums[2] * 256L 38 | + ipNums[3]; 39 | } 40 | 41 | public static String get_mpasswd() { 42 | try { 43 | byte[] seed = SecureRandom.getSeed(16); 44 | StringBuilder ret = new StringBuilder(); 45 | for(int i = 0;i < 16; i++) { 46 | ret.append((char) ((new Random().nextBoolean() ? 97 : 65) + Math.abs(seed[i] % 26))); 47 | } 48 | return ret.toString(); 49 | } catch (Throwable th) { 50 | return "1234567890123456"; 51 | } 52 | } 53 | 54 | public static long GetBkn(String skey) { 55 | int hash = 5381; 56 | for (int i = 0, len = skey.length(); i < len; ++i) 57 | hash += (hash << 5) + (int)skey.charAt(i); 58 | return hash & 2147483647; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/utils/StringUtil.java: -------------------------------------------------------------------------------- 1 | package com.toolq.utils; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/10/2 3:52 6 | */ 7 | public class StringUtil { 8 | public static String subString(String string, String str1, String str2){ 9 | int beginIndex = string.indexOf(str1); 10 | int endIndex = string.indexOf(str2); 11 | if(beginIndex < 0){ 12 | return null; 13 | } else if(endIndex < 0){ 14 | return null; 15 | } 16 | if(beginIndex > endIndex){ 17 | int tempIndex = beginIndex; 18 | beginIndex = endIndex; 19 | endIndex = tempIndex; 20 | str1 = str2; 21 | } 22 | return string.substring(beginIndex, endIndex).substring(str1.length()); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/utils/TeaUtil.java: -------------------------------------------------------------------------------- 1 | package com.toolq.utils; 2 | 3 | import com.toolq.utils.crypts.Crypter; 4 | 5 | /** 6 | * @author luoluo 7 | * @date 2020/10/5 2:51 8 | */ 9 | public class TeaUtil { 10 | public static byte[] encrypt(byte[] data, byte[] key) { 11 | Crypter crypter = new Crypter(); 12 | return crypter.encrypt(data, key); 13 | } 14 | 15 | public static byte[] decrypt(byte[] data, byte[] key) { 16 | Crypter crypter = new Crypter(); 17 | byte[] result = crypter.decrypt(data, key); 18 | if(result == null) { 19 | return crypter.decrypt(data, new byte[16]); 20 | } else { 21 | return result; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/utils/ZipUtil.java: -------------------------------------------------------------------------------- 1 | package com.toolq.utils; 2 | 3 | import com.toolq.helper.logger.TLog; 4 | 5 | import java.io.ByteArrayOutputStream; 6 | import java.io.IOException; 7 | import java.util.zip.Deflater; 8 | import java.util.zip.Inflater; 9 | 10 | /** 11 | * @author luoluo 12 | * @date 2020/10/7 4:11 13 | */ 14 | public class ZipUtil { 15 | public static byte[] uncompress(byte[] inputByte) { 16 | int len = 0; 17 | Inflater infl = new Inflater(); 18 | infl.setInput(inputByte); 19 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 20 | byte[] outByte = new byte[1024]; 21 | try { 22 | while (!infl.finished()) { 23 | len = infl.inflate(outByte); 24 | if (len == 0) { 25 | break; 26 | } 27 | bos.write(outByte, 0, len); 28 | } 29 | infl.end(); 30 | } catch (Exception e) { 31 | TLog.INSTANCE.warn("uncompress", e); 32 | } finally { 33 | try { 34 | bos.close(); 35 | } catch (IOException e) { 36 | TLog.INSTANCE.warn("uncompress finally", e); 37 | } 38 | } 39 | return bos.toByteArray(); 40 | } 41 | 42 | public static byte[] compress(byte[] inputByte) { 43 | int len = 0; 44 | Deflater defl = new Deflater(); 45 | defl.setInput(inputByte); 46 | defl.finish(); 47 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 48 | byte[] outputByte = new byte[1024]; 49 | try { 50 | while (!defl.finished()) { 51 | len = defl.deflate(outputByte); 52 | bos.write(outputByte, 0, len); 53 | } 54 | defl.end(); 55 | } finally { 56 | try { 57 | bos.close(); 58 | } catch (IOException e) { 59 | TLog.INSTANCE.warn("compress finally", e); 60 | } 61 | } 62 | return bos.toByteArray(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/java/com/toolq/utils/crypts/RC4.java: -------------------------------------------------------------------------------- 1 | package com.toolq.utils.crypts; 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/10/25 6:17 6 | */ 7 | public class RC4 { 8 | /** 加密 **/ 9 | public static byte[] encrypt(byte[] data, String key) { 10 | if (data == null || key == null) { 11 | return null; 12 | } 13 | return encrypt_byte(data, key); 14 | } 15 | 16 | /** 解密 **/ 17 | public static byte[] decrypt(byte[] data, String key) { 18 | if (data == null || key == null) { 19 | return null; 20 | } 21 | return RC4Base(data, key); 22 | } 23 | 24 | /** 加密字节码 **/ 25 | public static byte[] encrypt_byte(byte[] data, String key) { 26 | if (data == null || key == null) { 27 | return null; 28 | } 29 | return RC4Base(data, key); 30 | } 31 | 32 | private static byte[] initKey(String aKey) { 33 | byte[] b_key = aKey.getBytes(); 34 | byte[] state = new byte[256]; 35 | 36 | for (int i = 0; i < 256; i++) { 37 | state[i] = (byte) i; 38 | } 39 | int index1 = 0; 40 | int index2 = 0; 41 | if (b_key.length == 0) { 42 | b_key = "Skyblade".getBytes(); 43 | } 44 | for (int i = 0; i < 256; i++) { 45 | index2 = ((b_key[index1] & 0xff) + (state[i] & 0xff) + index2) & 0xff; 46 | byte tmp = state[i]; 47 | state[i] = state[index2]; 48 | state[index2] = tmp; 49 | index1 = (index1 + 1) % b_key.length; 50 | } 51 | return state; 52 | } 53 | 54 | private static byte[] RC4Base(byte[] input, String mKkey) { 55 | int x = 0; 56 | int y = 0; 57 | byte[] key = initKey(mKkey); 58 | int xorIndex; 59 | byte[] result = new byte[input.length]; 60 | 61 | for (int i = 0; i < input.length; i++) { 62 | x = (x + 1) & 0xff; 63 | y = ((key[x] & 0xff) + y) & 0xff; 64 | byte tmp = key[x]; 65 | key[x] = key[y]; 66 | key[y] = tmp; 67 | xorIndex = ((key[x] & 0xff) + (key[y] & 0xff)) & 0xff; 68 | result[i] = (byte) (input[i] ^ key[xorIndex]); 69 | } 70 | return result; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/ToolQManager.kt: -------------------------------------------------------------------------------- 1 | package com.toolq 2 | 3 | import com.toolq.helper.bot.QQAccount 4 | import java.util.concurrent.ConcurrentHashMap 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/10/1 21:25 9 | */ 10 | object ToolQManager { 11 | private val botMap = ConcurrentHashMap() 12 | 13 | @JvmStatic 14 | fun addBot(qq: Long, password: String, isHd : Boolean = false): ToolQ { 15 | if (botMap.containsKey(qq)) { 16 | return botMap[qq] as ToolQ 17 | } 18 | val account = QQAccount(qq, password) 19 | val toolQ = ToolQ(account, isHd) 20 | botMap[qq] = toolQ 21 | return toolQ 22 | } 23 | 24 | @JvmStatic 25 | fun getBot(qq: Long): ToolQ? { 26 | return botMap[qq] 27 | } 28 | 29 | @JvmStatic 30 | fun shutBot(qq: Long) : Boolean { 31 | if(botMap.containsKey(qq)) { 32 | val toolQ = botMap[qq] as ToolQ 33 | toolQ.shut() 34 | removeBot(toolQ, qq) 35 | return true 36 | } 37 | return false 38 | } 39 | 40 | @JvmStatic 41 | private fun removeBot(toolQ: ToolQ, qq: Long) { 42 | botMap.remove(qq, toolQ) 43 | } 44 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/BotEvent.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot 2 | 3 | import com.toolq.ToolQManager.getBot 4 | 5 | @ExperimentalUnsignedTypes 6 | abstract class BotEvent(botUin: Long) : Center(getBot(botUin)!!), IBotEvent { 7 | 8 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/HeartBeat.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot 2 | 3 | import com.toolq.BotConfig 4 | import com.toolq.ToolQ 5 | import com.toolq.helper.android.Android 6 | import com.toolq.helper.logger.TLog 7 | import com.toolq.helper.packet.ByteBuilder 8 | import java.lang.System.currentTimeMillis 9 | 10 | @ExperimentalUnsignedTypes 11 | class HeartBeat(private val toolQ: ToolQ) : Thread("HeartBeat") { 12 | companion object { 13 | fun addHeartBeat(toolQ: ToolQ) { 14 | toolQ.threadManager.addTask(HeartBeat(toolQ)) 15 | } 16 | } 17 | 18 | override fun run() { 19 | while (true) { 20 | // 防止心跳因为大量的事件监听器而出现误差 21 | var deviation = BotConfig.heartBeatCycleTime 22 | 23 | if(toolQ.botStatus == BotStatus.online) { 24 | val st = currentTimeMillis() 25 | val time = currentTimeMillis() 26 | 27 | 28 | toolQ.socketClient.clientOutPut?.send(toolQ.threadManager, makeHeartBeatPacket(toolQ.recorder.nextSsoSeq())) 29 | toolQ.center.getMultiTroopInfo(1065759865) 30 | TLog.info("A heartbeat packet was sent!") 31 | for (event in toolQ.eventVector) { 32 | event.heartbeatEvent(time) 33 | } 34 | deviation -= (currentTimeMillis() - st) 35 | } else if(toolQ.botStatus == BotStatus.ruin) break 36 | sleep(deviation.let { 37 | if(it < 0) 1000 else it 38 | } ) 39 | } 40 | } 41 | 42 | private fun makeHeartBeatPacket(seq: Int) : ByteArray { 43 | val builder = ByteBuilder() 44 | builder.writeInt(0xA) 45 | builder.writeByte(0.toByte()) 46 | builder.writeBytesWithSize(byteArrayOf(), 4) 47 | builder.writeByte(0.toByte()) 48 | builder.writeStringWithSize(toolQ.account.user.toString(), 4) 49 | 50 | val headBuilder = ByteBuilder() 51 | headBuilder.writeInt(seq) 52 | headBuilder.writeInt(toolQ.androidQQ.appId()) 53 | headBuilder.writeInt(toolQ.androidQQ.appId()) 54 | headBuilder.writeInt(16777216) 55 | headBuilder.writeInt(0) 56 | headBuilder.writeInt(256) 57 | headBuilder.writeBytesWithSize(byteArrayOf(), 4) 58 | headBuilder.writeStringWithSize("Heartbeat.Alive", 4) 59 | headBuilder.writeBytesWithSize(byteArrayOf(), 4) 60 | headBuilder.writeStringWithSize(Android.androidId, 4) 61 | headBuilder.writeBytesWithSize(Android.getKsid(), 4) 62 | headBuilder.writeStringWithShortSize(toolQ.androidQQ.agreementVersion(), 2) 63 | headBuilder.writeStringWithSize("", 4) 64 | 65 | builder.writeBytesWithSize(headBuilder.toByteArray(), 4) 66 | 67 | builder.writeInt(4) 68 | 69 | builder.writeSize(4) 70 | return builder.toByteArray() 71 | } 72 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/MsgInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot 2 | 3 | data class MsgInfo( 4 | private val shareId : Int, 5 | private val pkgName : String, 6 | 7 | val fromAppid : Int, 8 | val msgUid : Long) { 9 | 10 | var isReply = false 11 | var replyUin = 0L 12 | var replyMsgId = 0 13 | 14 | // AppShare消息信息 15 | val appShare = AppShare(shareId, pkgName) 16 | // 个性diy气泡ID 17 | var bubbleDiyTextId = 0 18 | } 19 | 20 | data class AppShare(val shareId : Int, val pkgName : String) -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQAt.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | class TQAt @ExperimentalUnsignedTypes constructor(val uin : ULong, val hasSpace : Boolean = false) : TQValue() { 4 | var flag : Byte = 0 5 | var strLength : Long = 0; 6 | var startPos : Int = 0 7 | 8 | override fun isAt(): Boolean = true 9 | override fun getType(): String = AT 10 | 11 | @ExperimentalUnsignedTypes 12 | override fun toString(): String = getJoiner().add(getType()) 13 | .also { 14 | it.add("uin=${uin.toString()}") 15 | if(hasSpace) { 16 | it.add("space=$hasSpace") 17 | } 18 | } 19 | .toString() 20 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQCode.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | import com.toolq.helper.bot.tqcodev2.ToolQCodeParser 4 | 5 | @ExperimentalUnsignedTypes 6 | open class TQCode : ArrayList() { 7 | @ExperimentalUnsignedTypes 8 | companion object { 9 | fun parse(str : String) : TQCode { 10 | val ret = TQCode() 11 | val list = ToolQCodeParser.parse(str) 12 | ret.addAll(list) 13 | return ret 14 | } 15 | } 16 | 17 | // 判断TQ码中是否保函图片 18 | fun hasImage() : Boolean { 19 | forEach { 20 | if(it.isImage()) return true 21 | } 22 | return false 23 | } 24 | 25 | fun getImages() : List { 26 | val list = ArrayList() 27 | forEach { 28 | if(it.isImage()) list.add(it.toImage()) 29 | } 30 | return list 31 | } 32 | 33 | fun getText() : String { 34 | val builder = StringBuffer() 35 | forEach { 36 | if(it.isText()) builder.append(it.toText().text) 37 | } 38 | return builder.toString() 39 | } 40 | 41 | override fun toString(): String { 42 | val result = StringBuilder() 43 | this.forEach { 44 | result.append(it.toString()) 45 | } 46 | return result.toString() 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQCommonFace.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | class TQCommonFace(val index : Int, val text : String = "") : TQValue() { 4 | override fun getType(): String = CFACE 5 | override fun isCommonFace(): Boolean = true 6 | 7 | override fun toString(): String = getJoiner() 8 | .add(getType()) 9 | .add("id=$index") 10 | .toString() 11 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQDice.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | import com.toolq.utils.RandomUtil 4 | 5 | class TQDice(val size : Int = RandomUtil.randInt(1 .. 6)) : TQValue() { 6 | 7 | override fun isDice(): Boolean = true 8 | 9 | override fun getType(): String = DICE 10 | 11 | override fun toString(): String = getJoiner() 12 | .add(getType()) 13 | .add("size=$size") 14 | .toString() 15 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQFace.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | class TQFace(val faceId : Int) : TQValue() { 4 | override fun isFace(): Boolean = true 5 | 6 | override fun getType(): String = FACE 7 | 8 | override fun toString(): String = getJoiner() 9 | .add(getType()) 10 | .add("id=$faceId") 11 | .toString() 12 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQFlashImage.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | import com.toolq.utils.* 4 | 5 | // QQ闪图 6 | class TQFlashImage private constructor() : TQValue() { 7 | override fun isFlashImage(): Boolean = true 8 | override fun getType(): String = FLASH_IMAGE 9 | 10 | var md5 : String = "" 11 | var url : String = "" 12 | 13 | constructor(md5 : String) : this() { 14 | if (md5.matches("([a-f\\d]{16,36}|[A-F\\d]{16,36})")) { 15 | this.md5 = md5 16 | this.url = getPicUrl() 17 | } else { 18 | throw RuntimeException("Be sure to give a correct MD5!") 19 | } 20 | } 21 | 22 | // 如果图片为群聊接收的图片则可通过md5向腾讯群聊图片服务器获取该图片 23 | fun getPicUrl() : String = "http://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toUpperCase()}/0?term=2" 24 | 25 | // 如果图片为私聊接收的图片则可通过md5向腾讯私聊图片服务器获取该图片 26 | // fun getC2CUrl() : String = "http://c2cpicdw.qpic.cn/offpic_new/0/0-0-${md5.toUpperCase()}/0?term=2" 27 | // 实验证明即使是私聊产生的聊天图片依然可以使用群聊图片服务器获取该图片,跳过resid的获取 28 | 29 | override fun toString(): String = getJoiner() 30 | .add(getType()) 31 | .add("md5=$md5") 32 | .toString() 33 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQFlashText.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | class TQFlashText(val txt : String, val id : Int = 2000) : TQValue() { 4 | override fun isFlashText(): Boolean = true 5 | 6 | override fun getType(): String = FLASH_TEXT 7 | 8 | override fun toString(): String = getJoiner().add(getType()).add("text=${encodeInput(txt)}").also { 9 | if(id != 2000) it.add("id=$id") 10 | }.toString() 11 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQImage.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | import com.toolq.utils.* 4 | 5 | class TQImage private constructor() : TQValue() { 6 | var md5 : String = "" 7 | var url : String = "" 8 | 9 | constructor(md5 : String) : this() { 10 | if (md5.matches("([a-f\\d]{16,36}|[A-F\\d]{16,36})")) { 11 | this.md5 = md5 12 | this.url = getPicUrl() 13 | } else { 14 | throw RuntimeException("Be sure to give a correct MD5!") 15 | } 16 | } 17 | 18 | // 如果图片为群聊接收的图片则可通过md5向腾讯群聊图片服务器获取该图片 19 | fun getPicUrl() : String = "http://gchat.qpic.cn/gchatpic_new/0/0-0-${md5.toUpperCase()}/0" 20 | 21 | // 如果图片为私聊接收的图片则可通过md5向腾讯私聊图片服务器获取该图片 22 | // fun getC2CUrl() : String = "http://c2cpicdw.qpic.cn/offpic_new/0/0-0-${md5.toUpperCase()}/0?term=2" 23 | // 实验证明即使是私聊产生的聊天图片依然可以使用群聊图片服务器获取该图片,跳过resid的获取 24 | 25 | override fun isImage(): Boolean = true 26 | 27 | override fun getType(): String = IMAGE 28 | 29 | override fun toString(): String = getJoiner() 30 | .add(getType()) 31 | .add("md5=$md5") 32 | .toString() 33 | } 34 | 35 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQJson.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | import com.google.gson.JsonParser 4 | 5 | class TQJson(val context : String) : TQValue() { 6 | init { 7 | try { 8 | JsonParser().parse(context) 9 | } catch (e : Exception) { 10 | throw RuntimeException("This json message is illegal...\n${e.message}") 11 | } 12 | } 13 | 14 | override fun getType(): String = JSON 15 | override fun isJson(): Boolean = true 16 | 17 | override fun toString(): String = getJoiner() 18 | .add(getType()) 19 | .add("content=${encodeInput(context)}") 20 | .toString() 21 | 22 | fun format() : String = JsonParser().parse(context).toString() 23 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQMFace.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | class TQMFace(val faceId : String) : TQValue() { 4 | override fun getType(): String = MFACE 5 | override fun isMFace(): Boolean = true 6 | 7 | val url = "https://i.gtimg.cn/club/item/parcel/item/" + 8 | faceId.substring(0, 2) + 9 | "/" + faceId + "/300x300.png" 10 | 11 | override fun toString(): String = getJoiner() 12 | .add(getType()) 13 | .add("id=${encodeInput(faceId)}") 14 | .toString() 15 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQMora.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | import com.toolq.utils.RandomUtil 4 | 5 | class TQMora(val number : Int = RandomUtil.randInt(0 .. 2)) : TQValue() { 6 | override fun isMora(): Boolean = true 7 | 8 | override fun getType(): String = MORA 9 | 10 | override fun toString(): String = getJoiner() 11 | .add(getType()) 12 | .add("num=$number") 13 | .toString() 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQPoke.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | class TQPoke(val id : Int, val size : Int = 0, val extId : Long = 4294967295L) : TQValue() { 4 | 5 | override fun isPoke(): Boolean = true 6 | 7 | override fun getType(): String = POKE 8 | 9 | override fun toString(): String = getJoiner() 10 | .add(getType()) 11 | .add("id=$id") 12 | .apply { 13 | if(size != 0) add("size=$size") 14 | if(extId != 4294967295) add("extId=$extId") 15 | } 16 | .toString() 17 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQPtt.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | import com.toolq.utils.* 4 | 5 | class TQPtt(md5: String) : TQValue() { 6 | val md5: String 7 | 8 | init { 9 | if(md5.matches("([a-f\\d]{16,36}|[A-F\\d]{16,36})")) 10 | this.md5 = md5 11 | else { 12 | throw RuntimeException("Be sure to give a correct MD5!") 13 | } 14 | } 15 | 16 | override fun isPtt(): Boolean = true 17 | override fun getType(): String = PTT 18 | 19 | // 是否是魔法语音 20 | var magicVoice : Boolean = false 21 | 22 | // 音频时长(发送音频可以提供) 23 | var time : Int = 0 24 | 25 | // 下载链接(发送音频无需提供) 26 | var downUrl = "" 27 | 28 | // uuid 特别标识 29 | // uin 语音上传者 30 | // 仅在接收音频时提供 31 | var uuid : String? = null 32 | var uin : Long? = null 33 | 34 | override fun toString(): String = getJoiner() 35 | .add(getType()) 36 | .add("md5=$md5") 37 | .run { 38 | if(magicVoice) add("magic=$magicVoice") else this 39 | } 40 | .toString() 41 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQShake.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | class TQShake : TQValue() { 4 | override fun isShake(): Boolean = true 5 | override fun getType(): String = SHAKE 6 | 7 | override fun toString(): String = getJoiner().add(getType()).toString() 8 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQText.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | class TQText(val text : String) : TQValue() { 4 | override fun isText() : Boolean = true 5 | 6 | override fun getType(): String = TEXT 7 | 8 | override fun toString(): String = encodeOutput(text) 9 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/TQXml.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode 2 | 3 | class TQXml(val context : String) : TQValue() { 4 | override fun getType(): String = XML 5 | override fun isXml(): Boolean = true 6 | 7 | override fun toString(): String = getJoiner() 8 | .add(getType()) 9 | .add("content=${encodeInput(context)}") 10 | .toString() 11 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/bot/tqcode/exception/TQCodeException.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot.tqcode.exception 2 | 3 | class TQCodeException : RuntimeException { 4 | constructor(th: Throwable?) : super(th) 5 | 6 | constructor(msg: String?) : super(msg) 7 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/logger/LoggerEvent.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.logger 2 | 3 | interface LoggerEvent { 4 | fun debug(message : Any?) 5 | 6 | fun debug(message : Any?, th: Throwable?) 7 | 8 | fun info(message: Any?) 9 | 10 | fun info(message : Any?, th: Throwable?) 11 | 12 | fun error(message: Any?) 13 | 14 | fun error(message : Any?, th: Throwable?) 15 | 16 | fun warn(message: Any?) 17 | 18 | fun warn(message : Any?, th: Throwable?) 19 | 20 | fun fatal(message: Any?) 21 | 22 | fun fatal(message : Any?, th: Throwable?) 23 | 24 | fun trace(message: Any?) 25 | 26 | fun trace(message : Any?, th: Throwable?) 27 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/logger/TLog.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.logger 2 | 3 | object TLog { 4 | var debug : Boolean = false 5 | 6 | private var loggerEvent : LoggerEvent? = null 7 | 8 | fun setEvent(loggerEvent: LoggerEvent) { 9 | TLog.loggerEvent = loggerEvent 10 | } 11 | 12 | fun debug(message: Any?) { 13 | loggerEvent?.debug(message) 14 | } 15 | 16 | fun debug(message: Any?, t: Throwable?) { 17 | loggerEvent?.debug(message, t) 18 | } 19 | 20 | fun error(message: Any?) { 21 | loggerEvent?.error(message) 22 | } 23 | 24 | fun error(message: Any?, t: Throwable?) { 25 | loggerEvent?.error(message, t) 26 | } 27 | 28 | fun warn(message: Any?) { 29 | loggerEvent?.warn(message) 30 | } 31 | 32 | fun warn(message: Any?, t: Throwable?) { 33 | loggerEvent?.warn(message, t) 34 | } 35 | 36 | fun fatal(message: Any?) { 37 | loggerEvent?.fatal(message) 38 | } 39 | 40 | fun fatal(message: Any?, t: Throwable?) { 41 | loggerEvent?.fatal(message, t) 42 | } 43 | 44 | fun info(message: Any?) { 45 | loggerEvent?.info(message) 46 | } 47 | 48 | fun info(message: Any?, t: Throwable?) { 49 | loggerEvent?.info(message, t) 50 | } 51 | 52 | fun trace(message: Any?) { 53 | loggerEvent?.trace(message) 54 | } 55 | 56 | fun trace(message: Any?, t: Throwable?) { 57 | loggerEvent?.trace(message, t) 58 | } 59 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/server/ToolQResponse.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.server 2 | 3 | import com.google.gson.JsonObject 4 | 5 | data class ToolQResponse( 6 | val ret: Int = -200, 7 | val data: JsonObject = JsonObject(), 8 | val msg: String = "" 9 | ) -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/server/ToolQServer.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.server 2 | 3 | import com.toolq.utils.JsonUtil 4 | import com.toolq.utils.OkhttpUtil 5 | 6 | class ToolQServer(private val cmd : String) { 7 | companion object { 8 | fun create(cmd : String) : ToolQServer = ToolQServer(cmd) 9 | 10 | @JvmStatic 11 | private val host : String = "https://luololi.cn/" 12 | } 13 | 14 | private val params : HashMap = HashMap() 15 | 16 | // 超时时间(秒) 17 | private var timeoutMs : Long = 10 18 | 19 | fun addParams(name : String, value : String) = params.put(name, value) 20 | 21 | fun setTimeOutMs(timeout : Long) { 22 | this.timeoutMs = timeout 23 | } 24 | 25 | fun request() : ToolQResponse { 26 | val okhttp = OkhttpUtil( 27 | ssl = true, 28 | proxy = false 29 | ) 30 | okhttp.defaultUserAgent() 31 | okhttp.readTimeOut = timeoutMs 32 | okhttp.connectTimeout = timeoutMs 33 | okhttp.writeTimeout = timeoutMs 34 | val response = okhttp.post("$host?s=$cmd", params) 35 | return if (response != null) { 36 | if(response.code == 200) { 37 | val body = response.body?.string() 38 | val json = JsonUtil.parseJsonObject(body) 39 | ToolQResponse( 40 | json.get("ret").asInt, 41 | json.get("data").asJsonObject, 42 | json.get("msg").asString 43 | ) 44 | } else { 45 | ToolQResponse() 46 | } 47 | } else ToolQResponse() 48 | } 49 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/socket/ConnectException.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.socket 2 | 3 | import com.toolq.resource.TString 4 | import java.lang.RuntimeException 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/9/30 22:07 9 | */ 10 | class ConnectException(val throwable: Throwable) : RuntimeException(TString.socket_connect_fail.get(), throwable) -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/socket/SocketAddress.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.socket 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/9/30 22:27 6 | */ 7 | class SocketAddress(val ip: String, val port: Int) -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/socket/SocketClientException.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.socket 2 | 3 | import com.toolq.resource.TString 4 | import java.lang.RuntimeException 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/10/1 0:27 9 | */ 10 | class SocketClientException(val throwable: Throwable) : RuntimeException(TString.socket_error.get(), throwable) -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/socket/SocketListener.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.socket 2 | 3 | interface SocketListener { 4 | fun onReceive(body: ByteArray?) 5 | fun onHighWayReceive(head: ByteArray?, data: ByteArray?) 6 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/thread/IResultThread.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.thread 2 | 3 | interface IResultThread { 4 | @Throws(Throwable::class) 5 | fun on(): T 6 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/helper/thread/ResultThread.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.thread 2 | 3 | import com.toolq.helper.logger.TLog 4 | import java.util.concurrent.BlockingQueue 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/10/2 0:48 9 | */ 10 | abstract class ResultThread : Thread(), IResultThread { 11 | private var queue: BlockingQueue? = null 12 | override fun run() { 13 | try { 14 | val t = on() 15 | queue!!.add(t) 16 | } catch (e: Throwable) { 17 | TLog.error(e) 18 | e.printStackTrace() 19 | } 20 | } 21 | 22 | fun setQueue(queue: BlockingQueue?) { 23 | this.queue = queue 24 | } 25 | 26 | @Throws(Throwable::class) 27 | abstract override fun on(): T 28 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/AddFriendResult.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | enum class AddFriendResult { 4 | // 成功 5 | Success, 6 | // 错误 7 | Fail, 8 | // 拒绝 9 | CANNOT, 10 | // 等待验证 11 | WaitVerify 12 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/AutoInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class AutoInfo( 4 | val uin : Long, 5 | val groupId : Byte, 6 | val groupName : String, 7 | val remark : String 8 | ) 9 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/FriendAdder.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | interface FriendAdder { 4 | // 加好友验证消息 5 | fun msg() : String 6 | 7 | // 给好友的备注 8 | fun remark() : String? 9 | 10 | // 回答问题 11 | fun answer(question : String) : String 12 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/FriendInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class FriendInfo( 4 | // QQ号码 5 | val uin : Long, 6 | // 昵称 7 | val nick : String, 8 | // 好友分组id 9 | val groupId : Byte, 10 | // 备注 11 | val remark : String, 12 | // 在线状态 13 | val status : Byte, 14 | // 显示在线状态 15 | val extStatus : Long 16 | ) 17 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/GroupInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class GroupInfo( 4 | // 群号 5 | val groupCode : Long, 6 | val groupUin : Long, 7 | // 群类型 8 | val groupFlag : Int, 9 | // 群主 10 | val ownerUin : Long, 11 | // 当前群成员数量 12 | val memberNumber : Long, 13 | // 群昵称 14 | val groupName : String, 15 | // 最大群成员数量 16 | val maxMemberNumber : Long, 17 | // 等级划分表 18 | val rankArray : List = ArrayList() 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/GroupMemberInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class GroupMemberInfo( 4 | // 是否为Bot的好友 5 | val isFriend : Boolean, 6 | val card : String, 7 | val concernType : Int, 8 | val role : Int, 9 | val nick : String, 10 | val location : String, 11 | val age : Int, 12 | val joinTime : Long, 13 | val lastSpeakTime : Long, 14 | val isVip : Boolean, 15 | val isYearVip : Boolean, 16 | val isSuperVip : Boolean, 17 | val isSuperQQ : Boolean, 18 | val vipLevel : Int, 19 | val job : String, 20 | val phone : String, 21 | val level : Int, 22 | val credit : Int, 23 | val isConcerned : Boolean, 24 | val sex : Int, 25 | val specialTitle : String = "", 26 | val specialTitleExpireTime : Long = 0 27 | ) 28 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/Key.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class StringKey(val key : String, val creationTime : Long, val expiredTime : Long) 4 | 5 | data class BytesKey(val key : ByteArray, val creationTime : Long, val expiredTime : Long) { 6 | override fun equals(other: Any?): Boolean { 7 | if (this === other) return true 8 | if (javaClass != other?.javaClass) return false 9 | 10 | other as BytesKey 11 | 12 | if (!key.contentEquals(other.key)) return false 13 | if (creationTime != other.creationTime) return false 14 | if (expiredTime != other.expiredTime) return false 15 | 16 | return true 17 | } 18 | 19 | override fun hashCode(): Int { 20 | var result = key.contentHashCode() 21 | result = 31 * result + creationTime.hashCode() 22 | result = 31 * result + expiredTime.hashCode() 23 | return result 24 | } 25 | } 26 | 27 | data class UserSt( 28 | var webSig : BytesKey, 29 | var sig : BytesKey, 30 | var key : BytesKey 31 | ) -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/MultiTroopInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | /** 4 | * @author luoluo 5 | * @date 2020/10/31 9:51 6 | */ 7 | data class MultiTroopInfo( 8 | /** 9 | * 群名称 10 | */ 11 | var groupName: String? = null, 12 | 13 | /** 14 | * 群号 15 | */ 16 | var groupCode: Long = 0, 17 | var groupUin: Long = 0, 18 | 19 | /** 20 | * 群成员数量 21 | */ 22 | var groupMemberSize: Int = 0, 23 | 24 | /** 25 | * 加群认证类型 26 | */ 27 | var certificationType: Long = 0, 28 | 29 | /** 30 | * 群主QQ 31 | */ 32 | var groupOwnerUin: Long = 0 33 | ) -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/Nick.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class Nick( 4 | val nick : String, 5 | val expiration : Long 6 | ) 7 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/ProtocolMode.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | enum class ProtocolMode { 4 | // 普通安卓协议 5 | Android, 6 | // 苹果协议 7 | Ios, 8 | // 鸿蒙 9 | HmOs, 10 | // 安卓Tim 11 | AndroidTim, 12 | // 电脑协议 13 | Pc, 14 | // 电脑Tim 15 | PcTim 16 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/QPayBalance.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class QPayBalance( 4 | val bargainor_id: String, 5 | val callback_url: String, 6 | val pay_flag: String, 7 | val pay_time: String, 8 | val real_fee: String, 9 | val retcode: String, 10 | val retmsg: String, 11 | val send_flag: String, 12 | val sp_billno: String, 13 | val sp_data: String, 14 | val transaction_id: String 15 | ) -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/QPayHbGate.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | import com.google.gson.JsonObject 4 | 5 | data class QPayHbGate( 6 | val retcode : Int, 7 | val retmsg : String, 8 | val pay_scene : String, 9 | val Pfaflag : String, 10 | val time_stamp : String, 11 | val skey_expire : String, 12 | val trans_seq : String, 13 | val skey : String, 14 | val bargainor_id : String, 15 | val bargainor_true_name : String, 16 | val desc : String, 17 | val total_fee : String, 18 | val purchaser_id : String, 19 | val purchaser_true_name : String, 20 | // 余额 21 | val balance : String, 22 | val creditcard_id : String, 23 | val creditcard_type : String, 24 | val mobile : String, 25 | val user_type : String, 26 | val user_attr : String, 27 | val interf_cache_ver : String, 28 | val pay_types : String, 29 | val transaction_id : String, 30 | val pay_types_seq : String 31 | ) 32 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/QPayHbPack.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class QPayHbPack( 4 | val retcode : Int, 5 | val retmsg : String, 6 | val is_confirm : String, 7 | val token_id : String 8 | ) 9 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/QPayWallet.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class QPayWallet( 4 | val ad_display: String, 5 | val authen_account_type: String, 6 | val authen_channel_state: String, 7 | val authen_channel_state_hex: String, 8 | val balance: String, 9 | val bind_ad_flag: String, 10 | val bind_ad_title: String, 11 | val bind_ad_url: String, 12 | val bind_banks: List, 13 | val charge_limit: String, 14 | val creditcard_id: String, 15 | val creditcard_type: String, 16 | val domain_name: String, 17 | val if_open_charge: String, 18 | val interf_cache_ver: String, 19 | val is_register: String, 20 | val pass_flag: String, 21 | val purchaser_id: String, 22 | val purchaser_true_name: String, 23 | val retcode: String, 24 | val retmsg: String, 25 | val skey: String, 26 | val skey_expire: String, 27 | val time_stamp: String, 28 | val time_window: String, 29 | val trans_seq: String, 30 | val user_attr: String, 31 | val user_info_extend: UserInfoExtend, 32 | val user_type: String 33 | ) 34 | 35 | data class UserInfoExtend( 36 | val creditcard_exp_date: String, 37 | val need_fill: String, 38 | val need_fill_new: String, 39 | val realauth_content: String, 40 | val realauth_url: String 41 | ) 42 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/TroopMemberInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class TroopMemberInfo( 4 | // qq 5 | val uin : Long, 6 | // 性别 7 | val gender : Byte, 8 | // 年龄 9 | val age : Byte, 10 | // 名称 11 | val nick : String, 12 | // 在线状态 13 | val status : Int, 14 | // 工作 15 | val job : String, 16 | // 手机号 17 | val phone : String, 18 | // 邮件 19 | val email : String, 20 | // 介绍 21 | val memo : String, 22 | // 默认备注 23 | val autoRemark : String, 24 | // 群成员等级 25 | val memberLevel : Long, 26 | // 加入时间 27 | val joinTime : Long, 28 | // 最后发言时间 29 | val lastTime : Long, 30 | // 信用等级 31 | val creditLevel : Long, 32 | // 头衔 33 | val specialTitle : String, 34 | // 头衔过期时间 35 | val specialTitleExpireTime : Long, 36 | // 禁言结束时间 37 | val shutUpTimeStamp : Long, 38 | // vip类型 39 | val vipType : Long, 40 | // vip等级 41 | val vipLevel : Long, 42 | // 群荣誉 43 | val groupHonor : List 44 | ) 45 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/TroopUserAppointInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class TroopUserAppointInfo( 4 | val uin : Long, 5 | val groupId : Long, 6 | val glamourLevel : Long = 0, 7 | val job : String = "", 8 | val gender : Byte = 0, 9 | val email : String = "", 10 | val nick : String = "", 11 | val name : String = "", 12 | val groupHonor : ArrayList = ArrayList() 13 | ) 14 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/UserFriendInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class UserFriendInfo( 4 | // qq 5 | val uin : Long, 6 | // 是否是双向好友 7 | val isFriend : Boolean = false, 8 | // 对方添加好友设置 9 | val addFriendSetting : AddFriendSetting = AddFriendSetting.NotAllow, 10 | // 加好友问题 11 | val userQuestion : ArrayList = ArrayList() 12 | ) 13 | 14 | enum class AddFriendSetting { 15 | // 允许任何人添加 0 16 | AllowAnyone, 17 | // 需要验证消息 1 18 | NeedVerify, 19 | // 需要回答正确问题 3 20 | AnswerRightQuestion, 21 | // 回答问题并由我确认 4 22 | AnswerQuestionForMe, 23 | // 不允许任何人 2 24 | NotAllow 25 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/UserInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class UserInfo( 4 | // 目标 5 | val uin: Long = 0, 6 | // 昵称 7 | var nick: String? = "", 8 | // 等级 9 | val level: Int = 0, 10 | // 点赞数量 11 | val voteCount: Int = 0, 12 | // 年龄 13 | val age: Int = 0, 14 | // 生日 15 | val birthday: Int = 0, 16 | // 国家 17 | val country: String? = "", 18 | // 省份 19 | val province: String? = "", 20 | // 城市 21 | val city: String? = null, 22 | // 邮箱 23 | val email: String? = "", 24 | // 照片墙图片数量 25 | val photoCount: Int = 0, 26 | // 未知 27 | val userFlag: Long = 0, 28 | // Face 29 | val face: Int = 0, 30 | // 默认备注 31 | val autoRemark: String? = "", 32 | // 说说摘要 33 | val qzoneFeedsDesc: String? = "", 34 | // 备注 35 | val remark: String? = "", 36 | // 展示名 37 | val showName: String? = "" 38 | ) -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/dataClass/VipInfo.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.dataClass 2 | 3 | data class VipInfo( 4 | // 会员id 5 | val id : Int, 6 | // 会员等级 7 | val level: Int 8 | ) 9 | -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/protocol/friendlist/GetFriendList.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.friendlist 2 | 3 | import com.toolq.helper.jce.JceHelper 4 | import com.toolq.qq.protocol.jce.friendlist.GetFriendListReq 5 | import com.toolq.utils.HexUtil 6 | 7 | class GetFriendList { 8 | companion object { 9 | private val vec0xd50 = HexUtil.hexStringToBytes("08 92 4E C8 B7 2C 01 C8 A8 31 01 C8 DD 49 01 C8 B0 58 01 C8 C7 7A 01") 10 | 11 | fun makeGetFriendPacket(requestId : Int, uin : Long, start : Int, friendCount : Int) : ByteArray { 12 | val req = GetFriendListReq() 13 | req.reqtype = 0 14 | req.ifReflush = 1 15 | req.uin = uin 16 | req.startIndex = start.toShort() 17 | req.getfriendCount = friendCount.toShort() 18 | req.groupid = 0 19 | req.ifGetGroupInfo = 1 20 | req.groupstartIndex = 0 21 | req.getgroupCount = 0 22 | req.ifGetMSFGroup = 0 23 | req.ifShowTermType = 1 24 | req.version = 31 25 | req.eAppType = 0 26 | req.ifGetDOVId = 0 27 | req.vec0xd50Req = vec0xd50 28 | req.vecSnsTypelist = ArrayList() 29 | req.vecSnsTypelist.also { 30 | it.add(13580) 31 | it.add(13581) 32 | it.add(13582) 33 | } 34 | return JceHelper.encodePacket(req, "mqq.IMService.FriendListServiceServantObj", "GetFriendListReq", "FL", requestId) 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/protocol/highway/utils/HighwayUtil.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.highway.utils 2 | 3 | import com.toolq.qq.protocol.protobuf.highway.CSDataHighwayHead 4 | import com.toolq.qq.protocol.protobuf.highway.CSDataHighwayHead.DataHighwayHead 5 | 6 | class HighwayUtil { 7 | companion object { 8 | fun makeReqDataHighwayHead(size: Long, uKey: ByteArray, md5: ByteArray, uin : Long, cmd : String, seq: Int, appid : Long, dataFlag : Int, cmdId : Int, localeId : Int) : CSDataHighwayHead.ReqDataHighwayHead { 9 | val head : CSDataHighwayHead.ReqDataHighwayHead = CSDataHighwayHead.ReqDataHighwayHead() 10 | head.msg_basehead.set( 11 | makeDataHighWayHead(uin, cmd, seq, appid, dataFlag, cmdId, localeId) 12 | ) 13 | head.msg_seghead.set( 14 | makeSegHead(md5, uKey, size) 15 | ) 16 | return head 17 | } 18 | 19 | private fun makeSegHead(md5 : ByteArray, ticket : ByteArray, size : Long) : CSDataHighwayHead.SegHead { 20 | val segHead = CSDataHighwayHead.SegHead() 21 | segHead.bytes_file_md5.set(md5) 22 | segHead.bytes_md5.set(md5) 23 | segHead.uint64_dataoffset.set(0) 24 | segHead.bytes_serviceticket.set(ticket) 25 | segHead.uint64_filesize.set(size) 26 | segHead.uint32_datalength.set(size.toInt()) 27 | return segHead 28 | } 29 | 30 | fun makeDataHighWayHead(uin : Long, cmd : String, seq: Int, appid : Long, dataFlag : Int, cmdId : Int, localeId : Int) : DataHighwayHead { 31 | val head = DataHighwayHead() 32 | head.uint32_version.set(1) 33 | head.bytes_uin.set(uin.toString()) 34 | head.bytes_command.set(cmd) 35 | head.uint32_seq.set(seq) 36 | head.uint64_appid.set(appid) 37 | head.uint32_dataflag.set(dataFlag) 38 | head.uint32_command_id.set(cmdId) 39 | head.locale_id.set(localeId) 40 | return head 41 | } 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/qq/protocol/pay/HbType.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.qq.protocol.pay 2 | 3 | enum class HbType(val busId: Int , 4 | val channel : Int) { 5 | /** 6 | * 普通红包 7 | */ 8 | Common(1, 1), 9 | 10 | /** 11 | * 拼手气红包 12 | */ 13 | Lucky(2, 1), 14 | 15 | /** 16 | * 接龙红包 17 | */ 18 | Proverb(2, 524288), 19 | 20 | /** 21 | * 专属普通 22 | */ 23 | ExclusiveComm(1, 1024), 24 | 25 | /** 26 | * 专属拼手气 27 | */ 28 | ExclusiveLucky(2, 1024), 29 | 30 | /** 31 | * 口令红包 32 | */ 33 | Password(2, 32), 34 | 35 | /** 36 | * 语音红包 37 | */ 38 | Voice(2, 65536) 39 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/resource/TString.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.resource 2 | 3 | import com.toolq.BotConfig 4 | 5 | /** 6 | * @author luoluo 7 | * @date 2020/9/30 22:11 8 | */ 9 | object TString { 10 | @JvmField 11 | val socket_connect_fail = Couple("Socket连接失败!", "Socket connection failed!") 12 | @JvmField 13 | val socket_error = Couple("Socket出现错误", "Socket error") 14 | @JvmField 15 | val socket_connect = Couple("正在连接%s:%s...", "Connect %s:%s...") 16 | @JvmField 17 | val slider_get_ticket = Couple("请滑动滑块", "Sliding slider") 18 | @JvmField 19 | val sms_get_code = Couple("获取验证码", "Get verification code") 20 | var sms_get_code_button = Couple("获取", "Get") 21 | @JvmField 22 | val bot_account_error = Couple("账号密码不合法", "Invalid account password") 23 | val bot_server_error = Couple("无法获取机器人服务器", "Unable to get the robot server") 24 | @JvmField 25 | val jce_packet_type_error = Couple("该对象不是继承Jce类。", "The object does not inherit the Jce class.") 26 | val acgLeague = Couple("二次元编程社团", "https://blog.acgp.club/index.php/archives/42/") 27 | val acgLeagueAgreement = Couple("二次元编程社团规则", "ToolQ为二次元编程社团的内部项目虽然属于二次元编程社团但仅为首开发者拥有,代码贡献者仅仅拥有对部分代码的改写权!") 28 | @JvmField 29 | val bot_not_found = Couple("Bot在ToolQManager中不存在", "Bot does not exist in Tool Q Manager") 30 | 31 | /** 32 | * 字符串对集 33 | */ 34 | class Couple(val chinese: String, val english: String) { 35 | fun get(): String { 36 | return if (BotConfig.isChinese) chinese else english 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/utils/BotUtils.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.utils 2 | 3 | import kotlin.random.Random 4 | 5 | object BotUtils { 6 | fun regex(regex: String, text: String): String? { 7 | val r = Regex(regex) 8 | val find = r.find(text) 9 | return find?.value 10 | } 11 | 12 | fun regex(first: String, last: String , text: String): String? { 13 | val regex = "(?<=$first).*?(?=$last)" 14 | return regex(regex, text) 15 | } 16 | 17 | fun OkhttpUtil.setBotCookie(uin : Long, skey : String, pskey : String, p4token : String = "") { 18 | header("cookie", "uin=o$uin") 19 | header("cookie", "skey=$skey") 20 | header("cookie", "p_uin=o$uin") 21 | header("cookie", "p_skey=$pskey") 22 | header("cookie", "p4token=$p4token") 23 | header("cookie", "qq_locale_id=2052") 24 | } 25 | 26 | fun String.toBkn() : Long = QQUtil.GetBkn(this) 27 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/utils/CacheUtil.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.utils 2 | 3 | import com.toolq.BotConfig 4 | import com.toolq.helper.logger.TLog 5 | import com.toolq.qq.protocol.protobuf.message.msg_comm 6 | import java.io.File 7 | 8 | object CacheUtil { 9 | fun saveUpImage(data : ByteArray) { 10 | val path = (BotConfig.getDataPath() + "/cache/upImage").toFile() 11 | if(!path.exists()) path.mkdirs() 12 | val md5 = data.toMd5Byte().toHex() 13 | val name = "$md5.jpg" 14 | if(data.size <= 20 * 1024 * 1024) 15 | FileUtil.saveFile("${path.absolutePath}/$name", data) 16 | } 17 | 18 | fun readUpImage(md5 : ByteArray) : ByteArray? { 19 | val file = (BotConfig.getDataPath() + "/cache/upImage/${md5.toHex()}.jpg").toFile() 20 | if(file.exists()) { 21 | return FileUtil.readFile(file).apply { 22 | file.delete() 23 | } 24 | } 25 | return null 26 | } 27 | 28 | fun saveTroopMsg(msg: msg_comm.Msg) { 29 | val msgSeq = msg.msg_head.get().msg_seq.get() 30 | val groupInfo = msg.msg_head.get().group_info.get() 31 | val groupCode = groupInfo.group_code.get() 32 | val path = (BotConfig.getDataPath() + "/cache/msg/group/$groupCode/").toFile() 33 | if(!path.exists()) path.mkdirs() 34 | val name = "$msgSeq.bin" 35 | FileUtil.saveFile("${path.absolutePath}/$name", GZipUtil.compress(msg.toByteArray())!!) 36 | } 37 | 38 | fun saveFriendMsg(msg: msg_comm.Msg) { 39 | val msgSeq = msg.msg_head.get().msg_seq.get() 40 | val path = (BotConfig.getDataPath() + "/cache/msg/friend/${msg.msg_head.get().from_uin.get()}/").toFile() 41 | if(!path.exists()) path.mkdirs() 42 | val name = "$msgSeq.bin" 43 | FileUtil.saveFile("${path.absolutePath}/$name", GZipUtil.compress(msg.toByteArray())!!) 44 | } 45 | 46 | fun readTroopMsg(groupId : Long, seq : Int) : msg_comm.Msg { 47 | val path = (BotConfig.getDataPath() + "/cache/msg/group/$groupId/").toFile() 48 | if(!path.exists()) path.mkdirs() 49 | val ret = msg_comm.Msg() 50 | try { 51 | val file = File("${path.absolutePath}/$seq.bin") 52 | val bytes = GZipUtil.uncompress(FileUtil.readFile(file)) 53 | ret.parse(bytes) 54 | } catch (e : Exception) { 55 | TLog.info("无法读取缓存的群聊聊天记录") 56 | } 57 | return ret 58 | } 59 | 60 | fun readFriendMsg(uin : Long, seq : Int) : msg_comm.Msg { 61 | val path = (BotConfig.getDataPath() + "/cache/msg/friend/$uin/").toFile() 62 | if(!path.exists()) path.mkdirs() 63 | val ret = msg_comm.Msg() 64 | try { 65 | val file = File("${path.absolutePath}/$seq.bin") 66 | val bytes = GZipUtil.uncompress(FileUtil.readFile(file)) 67 | ret.parse(bytes) 68 | } catch (e : Exception) { 69 | TLog.info("无法读取缓存的好友聊天记录") 70 | } 71 | return ret 72 | } 73 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/utils/DesECBUtil.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.utils 2 | 3 | import java.nio.ByteBuffer 4 | import java.security.Key 5 | import javax.crypto.Cipher 6 | 7 | import javax.crypto.spec.SecretKeySpec 8 | 9 | 10 | 11 | 12 | object DesECBUtil { 13 | /** 14 | * 加密数据 15 | * @param encryptString 注意:这里的数据长度只能为8的倍数 16 | * @param encryptKey 17 | * @return 18 | * @throws Exception 19 | */ 20 | @Throws(Exception::class) 21 | fun encryptDES(encryptString: String, encryptKey: String): String { 22 | val key = SecretKeySpec(getKey(encryptKey), "DES") 23 | val cipher = Cipher.getInstance("DES/ECB/NoPadding") 24 | cipher.init(Cipher.ENCRYPT_MODE, key) 25 | val encryptedData = cipher.doFinal(setStuff(encryptString.toByteArray())) 26 | return encryptedData.toHex() 27 | } 28 | 29 | /** 30 | * 自定义一个key 31 | * @param 32 | */ 33 | private fun getKey(keyRule: String): ByteArray { 34 | val key: Key? 35 | val keyByte = keyRule.toByteArray() 36 | // 创建一个空的八位数组,默认情况下为0 37 | val byteTemp = ByteArray(8) 38 | // 将用户指定的规则转换成八位数组 39 | var i = 0 40 | while (i < byteTemp.size && i < keyByte.size) { 41 | byteTemp[i] = keyByte[i] 42 | i++ 43 | } 44 | key = SecretKeySpec(byteTemp, "DES") 45 | return key.getEncoded() 46 | } 47 | 48 | /*** 49 | * 解密数据 50 | * @param decryptString 51 | * @param decryptKey 52 | * @return 53 | * @throws Exception 54 | */ 55 | @Throws(Exception::class) 56 | fun decryptDES(decryptString: String, decryptKey: String): String { 57 | val key = SecretKeySpec(getKey(decryptKey), "DES") 58 | val cipher = Cipher.getInstance("DES/ECB/NoPadding") 59 | cipher.init(Cipher.DECRYPT_MODE, key) 60 | val decryptedData = cipher.doFinal(decryptString.hexToBs()) 61 | return String(decryptedData) 62 | } 63 | 64 | //填充数据 65 | private fun setStuff(msg: ByteArray): ByteArray { 66 | val i = msg.size % 8 67 | return if (i == 0) { 68 | msg 69 | } else { 70 | val a = 8 - i 71 | val sb = StringBuffer() 72 | for (s in 0 until a) { 73 | sb.append(" ") 74 | } 75 | var data = sb.toString().toByteArray() 76 | data = ByteBuffer.allocate(msg.size + data.size).put(msg).put(data).array() 77 | data 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/utils/FileUtil.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.utils 2 | 3 | import com.toolq.helper.logger.TLog.warn 4 | import kotlin.Throws 5 | import java.io.* 6 | 7 | /** 8 | * @author luoluo 9 | * @date 2020/10/3 21:50 10 | */ 11 | object FileUtil { 12 | @Throws(IOException::class) 13 | fun readFile(f: File): ByteArray { 14 | return readFile(f.absolutePath) 15 | } 16 | 17 | @Throws(IOException::class) 18 | fun readFile(filename: String?): ByteArray { 19 | return readFileBytes(filename) 20 | } 21 | 22 | @Throws(IOException::class) 23 | fun readFileString(f: File): String { 24 | return String(readFile(f)) 25 | } 26 | 27 | @JvmStatic 28 | @Throws(IOException::class) 29 | fun readFileString(path: String?): String { 30 | return String(readFileBytes(path)) 31 | } 32 | 33 | @Throws(IOException::class) 34 | fun readFileBytes(path: String?): ByteArray { 35 | return readFileBytes(FileInputStream(path)) 36 | } 37 | 38 | @Throws(IOException::class) 39 | fun readFileBytes(inputStream: InputStream): ByteArray { 40 | val byteArrayOutputStream = ByteArrayOutputStream() 41 | while (true) { 42 | val read = inputStream.read() 43 | if (read == -1) { 44 | inputStream.close() 45 | val byteArray = byteArrayOutputStream.toByteArray() 46 | byteArrayOutputStream.close() 47 | return byteArray 48 | } 49 | byteArrayOutputStream.write(read) 50 | } 51 | } 52 | 53 | @Throws(IOException::class) 54 | fun saveFile(path: String, content: String) { 55 | saveFile(path, content.toByteArray()) 56 | } 57 | 58 | @Throws(IOException::class) 59 | fun saveFile(path: String, content: ByteArray) { 60 | val file = File(path) 61 | if (!file.exists()) { 62 | if (!file.createNewFile()) { 63 | warn(String.format("【%s】文件创建失败!", path)) 64 | return 65 | } 66 | } 67 | val fileOutputStream = FileOutputStream(file) 68 | fileOutputStream.write(content) 69 | fileOutputStream.close() 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/utils/GZipUtil.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.utils 2 | 3 | import java.io.ByteArrayInputStream 4 | import java.io.ByteArrayOutputStream 5 | import java.util.zip.GZIPInputStream 6 | import java.util.zip.GZIPOutputStream 7 | 8 | 9 | class GZipUtil { 10 | companion object { 11 | fun compress(bytes: ByteArray?): ByteArray? { 12 | if (bytes == null || bytes.isEmpty()) { 13 | return null 14 | } 15 | val out = ByteArrayOutputStream() 16 | val gzip: GZIPOutputStream 17 | try { 18 | gzip = GZIPOutputStream(out) 19 | gzip.write(bytes) 20 | gzip.close() 21 | } catch (e: Exception) { 22 | e.printStackTrace() 23 | } 24 | return out.toByteArray() 25 | } 26 | 27 | fun uncompress(bytes: ByteArray?): ByteArray? { 28 | if (bytes == null || bytes.isEmpty()) { 29 | return null 30 | } 31 | val out = ByteArrayOutputStream() 32 | val `in` = ByteArrayInputStream(bytes) 33 | try { 34 | val ungzip = GZIPInputStream(`in`) 35 | val buffer = ByteArray(256) 36 | var n: Int 37 | while (ungzip.read(buffer).also { n = it } >= 0) { 38 | out.write(buffer, 0, n) 39 | } 40 | } catch (e: Exception) { 41 | e.printStackTrace() 42 | } 43 | return out.toByteArray() 44 | } 45 | 46 | 47 | } 48 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/utils/ImageUtil.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.utils 2 | 3 | class ImageUtil { 4 | companion object { 5 | fun ByteArray?.isGif() : Boolean { 6 | this?.let { 7 | if(it.size > 6) return it[0].toInt() == 0x47 8 | && it[1].toInt() == 0x49 9 | && it[2].toInt() == 0x46 10 | && it[3].toInt() == 0x38 11 | && (it[4].toInt() == 0x39 || it[4].toInt() == 0x37 ) 12 | && it[5].toInt() == 0x61 13 | // GIF文件版本号: 14 | // 87a - 1987年5月       15 | // 89a - 1989年7月 16 | } 17 | return false 18 | } 19 | 20 | fun ByteArray?.isJpeg() : Boolean { 21 | this?.let { 22 | if(it.isNotEmpty()) { 23 | return it[0].toInt() + it[1].toInt() == 0xff + 0xd8 && 24 | it[6] == 'J'.toByte() && 25 | it[7] == 'F'.toByte() && 26 | it[8] == 'I'.toByte() && 27 | it[6] == 'F'.toByte() 28 | } 29 | } 30 | return false 31 | } 32 | 33 | fun ByteArray?.isPng() : Boolean { 34 | this?.let { 35 | if(it.isNotEmpty()) { 36 | return it[0].toInt() == 0x89 && 37 | it[1] == 'P'.toByte() && 38 | it[2] == 'N'.toByte() && 39 | it[3] == 'G'.toByte() && 40 | it[4].toInt() == 0x0d && 41 | it[5].toInt() == 0x0a && 42 | it[6].toInt() == 0x1a && 43 | it[7].toInt() == 0x0a 44 | } 45 | } 46 | return false 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/utils/RandomUtil.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.utils 2 | 3 | import java.lang.StringBuilder 4 | import java.util.* 5 | 6 | /** 7 | * @author luoluo 8 | * @date 2020/10/4 1:17 9 | */ 10 | object RandomUtil { 11 | @JvmStatic 12 | fun getRandomString(length: Int): String { 13 | val str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" 14 | val random = Random() 15 | val sb = StringBuilder() 16 | for (i in 0 until length) { 17 | val number = random.nextInt(62) 18 | sb.append(str[number]) 19 | } 20 | return sb.toString() 21 | } 22 | 23 | @JvmStatic 24 | fun randInt(intRange: IntRange) = randInt(intRange.first, intRange.last) 25 | 26 | @JvmStatic 27 | fun randInt(min: Int, max: Int): Int { 28 | return Random().nextInt(max - min) + min 29 | } 30 | 31 | @JvmStatic 32 | fun randomMd5(): String { 33 | return getRandomString(16).toLowerCase() 34 | } 35 | 36 | fun randInt(intRange: IntProgression): Int = randInt(intRange.first, intRange.last) 37 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/utils/SocketUtil.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.utils 2 | 3 | import com.toolq.BotConfig 4 | import java.lang.Exception 5 | import java.net.* 6 | 7 | /** 8 | * @author luoluo 9 | * @date 2020/9/30 22:02 10 | */ 11 | object SocketUtil { 12 | /** 13 | * @author luoluo 14 | * @date 2020/9/30 15 | * @param host 地址 16 | * @param port 端口 17 | * @return boolean 18 | * @desc 检测Socket服务是否可以连接成功! 19 | */ 20 | fun isRunning(host: String, port: Int): Boolean { 21 | var sClient: Socket? = null 22 | try { 23 | val saAdd: SocketAddress = InetSocketAddress(host.trim { it <= ' ' }, port) 24 | sClient = Socket() 25 | sClient.connect(saAdd, BotConfig.defaultPacketWaitTime.toInt()) 26 | return true 27 | } catch (e: Exception) { 28 | } finally { 29 | try { 30 | sClient?.close() 31 | } catch (ignore: Throwable) { } 32 | } 33 | return false 34 | } 35 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/kotlin/com/toolq/utils/XmlUtil.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.utils 2 | 3 | import java.util.* 4 | 5 | class XmlUtil { 6 | companion object { 7 | fun serviceId(xml : String) : Int { 8 | val noSpace = xml.replace(" ", "") 9 | val lowCase = noSpace.toLowerCase() 10 | val splitStart = lowCase.split("serviceid=\"")[1] 11 | val splitEnd = splitStart.split("\"")[0] 12 | return splitEnd.trim().toInt() 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /ToolQ-Core/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ToolQ-Windows/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") version "1.4.30" 3 | id("com.github.johnrengelman.shadow") version "6.1.0" // 全量打包插件 4 | } 5 | 6 | group = "com.toolq" 7 | version = "1.0-SNAPSHOT" 8 | 9 | dependencies { 10 | val ktorVersion = "1.5.1" 11 | 12 | implementation(project(":ToolQ-Core")) 13 | 14 | implementation("com.google.code.gson", "gson", "2.8.6") 15 | implementation("com.squareup.okhttp3", "okhttp", "4.9.0") 16 | 17 | implementation( 18 | fileTree( 19 | mapOf( 20 | "dir" to "libs", 21 | "include" to listOf("*.jar") 22 | ) 23 | ) 24 | ) 25 | } 26 | 27 | tasks.jar { 28 | manifest { 29 | attributes( 30 | mapOf( 31 | "Main-Class" to "test.Main" 32 | ) 33 | ) 34 | } 35 | } 36 | 37 | tasks.build { 38 | // build时执行shadowJar任务 39 | dependsOn(tasks.shadowJar) 40 | } 41 | 42 | tasks.withType { 43 | options.encoding = "UTF-8" 44 | } 45 | 46 | tasks.withType { 47 | kotlinOptions.jvmTarget = "1.8" 48 | } 49 | -------------------------------------------------------------------------------- /ToolQ-Windows/libs/org.eclipse.swt.win32.win32.x86_64-4.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d8kzdzt/ToolQ/4f7358fab8afff8cdeb8bf37529bae78105c0b3d/ToolQ-Windows/libs/org.eclipse.swt.win32.win32.x86_64-4.3.jar -------------------------------------------------------------------------------- /ToolQ-Windows/src/main/kotlin/com/toolq/helper/bot/IBotFunctionWindow.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.helper.bot 2 | 3 | import com.toolq.BotConfig 4 | import com.toolq.ToolQ 5 | import com.toolq.helper.logger.TLog 6 | import com.toolq.utils.SwtUtil 7 | import org.eclipse.swt.widgets.Shell 8 | 9 | class IBotFunctionWindow : BotConfig.IBotFunction() { 10 | override fun GetSMSCode(toolQ: ToolQ, bot: Long, phone: String?, msg: String?, dt104: ByteArray?, dt174: ByteArray?): String? { 11 | var code : String? = null 12 | SwtUtil.sms_code("手机号:%s\n 需要验证码验证登录,是否获取验证码?\n本次验证过后,只要不变更ToolQ版本,一般不需要重新验证!\nToolQ不会以任何形式收集您的个人信息!".format(phone), 13 | object : SwtUtil.DeviceLockEvent() { 14 | override fun getSMSCode() : Boolean = submitAVerificationCodeRequest(toolQ, dt104, dt174) 15 | override fun checkCode(shell: Shell, sCode: String?) { 16 | if(!sCode.isNullOrEmpty()) { 17 | code = sCode 18 | if(code == null) { 19 | TLog.warn("Kotlin与Java交互出现问题!") 20 | } else shell.close() 21 | } else TLog.warn("输入的验证码为空或Null") 22 | } 23 | }) 24 | return code 25 | } 26 | 27 | // windows 专用ticket获取 28 | override fun ticket(url: String, iqq: IQQ?): String? { 29 | return SwtUtil.ticket(url) 30 | } 31 | } -------------------------------------------------------------------------------- /ToolQ-Windows/src/main/kotlin/com/toolq/win/GUIUtil.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.win 2 | 3 | import com.toolq.BotConfig 4 | import com.toolq.helper.logger.TLog 5 | import org.eclipse.swt.SWT 6 | import org.eclipse.swt.widgets.Display 7 | import org.eclipse.swt.widgets.MessageBox 8 | import org.eclipse.swt.widgets.Shell 9 | import kotlin.system.exitProcess 10 | 11 | class GUIUtil { 12 | companion object { 13 | // 不可挽救性质的提示退出 14 | fun irretrievableReminder(title: String, msg: String) { 15 | val display = Display() 16 | val shell = Shell(display, SWT.TITLE) 17 | val messageBox = MessageBox(shell, SWT.ICON_QUESTION or SWT.OK) 18 | messageBox.text = title 19 | messageBox.message = msg 20 | val result = messageBox.open() 21 | shell.packOpen() 22 | while (!shell.isDisposed) { 23 | if (!display.readAndDispatch()) { 24 | display.sleep() 25 | if(result != BotConfig.sdkVersion shl 13478) { 26 | TLog.error(title, RuntimeException(msg)) 27 | exitProcess(1) 28 | } 29 | } 30 | } 31 | display.dispose() 32 | } 33 | 34 | @JvmStatic 35 | fun Shell.packOpen() { 36 | pack() 37 | open() 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /ToolQ-Windows/src/main/kotlin/com/toolq/win/InitManager.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.win 2 | 3 | import com.toolq.BotConfig 4 | import com.toolq.helper.bot.IBotFunctionWindow 5 | import com.toolq.utils.toFile 6 | import com.toolq.win.GUIUtil.Companion.irretrievableReminder 7 | 8 | class InitManager { 9 | companion object { 10 | fun init(path : String) { 11 | BotConfig.setOs("win") 12 | BotConfig.init(path.toFile().let { 13 | if(!it.exists()) { 14 | if(!it.mkdirs()) irretrievableReminder("创建数据文件路径失败", "无法创建文件夹") 15 | } else if(it.isFile) { 16 | if(!it.delete() || !it.mkdirs() ) { 17 | irretrievableReminder("创建数据文件夹失败", "无法创建") 18 | } 19 | } 20 | if(!it.canExecute() || !it.canRead() || !it.canWrite()) { 21 | irretrievableReminder("数据文件夹权限错误", "无读写执行权限") 22 | } 23 | it.absolutePath 24 | }) 25 | BotConfig.setAllowFriendMessage(true) 26 | BotConfig.IBotFunction = IBotFunctionWindow() 27 | } 28 | 29 | 30 | } 31 | 32 | 33 | } -------------------------------------------------------------------------------- /ToolQ-Windows/src/main/kotlin/com/toolq/win/RabbitMain.kt: -------------------------------------------------------------------------------- 1 | package com.toolq.win 2 | 3 | import com.toolq.helper.logger.TLog 4 | import java.io.File 5 | 6 | class RabbitMain { 7 | private fun gui() { 8 | 9 | } 10 | 11 | companion object { 12 | // 控制台模式 13 | const val cmdMode = false 14 | 15 | @JvmStatic 16 | fun main(args: Array) { 17 | TLog.debug = true 18 | // args[0] 数据文件路径 19 | InitManager.init(args[0]) 20 | if(cmdMode) { 21 | 22 | } else RabbitMain().gui() 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /ToolQ-Windows/src/main/kotlin/test/Config.kt: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | /** 4 | * @author 真心 5 | * @date 2021/1/29 21:02 6 | * @email qgzhenxin@qq.com 7 | * @description: 配置文件 8 | */ 9 | data class Config( 10 | val password: String, 11 | val qq: Long, 12 | val port: Int, 13 | val payWord : String 14 | ) 15 | -------------------------------------------------------------------------------- /ToolQ-Windows/src/main/kotlin/test/Main.kt: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import com.google.gson.Gson 4 | import com.toolq.ToolQManager 5 | import com.toolq.helper.logger.LoggerEvent 6 | import com.toolq.helper.logger.TLog 7 | import com.toolq.qq.protocol.pay.HbType 8 | import com.toolq.qq.protocol.pay.LuckyPacket 9 | import com.toolq.utils.* 10 | import com.toolq.win.RabbitMain 11 | import okio.ByteString.Companion.decodeHex 12 | 13 | 14 | @ExperimentalUnsignedTypes 15 | object Main { 16 | lateinit var config: Config 17 | 18 | @Throws(Exception::class) 19 | @JvmStatic 20 | fun main(args: Array) { 21 | RabbitMain.main( 22 | arrayOf( 23 | "data" 24 | ) 25 | ) 26 | 27 | config = Gson().fromJson( 28 | FileUtil.readFileString("config.dev.json"), 29 | Config::class.java 30 | ) 31 | 32 | TLog.setEvent(object : LoggerEvent { 33 | override fun debug(message: Any?) { 34 | println(message) 35 | } 36 | 37 | override fun debug(message: Any?, th: Throwable?) { 38 | println("$message ==> $th") 39 | } 40 | 41 | override fun info(message: Any?) { 42 | println(message) 43 | } 44 | 45 | override fun info(message: Any?, th: Throwable?) { 46 | println("$message ==> $th") 47 | } 48 | 49 | override fun error(message: Any?) { 50 | println(message) 51 | } 52 | 53 | override fun error(message: Any?, th: Throwable?) { 54 | println("$message ==> $th") 55 | } 56 | 57 | override fun warn(message: Any?) { 58 | println(message) 59 | } 60 | 61 | override fun warn(message: Any?, th: Throwable?) { 62 | println("$message ==> $th") 63 | } 64 | 65 | override fun fatal(message: Any?) { 66 | println(message) 67 | } 68 | 69 | override fun fatal(message: Any?, th: Throwable?) { 70 | println("$message ==> $th") 71 | } 72 | 73 | override fun trace(message: Any?) { 74 | println(message) 75 | } 76 | 77 | override fun trace(message: Any?, th: Throwable?) { 78 | println("$message ==> $th") 79 | } 80 | 81 | }) 82 | 83 | test() 84 | 85 | } 86 | 87 | private fun test() { 88 | val testTroopId = 1038106737L 89 | 90 | TLog.info("Start running...") 91 | val toolQ = ToolQManager.addBot( 92 | config.qq, 93 | config.password, 94 | isHd = false) 95 | toolQ.addBotEvent(HandleMsg(config.qq)) 96 | 97 | toolQ.setPayPassword(config.payWord) 98 | 99 | println("登录状态:" + toolQ.login()) 100 | println(toolQ.botStatus) 101 | println("=====================================") 102 | } 103 | } 104 | 105 | -------------------------------------------------------------------------------- /ToolQ-Windows/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | group = "com.toolq" 2 | version = "1.0.0-SNAPSHOT" 3 | 4 | subprojects { 5 | repositories { 6 | mavenLocal() 7 | maven { 8 | name = "AliyunCentral" 9 | setUrl("https://maven.aliyun.com/repository/central/") 10 | } 11 | maven { 12 | name = "AliyunJCenter" 13 | setUrl("https://maven.aliyun.com/repository/public/") 14 | } 15 | } 16 | 17 | tasks.withType(JavaCompile) { 18 | options.encoding = "UTF-8" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /config.example.json: -------------------------------------------------------------------------------- 1 | // 请复制一份重命名为config.dev.json使用 2 | { 3 | "qq": 10001, 4 | "password": "10001", 5 | "payWord" : "123456", 6 | // 支付密码 7 | "port": 8887 8 | } 9 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "ToolQ" 2 | 3 | include("ToolQ-Core") 4 | include("ToolQ-Windows") --------------------------------------------------------------------------------