@ginstone/nga-api
Version:
344 lines (343 loc) • 11.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NukeApi = void 0;
const NgaUploadClient_1 = require("../client/NgaUploadClient");
const NukeParams_1 = require("../params/NukeParams");
const BlockSubForum_1 = require("../response/nuke/BlockSubForum");
const CheckIn_1 = require("../response/nuke/CheckIn");
const FavorFolder_1 = require("../response/nuke/FavorFolder");
const ObjUtils_1 = require("../utils/ObjUtils");
const FavorForum_1 = require("../response/nuke/FavorForum");
const MissionInfo_1 = require("../response/nuke/MissionInfo");
const MissionCheckIn_1 = require("../response/nuke/MissionCheckIn");
const NoticeBody_1 = require("../response/nuke/NoticeBody");
const SimpleUserInfo_1 = require("../response/field/user/SimpleUserInfo");
const PrivateMessage_1 = require("../response/nuke/PrivateMessage");
const TopicKey_1 = require("../response/nuke/TopicKey");
const UserInfoNuke_1 = require("../response/field/user/UserInfoNuke");
const Medal_1 = require("../response/field/Medal");
const BlockData_1 = require("../response/nuke/BlockData");
const ItemParams_1 = require("../params/ItemParams");
const ItemData_1 = require("../response/nuke/ItemData");
// noinspection JSUnusedGlobalSymbols
/**
* nuke.php 的接口
*/
class NukeApi {
}
/**
* 附件上传
* @param attachUrl 上传地址,从post准备请求中获取
* @param params 上传参数
*/
NukeApi.attachUpload = (attachUrl, params) => new NgaUploadClient_1.NgaUploadClient().upload(attachUrl, params);
/**
* 删除附件
* @param client 客户端
* @param params 参数
*/
NukeApi.attachDel = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 添加子版面屏蔽
* @param client 客户端
* @param fid 父版面id
* @param id 通过ThreadApi获取: 子版面在635版的镜像ID或在主题列表中的主题id
*/
NukeApi.blockSubForumAdd = (client, fid, id) => {
let param = new NukeParams_1.BlockSubForumParam("set", fid);
param.add = id;
return client.nuke(param).then(r => r[0]);
};
/**
* 移除子版面屏蔽
* @param client 客户端
* @param fid 父版面id
* @param id 通过ThreadApi获取: 子版面在635版的镜像ID或在主题列表中的主题id
*/
NukeApi.blockSubForumDel = (client, fid, id) => {
let param = new NukeParams_1.BlockSubForumParam("set", fid);
param.del = id;
return client.nuke(param).then(r => r[0]);
};
/**
* 查询子版面屏蔽情况
* @param client 客户端
* @param fid 父版面id
*/
NukeApi.blockSubForumList = (client, fid) => client.nuke(new NukeParams_1.BlockSubForumParam("get", fid)).then(r => new BlockSubForum_1.BlockSubForumBody(r[0]));
/**
* 用户签到
* @param client 客户端
*/
NukeApi.checkIn = (client) => client.nuke(new NukeParams_1.CheckInParam()).then(r => new CheckIn_1.CheckInBody(r[0]));
/**
* 查询签到状态
* @param client 客户端
*/
NukeApi.checkInStatus = (client) => client.nuke(new NukeParams_1.CheckInStatusParam()).then(r => new CheckIn_1.CheckInStatusBody(r));
/**
* 查询收藏夹列表
* @param client 客户端
* @param params 参数
*/
NukeApi.favorFolderList = (client, params) => client.nuke(params).then(r => {
const arr = r[0];
return arr.map(i => new FavorFolder_1.FavorFolder(i));
});
/**
* 修改收藏夹
* @param client 客户端
* @param params 参数
*/
NukeApi.favorFolderModify = (client, params) => client.nuke(params).then(r => r[0]);
/**
*查询收藏版面
* @param client 客户端
*/
NukeApi.favorForumList = (client) => client.nuke(new NukeParams_1.FavorForumListParam()).then(r => (0, ObjUtils_1.values)(r[0]).map(item => new FavorForum_1.FavorForum(item)));
/**
* 添加和删除收藏版面
* @param client 客户端
* @param params 参数
*/
NukeApi.favorForumEdit = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 添加收藏主题和回复
* @param client 客户端
* @param params 参数
*/
NukeApi.favorTopicAdd = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 删除收藏的主题和回复
* @param client 客户端
* @param params 参数
*/
NukeApi.favorTopicDel = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 检查签到类任务
* @param client 客户端
* @param params 参数
*/
NukeApi.missionCheckIn = (client, params) => client.nuke(params).then(r => new MissionCheckIn_1.MissionCheckIn(r));
/**
* 查询任务列表
* @param client 客户端
* @param params 参数
*/
NukeApi.missionList = (client, params) => client.nuke(params).then(r => {
const re = r[0];
return re.map(i => new MissionInfo_1.MissionInfo(i));
});
/**
* 清空提醒消息
* @param client 客户端
*/
NukeApi.noticeClear = (client) => client.nuke(new NukeParams_1.NoticeClearParam()).then(r => r[0]);
/**
* 关闭 / 开启某一楼提醒消息
* @param client 客户端
* @param params 参数
*/
NukeApi.noticeEnable = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 查询提醒消息
* @param client 客户端
* @param time_limit 时间戳,只返回该时间戳之后的提醒消息
*/
NukeApi.noticeList = (client, time_limit) => client.nuke(new NukeParams_1.NoticeListParam(time_limit)).then(res => {
const arr = res;
if (!arr[0]) {
return undefined;
}
const result = JSON.parse(arr[0].replace("/*$js$*/", "")
.replace(/([,{\s])(\d+?):/g, "$1\"$2\":"));
return new NoticeBody_1.NoticeBody(result);
});
/**
* 获取当前登录用户提醒信息状态(疑似无效)
* @param client 客户端
*/
NukeApi.noticeStatus = (client) => client.nuke(new NukeParams_1.NoticeStatusParam());
/**
* 从私信黑名单移除用户
* @param client 客户端
* @param userId 希望移除的用户id
*/
NukeApi.pmBlockDel = (client, userId) => client.nuke(new NukeParams_1.PmBlockDelParam(userId)).then(r => r[0]);
/**
* 添加用户到私信黑名单
* @param client 客户端
* @param userId 希望添加的用户id
*/
NukeApi.pmBlockAdd = (client, userId) => client.nuke(new NukeParams_1.PmBlockAddParam(userId)).then(r => r[0]);
/**
* 查询私信黑名单
* @param client 客户端
*/
NukeApi.pmBlockList = (client) => client.nuke(new NukeParams_1.PmBlockListParam()).then(res => (0, ObjUtils_1.values)(res[0]).map(i => new SimpleUserInfo_1.SimpleUserInfo(i)));
/**
* 向私信会话中添加更多的参与者
* @param client 客户端
* @param params 参数
*/
NukeApi.pmAdd = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 私信会话踢人
* @param client 客户端
* @param params 参数
*/
NukeApi.pmKick = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 查询私信列表
* @param client 客户端
* @param page 页数
*/
NukeApi.pmList = (client, page) => client.nuke(new NukeParams_1.PmListParam(page)).then(r => new PrivateMessage_1.PmListBody(r[0]));
/**
* 发送新私信
* @param client 客户端
* @param params 参数
*/
NukeApi.pmNew = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 查询私信内容
* @param client 客户端
* @param params 参数
*/
NukeApi.pmRead = (client, params) => client.nuke(params).then(r => new PrivateMessage_1.PmReplyBody(r[0]));
/**
* 回复私信
* @param client 客户端
* @param params 参数
*/
NukeApi.pmReply = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 点赞或点踩
* @param client 客户端
* @param params 参数
*/
NukeApi.topicRecommend = (client, params) => client.nuke(params).then((res) => {
return {
//提示消息
message: res[0],
//总分变动值
value: res[1]
};
});
/**
* 设置签名
* @param client 客户端
* @param params 参数
*/
NukeApi.signatureSet = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 投票/投注
* @param client 客户端
* @param params 参数
*/
NukeApi.vote = (client, params) => client.nuke(params);
/**
* 查询版面的主题分类
* @param client 客户端
* @param fid 版面id
*/
NukeApi.topicKeyList = (client, fid) => client.nuke(new NukeParams_1.TopicKeyParam(fid)).then(r => {
const arr = r[0];
return arr.map(i => new TopicKey_1.TopicKey((i)));
});
/**
* 根据用户id查询用户信息
* @param client 客户端
* @param userId 用户id
*/
NukeApi.userInfoGetById = (client, userId) => {
const param = new NukeParams_1.UserInfoParam();
param.uid = userId;
return client.nuke(param).then(res => {
return new UserInfoNuke_1.UserInfoNuke(res[0]);
});
};
/**
* 根据用户名查询用户信息
* @param client 客户端
* @param username 用户名
*/
NukeApi.userInfoGetByName = (client, username) => {
const param = new NukeParams_1.UserInfoParam();
param.username = username;
return client.nuke(param).then(res => {
return new UserInfoNuke_1.UserInfoNuke(res[0]);
});
};
/**
* 举报
* @param client 客户端
* @param params 参数
*/
NukeApi.report = (client, params) => client.nuke(params).then(r => r[0]);
/**
* 查询徽章信息
* @param client 客户端
* @param subTypes 徽章id
*/
NukeApi.medalInfoList = (client, subTypes) => {
const params = new ItemParams_1.ItemInfoParam(subTypes.map(item => "2," + item));
return client.nuke(params).then(res => {
const arr = res;
if (!arr[0]) {
return new Array();
}
const result = JSON.parse(arr[0].replace("/*$js$*/", ""));
return (0, ObjUtils_1.values)(result).map(item => {
const raw = item;
const { icon, name, dscp } = raw;
const id = Number(icon.split(".")[0]);
return new Medal_1.Medal([icon, name, dscp.replace("徽章注释: ", ""), id]);
});
});
};
/**
* 查询版面权限信息
* @param client 客户端
* @param forumId 版面id
*/
NukeApi.privilegeList = (client, forumId) => {
const params = new NukeParams_1.PrivilegeListParam(forumId);
return client.nuke(params).then(r => r[0]);
};
/**
* 查询屏蔽数据(用户、关键字)
* @param client 客户端
*/
NukeApi.blockDataList = (client) => client.nuke(new NukeParams_1.BlockDataListParam(client.userId)).then(r => new BlockData_1.BlockDataBody(r));
/**
* 设置屏蔽数据(用户、关键字)
* @param client 客户端
* @param data 配置信息,来自查询接口
*/
NukeApi.blockDataSet = (client, data) => client.nuke(new NukeParams_1.BlockDataSetParam(data)).then(r => r[0]);
/**
* 查询商店里的道具列表
* @param client 客户端
* @param param 参数
*/
NukeApi.itemStore = (client, param) => client.nuke(param).then(r => new ItemData_1.ItemData(r[0]));
/**
* 查询自己的道具列表
* @param client 客户端
* @param page 页数
*/
NukeApi.itemInventory = (client, page) => client.nuke(new ItemParams_1.ItemInventoryParam(page)).then(r => new ItemData_1.ItemData(r[0]));
/**
* 购买道具
* @param client 客户端
* @param param 参数
*/
NukeApi.itemBuy = (client, param) => client.nuke(param).then(r => r[0]);
/**
* 使用道具
* @param client 客户端
* @param param 参数
*/
NukeApi.itemUse = (client, param) => client.nuke(param).then(r => r[0]);
exports.NukeApi = NukeApi;