Skip to content

Commit

Permalink
feat: 自动检测签名服务器版本
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Dec 28, 2023
1 parent 6c1727d commit 5681dc3
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 23 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ services:
image: xzhouqd/qsign:core-1.1.9
restart: unless-stopped
environment:
# 需要与下方的 SIGN_VER 同步
# 配置请参考 https://hub.docker.com/r/xzhouqd/qsign
- BASE_PATH=/srv/qsign/qsign/txlib/8.9.71
q2tg:
Expand All @@ -55,7 +54,6 @@ services:
- ZINC_USERNAME=admin
- ZINC_PASSWORD=password
- SIGN_API=http://sign:8080/sign?key=114514
- SIGN_VER=8.9.71 # 与上方 sign 容器的配置同步
- TG_CONNECTION=tcp # 连接 Telegram 的方式,也可以改成 websocket
# 要支持转发时自动识别语音,请设置以下参数
- BAIDU_APP_ID=
Expand Down
1 change: 0 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ model QqBot {
platform Int @default(0)
Instance Instance[]
signApi String?
signVer String?
}

model Message {
Expand Down
2 changes: 0 additions & 2 deletions src/client/OicqClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ interface CreateOicqParams {
password: string;
platform: Platform;
signApi?: string;
signVer?: string;
// 当需要验证手机时调用此方法,应该返回收到的手机验证码
onVerifyDevice: (phone: string) => Promise<string>;
// 当滑块时调用此方法,返回 ticker,也可以返回假值改用扫码登录
Expand Down Expand Up @@ -124,7 +123,6 @@ export default class OicqClient extends Client {
ffmpeg_path: process.env.FFMPEG_PATH,
ffprobe_path: process.env.FFPROBE_PATH,
sign_api_addr: params.signApi || process.env.SIGN_API,
ver: params.signVer || process.env.SIGN_VER,
});
client.on('system.login.device', loginDeviceHandler);
client.on('system.login.slider', loginSliderHandler);
Expand Down
15 changes: 1 addition & 14 deletions src/controllers/SetupController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export default class SetupController {
password: this.instance.qq.password,
platform: this.instance.qq.platform,
signApi: this.instance.qq.signApi,
signVer: this.instance.qq.signVer,
onVerifyDevice: async (phone) => {
return await this.setupService.waitForOwnerInput(`请输入手机 ${phone} 收到的验证码`);
},
Expand Down Expand Up @@ -112,21 +111,9 @@ export default class SetupController {
signApi = setupHelper.checkSignApiAddress(signApi);
}

let signVer: string;

if (signApi && !process.env.SIGN_VER) {
signVer = await this.setupService.waitForOwnerInput('请输入签名服务器版本,当前支持安卓(8.9.63、8.9.68、8.9.70)、Tim(3.5.1、3.5.2)', [
[Button.text('8.9.63', true, true)],
[Button.text('8.9.68', true, true)],
[Button.text('8.9.70', true, true)],
[Button.text('3.5.1', true, true)],
[Button.text('3.5.2', true, true)],
]);
}

let password = await this.setupService.waitForOwnerInput('请输入密码', undefined, true);
password = md5Hex(password);
this.oicq = await this.setupService.createOicq(uin, password, platform, signApi, signVer);
this.oicq = await this.setupService.createOicq(uin, password, platform, signApi);
this.instance.qqBotId = this.oicq.id;
await this.setupService.informOwner(`登录成功`);
}
Expand Down
1 change: 0 additions & 1 deletion src/models/Instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export default class Instance {
password: this.qq.password,
platform: this.qq.platform,
signApi: this.qq.signApi,
signVer: this.qq.signVer,
onVerifyDevice: async (phone) => {
return await this.waitForOwnerInput(`请输入手机 ${phone} 收到的验证码`);
},
Expand Down
6 changes: 3 additions & 3 deletions src/services/SetupService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ export default class SetupService {
});
}

public async createOicq(uin: number, password: string, platform: Platform, signApi: string, signVer: string) {
const dbQQBot = await db.qqBot.create({ data: { uin, password, platform, signApi, signVer } });
public async createOicq(uin: number, password: string, platform: Platform, signApi: string) {
const dbQQBot = await db.qqBot.create({ data: { uin, password, platform, signApi } });
return await OicqClient.create({
id: dbQQBot.id,
uin, password, platform, signApi, signVer,
uin, password, platform, signApi,
onVerifyDevice: async (phone) => {
return await this.waitForOwnerInput(`请输入手机 ${phone} 收到的验证码`);
},
Expand Down

0 comments on commit 5681dc3

Please sign in to comment.