115 lines
4.7 KiB
JavaScript
115 lines
4.7 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.IMHelp = void 0;
|
|
const app_env_1 = require("../../../app.env");
|
|
const tls_sig_api_v2_typescript_1 = require("tls-sig-api-v2-typescript");
|
|
const fetch_help_1 = require("./fetch_help");
|
|
const help_1 = require("./help");
|
|
class IMHelp {
|
|
static async kickUser(imUid) {
|
|
const url = `https://console.tim.qq.com/v4/im_open_login_svc/kick?${this.getUrlParams()}`;
|
|
const res = await fetch_help_1.FetchHelp.post(url, {
|
|
UserID: imUid,
|
|
});
|
|
const json = (await res.json());
|
|
return json;
|
|
}
|
|
static async updateUserProfile(imUid, nick, avatar) {
|
|
const url = `https://console.tim.qq.com/v4/profile/portrait_set?${this.getUrlParams()}`;
|
|
const res = await fetch_help_1.FetchHelp.post(url, {
|
|
From_Account: imUid,
|
|
ProfileItem: [
|
|
{
|
|
Tag: 'Tag_Profile_IM_Nick',
|
|
Value: nick,
|
|
},
|
|
{
|
|
Tag: 'Tag_Profile_IM_Image',
|
|
Value: avatar,
|
|
},
|
|
{
|
|
Tag: 'Tag_Profile_IM_AllowType',
|
|
Value: 'AllowType_Type_NeedConfirm',
|
|
},
|
|
],
|
|
});
|
|
const json = (await res.json());
|
|
return json;
|
|
}
|
|
static async multiaccountImportUser(arr) {
|
|
const url = `https://console.tim.qq.com/v4/im_open_login_svc/multiaccount_import?${this.getUrlParams()}`;
|
|
const res = await fetch_help_1.FetchHelp.post(url, {
|
|
AccountList: arr,
|
|
});
|
|
const json = (await res.json());
|
|
return json;
|
|
}
|
|
static async friendImport(imUid, friendImUids) {
|
|
const url = `https://console.tim.qq.com/v4/sns/friend_import?${this.getUrlParams()}`;
|
|
const res = await fetch_help_1.FetchHelp.post(url, {
|
|
From_Account: imUid,
|
|
AddFriendItem: friendImUids.map((item) => {
|
|
return {
|
|
To_Account: item.imUid,
|
|
Remark: item.Remark,
|
|
AddSource: 'AddSource_Type_Web',
|
|
};
|
|
}),
|
|
});
|
|
const json = (await res.json());
|
|
return json;
|
|
}
|
|
static async createGroup(group) {
|
|
const url = `https://console.tim.qq.com/v4/group_open_http_svc/create_group?${this.getUrlParams()}`;
|
|
const res = await fetch_help_1.FetchHelp.post(url, group);
|
|
const json = (await res.json());
|
|
return json;
|
|
}
|
|
static async getGroupInfo(GroupIdList) {
|
|
const url = `https://console.tim.qq.com/v4/group_open_http_svc/get_group_info?${this.getUrlParams()}`;
|
|
const res = await fetch_help_1.FetchHelp.post(url, {
|
|
GroupIdList,
|
|
});
|
|
const json = (await res.json());
|
|
return json;
|
|
}
|
|
static async modifyGroupBaseInfo(params) {
|
|
const url = `https://console.tim.qq.com/v4/group_open_http_svc/modify_group_base_info?${this.getUrlParams()}`;
|
|
const res = await fetch_help_1.FetchHelp.post(url, params);
|
|
const json = (await res.json());
|
|
return json;
|
|
}
|
|
static async importGroupMemberExist(params) {
|
|
const url = `https://console.tim.qq.com/v4/group_open_http_svc/get_role_in_group?${this.getUrlParams()}`;
|
|
const res = await fetch_help_1.FetchHelp.post(url, {
|
|
GroupId: params.GroupId,
|
|
User_Account: [params.User_Account],
|
|
});
|
|
const json = (await res.json());
|
|
return (json.ErrorCode == 0 &&
|
|
json.UserIdList.length > 0 &&
|
|
json.UserIdList[0].Role != 'NotMember');
|
|
}
|
|
static async importGroupMember(params) {
|
|
const url = `https://console.tim.qq.com/v4/group_open_http_svc/import_group_member?${this.getUrlParams()}`;
|
|
const res = await fetch_help_1.FetchHelp.post(url, params);
|
|
const json = (await res.json());
|
|
return json;
|
|
}
|
|
static async sendGroupMsg(params) {
|
|
const url = `https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg?${this.getUrlParams()}`;
|
|
const res = await fetch_help_1.FetchHelp.post(url, params);
|
|
const json = (await res.json());
|
|
return json;
|
|
}
|
|
static getUrlParams() {
|
|
const api = new tls_sig_api_v2_typescript_1.Api(app_env_1.AppEnv.IM_APP_ID, app_env_1.AppEnv.IM_SECRET_KEY);
|
|
const random = help_1.Help.getRandomInt(0, 4294967295);
|
|
const expire = 86400 * 180;
|
|
const sign = api.genSig(app_env_1.AppEnv.IM_APP_IDENTIFIER, expire);
|
|
const params = `sdkappid=${app_env_1.AppEnv.IM_APP_ID}&identifier=${app_env_1.AppEnv.IM_APP_IDENTIFIER}&usersig=${sign}&random=${random}&contenttype=json`;
|
|
return params;
|
|
}
|
|
}
|
|
exports.IMHelp = IMHelp;
|
|
//# sourceMappingURL=im_help.js.map
|