Skip to content

Commit 5a75704

Browse files
authored
api: update_signature (#24)
* WIP: build_set_signature_packet * update signature
1 parent b83b47c commit 5a75704

File tree

6 files changed

+116
-0
lines changed

6 files changed

+116
-0
lines changed

rq-engine/src/command/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub mod online_push;
1111
pub mod pb_message_svc;
1212
pub mod profile_service;
1313
pub mod reg_prxy_svc;
14+
pub mod signature;
1415
pub mod stat_svc;
1516
pub mod summary_card;
1617
pub mod visitor_svc;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use crate::command::common::PbToBytes;
2+
use crate::pb::sig_act;
3+
use crate::protocol::packet::Packet;
4+
5+
impl super::super::super::Engine {
6+
pub fn build_update_signature_packet(&self, signature: String) -> Packet {
7+
let req = sig_act::ReqBody {
8+
cmd: Some(2),
9+
seq: Some(chrono::Utc::now().timestamp_millis() as u64),
10+
plf: Some(sig_act::Platform {
11+
platform: Some(109),
12+
osver: Some(self.transport.device.version.release.to_owned()),
13+
mqqver: Some(self.transport.version.sort_version_name.into()),
14+
}),
15+
auth_req: Some(sig_act::SigauthReq {
16+
uin_disable: Some(self.uin() as u64),
17+
itemid: Some(0),
18+
len: Some(signature.len() as i32 + 27),
19+
data: Some({
20+
let mut buf = vec![0x3, signature.as_bytes().len() as u8 + 1, 0x20];
21+
buf.extend(signature.into_bytes());
22+
buf.extend([
23+
0x91, 0x04, 0x00, 0x00, 0x00, 0x00, 0x92, 0x04, 0x00, 0x00, 0x00, 0x00,
24+
0xA2, 0x04, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x04, 0x00, 0x00, 0x00, 0x00,
25+
]);
26+
buf
27+
}),
28+
fontid: Some(0),
29+
}),
30+
source: Some(1),
31+
..Default::default()
32+
};
33+
self.uni_packet("Signature.auth", req.to_bytes())
34+
}
35+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod builder;

rq-engine/src/pb/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ pub mod profilecard {
3838
include!(concat!(env!("OUT_DIR"), "/profilecard.rs"));
3939
}
4040

41+
pub mod sig_act {
42+
include!(concat!(env!("OUT_DIR"), "/sig_act.rs"));
43+
}
44+
4145
pub mod structmsg {
4246
include!(concat!(env!("OUT_DIR"), "/structmsg.rs"));
4347
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
syntax = "proto2";
2+
package sig_act;
3+
4+
message Platform {
5+
optional int64 platform = 1;
6+
optional string osver = 2;
7+
optional string mqqver = 3;
8+
}
9+
10+
message ReqBody {
11+
optional uint32 cmd = 1;
12+
optional uint64 seq = 2;
13+
optional Platform plf = 3;
14+
optional SigactReq req = 4;
15+
optional SigauthReq authReq = 5;
16+
optional uint32 source = 6;
17+
}
18+
19+
message RspBody {
20+
optional int32 ret = 1;
21+
optional string desc = 2;
22+
optional uint32 cmd = 3;
23+
optional uint64 seq = 4;
24+
optional SigactRsp rsp = 5;
25+
optional SigauthRsp authRsp = 6;
26+
}
27+
28+
message SigactReq {
29+
optional uint64 uinDisable = 1;
30+
optional int32 actid = 2;
31+
optional int32 acttype = 3;
32+
}
33+
34+
message SigactRsp {
35+
optional uint64 uin = 1;
36+
optional uint32 rank = 2;
37+
}
38+
39+
message SigauthReq {
40+
optional uint64 uinDisable = 1;
41+
optional int32 itemid = 2;
42+
optional int32 len = 3;
43+
optional bytes data = 4;
44+
optional int32 fontid = 5;
45+
}
46+
47+
message SigauthRsp {
48+
optional bytes result = 1;
49+
optional string url = 2;
50+
optional TipsInfo tipsInfo = 3;
51+
optional int32 authfailedAppid = 4;
52+
53+
message TipsInfo {
54+
optional bool valid = 1;
55+
optional int32 ret = 2;
56+
optional uint32 type = 3;
57+
optional string titleWording = 4;
58+
optional string wording = 5;
59+
optional string rightBtnWording = 6;
60+
optional string leftBtnWording = 7;
61+
optional string vipType = 8;
62+
optional uint32 vipMonth = 9;
63+
optional string url = 10;
64+
}
65+
}

rs-qq/src/client/api.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ impl super::Client {
184184

185185
/// API
186186
impl super::Client {
187+
pub async fn update_signature(&self, signature: String) -> RQResult<()> {
188+
let req = self
189+
.engine
190+
.read()
191+
.await
192+
.build_update_signature_packet(signature);
193+
let _ = self.send_and_wait(req).await?;
194+
Ok(())
195+
}
196+
187197
/// 修改个人资料
188198
pub async fn update_profile_detail(&self, profile: ProfileDetailUpdate) -> RQResult<()> {
189199
let req = self

0 commit comments

Comments
 (0)